Updated on 2026-08-14
This commit is contained in:
parent
5db8900311
commit
bba00924d4
18 changed files with 110 additions and 314 deletions
|
|
@ -87,6 +87,15 @@ internal class DefaultWalletAccountsFetcher @Inject constructor(
|
|||
store.updateData { response }
|
||||
}
|
||||
|
||||
override suspend fun update(
|
||||
userWalletId: UserWalletId,
|
||||
transform: (GetWalletAccountsResponse?) -> GetWalletAccountsResponse?,
|
||||
) {
|
||||
val store = getAccountsResponseStore(userWalletId = userWalletId)
|
||||
|
||||
store.updateData { transform(it) }
|
||||
}
|
||||
|
||||
override suspend fun push(
|
||||
userWalletId: UserWalletId,
|
||||
accounts: List<WalletAccountDTO>,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ interface WalletAccountsSaver {
|
|||
/** Store wallet accounts [response] by [userWalletId] */
|
||||
suspend fun store(userWalletId: UserWalletId, response: GetWalletAccountsResponse)
|
||||
|
||||
suspend fun update(
|
||||
userWalletId: UserWalletId,
|
||||
transform: (GetWalletAccountsResponse?) -> GetWalletAccountsResponse?,
|
||||
)
|
||||
|
||||
/** Push wallet accounts [body] by [userWalletId] */
|
||||
@Throws
|
||||
suspend fun push(userWalletId: UserWalletId, body: SaveWalletAccountsResponse): GetWalletAccountsResponse?
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.tangem.blockchain.transactionhistory.models.TransactionHistoryRequest
|
|||
import com.tangem.blockchain.yieldsupply.YieldSupplyContractCallDataProviderFactory
|
||||
import com.tangem.blockchainsdk.BlockchainSDKFactory
|
||||
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.crypto.hdWallet.DerivationPath
|
||||
|
|
@ -623,6 +624,22 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
override suspend fun getNativeTokenBalance(
|
||||
userWalletId: UserWalletId,
|
||||
networkId: String,
|
||||
derivationPath: String?,
|
||||
): BigDecimal {
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(networkId)) { "blockchain not found" }
|
||||
val walletManager = getOrCreateWalletManager(userWalletId, blockchain, derivationPath)
|
||||
|
||||
return walletManager?.wallet?.amounts
|
||||
?.firstNotNullOfOrNull { amountEntry ->
|
||||
amountEntry.takeIf { amountEntry.key is AmountType.Coin }
|
||||
}
|
||||
?.value?.value
|
||||
?: BigDecimal.ZERO
|
||||
}
|
||||
|
||||
override suspend fun getAssetRequirements(
|
||||
userWalletId: UserWalletId,
|
||||
currency: CryptoCurrency,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue