Skip to content

Commit 0aacfd8

Browse files
committed
Fix: Don't set price to 0 on update fail
Don't update the price if none is available from the provider. Keep last known price.
1 parent d31f30f commit 0aacfd8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/services/crypto.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ class CryptoService {
6767
privKey: chainKeys[chain],
6868
walletAddress: WalletStore.getWalletAddressByChain(chain),
6969
});
70-
WalletStore.setPrice(
71-
wallet.symbol,
72-
parseFloat(prices[wallet.name.toLowerCase()]?.usd ?? '0'),
73-
);
70+
// Don't update the price if none is available from the provider
71+
let newPrice = prices[wallet.name.toLowerCase()]?.usd ?? null;
72+
if (newPrice !== null) {
73+
// The price can be actually 0
74+
newPrice = parseFloat(newPrice);
75+
WalletStore.setPrice(wallet.symbol, newPrice);
76+
}
7477
let cryptoWallet = WalletFactory.getWallet(wallet);
7578
const balance = await cryptoWallet.getBalance();
7679
const unconfirmedBalance = balance.getUnconfirmedBalance();

0 commit comments

Comments
 (0)