diff --git a/src/core/setup.ts b/src/core/setup.ts index bb1bec4a3..bb211cc23 100644 --- a/src/core/setup.ts +++ b/src/core/setup.ts @@ -90,7 +90,16 @@ const defaultTestnetTokens: ITokenWithoutLogo[] = Object.keys(testnetContracts) usdBalance: 0, } }) -export const getDefaultTokens = (chainId: ChainTypesByIdType) => - chainTypesById[chainId] === ChainTypeEnum.MAINNET +export const getDefaultTokens = (chainId: ChainTypesByIdType) => { + const usdRifTestnet = { + decimals: 18, + name: 'RIF US Dollar', + symbol: 'USDRIF', + contractAddress: '0x8dbf326e12a9ff37ed6ddf75ada548c2640a6482', + balance: '0x00', + usdBalance: 0, + } as ITokenWithoutLogo + return chainTypesById[chainId] === ChainTypeEnum.MAINNET ? defaultMainnetTokens - : defaultTestnetTokens + : [...defaultTestnetTokens, usdRifTestnet] +} diff --git a/src/subscriptions/rifSockets.ts b/src/subscriptions/rifSockets.ts index 7f73ee8b8..caa7ed6b9 100644 --- a/src/subscriptions/rifSockets.ts +++ b/src/subscriptions/rifSockets.ts @@ -1,6 +1,7 @@ import EventEmitter from 'eventemitter3' import { RIFWallet } from '@rsksmart/rif-wallet-core' import { + ITokenWithBalance, RifWalletServicesFetcher, RifWalletServicesSocket, } from '@rsksmart/rif-wallet-services' @@ -95,12 +96,16 @@ export const rifSockets = ({ } const defaultTokens = getDefaultTokens(chainId) - defaultTokens.forEach(t => { + const defaultTokensWithBalance = defaultTokens.map(t => { const tokenBalance = balances[t.contractAddress] - t.balance = tokenBalance?.balance ?? t.balance - t.usdBalance = tokenBalance?.usdBalance ?? t.usdBalance + return { + ...t, + logo: '', + balance: tokenBalance?.balance ?? t.balance, + usdBalance: tokenBalance?.usdBalance ?? t.usdBalance, + } as ITokenWithBalance }) - dispatch(addOrUpdateBalances(defaultTokens)) + dispatch(addOrUpdateBalances(defaultTokensWithBalance)) rifWalletServicesSocket.removeAllListeners()