Skip to content

Commit

Permalink
fix(evm_phase_1): AND-6819 Erc20 L2 Balances not showing without Unif…
Browse files Browse the repository at this point in the history
…ied Balances (#4169)
  • Loading branch information
dtverdota-bc committed Nov 30, 2022
1 parent dbafc39 commit 83d5594
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
Expand Up @@ -5,7 +5,6 @@ import com.blockchain.core.chains.erc20.data.store.Erc20L2DataSource
import com.blockchain.core.chains.erc20.data.store.Erc20L2Store
import com.blockchain.core.chains.erc20.domain.Erc20L2StoreService
import com.blockchain.core.chains.erc20.domain.model.Erc20Balance
import com.blockchain.core.chains.ethereum.EthDataManager
import com.blockchain.data.FreshnessStrategy
import com.blockchain.data.FreshnessStrategy.Companion.withKey
import com.blockchain.data.KeyedFreshnessStrategy
Expand All @@ -22,7 +21,6 @@ import kotlinx.coroutines.rx3.asObservable

internal class Erc20L2StoreRepository(
private val assetCatalogue: AssetCatalogue,
private val ethDataManager: EthDataManager,
private val erc20L2DataSource: Erc20L2DataSource
) : Erc20L2StoreService {

Expand All @@ -33,7 +31,9 @@ internal class Erc20L2StoreRepository(
return erc20L2DataSource
.streamData(refreshStrategy)
.mapData {
it.addresses.firstOrNull { it.address == ethDataManager.accountAddress }
// It's ok to take first here, by the time we support multiple ETH addresses we'll be using
// unified balances anyway.
it.addresses.firstOrNull()
?.balances?.mapNotNull { balance ->
val asset = if (balance.contractAddress == NonCustodialEvmService.NATIVE_IDENTIFIER) {
assetCatalogue.assetInfoFromNetworkTicker(networkTicker)
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/com/blockchain/koin/coreModule.kt
Expand Up @@ -298,7 +298,6 @@ val coreModule = module {
scoped<Erc20L2StoreService> {
Erc20L2StoreRepository(
assetCatalogue = get(),
ethDataManager = get(),
erc20L2DataSource = get()
)
}
Expand Down
Expand Up @@ -6,7 +6,6 @@ import com.blockchain.api.ethereum.evm.EvmBalanceResponse
import com.blockchain.core.chains.erc20.data.Erc20L2StoreRepository
import com.blockchain.core.chains.erc20.domain.Erc20L2StoreService
import com.blockchain.core.chains.erc20.domain.model.Erc20Balance
import com.blockchain.core.chains.ethereum.EthDataManager
import com.blockchain.data.DataResource
import info.blockchain.balance.AssetCatalogue
import info.blockchain.balance.AssetCategory
Expand All @@ -26,12 +25,10 @@ import org.junit.Test

class Erc20L2StoreRepositoryTest {
private val assetCatalogue = mockk<AssetCatalogue>()
private val ethDataManager = mockk<EthDataManager>()
private val erc20L2DataSource = mockk<Erc20L2DataSource>()

private val erc20L2StoreService: Erc20L2StoreService = Erc20L2StoreRepository(
assetCatalogue = assetCatalogue,
ethDataManager = ethDataManager,
erc20L2DataSource = erc20L2DataSource
)

Expand Down Expand Up @@ -94,7 +91,6 @@ class Erc20L2StoreRepositoryTest {
every { erc20L2DataSource.invalidate(any()) } just Runs
every { assetCatalogue.assetFromL1ChainByContractAddress(l1chain = "CRYPTO_NATIVE", any()) } returns cryptoCurrency
every { assetCatalogue.assetInfoFromNetworkTicker(symbol = "CRYPTO_NATIVE") } returns cryptoCurrencyNative
every { ethDataManager.accountAddress } returns "accountHash"
}

@Test
Expand Down

0 comments on commit 83d5594

Please sign in to comment.