Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
IOS-7274 Kaspa / Add custom comissions (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseiMuraveinik1 authored Jul 31, 2024
1 parent 8f34772 commit 4797342
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions BlockchainSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
DA71441E2795C2EA0052AFB4 /* SolanaNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA71441D2795C2EA0052AFB4 /* SolanaNetworkService.swift */; };
DA7C9A182C07B1C600C8C423 /* KoinosNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA7C9A172C07B1C600C8C423 /* KoinosNetworkService.swift */; };
DA7C9A1A2C07B30500C8C423 /* KoinosAccountInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA7C9A192C07B30500C8C423 /* KoinosAccountInfo.swift */; };
DA7D86E72C5837E700D85866 /* KaspaFeeParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA7D86E62C5837E700D85866 /* KaspaFeeParameters.swift */; };
DA82433D27A2B06500CFC2C0 /* PolkadotJsonRpcProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA82433C27A2B06500CFC2C0 /* PolkadotJsonRpcProvider.swift */; };
DA82433F27A2B07800CFC2C0 /* PolkadotNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA82433E27A2B07800CFC2C0 /* PolkadotNetwork.swift */; };
DA82434127A2B0AD00CFC2C0 /* PolkadotTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA82434027A2B0AD00CFC2C0 /* PolkadotTarget.swift */; };
Expand Down Expand Up @@ -1421,6 +1422,7 @@
DA7C9A172C07B1C600C8C423 /* KoinosNetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KoinosNetworkService.swift; sourceTree = "<group>"; };
DA7C9A192C07B30500C8C423 /* KoinosAccountInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KoinosAccountInfo.swift; sourceTree = "<group>"; };
DA7CA47527AD4BD90041B1A1 /* PolkadotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolkadotTests.swift; sourceTree = "<group>"; };
DA7D86E62C5837E700D85866 /* KaspaFeeParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KaspaFeeParameters.swift; sourceTree = "<group>"; };
DA82433C27A2B06500CFC2C0 /* PolkadotJsonRpcProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolkadotJsonRpcProvider.swift; sourceTree = "<group>"; };
DA82433E27A2B07800CFC2C0 /* PolkadotNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolkadotNetwork.swift; sourceTree = "<group>"; };
DA82434027A2B0AD00CFC2C0 /* PolkadotTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolkadotTarget.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3412,6 +3414,7 @@
DA63B09929CB3FC700AC6E49 /* KaspaWalletManager.swift */,
DA63B09529CB3FC700AC6E49 /* Address */,
DA63B08F29CB3FC700AC6E49 /* Network */,
DA7D86E62C5837E700D85866 /* KaspaFeeParameters.swift */,
);
path = Kaspa;
sourceTree = "<group>";
Expand Down Expand Up @@ -5099,6 +5102,7 @@
B6F89EB02BB215830009A453 /* SubscanPolkadotAccountHealthNetworkService.swift in Sources */,
EFC5E5132C3597CF00EC5C87 /* CardanoFeeParameters.swift in Sources */,
DA63B09E29CB3FC700AC6E49 /* KaspaTransaction.swift in Sources */,
DA7D86E72C5837E700D85866 /* KaspaFeeParameters.swift in Sources */,
DAED921F27A150E500F188D7 /* PolkadotAddressService.swift in Sources */,
EF5820412B31B54D00940387 /* EstimationFeeAddressFactory.swift in Sources */,
DC5E65352B16541D00E81AA5 /* BitcoinScript.swift in Sources */,
Expand Down
19 changes: 19 additions & 0 deletions BlockchainSdk/Blockchains/Kaspa/KaspaFeeParameters.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// KaspaFeeParameters.swift
// BlockchainSdk
//
// Created by Aleksei Muraveinik on 29.07.24.
// Copyright © 2024 Tangem AG. All rights reserved.
//

import Foundation

public struct KaspaFeeParameters: FeeParameters {
public let valuePerUtxo: Decimal
public let utxoCount: Int

public init(valuePerUtxo: Decimal, utxoCount: Int) {
self.valuePerUtxo = valuePerUtxo
self.utxoCount = utxoCount
}
}
11 changes: 8 additions & 3 deletions BlockchainSdk/Blockchains/Kaspa/KaspaWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ class KaspaWalletManager: BaseManager, WalletManager {
.eraseToAnyPublisher()
}

let feePerUtxo = 10_000
let fee = feePerUtxo * numberOfUtxos
let feePerUtxo: Decimal = 0.0001
let fee = feePerUtxo * Decimal(numberOfUtxos)

return Just([Fee(Amount(with: wallet.blockchain, value: Decimal(fee) / wallet.blockchain.decimalValue))])
let params = KaspaFeeParameters(
valuePerUtxo: feePerUtxo,
utxoCount: numberOfUtxos
)

return Just([Fee(Amount(with: wallet.blockchain, value: fee), parameters: params)])
.setFailureType(to: Error.self)
.eraseToAnyPublisher()
}
Expand Down

0 comments on commit 4797342

Please sign in to comment.