Skip to content

Commit

Permalink
fix(bridge-ui): Chain block (#13452)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Mar 25, 2023
1 parent 7285947 commit cb32862
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/components/Transaction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
// confirm after switch chain that it worked.
if (!isOnCorrectChain($signer, bridgeTx.toChainId)) {
if (!(await isOnCorrectChain($signer, bridgeTx.toChainId))) {
errorToast('You are connected to the wrong chain in your wallet');
return;
}
Expand Down Expand Up @@ -128,7 +128,7 @@
}
// confirm after switch chain that it worked.
if (!isOnCorrectChain($signer, bridgeTx.fromChainId)) {
if (!(await isOnCorrectChain($signer, bridgeTx.fromChainId))) {
errorToast('You are connected to the wrong chain in your wallet');
return;
}
Expand Down
19 changes: 13 additions & 6 deletions packages/bridge-ui/src/components/form/BridgeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,24 @@
return allowance;
}
function isBtnDisabled(
async function isBtnDisabled(
signer: Signer,
amount: string,
token: Token,
tokenBalance: string,
requiresAllowance: boolean,
memoError: string,
fromChain: Chain,
) {
if (!signer) return true;
if (!tokenBalance) return true;
const chainId = $fromChain.id;
if (!fromChain) return true;
const chainId = fromChain.id;
if (!chainId || !chains[chainId.toString()]) return true;
if (!(await isOnCorrectChain(signer, fromChain.id))) return true;
if (!amount || ethers.utils.parseUnits(amount).eq(BigNumber.from(0)))
return true;
if (isNaN(parseFloat(amount))) return true;
Expand Down Expand Up @@ -218,7 +222,7 @@
throw Error('Invalid custom recipient address');
}
if (!isOnCorrectChain($signer, $fromChain.id)) {
if (!(await isOnCorrectChain($signer, $fromChain.id))) {
errorToast('You are connected to the wrong chain in your wallet');
return;
}
Expand Down Expand Up @@ -373,14 +377,17 @@
$: getUserBalance($signer, $token, $fromChain);
$: btnDisabled = isBtnDisabled(
$: isBtnDisabled(
$signer,
amount,
$token,
tokenBalance,
requiresAllowance,
memoError,
);
$fromChain,
)
.then((d) => (btnDisabled = d))
.catch((e) => console.error(e));
$: checkAllowance(amount, $token, $bridgeType, $fromChain, $signer)
.then((a) => (requiresAllowance = a))
Expand Down

0 comments on commit cb32862

Please sign in to comment.