diff --git a/components/page/bridge/hooks/useGetFee.ts b/components/page/bridge/hooks/useGetFee.ts index e064e0e..350a39f 100644 --- a/components/page/bridge/hooks/useGetFee.ts +++ b/components/page/bridge/hooks/useGetFee.ts @@ -55,20 +55,31 @@ const useGetFee = ({ token }: { token: TokenType }) => { useEffect(() => { (async () => { - const tonBridgeClient = new TonbridgeBridgeClient( - window.client, - oraiAddress, - network.CW_TON_BRIDGE - ); + if (token) { + const tokenInTon = TonTokenList(TonNetwork.Mainnet).find( + (tk) => tk.coingeckoId === token.coingeckoId + ); + if (!tokenInTon) { + return; + } + + const tonBridgeClient = new TonbridgeBridgeClient( + window.client, + oraiAddress, + network.CW_TON_BRIDGE + ); - const config = await tonBridgeClient.config(); - if (config) { - const { relayer_fee } = config; + const config = await tonBridgeClient.pairMapping({ + key: tokenInTon?.contractAddress, + }); + const pairMapping = config.pair_mapping; - setBridgeFee(toDisplay(relayer_fee)); + setBridgeFee( + parseInt(pairMapping.relayer_fee) / 10 ** pairMapping.remote_decimals + ); } })(); - }, []); + }, [token, oraiAddress]); return { bridgeFee, diff --git a/components/page/bridge/index.tsx b/components/page/bridge/index.tsx index a626895..1a7bbb3 100644 --- a/components/page/bridge/index.tsx +++ b/components/page/bridge/index.tsx @@ -96,6 +96,7 @@ const Bridge = () => { ? oraiAddress || "" : tonAddress || ""; + console.log("Read token:", { token }); const { bridgeFee, tokenFee } = useGetFee({ token, }); @@ -618,7 +619,7 @@ const Bridge = () => { {numberWithCommas(bridgeFee || 0, undefined, { maximumFractionDigits: CW20_DECIMALS, })}{" "} - ORAI + {token?.symbol}
diff --git a/package.json b/package.json index c586523..fcb9a19 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@oraichain/orai-bitcoin": "^2.0.0", "@oraichain/oraidex-common": "^1.0.88-beta.1", "@oraichain/ton-bridge-contracts": "^0.15.5", - "@oraichain/tonbridge-contracts-sdk": "1.3.0", + "@oraichain/tonbridge-contracts-sdk": "^1.3.1", "@orbs-network/ton-access": "^2.3.3", "@tanstack/react-query": "^5.49.2", "@ton/core": "~0", diff --git a/yarn.lock b/yarn.lock index 3b9463c..9adb585 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1624,10 +1624,10 @@ dotenv "^16.4.5" varstruct "^6.1.3" -"@oraichain/tonbridge-contracts-sdk@1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-contracts-sdk/-/tonbridge-contracts-sdk-1.3.0.tgz#b03f28005722604fe4d557dd8e58ef214ade5874" - integrity sha512-yTGlH5Oyq6s3cj63EJoBx+n4YxqhN6EcC8I0h9HmlOnGxzZgLY3AUkFjkFPgn5prH9dIfixhXnfh/TPXq0j9Pw== +"@oraichain/tonbridge-contracts-sdk@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-contracts-sdk/-/tonbridge-contracts-sdk-1.3.1.tgz#5c2981b5c1c99bda7db143d8f294449bdc15f2d7" + integrity sha512-atSmGRzlGodjidY32I50UJPtVIriaoeqOOw/Qx2qnCk2S/1z5oAotPO9mfHeLALb3rgN/gtXhtQj/dqCU0rlsA== "@orbs-network/ton-access@^2.3.3": version "2.3.3"