Skip to content

Commit

Permalink
chain id check
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Mar 24, 2023
1 parent 31ad254 commit 83e6d36
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/bridge-ui/src/components/form/BridgeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,26 @@
throw Error('Invalid custom recipient address');
}
const signerChain = await $signer.getChainId();
if (signerChain !== $fromChain.id) {
errorToast('You are connected to the wrong chain in your wallet');
return;
}
const bridgeAddress = chains[$fromChain.id].bridgeAddress;
const tokenVaultAddress = tokenVaults[$fromChain.id];
const codeNotDeployed = [bridgeAddress, tokenVaultAddress].find(
async (a) => {
return (await $signer.provider.getCode(a)) === '0x';
},
);
if (codeNotDeployed) {
errorToast('You are connected to the wrong chain in your wallet');
return;
}
const amountInWei = ethers.utils.parseUnits(amount, $token.decimals);
const provider = providers[$toChain.id];
Expand All @@ -236,8 +256,8 @@
tokenAddress: await addrForToken(),
fromChainId: $fromChain.id,
toChainId: $toChain.id,
tokenVaultAddress: tokenVaults[$fromChain.id],
bridgeAddress: chains[$fromChain.id].bridgeAddress,
tokenVaultAddress: tokenVaultAddress,
bridgeAddress: bridgeAddress,
processingFeeInWei: getProcessingFee(),
memo: memo,
isBridgedTokenAlreadyDeployed,
Expand Down

0 comments on commit 83e6d36

Please sign in to comment.