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 18, 2023
1 parent dbf7a24 commit 1103695
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

1 comment on commit 1103695

@vercel
Copy link

@vercel vercel bot commented on 1103695 Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bridge-ui-v2-internal – ./packages/bridge-ui-v2

bridge-ui-v2-internal-taikoxyz.vercel.app
bridge-ui-v2-internal.vercel.app
bridge-ui-v2-internal-git-main-taikoxyz.vercel.app

Please sign in to comment.