From 081be64591b48cfa4fb10baf3067cf974476e298 Mon Sep 17 00:00:00 2001 From: Francisco Ramos Date: Fri, 14 Jul 2023 09:42:30 +0200 Subject: [PATCH] feat(bridge-ui-v2): account balance (#14159) Co-authored-by: Korbinian --- packages/bridge-ui-v2/package.json | 1 + .../components/AmountInput/AmountInput.svelte | 53 ++++++++++++++++++- .../src/components/Bridge/Bridge.svelte | 8 +-- .../src/components/Faucet/Faucet.svelte | 11 ++-- .../components/LoadingText/LoadingText.svelte | 9 ++++ .../src/components/LoadingText/index.ts | 0 .../bridge-ui-v2/src/libs/chain/chains.ts | 27 +++++++--- .../bridge-ui-v2/src/libs/token/getAddress.ts | 49 +++++++++++++++++ .../bridge-ui-v2/src/libs/token/getBalance.ts | 26 +++++++++ packages/bridge-ui-v2/src/libs/token/index.ts | 2 + .../bridge-ui-v2/src/libs/token/tokens.ts | 9 ++++ .../src/libs/util/truncateString.ts | 3 ++ 12 files changed, 181 insertions(+), 17 deletions(-) create mode 100644 packages/bridge-ui-v2/src/components/LoadingText/LoadingText.svelte create mode 100644 packages/bridge-ui-v2/src/components/LoadingText/index.ts create mode 100644 packages/bridge-ui-v2/src/libs/token/getAddress.ts create mode 100644 packages/bridge-ui-v2/src/libs/token/getBalance.ts create mode 100644 packages/bridge-ui-v2/src/libs/util/truncateString.ts diff --git a/packages/bridge-ui-v2/package.json b/packages/bridge-ui-v2/package.json index eebbbf12654..9f689a0e0f8 100644 --- a/packages/bridge-ui-v2/package.json +++ b/packages/bridge-ui-v2/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "dev": "vite dev", + "dev:a3": "vite dev --mode a3", "build": "vite build", "preview": "vite preview", "test:pw": "playwright test", diff --git a/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte b/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte index 7f92fdf456f..1c867eae6fc 100644 --- a/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte +++ b/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte @@ -1,10 +1,54 @@
@@ -12,7 +56,14 @@
{$t('amount_input.balance')}: - 399.92 ETH + + {#if computingTokenBalance} + + + {:else} + {renderTokenBalance(tokenBalance)} + {/if} +
diff --git a/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte b/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte index 5f707c337b9..0a42443ab82 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte @@ -9,8 +9,10 @@ import { ProcessingFee } from '$components/ProcessingFee'; import { RecipientInput } from '$components/RecipientInput'; import { TokenDropdown } from '$components/TokenDropdown'; - import { tokens } from '$libs/token'; + import { type Token, tokens } from '$libs/token'; import { destChain, srcChain } from '$stores/network'; + + let selectedToken: Token; @@ -18,10 +20,10 @@
- +
- +