diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/solana/ResultExt.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/solana/ResultExt.kt deleted file mode 100644 index a6b029da8..000000000 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/solana/ResultExt.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.tangem.blockchain.blockchains.solana - -import com.tangem.blockchain.extensions.Result -import com.tangem.blockchain.extensions.SimpleResult -import com.tangem.common.CompletionResult - -internal fun Result.toSimpleResult(): SimpleResult { - return when (this) { - is Result.Success -> SimpleResult.Success - is Result.Failure -> SimpleResult.Failure(this.error) - } -} - -internal inline fun CompletionResult.successOr(failureClause: (CompletionResult.Failure) -> Nothing): T { - return when (this) { - is CompletionResult.Success -> this.data - is CompletionResult.Failure -> failureClause(this) - } -} diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/VechainTransactionBuilder.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/VechainTransactionBuilder.kt index 18c6ff41e..c09b5d394 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/VechainTransactionBuilder.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/VechainTransactionBuilder.kt @@ -37,21 +37,21 @@ class VechainTransactionBuilder(blockchain: Blockchain, private val publicKey: W minimum = Fee.Vechain( amount = Amount( token = VechainWalletManager.VTHO_TOKEN, - value = gas.toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL) + value = gas.toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL), ), gasPriceCoef = 0, ), normal = Fee.Vechain( amount = Amount( token = VechainWalletManager.VTHO_TOKEN, - value = (gas * 1.5).toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL) + value = (gas * 1.5).toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL), ), gasPriceCoef = 127, ), priority = Fee.Vechain( amount = Amount( token = VechainWalletManager.VTHO_TOKEN, - value = (gas * 2).toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL) + value = (gas * 2).toBigDecimal().movePointLeft(GAS_TO_VET_DECIMAL), ), gasPriceCoef = 255, ), @@ -85,7 +85,7 @@ class VechainTransactionBuilder(blockchain: Blockchain, private val publicKey: W fee, transactionData.destinationAddress, blockInfo, - nonce + nonce, ) val publicKeys = DataVector() @@ -95,7 +95,10 @@ class VechainTransactionBuilder(blockchain: Blockchain, private val publicKey: W signatures.add(unmarshalSignature(signature, hash, publicKey)) val compileWithSignatures = TransactionCompiler.compileWithSignatures( - coinType, inputData.toByteArray(), signatures, publicKeys + coinType, + inputData.toByteArray(), + signatures, + publicKeys, ) val output = VeChain.SigningOutput.parseFrom(compileWithSignatures) diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/network/VechainNetworkService.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/network/VechainNetworkService.kt index ac47f3c12..dfd27de39 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/network/VechainNetworkService.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/vechain/network/VechainNetworkService.kt @@ -47,7 +47,7 @@ internal class VechainNetworkService( accountResponse = accountInfoDeferred.await().extractResult(), pendingTxsInfo = pendingTxsDeferred.awaitAll().map { it.extractResult() }, tokenBalances = tokenBalances, - ) + ), ) } } catch (e: Exception) { diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/VechainWalletManagerAssembly.kt b/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/VechainWalletManagerAssembly.kt index 2e8125247..e67472ddc 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/VechainWalletManagerAssembly.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/assembly/impl/VechainWalletManagerAssembly.kt @@ -9,7 +9,7 @@ internal object VechainWalletManagerAssembly : WalletManagerAssembly retryIO( +internal suspend fun retryIO( times: Int = 3, initialDelay: Long = 100, maxDelay: Long = 1000, @@ -36,24 +37,31 @@ sealed class Result { } } -inline fun Result.successOr(failureClause: (Result.Failure) -> T): T { +internal inline fun Result.successOr(failureClause: (Result.Failure) -> T): T { return when (this) { is Result.Success -> this.data is Result.Failure -> failureClause(this) } } -inline fun Result.map(block: (A) -> B): Result { +internal inline fun Result.map(block: (A) -> B): Result { return when (this) { is Result.Success -> Result.Success(block(this.data)) is Result.Failure -> this } } -fun Result.Failure.toSimpleFailure(): SimpleResult.Failure { +internal fun Result.Failure.toSimpleFailure(): SimpleResult.Failure { return SimpleResult.Failure(error) } +internal fun Result.toSimpleResult(): SimpleResult { + return when (this) { + is Result.Success -> SimpleResult.Success + is Result.Failure -> SimpleResult.Failure(this.error) + } +} + sealed class SimpleResult { object Success : SimpleResult() data class Failure(val error: BlockchainError) : SimpleResult() @@ -65,9 +73,16 @@ sealed class SimpleResult { } } -inline fun SimpleResult.successOr(failureClause: (SimpleResult.Failure) -> Nothing): SimpleResult.Success { +internal inline fun SimpleResult.successOr(failureClause: (SimpleResult.Failure) -> Nothing): SimpleResult.Success { return when (this) { is SimpleResult.Success -> this is SimpleResult.Failure -> failureClause(this) } } + +internal inline fun CompletionResult.successOr(failureClause: (CompletionResult.Failure) -> Nothing): T { + return when (this) { + is CompletionResult.Success -> this.data + is CompletionResult.Failure -> failureClause(this) + } +}