Skip to content

Commit

Permalink
Merge branch 'develop' into feature/IOS-8113_ci_cd_beta_builds_workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Fedorov <[email protected]>
  • Loading branch information
m3g0byt3 committed Nov 2, 2024
2 parents 67c6d99 + 9720f64 commit d6d649a
Show file tree
Hide file tree
Showing 152 changed files with 1,147 additions and 622 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import WalletCore
import TangemSdk
import CryptoKit
import TangemFoundation

final class AlgorandTransactionBuilder {
private let publicKey: Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Combine
import TangemFoundation

final class AlgorandWalletManager: BaseManager {
// MARK: - Private Properties
Expand Down
7 changes: 4 additions & 3 deletions BlockchainSdk/Blockchains/Aptos/AptosNetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Combine
import TangemFoundation

class AptosNetworkService: MultiNetworkProvider {
// MARK: - Protperties
Expand Down Expand Up @@ -38,8 +39,8 @@ class AptosNetworkService: MultiNetworkProvider {
}

guard
let balanceValue = Decimal(coinJson.data.coin?.value),
let sequenceNumber = Decimal(accountJson.data.sequenceNumber)
let balanceValue = Decimal(stringValue: coinJson.data.coin?.value),
let sequenceNumber = Decimal(stringValue: accountJson.data.sequenceNumber)
else {
throw WalletError.failedToParseNetworkResponse()
}
Expand Down Expand Up @@ -73,7 +74,7 @@ class AptosNetworkService: MultiNetworkProvider {
.calculateUsedGasPriceUnit(transactionBody: transactionBody)
.withWeakCaptureOf(self)
.tryMap { service, response in
guard let gasUsed = Decimal(response.first?.gasUsed) else {
guard let gasUsed = Decimal(stringValue: response.first?.gasUsed) else {
throw WalletError.failedToGetFee
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import WalletCore
import TangemSdk
import TangemFoundation

final class AptosTransactionBuilder {
private let publicKey: Data
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Blockchains/Binance/BinanceWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import Combine
import BinanceChain
import struct TangemSdk.SignResponse
import TangemFoundation

class BinanceWalletManager: BaseManager, WalletManager {
var txBuilder: BinanceTransactionBuilder!
Expand Down Expand Up @@ -100,7 +101,7 @@ extension BinanceWalletManager: TransactionFeeProvider {
.tryMap { [weak self] feeString throws -> [Fee] in
guard let self = self else { throw WalletError.empty }

guard let feeValue = Decimal(feeString) else {
guard let feeValue = Decimal(stringValue: feeString) else {
throw WalletError.failedToGetFee
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ import TangemSdk

@available(iOS 13.0, *)
class BitcoinBech32AddressService {
private let converter: SegWitBech32AddressConverter
private let segWitConverter: SegWitBech32AddressConverter
private let tapRootConverter: TaprootAddressConverter

init(networkParams: INetwork) {
let scriptConverter = ScriptConverter()
converter = SegWitBech32AddressConverter(prefix: networkParams.bech32PrefixPattern, scriptConverter: scriptConverter)
segWitConverter = SegWitBech32AddressConverter(
prefix: networkParams.bech32PrefixPattern,
scriptConverter: scriptConverter
)
tapRootConverter = TaprootAddressConverter(
prefix: networkParams.bech32PrefixPattern,
scriptConverter: scriptConverter
)
}
}

Expand All @@ -25,7 +33,7 @@ class BitcoinBech32AddressService {
@available(iOS 13.0, *)
extension BitcoinBech32AddressService: BitcoinScriptAddressProvider {
func makeScriptAddress(from scriptHash: Data) throws -> String {
return try converter.convert(scriptHash: scriptHash).stringValue
return try segWitConverter.convert(scriptHash: scriptHash).stringValue
}
}

Expand All @@ -34,12 +42,9 @@ extension BitcoinBech32AddressService: BitcoinScriptAddressProvider {
@available(iOS 13.0, *)
extension BitcoinBech32AddressService: AddressValidator {
func validate(_ address: String) -> Bool {
do {
_ = try converter.convert(address: address)
return true
} catch {
return false
}
let segwitAddress = try? segWitConverter.convert(address: address)
let taprootAddress = try? tapRootConverter.convert(address: address)
return segwitAddress != nil || taprootAddress != nil
}
}

Expand All @@ -56,7 +61,7 @@ extension BitcoinBech32AddressService: AddressProvider {
hdPublicKeyData: compressedKey
)

let address = try converter.convert(publicKey: bitcoinCorePublicKey, type: .p2wpkh).stringValue
let address = try segWitConverter.convert(publicKey: bitcoinCorePublicKey, type: .p2wpkh).stringValue
return PlainAddress(value: address, publicKey: publicKey, type: addressType)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import TangemSdk
import Combine
import BitcoinCore
import TangemFoundation

class BitcoinWalletManager: BaseManager, WalletManager, DustRestrictable {
var allowsFeeSelection: Bool { true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import WalletCore
import BigInt
import TangemSdk
import TangemFoundation

// You can decode your CBOR transaction here: https://cbor.me
class CardanoTransactionBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Combine
import TangemSdk
import TangemFoundation

class CardanoWalletManager: BaseManager, WalletManager {
var transactionBuilder: CardanoTransactionBuilder!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import CryptoKit
import TangemSdk
import TangemFoundation

final class ChiaTransactionBuilder {
// MARK: - Private Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import WalletCore
import TangemFoundation

class CosmosTransactionBuilder {
private let publicKey: Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Combine
import TangemSdk
import TangemFoundation

class DogecoinWalletManager: BitcoinWalletManager {
override var minimalFee: Decimal { 0.01 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import Moya
import Combine
import BigInt
import TangemFoundation

class EthereumNetworkService: MultiNetworkProvider {
let providers: [EthereumJsonRpcProvider]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// CanxiumExternalLinkProvider.swift
// TangemApp
//
// Created by Alexander Osokin on 02.11.2024.
// Copyright © 2024 Tangem AG. All rights reserved.
//

struct CanxiumExternalLinkProvider: ExternalLinkProvider {
var testnetFaucetURL: URL? { nil }

private var baseExplorerUrl: String {
"https://scan.canxium.org"
}

func url(address: String, contractAddress: String?) -> URL? {
URL(string: "\(baseExplorerUrl)/address/\(address)")
}

func url(transaction hash: String) -> URL? {
URL(string: "\(baseExplorerUrl)/tx/\(hash)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import Hedera
import CryptoSwift
import TangemSdk
import TangemFoundation

final class HederaTransactionBuilder {
private let publicKey: Data
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Blockchains/ICP/ICPTransactionBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import WalletCore
import IcpKit
import Combine
import TangemFoundation

final class ICPTransactionBuilder {
// MARK: - Private Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import WalletCore
import TangemFoundation

class KaspaTransactionBuilder {
let maxInputCount = 84
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import TangemSdk
import TangemFoundation

class KoinosTransactionBuilder {
private let koinosNetworkParams: KoinosNetworkParams
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Blockchains/Mantle/MantleWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import BigInt
import Combine
import TangemFoundation

// This is a workaround for sending a Mantle transaction.
// Unfortunately, Mantle's current implementation does not conform to our existing fee calculation rules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import TangemFoundation

struct NEARProtocolConfig {
struct Costs {
Expand Down Expand Up @@ -48,7 +49,7 @@ extension NEARProtocolConfig {
cumulativeAdditionalSendCost: Decimal(3850000000000) + Decimal(101765125000),
cumulativeAdditionalExecutionCost: Decimal(3850000000000) + Decimal(101765125000)
),
storageAmountPerByte: Decimal("10000000000000000000")!
storageAmountPerByte: Decimal(stringValue: "10000000000000000000")!
)
}
}
1 change: 1 addition & 0 deletions BlockchainSdk/Blockchains/NEAR/NEARWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Combine
import TangemFoundation

final class NEARWalletManager: BaseManager {
private let networkService: NEARNetworkService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Combine
import TangemFoundation

final class NEARNetworkService: MultiNetworkProvider {
let providers: [NEARNetworkProvider]
Expand Down Expand Up @@ -67,7 +68,7 @@ final class NEARNetworkService: MultiNetworkProvider {
let senderIsNotReceiverCumulativeAdditionalSendCost = Decimal(createAccountCostConfig.sendNotSir)
+ Decimal(addKeyCostConfig.sendNotSir)

let storageAmountPerByte = Decimal(result.runtimeConfig.storageAmountPerByte)
let storageAmountPerByte = Decimal(stringValue: result.runtimeConfig.storageAmountPerByte)
?? NEARProtocolConfig.fallbackProtocolConfig.storageAmountPerByte

return NEARProtocolConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Combine
import ScaleCodec
import TangemFoundation

class PolkadotTransactionBuilder {
private let walletPublicKey: Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Combine
import CryptoKit
import TangemSdk
import BigInt
import TangemFoundation

class PolkadotWalletManager: BaseManager, WalletManager {
private let network: PolkadotNetwork
Expand Down Expand Up @@ -42,7 +43,7 @@ class PolkadotWalletManager: BaseManager, WalletManager {
let decimals = wallet.blockchain.decimalCount
guard
let formatted = EthereumUtils.formatToPrecision(balance, numberDecimals: decimals, formattingDecimals: decimals, decimalSeparator: ".", fallbackToScientific: false),
let value = Decimal(formatted)
let value = Decimal(stringValue: formatted)
else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import TangemFoundation

struct RadiantAmountUnspentTransaction {
let decimalValue: Decimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import TangemSdk
import WalletCore
import TangemFoundation

class RadiantTransactionBuilder {
private let walletPublicKey: Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import TangemSdk
import WalletCore
import TangemFoundation

struct RadiantScriptUtils {
/// Default implementation BitcoinCash signed scripts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Moya
import Combine
import TangemFoundation

/// Documentations:
/// https://github.com/RavenDevKit/insight-api
Expand Down Expand Up @@ -144,15 +145,15 @@ private extension RavencoinNetworkProvider {
$0.scriptPubKey.addresses.contains { $0 == walletAddress }
}

value = outputs.compactMap { Decimal($0.value) }.reduce(0, +)
value = outputs.compactMap { Decimal(stringValue: $0.value) }.reduce(0, +)

} else {
// Find all outputs from the our address
let outputs = transaction.vout.filter {
$0.scriptPubKey.addresses.contains { $0 != walletAddress }
}

value = outputs.compactMap { Decimal($0.value) }.reduce(0, +)
value = outputs.compactMap { Decimal(stringValue: $0.value) }.reduce(0, +)
}

let otherAddresses = transaction.vout.filter {
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Blockchains/Solana/SolanaNetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Combine
import SolanaSwift
import TangemFoundation

@available(iOS 13.0, *)
class SolanaNetworkService {
Expand Down Expand Up @@ -251,7 +252,7 @@ class SolanaNetworkService {
guard
let info = $0.account.data.value?.parsed.info,
let token = tokens.first(where: { $0.contractAddress == info.mint }),
let integerAmount = Decimal(info.tokenAmount.amount)
let integerAmount = Decimal(stringValue: info.tokenAmount.amount)
else {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Blockchains/Solana/SolanaWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import Combine
import TangemSdk
import SolanaSwift
import TangemFoundation

class SolanaWalletManager: BaseManager, WalletManager {
var solanaSdk: Solana!
Expand Down
Loading

0 comments on commit d6d649a

Please sign in to comment.