From dee3bcb993cbcb44bece9a91f8139319fb5a1032 Mon Sep 17 00:00:00 2001 From: Zach Couchman Date: Mon, 5 Feb 2024 15:32:25 +1100 Subject: [PATCH] Small bridge txn fixes (#1442) Co-authored-by: Zach Couchman --- .../components/Transactions/Transactions.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/checkout/widgets-lib/src/components/Transactions/Transactions.tsx b/packages/checkout/widgets-lib/src/components/Transactions/Transactions.tsx index 2bd3b59dbe..20de96eac7 100644 --- a/packages/checkout/widgets-lib/src/components/Transactions/Transactions.tsx +++ b/packages/checkout/widgets-lib/src/components/Transactions/Transactions.tsx @@ -232,6 +232,31 @@ export function Transactions({ onBackButtonClick }: TransactionsProps) { return client.getTransactions({ txType: TransactionType.BRIDGE, fromAddress: address }); }, []); + const handleBackButtonClick = () => { + if (from) { + bridgeDispatch({ + payload: { + type: BridgeActions.SET_WALLETS_AND_NETWORKS, + from: { + web3Provider: from?.web3Provider, + walletAddress: from?.walletAddress, + network: from?.network, + }, + to: null, + }, + }); + bridgeDispatch({ + payload: { + type: BridgeActions.SET_TOKEN_AND_AMOUNT, + token: null, + amount: '', + }, + }); + } + + onBackButtonClick(); + }; + const fetchData = useCallback(async () => { if (!from?.walletAddress) return undefined; @@ -281,7 +306,7 @@ export function Transactions({ onBackButtonClick }: TransactionsProps) { setLoading(false); })(); - }, [from?.walletAddress, checkout]); + }, [from, checkout]); useEffect(() => { page({ @@ -296,7 +321,7 @@ export function Transactions({ onBackButtonClick }: TransactionsProps) { header={( sendBridgeWidgetCloseEvent(eventTarget)} />