From a0035c18af3d6ddbd22e84bb111d8cb17d16899b Mon Sep 17 00:00:00 2001 From: Georgios Jason Efstathiou Date: Mon, 18 Sep 2023 12:50:51 +0300 Subject: [PATCH] fix: token store race cond, broken fiat estimates on projects view & claim project flow --- .../aggregate-fiat-estimate.svelte | 11 ++++-- .../token-amounts-table.svelte | 36 ++++++++++++++----- .../utils/fiat-estimates/fiat-estimates.ts | 23 ++++++------ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/lib/components/aggregate-fiat-estimate/aggregate-fiat-estimate.svelte b/src/lib/components/aggregate-fiat-estimate/aggregate-fiat-estimate.svelte index 72644151d..dc0323a7f 100644 --- a/src/lib/components/aggregate-fiat-estimate/aggregate-fiat-estimate.svelte +++ b/src/lib/components/aggregate-fiat-estimate/aggregate-fiat-estimate.svelte @@ -32,7 +32,7 @@ const connected = tokensStore.connected; $: { - if ($connected && amounts) { + if ($connected && amounts && $connected) { const prices = $priceStore; includesUnknownPrice = false; @@ -41,7 +41,14 @@ fiatEstimateCents = 'pending'; } else { fiatEstimateCents = amounts.reduce((sum, { tokenAddress, amount }) => { - const res = fiatEstimates.convert({ amount, tokenAddress }); + const token = tokensStore.getByAddress(tokenAddress); + + if (!token) { + includesUnknownPrice = true; + return sum; + } + + const res = fiatEstimates.convert({ amount, tokenAddress }, token.info.decimals); if (res === 'unsupported') { includesUnknownPrice = true; diff --git a/src/lib/components/token-amounts-table/token-amounts-table.svelte b/src/lib/components/token-amounts-table/token-amounts-table.svelte index 8c3886d3b..1bfe6f128 100644 --- a/src/lib/components/token-amounts-table/token-amounts-table.svelte +++ b/src/lib/components/token-amounts-table/token-amounts-table.svelte @@ -1,7 +1,7 @@