Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Darwinia and Crab native token address mutation #576

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/apps/src/bridges/helix-lpbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/src/bridges/helixbridge-dvmdvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/src/bridges/helixbridge-dvmevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
14 changes: 2 additions & 12 deletions packages/apps/src/components/transfer-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,10 @@ interface Props {
transferValue: TransferValue;
isOpen: boolean;
onClose: () => void;
onSuccess: () => void;
refetchRelayers: () => Promise<ApolloQueryResult<RelayersResponseData>>;
}

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);
Expand Down Expand Up @@ -72,7 +63,6 @@ export default function TransferModal({
if (receipt?.status === "success") {
setTxHash(receipt.transactionHash);
setDisabled(true);
onSuccess();
}
} catch (err) {
console.error(err);
Expand All @@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/src/components/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading