Updated on 2026-08-14
This commit is contained in:
parent
a51012484f
commit
32ced9df85
12 changed files with 87 additions and 33 deletions
|
|
@ -186,6 +186,7 @@ internal class DefaultCurrenciesRepository(
|
|||
override suspend fun getMultiCurrencyWalletCurrency(
|
||||
userWalletId: UserWalletId,
|
||||
id: CryptoCurrency.ID,
|
||||
derivationPath: Network.DerivationPath,
|
||||
): CryptoCurrency = withContext(dispatchers.io) {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
ensureIsCorrectUserWallet(userWallet, isMultiCurrencyWalletExpected = true)
|
||||
|
|
@ -194,10 +195,14 @@ internal class DefaultCurrenciesRepository(
|
|||
"Unable to find tokens response for user wallet with provided ID: $userWalletId"
|
||||
}
|
||||
|
||||
responseCurrenciesFactory.createCurrency(id, response, userWallet.scanResponse)
|
||||
responseCurrenciesFactory.createCurrency(id, response, userWallet.scanResponse, derivationPath.value)
|
||||
}
|
||||
|
||||
override suspend fun getNetworkCoin(userWalletId: UserWalletId, networkId: Network.ID): CryptoCurrency.Coin {
|
||||
override suspend fun getNetworkCoin(
|
||||
userWalletId: UserWalletId,
|
||||
networkId: Network.ID,
|
||||
derivationPath: Network.DerivationPath,
|
||||
): CryptoCurrency.Coin {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
ensureIsCorrectUserWallet(userWallet = userWallet, isMultiCurrencyWalletExpected = true)
|
||||
|
||||
|
|
@ -207,15 +212,12 @@ internal class DefaultCurrenciesRepository(
|
|||
"Unable to find tokens response for user wallet with provided ID: $userWalletId"
|
||||
}
|
||||
val blockchain = Blockchain.fromId(networkId.value)
|
||||
val derivationPath = blockchain
|
||||
.derivationPath(userWallet.scanResponse.derivationStyleProvider.getDerivationStyle())
|
||||
?.rawPath
|
||||
val blockchainNetworkId = blockchain.toNetworkId()
|
||||
val coinId = blockchain.toCoinId()
|
||||
|
||||
val storedCoin = storedTokens.tokens
|
||||
.find {
|
||||
it.networkId == blockchain.toNetworkId() &&
|
||||
it.id == blockchain.toCoinId() &&
|
||||
it.derivationPath == derivationPath
|
||||
it.networkId == blockchainNetworkId && it.id == coinId && it.derivationPath == derivationPath.value
|
||||
} ?: error("Coin in this network $networkId not found")
|
||||
|
||||
val coin = responseCurrenciesFactory.createCurrency(storedCoin, userWallet.scanResponse)
|
||||
|
|
|
|||
|
|
@ -20,13 +20,10 @@ internal class ResponseCryptoCurrenciesFactory(private val demoConfig: DemoConfi
|
|||
currencyId: CryptoCurrency.ID,
|
||||
response: UserTokensResponse,
|
||||
scanResponse: ScanResponse,
|
||||
derivationPath: String?,
|
||||
): CryptoCurrency {
|
||||
val responseTokenId = currencyId.rawCurrencyId
|
||||
val blockchain = Blockchain.fromId(currencyId.rawNetworkId)
|
||||
val networkId = blockchain.toNetworkId()
|
||||
val derivationPath = blockchain
|
||||
.derivationPath(scanResponse.derivationStyleProvider.getDerivationStyle())
|
||||
?.rawPath
|
||||
val networkId = Blockchain.fromId(currencyId.rawNetworkId).toNetworkId()
|
||||
|
||||
val token = requireNotNull(
|
||||
value = response.tokens
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue