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(bridge-ui-v2): processing fee #14696

Merged
merged 8 commits into from
Sep 18, 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
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
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.