Skip to content

Commit 0abd519

Browse files
Merge pull request coingrig#3 from coingrig/feature/fix-price-update
fix: Don't set price to 0 on update fail
2 parents 6d2ad55 + 0aacfd8 commit 0abd519

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
@@ -74,10 +74,13 @@ class CryptoService {
7474
privKey: chainKeys[chain],
7575
walletAddress: WalletStore.getWalletAddressByChain(chain),
7676
});
77-
WalletStore.setPrice(
78-
wallet.symbol,
79-
parseFloat(prices[wallet.name.toLowerCase()]?.usd ?? '0'),
80-
);
77+
// Don't update the price if none is available from the provider
78+
let newPrice = prices[wallet.name.toLowerCase()]?.usd ?? null;
79+
if (newPrice !== null) {
80+
// The price can be actually 0
81+
newPrice = parseFloat(newPrice);
82+
WalletStore.setPrice(wallet.symbol, newPrice);
83+
}
8184
let cryptoWallet = WalletFactory.getWallet(wallet);
8285
const balance = await cryptoWallet.getBalance();
8386
const unconfirmedBalance = balance.getUnconfirmedBalance();

0 commit comments

Comments
 (0)