Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-18 18:05:18 +08:00
parent e98780ff93
commit 479d142807
283 changed files with 2338 additions and 2730 deletions

View file

@ -97,15 +97,12 @@ class TransactionManagerImpl(
private fun handleSendResult(result: SimpleResult): SendTxResult {
when (result) {
is SimpleResult.Success -> {
return SendTxResult.Success
}
is SimpleResult.Success -> return SendTxResult.Success
is SimpleResult.Failure -> {
val error = (result.error as? BlockchainSdkError) ?: return SendTxResult.UnknownError()
val error = result.error as? BlockchainSdkError ?: return SendTxResult.UnknownError()
when (error) {
is BlockchainSdkError.WrappedTangemError -> {
val tangemSdkError = (error.tangemError as? TangemSdkError)
?: return SendTxResult.UnknownError()
val tangemSdkError = error.tangemError as? TangemSdkError ?: return SendTxResult.UnknownError()
if (tangemSdkError is TangemSdkError.UserCancelled) return SendTxResult.UserCancelledError
return SendTxResult.TangemSdkError(tangemSdkError.code, tangemSdkError.cause)
}
@ -202,6 +199,5 @@ class TransactionManagerImpl(
companion object {
private const val HEX_PREFIX = "0x"
private const val DEFAULT_GAS_LIMIT = 300000L
}
}

View file

@ -82,11 +82,7 @@ class UserWalletManagerImpl(
override fun addToken(currency: Currency) {
val action = if (currency is NativeToken) {
val card = appStateHolder.getActualCard()
if (card != null) {
addNativeTokenToWalletAction(currency, card)
} else {
throw IllegalStateException("card not found")
}
if (card != null) addNativeTokenToWalletAction(currency, card) else error("Card not found")
} else {
addNonNativeTokenToWalletAction(currency as NonNativeToken)
}
@ -184,12 +180,15 @@ class UserWalletManagerImpl(
}
private fun createDerivationParams(derivationStyle: DerivationStyle?): DerivationParams? {
return derivationStyle?.let { DerivationParams.Default(derivationStyle) } //todo clarify if its need to add Custom
//todo clarify if its need to add Custom
return derivationStyle?.let { DerivationParams.Default(derivationStyle) }
}
private fun getActualWalletManager(blockchain: Blockchain): WalletManager {
val card = requireNotNull(appStateHolder.getActualCard()) { "card not found" }
val blockchainNetwork = BlockchainNetwork(blockchain, card)
return requireNotNull(appStateHolder.walletState?.getWalletManager(blockchainNetwork)) { "no wallet manager found" }
return requireNotNull(appStateHolder.walletState?.getWalletManager(blockchainNetwork)) {
"No wallet manager found"
}
}
}