Skip to content

Commit 814fce1

Browse files
authored
Merge pull request #24 from oraidex/hot_fix/fix_error_on_submiting_ton
update code for fixing error on submiting ton
2 parents d2fc058 + ce19ad8 commit 814fce1

File tree

4 files changed

+64
-42
lines changed

4 files changed

+64
-42
lines changed

components/page/bridge/constants.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { toNano } from "@ton/core";
22

33
const FWD_AMOUNT = toNano(0.15);
4-
const TON_MESSAGE_VALID_UNTIL = 100000;
5-
const BRIDGE_TON_TO_ORAI_MINIMUM_GAS = toNano(1);
4+
const BRIDGE_TON_TO_ORAI_MINIMUM_GAS = 50000001n;
5+
const BRIDGE_JETTON_TO_ORAI_MINIMUM_GAS = toNano(1);
66
const EXTERNAL_MESSAGE_FEE = toNano(0.01);
77
const MINIMUM_BRIDGE_PER_USD = 10;
88

99
export {
1010
FWD_AMOUNT,
11-
TON_MESSAGE_VALID_UNTIL,
1211
BRIDGE_TON_TO_ORAI_MINIMUM_GAS,
12+
BRIDGE_JETTON_TO_ORAI_MINIMUM_GAS,
1313
EXTERNAL_MESSAGE_FEE,
1414
MINIMUM_BRIDGE_PER_USD,
1515
};

components/page/bridge/index.tsx

+23-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ import {
5050
JettonWallet,
5151
} from "@oraichain/ton-bridge-contracts";
5252
import { TonbridgeBridgeClient } from "@oraichain/tonbridge-contracts-sdk";
53-
import { Address, Cell, beginCell, toNano } from "@ton/core";
53+
import {
54+
Address,
55+
Cell,
56+
Sender,
57+
beginCell,
58+
storeStateInit,
59+
toNano,
60+
} from "@ton/core";
5461
import { TonClient } from "@ton/ton";
5562
import { Base64 } from "@tonconnect/protocol";
5663
import { useEffect, useState } from "react";
@@ -76,12 +83,11 @@ import {
7683
} from "@/hooks/useFillNetwork";
7784
import {
7885
FWD_AMOUNT,
79-
TON_MESSAGE_VALID_UNTIL,
8086
BRIDGE_TON_TO_ORAI_MINIMUM_GAS,
81-
MINIMUM_BRIDGE_PER_USD,
87+
BRIDGE_JETTON_TO_ORAI_MINIMUM_GAS,
8288
} from "./constants";
8389
import { getMixPanelClient } from "@/libs/mixpanel";
84-
import { useTonConnectUI } from "@tonconnect/ui-react";
90+
import { TonConnectUI, useTonConnectUI } from "@tonconnect/ui-react";
8591
import { useCoinGeckoPrices } from "@/hooks/useCoingecko";
8692
import SelectCommon from "@/components/commons/select";
8793
import { NetworkWithIcon } from "@/constants/chainInfo";
@@ -386,6 +392,8 @@ const Bridge = () => {
386392

387393
setLoading(true);
388394

395+
const tonClient = await getTonClient();
396+
389397
const tokenInOrai = OraichainTokenList(
390398
process.env.NEXT_PUBLIC_ENV as Environment
391399
).find((tk) => tk.coingeckoId === token.coingeckoId);
@@ -402,6 +410,9 @@ const Bridge = () => {
402410
const bridgeAdapterAddress = Address.parse(
403411
TonInteractionContract[tonNetwork].bridgeAdapter
404412
);
413+
const bridgeAdapterClient = tonClient.open(
414+
BridgeAdapter.createFromAddress(bridgeAdapterAddress)
415+
);
405416
const fmtAmount = new BigDecimal(10).pow(token.decimal).mul(amount);
406417
const isNativeTon: boolean = token.contractAddress === TON_ZERO_ADDRESS;
407418
const toAddress: string = isNativeTon
@@ -411,10 +422,10 @@ const Bridge = () => {
411422
const oraiAddressBech32 = fromBech32(oraiAddress).data;
412423
const gasAmount = isNativeTon
413424
? fmtAmount.add(BRIDGE_TON_TO_ORAI_MINIMUM_GAS).toString()
414-
: BRIDGE_TON_TO_ORAI_MINIMUM_GAS.toString();
425+
: BRIDGE_JETTON_TO_ORAI_MINIMUM_GAS.toString();
415426
const timeout = BigInt(Math.floor(new Date().getTime() / 1000) + 3600);
416427

417-
let memo = beginCell().endCell();
428+
let memo = beginCell().storeStringRefTail("").endCell();
418429

419430
if (toNetwork.id === NetworkList["osmosis-1"].id) {
420431
const osmosisAddress = await window.Keplr.getKeplrAddr(toNetwork.id);
@@ -514,7 +525,7 @@ const Bridge = () => {
514525
: getOtherBridgeTokenPayload();
515526

516527
const tx = await tonConnectUI.sendTransaction({
517-
validUntil: TON_MESSAGE_VALID_UNTIL,
528+
validUntil: Date.now() + 5 * 60 * 1000,
518529
messages: [
519530
{
520531
address: toAddress, // dia chi token
@@ -752,7 +763,9 @@ const Bridge = () => {
752763
sender: fromAddress,
753764
receiver: toAddress,
754765
memo,
755-
timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout),
766+
timeoutTimestamp: calculateTimeoutTimestamp(
767+
ibcInfo.timeout
768+
) as any,
756769
}),
757770
},
758771
];
@@ -931,8 +944,8 @@ const Bridge = () => {
931944
numAmount > toDisplay(amounts[token?.denom] || "0");
932945

933946
if (token?.contractAddress === TON_ZERO_ADDRESS) {
934-
newValidateAmount.status = numAmount > bridgeFee + 1;
935-
newValidateAmount.minAmount = bridgeFee + 1;
947+
newValidateAmount.status = numAmount > bridgeFee;
948+
newValidateAmount.minAmount = bridgeFee;
936949
}
937950
}
938951

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
"@oraichain/orai-bitcoin": "^2.0.0",
2525
"@oraichain/oraidex-common": "^1.1.21",
2626
"@oraichain/oraidex-universal-swap": "^1.1.3",
27-
"@oraichain/ton-bridge-contracts": "^0.15.5",
28-
"@oraichain/tonbridge-contracts-sdk": "^1.3.1",
27+
"@oraichain/ton-bridge-contracts": "^0.15.8",
28+
"@oraichain/tonbridge-contracts-sdk": "^1.3.6",
2929
"@orbs-network/ton-access": "^2.3.3",
3030
"@tanstack/react-query": "^5.49.2",
31-
"@ton/core": "~0",
3231
"@ton/crypto": "^3.2.0",
33-
"@ton/ton": "^13.11.2",
32+
"@ton/core": "^0.56.3",
33+
"@ton/ton": "^14.0.0",
3434
"@tonconnect/protocol": "^2.2.6",
3535
"@tonconnect/sdk": "^3.0.3",
36-
"@tonconnect/ui-react": "^2.0.6",
36+
"@tonconnect/ui-react": "^2.0.9",
3737
"@types/mixpanel-browser": "^2.49.1",
3838
"@walletconnect/browser-utils": "^1.8.0",
3939
"@walletconnect/ethereum-provider": "^1.7.8",

yarn.lock

+33-24
Original file line numberDiff line numberDiff line change
@@ -1667,10 +1667,10 @@
16671667
tronweb "5.3.2"
16681668
ts-protoc-gen "^0.15.0"
16691669

1670-
"@oraichain/ton-bridge-contracts@^0.15.5":
1671-
version "0.15.5"
1672-
resolved "https://registry.yarnpkg.com/@oraichain/ton-bridge-contracts/-/ton-bridge-contracts-0.15.5.tgz#1c169630527ca0dd5e8e1fe7d6b3570e5d6c0b5e"
1673-
integrity sha512-5Zs8Gj5p9+phKC7iE71xjjb4aTU42yihKrgiUhJz1msb/DLP13aOSyM9dd8f6e/0SA/Ar4EXZ97q1tknVTkIAw==
1670+
"@oraichain/[email protected].8":
1671+
version "0.15.8"
1672+
resolved "https://registry.yarnpkg.com/@oraichain/ton-bridge-contracts/-/ton-bridge-contracts-0.15.8.tgz#7e5842bbb8cec6ac70319db2df0c961416d0d18a"
1673+
integrity sha512-0ZPIygoo+1pz7jp1Rv74P8tYltnLaX4y6bPhGP3S/OHGN1LiIyPE+ch08Ng+AqgYkt54uycJoyMKDCLXzNacCw==
16741674
dependencies:
16751675
"@cosmjs/tendermint-rpc" "^0.32.4"
16761676
"@orbs-network/ton-access" "^2.3.3"
@@ -1679,10 +1679,10 @@
16791679
dotenv "^16.4.5"
16801680
varstruct "^6.1.3"
16811681

1682-
"@oraichain/tonbridge-contracts-sdk@^1.3.1":
1683-
version "1.3.1"
1684-
resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-contracts-sdk/-/tonbridge-contracts-sdk-1.3.1.tgz#5c2981b5c1c99bda7db143d8f294449bdc15f2d7"
1685-
integrity sha512-atSmGRzlGodjidY32I50UJPtVIriaoeqOOw/Qx2qnCk2S/1z5oAotPO9mfHeLALb3rgN/gtXhtQj/dqCU0rlsA==
1682+
"@oraichain/[email protected].6":
1683+
version "1.3.6"
1684+
resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-contracts-sdk/-/tonbridge-contracts-sdk-1.3.6.tgz#1ee1309e6bb8e186eaa5d706c7d32276ef976402"
1685+
integrity sha512-k1DgzfYg3nQNPn2dLiXbkDHXd1WREQA9Dl0ezQ5kPtnlbNK9XjmxSco2gmaJwql0tE3cbBExUflfG0MaRF0dWw==
16861686

16871687
"@orbs-network/ton-access@^2.3.3":
16881688
version "2.3.3"
@@ -1852,7 +1852,7 @@
18521852
dependencies:
18531853
"@tanstack/query-core" "5.49.1"
18541854

1855-
"@ton/core@~0":
1855+
"@ton/core@0.56.3":
18561856
version "0.56.3"
18571857
resolved "https://registry.yarnpkg.com/@ton/core/-/core-0.56.3.tgz#1162764573abb76032eba70f8497e5cb2ea532ee"
18581858
integrity sha512-HVkalfqw8zqLLPehtq0CNhu5KjVzc7IrbDwDHPjGoOSXmnqSobiWj8a5F+YuWnZnEbQKtrnMGNOOjVw4LG37rg==
@@ -1875,10 +1875,10 @@
18751875
jssha "3.2.0"
18761876
tweetnacl "1.0.3"
18771877

1878-
"@ton/ton@^13.11.2":
1879-
version "13.11.2"
1880-
resolved "https://registry.yarnpkg.com/@ton/ton/-/ton-13.11.2.tgz#e40204df6a663fdf1b862dfe8ba2a91be3c0dddc"
1881-
integrity sha512-EPqW+ZTe0MmfqguJEIGMuAqTAFRKMEce95HlDx8h6CGn2y3jiMgV1/oO+WpDIOiX+1wnTu+xtajk8JTWr8nKRQ==
1878+
"@ton/ton@14.0.0":
1879+
version "14.0.0"
1880+
resolved "https://registry.yarnpkg.com/@ton/ton/-/ton-14.0.0.tgz#a66fbbfb159200892557442039a0341cda71fc2d"
1881+
integrity sha512-xb2CY6U0AlHUKc7DV7xK/K4Gqn6YoR253yUrM2E7L5WegVFsDF0CQRUIfpYACCuj1oUywQc5J2oMolYNu/uGkA==
18821882
dependencies:
18831883
axios "^1.6.7"
18841884
dataloader "^2.0.0"
@@ -1908,7 +1908,16 @@
19081908
tweetnacl "^1.0.3"
19091909
tweetnacl-util "^0.15.1"
19101910

1911-
"@tonconnect/[email protected]", "@tonconnect/sdk@^3.0.3":
1911+
"@tonconnect/[email protected]":
1912+
version "3.0.5"
1913+
resolved "https://registry.yarnpkg.com/@tonconnect/sdk/-/sdk-3.0.5.tgz#08a202bdc8ea897c37221fd69925c35cd2106323"
1914+
integrity sha512-ow0qnN4s3iQ/r2uXobZ7YzdQBtan/36CgCT9IP35G07g38UxsUXwzw8ANmJTDj/JPiQcIKuYBMfIwIX9zLM0wg==
1915+
dependencies:
1916+
"@tonconnect/isomorphic-eventsource" "^0.0.2"
1917+
"@tonconnect/isomorphic-fetch" "^0.0.3"
1918+
"@tonconnect/protocol" "^2.2.6"
1919+
1920+
"@tonconnect/sdk@^3.0.3":
19121921
version "3.0.3"
19131922
resolved "https://registry.yarnpkg.com/@tonconnect/sdk/-/sdk-3.0.3.tgz#0cc6a570817194c648193f7a1db525419c570e3f"
19141923
integrity sha512-ElVre1DPixzQLgLtQIa8Wu5xS8nozlgblZTJhFFPrk82M2rZ+sawyF+LAVwt9wZRN7+htWnJrNz0+bBr4b3geA==
@@ -1917,19 +1926,19 @@
19171926
"@tonconnect/isomorphic-fetch" "^0.0.3"
19181927
"@tonconnect/protocol" "^2.2.6"
19191928

1920-
"@tonconnect/ui-react@^2.0.6":
1921-
version "2.0.6"
1922-
resolved "https://registry.yarnpkg.com/@tonconnect/ui-react/-/ui-react-2.0.6.tgz#9adadda97da0c8ff2e40eee5dbaa1693aa6662b5"
1923-
integrity sha512-9VRYP2o/YW4ti+rOMSptIYaRO39V5UFmzdUl18AmDFDdynjacAIht/IInO+AGAKfrnF9bUk/J5NgLcbxVqvZww==
1929+
"@tonconnect/ui-react@^2.0.9":
1930+
version "2.0.9"
1931+
resolved "https://registry.yarnpkg.com/@tonconnect/ui-react/-/ui-react-2.0.9.tgz#c226b81110e05b7e259bbf965ad5da42318a5dd3"
1932+
integrity sha512-wN7tEZpQiRYSUcdNAxFsDkk5TYo8krIu00ZLE1R5kXyr+XpO120jOmTEweBSXvIzTgEVkD/PxDZbBQQxRTXsUw==
19241933
dependencies:
1925-
"@tonconnect/ui" "2.0.6"
1934+
"@tonconnect/ui" "2.0.9"
19261935

1927-
"@tonconnect/[email protected].6":
1928-
version "2.0.6"
1929-
resolved "https://registry.yarnpkg.com/@tonconnect/ui/-/ui-2.0.6.tgz#4cf092b3ff138238fa7ae7d4754d8bfed549d892"
1930-
integrity sha512-JMTSxgbnpDjpHi9g0s7w3tpAiLHa8BHUpaBrbSTDcKGQVEm7+NtqhN+gQkGkm8pV7NYRqiS/sKUpRQ1MyjtTBQ==
1936+
"@tonconnect/[email protected].9":
1937+
version "2.0.9"
1938+
resolved "https://registry.yarnpkg.com/@tonconnect/ui/-/ui-2.0.9.tgz#589285c9b8f4b0d94c10b3feadfae266bf086503"
1939+
integrity sha512-ZxofTBf81NqrxyD0ybI8AuFHN11uKVg/00xTDFhP5FoPB8rYC7En9qE2VJ6IvwvtTpmh8jspi2ancOHUMBoCQA==
19311940
dependencies:
1932-
"@tonconnect/sdk" "3.0.3"
1941+
"@tonconnect/sdk" "3.0.5"
19331942
classnames "^2.3.2"
19341943
deepmerge "^4.2.2"
19351944
ua-parser-js "^1.0.35"

0 commit comments

Comments
 (0)