From 38f5f6a4dd6cc20f1bc7c739e3db027573db55dc Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Sat, 18 Nov 2023 02:15:39 +0800 Subject: [PATCH 1/2] Reset transferValue after closing Transfer Summary --- packages/apps/src/components/transfer-modal.tsx | 14 ++------------ packages/apps/src/components/transfer.tsx | 4 ++-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/apps/src/components/transfer-modal.tsx b/packages/apps/src/components/transfer-modal.tsx index f01a7461d..acd0cb127 100644 --- a/packages/apps/src/components/transfer-modal.tsx +++ b/packages/apps/src/components/transfer-modal.tsx @@ -23,19 +23,10 @@ interface Props { transferValue: TransferValue; isOpen: boolean; onClose: () => void; - onSuccess: () => void; refetchRelayers: () => Promise>; } -export default function TransferModal({ - sender, - recipient, - transferValue, - isOpen, - onClose, - onSuccess, - refetchRelayers, -}: Props) { +export default function TransferModal({ sender, recipient, transferValue, isOpen, onClose, refetchRelayers }: Props) { const { bridgeClient, sourceValue, targetValue, fee, transfer } = useTransfer(); const [txHash, setTxHash] = useState(""); const [busy, setBusy] = useState(false); @@ -72,7 +63,6 @@ export default function TransferModal({ if (receipt?.status === "success") { setTxHash(receipt.transactionHash); setDisabled(true); - onSuccess(); } } catch (err) { console.error(err); @@ -81,7 +71,7 @@ export default function TransferModal({ setBusy(false); } } - }, [bridgeClient, onSuccess, recipient, refetchRelayers, sender, transfer, transferValue]); + }, [bridgeClient, recipient, refetchRelayers, sender, transfer, transferValue]); // Reset state useEffect(() => { diff --git a/packages/apps/src/components/transfer.tsx b/packages/apps/src/components/transfer.tsx index 1adf50fcd..59b93f656 100644 --- a/packages/apps/src/components/transfer.tsx +++ b/packages/apps/src/components/transfer.tsx @@ -336,8 +336,8 @@ export default function Transfer() { recipient={recipient || address} transferValue={deferredTransferValue} isOpen={isOpen} - onClose={setIsOpenFalse} - onSuccess={() => { + onClose={() => { + setIsOpenFalse(); setTransferValue({ value: "", formatted: 0n }); }} refetchRelayers={refetchRelayers} From d2cdf7a486c2d33ba778d3a961d261eba02e48a9 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Sat, 18 Nov 2023 02:19:11 +0800 Subject: [PATCH 2/2] Fix RING and CRAB address mutation --- packages/apps/src/bridges/helix-lpbridge.ts | 4 ++-- packages/apps/src/bridges/helixbridge-dvmdvm.ts | 4 ++-- packages/apps/src/bridges/helixbridge-dvmevm.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/apps/src/bridges/helix-lpbridge.ts b/packages/apps/src/bridges/helix-lpbridge.ts index 0db8e413f..678eaeb58 100644 --- a/packages/apps/src/bridges/helix-lpbridge.ts +++ b/packages/apps/src/bridges/helix-lpbridge.ts @@ -22,8 +22,8 @@ export class HelixLpBridge extends BaseBridge { sourceToken?: Token; targetToken?: Token; }) { - const sourceToken = args.sourceToken; - const targetToken = args.targetToken; + const sourceToken = args.sourceToken ? { ...args.sourceToken } : undefined; // DON'T USE `const sourceToken = args.sourceToken` + const targetToken = args.targetToken ? { ...args.targetToken } : undefined; if (args.sourceChain?.network === "darwinia-dvm" && sourceToken?.symbol === "RING") { sourceToken.address = "0xE7578598Aac020abFB918f33A20faD5B71d670b4"; } else if (args.targetChain?.network === "darwinia-dvm" && targetToken?.symbol === "RING") { diff --git a/packages/apps/src/bridges/helixbridge-dvmdvm.ts b/packages/apps/src/bridges/helixbridge-dvmdvm.ts index ec84105e9..117668adb 100644 --- a/packages/apps/src/bridges/helixbridge-dvmdvm.ts +++ b/packages/apps/src/bridges/helixbridge-dvmdvm.ts @@ -27,8 +27,8 @@ export class HelixBridgeDVMDVM extends BaseBridge { sourceToken?: Token; targetToken?: Token; }) { - const sourceToken = args.sourceToken; - const targetToken = args.targetToken; + const sourceToken = args.sourceToken ? { ...args.sourceToken } : undefined; // DON'T USE `const sourceToken = args.sourceToken` + const targetToken = args.targetToken ? { ...args.targetToken } : undefined; if (args.sourceChain?.network === "darwinia-dvm" && sourceToken?.symbol === "RING") { sourceToken.address = "0xE7578598Aac020abFB918f33A20faD5B71d670b4"; } else if (args.targetChain?.network === "darwinia-dvm" && targetToken?.symbol === "RING") { diff --git a/packages/apps/src/bridges/helixbridge-dvmevm.ts b/packages/apps/src/bridges/helixbridge-dvmevm.ts index 6828d3461..00e69fbb9 100644 --- a/packages/apps/src/bridges/helixbridge-dvmevm.ts +++ b/packages/apps/src/bridges/helixbridge-dvmevm.ts @@ -24,8 +24,8 @@ export class HelixBridgeDVMEVM extends BaseBridge { sourceToken?: Token; targetToken?: Token; }) { - const sourceToken = args.sourceToken; - const targetToken = args.targetToken; + const sourceToken = args.sourceToken ? { ...args.sourceToken } : undefined; // DON'T USE `const sourceToken = args.sourceToken` + const targetToken = args.targetToken ? { ...args.targetToken } : undefined; if (args.sourceChain?.network === "darwinia-dvm" && sourceToken?.symbol === "RING") { sourceToken.address = "0xE7578598Aac020abFB918f33A20faD5B71d670b4"; } else if (args.targetChain?.network === "darwinia-dvm" && targetToken?.symbol === "RING") {