From bfc67024fc0755ace8116949a600ff6471720886 Mon Sep 17 00:00:00 2001 From: Griko Nibras Date: Fri, 12 Jan 2024 16:41:18 +0700 Subject: [PATCH 1/3] fix: attempt resolve changing wallet account issue [FRE-512] Signed-off-by: Griko Nibras --- .../TransactionDialog/TransactionDialogContent.tsx | 8 ++++++-- src/context/account.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/TransactionDialog/TransactionDialogContent.tsx b/src/components/TransactionDialog/TransactionDialogContent.tsx index ab8c2155..f633c096 100644 --- a/src/components/TransactionDialog/TransactionDialogContent.tsx +++ b/src/components/TransactionDialog/TransactionDialogContent.tsx @@ -6,7 +6,7 @@ import { useState } from "react"; import { toast } from "react-hot-toast"; import { useAccount as useWagmiAccount } from "wagmi"; -import { getTrackAccount } from "@/context/account"; +import { getTrackAccount, trackAccount } from "@/context/account"; import { useSettingsStore } from "@/context/settings"; import { addTxHistory, @@ -71,6 +71,9 @@ function TransactionDialogContent({ try { const userAddresses: Record = {}; + const [sourceChainID] = route.chainIDs; + const sourceWalletName = getTrackAccount(sourceChainID)!; + for (const chainID of route.chainIDs) { const chain = chains.find((c) => c.chainID === chainID); if (!chain) { @@ -80,7 +83,7 @@ function TransactionDialogContent({ if (chain.chainType === "cosmos") { const { wallets } = getWalletRepo(chain.chainName); - const walletName = getTrackAccount(chainID); + const walletName = getTrackAccount(chainID) || sourceWalletName; const wallet = wallets.find((w) => w.walletName === walletName); if (!wallet) { throw new Error( @@ -89,6 +92,7 @@ function TransactionDialogContent({ } if (wallet.isWalletDisconnected) { await wallet.connect(); + trackAccount.track(chainID, walletName); } if (!wallet.address) { diff --git a/src/context/account.ts b/src/context/account.ts index 3af6d73d..2119e6b8 100644 --- a/src/context/account.ts +++ b/src/context/account.ts @@ -1,5 +1,5 @@ import { create } from "zustand"; -import { persist } from "zustand/middleware"; +import { createJSONStorage, persist } from "zustand/middleware"; type TrackAccountStore = Record; @@ -9,6 +9,7 @@ const store = create( persist(() => defaultValues, { name: "TrackAccountState", version: 1, + storage: createJSONStorage(() => window.sessionStorage), }), ); From 820a30958775f36475c7c685dc097c5e83723341 Mon Sep 17 00:00:00 2001 From: Griko Nibras Date: Fri, 12 Jan 2024 16:41:39 +0700 Subject: [PATCH 2/3] feat: persist amount in and out Signed-off-by: Griko Nibras --- src/components/SwapWidget/useSwapWidget.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/SwapWidget/useSwapWidget.ts b/src/components/SwapWidget/useSwapWidget.ts index 561b7a3b..6c65d5c7 100644 --- a/src/components/SwapWidget/useSwapWidget.ts +++ b/src/components/SwapWidget/useSwapWidget.ts @@ -292,8 +292,10 @@ const useFormValuesStore = create( persist(() => defaultValues, { name: "SwapWidgetState", version: 1, - storage: createJSONStorage(() => sessionStorage), + storage: createJSONStorage(() => window.sessionStorage), partialize: (state): Partial => ({ + amountIn: state.amountIn, + amountOut: state.amountOut, sourceChain: state.sourceChain, sourceAsset: state.sourceAsset, destinationChain: state.destinationChain, From 69d28fd6a3b617dfefbbec97917bf0d8d25e3730 Mon Sep 17 00:00:00 2001 From: Griko Nibras Date: Fri, 12 Jan 2024 16:41:50 +0700 Subject: [PATCH 3/3] feat: animate tx dialog Signed-off-by: Griko Nibras --- src/components/TransactionDialog/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TransactionDialog/index.tsx b/src/components/TransactionDialog/index.tsx index f1f00eba..06a4cc01 100644 --- a/src/components/TransactionDialog/index.tsx +++ b/src/components/TransactionDialog/index.tsx @@ -70,7 +70,7 @@ function TransactionDialog({ Preview Route {isOpen && ( -
+
{route && (