Skip to content

Commit

Permalink
fix(bridge-ui-v2): processing fee (#14696)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorbinianK committed Sep 28, 2023
1 parent 3dccdad commit 872c056
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
error = false;
try {
let destBalance;
// Get the balance of the user on the destination chain
const destBalance = await getBalance({
token,
destBalance = await getBalance({
userAddress,
srcChainId: destChainId,
});
Expand Down
11 changes: 9 additions & 2 deletions packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPublicClient } from '@wagmi/core';
import { fetchBalance, getPublicClient } from '@wagmi/core';
import { type Address, zeroAddress } from 'viem';

import { routingContractsMap } from '$bridgeConfig';
Expand Down Expand Up @@ -72,7 +72,14 @@ export async function checkBalanceToBridge({
// since we are briding a token, we need the ETH balance of the wallet
balance = await getPublicClient().getBalance(wallet.account);

if (!tokenAddress || tokenAddress === zeroAddress || balance === BigInt(0)) return false;
const tokenBalance = await fetchBalance({
address: wallet.account.address,
token: tokenAddress,
chainId: srcChainId,
});

if (!tokenAddress || tokenAddress === zeroAddress || balance === BigInt(0) || tokenBalance.value <= amount)
throw new InsufficientBalanceError('you do not have enough balance to bridge');

const bridge = bridges[token.type];

Expand Down

0 comments on commit 872c056

Please sign in to comment.