Skip to content

Commit

Permalink
fix check fee bridge sol
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Dec 28, 2024
1 parent 6c4621e commit 46a225c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
solChainId,
toDisplay,
MAX_ORAICHAIN_DENOM,
MAX_SOL_CONTRACT_ADDRESS
MAX_SOL_CONTRACT_ADDRESS,
ORAI_SOL_CONTRACT_ADDRESS,
ORAI
} from '@oraichain/oraidex-common';
import {
chainInfos,
Expand Down Expand Up @@ -516,8 +518,8 @@ const Balance: React.FC<BalanceProps> = () => {

const web3Solana = new Web3SolanaProgramInteraction();
console.log('from token address: ', fromToken.contractAddress);

if (fromToken.contractAddress !== MAX_SOL_CONTRACT_ADDRESS) {
const isListCheckBalanceSolToOraichain = [ORAI_SOL_CONTRACT_ADDRESS];
if (isListCheckBalanceSolToOraichain.includes(fromToken.contractAddress)) {
// TODO: need check if support new token in solana
const currentBridgeBalance = await window.client.getBalance(ORAICHAIN_RELAYER_ADDRESS, toToken.denom);
console.log(
Expand Down Expand Up @@ -560,16 +562,16 @@ const Balance: React.FC<BalanceProps> = () => {
}

const receiverAddress = ORAICHAIN_RELAYER_ADDRESS;

if (fromToken.denom === MAX_ORAICHAIN_DENOM) {
const listCheckNotBalanceOraichainToSol = [ORAI];
if (!listCheckNotBalanceOraichainToSol.includes(fromToken.denom)) {
const web3Solana = new Web3SolanaProgramInteraction();
const bridgeBalance =
fromToken.contractAddress === NATIVE_MINT.toBase58()
? await web3Solana.getSolanaBalance(new PublicKey(SOL_RELAYER_ADDRESS))
: await web3Solana.getTokenBalance(SOL_RELAYER_ADDRESS, toToken.contractAddress);
console.log('token balance to solana: ', bridgeBalance, toToken.contractAddress);
if (bridgeBalance < transferAmount) {
const message = `Transfer ${fromToken.denom} to Solana failed. The bridge balance only has ${bridgeBalance}${fromToken.denom}, wanted ${transferAmount}${fromToken.denom}`;
const message = `Transfer ${fromToken.name} to Solana failed. The bridge balance only has ${bridgeBalance}${fromToken.name}, wanted ${transferAmount}${fromToken.name}`;
displayToast(TToastType.TX_FAILED, {
message
});
Expand Down

0 comments on commit 46a225c

Please sign in to comment.