From 741845ab90b4e8241d0a5240b5f6c4b749e3ae47 Mon Sep 17 00:00:00 2001 From: Nikita Yutanov Date: Tue, 3 Sep 2024 02:03:13 +0300 Subject: [PATCH] Optimize state reading --- .../swap/components/swap-form/swap-form.tsx | 6 +- frontend/src/features/swap/consts/index.ts | 3 + frontend/src/features/swap/consts/vara.ts | 15 +++ .../src/features/swap/hooks/use-bridge.ts | 120 ++---------------- .../src/features/swap/hooks/use-ft-symbols.ts | 40 ++++++ .../src/features/swap/hooks/vara/index.ts | 3 +- .../swap/hooks/vara/use-ft-addresses.ts | 38 ++++++ .../hooks/vara/use-fungible-token-balance.ts | 13 +- .../swap/hooks/vara/use-vara-config.ts | 6 +- frontend/src/features/swap/utils.ts | 18 ++- 10 files changed, 138 insertions(+), 124 deletions(-) create mode 100644 frontend/src/features/swap/consts/vara.ts create mode 100644 frontend/src/features/swap/hooks/use-ft-symbols.ts create mode 100644 frontend/src/features/swap/hooks/vara/use-ft-addresses.ts diff --git a/frontend/src/features/swap/components/swap-form/swap-form.tsx b/frontend/src/features/swap/components/swap-form/swap-form.tsx index 29f33d42..05b0d1ee 100644 --- a/frontend/src/features/swap/components/swap-form/swap-form.tsx +++ b/frontend/src/features/swap/components/swap-form/swap-form.tsx @@ -25,7 +25,7 @@ function SwapForm({ networkIndex, disabled, useHandleSubmit, useBalance, renderS const FromNetwork = isVaraNetwork ? Network.Vara : Network.Eth; const ToNetwork = isVaraNetwork ? Network.Eth : Network.Vara; - const { address, options, symbol, pair, ...bridge } = useBridge(networkIndex); + const { address, options, symbol, pair, nativeSymbol, ...bridge } = useBridge(networkIndex); const { fee, ...config } = useVaraConfig(isVaraNetwork); const balance = useBalance(address); const { onSubmit, isSubmitting } = useHandleSubmit(address, fee.value); @@ -41,7 +41,7 @@ function SwapForm({ networkIndex, disabled, useHandleSubmit, useBalance, renderS const renderFromBalance = () => ( @@ -81,7 +81,7 @@ function SwapForm({ networkIndex, disabled, useHandleSubmit, useBalance, renderS heading="Expected Fee" value={fee.formattedValue} isLoading={config.isLoading} - unit={symbol.native} + unit={nativeSymbol} />