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/solana #1108

Merged
merged 5 commits into from
Jan 2, 2025
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
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
"@lucky-canvas/react": "^0.1.13",
"@oraichain/bitcoin-bridge-contracts-sdk": "^1.1.9",
"@oraichain/bitcoin-bridge-lib-js": "^1.1.9",
"@oraichain/common": "1.2.4",
"@oraichain/common": "1.2.8",
"@oraichain/common-contracts-sdk": "^1.0.31",
"@oraichain/ethereum-multicall": "^1.0.2",
"@oraichain/kawaiiverse-txs": "^0.0.3",
"@oraichain/orai-bitcoin": "2.0.0",
"@oraichain/oraidex-common": "2.0.6",
"@oraichain/orai-token-inspector": "^0.1.24",
"@oraichain/oraidex-common-ui": "1.0.11",
"@oraichain/oraidex-contracts-sdk": "1.0.55",
"@oraichain/oraidex-universal-swap": "1.2.0-beta28",
"@oraichain/oraidex-universal-swap": "1.3.1",
"@oraichain/oraiswap-v3": "1.2.0-beta26",
"@oraichain/ton-bridge-contracts": "^0.15.8",
"@oraichain/tonbridge-contracts-sdk": "^1.3.1",
Expand Down Expand Up @@ -170,7 +169,7 @@
"axios": "0.26.1",
"@sentry/react": "7.99.0",
"@cosmjs/amino": "0.32.4",
"@oraichain/oraidex-common": "2.0.6"
"@oraichain/oraidex-common": "2.0.8"
},
"overrides": {
"cosmjs-types@>0.7.0 <0.8.0": "0.7.1",
Expand Down
42 changes: 6 additions & 36 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -614,47 +614,23 @@ const Balance: React.FC<BalanceProps> = () => {
const fromBalance = from && initFromBalance ? subAmount + BigInt(initFromBalance) : BigInt(0);
const condition = fromAmount > 0 && toAmount(fromAmount, from.decimals) <= fromBalance;
assert(condition, 'Your balance is insufficient to make this transfer');

displayToast(TToastType.TX_BROADCASTING);
let result: DeliverTxResponse | string | any;

let newToToken = to;
if (toNetworkChainId) {
// ORAICHAIN -> EVM (BSC/ETH/TRON) ( TO: TOKEN ORAIBRIDGE)
newToToken = [...otherChainTokens, ...oraichainTokens].find(
(flat) => flat.chainId === toNetworkChainId && flat.coinGeckoId === from.coinGeckoId
);

// TODO: vuonghuuhung support dynamic bridge orai <-> solana
// if (from.chainId === SolanaNetworkConfig.chainId) {
// newToToken = [...allOraichainTokens, ...allOtherChainTokens].find(
// (flat) =>
// flat.chainId === toNetworkChainId &&
// flat.coinGeckoId === from.coinGeckoId &&
// flat.denom.includes(from.denom)
// );
// }

// if (toNetworkChainId === SolanaNetworkConfig.chainId) {
// console.log('🚀 ~ onClickTransfer ~ toNetworkChainId', toNetworkChainId);
// const subDenom = from.denom.split('/')[2];
// const targetTokenInfo = onChainTokenToTokenItem(
// await tokenInspector.inspectTokenFromSpecifiedChain({
// tokenId: subDenom,
// chainId: toNetworkChainId
// })
// );
// newToToken = targetTokenInfo;
// }

// console.log('🚀 ~ onClickTransfer ~ newToToken', newToToken);
assert(newToToken, 'Cannot find newToToken token that matches from token to bridge!');
}

assert(
newToToken.coinGeckoId === from.coinGeckoId,
`From token ${from.coinGeckoId} is different from to token ${newToToken.coinGeckoId}`
);

// check transfer TON <=> ORAICHAIN,Osmosis
const { isFromTonToCosmos, isFromCosmosToTON, isFromCosmosToCosmos } = await checkTransferTon(toNetworkChainId);
console.log({ isFromTonToCosmos, isFromCosmosToTON, isFromCosmosToCosmos });

if (isFromCosmosToCosmos || isFromTonToCosmos || isFromCosmosToTON) {
return await handleTransferTon({
isTonToCosmos: isFromTonToCosmos,
Expand All @@ -664,12 +640,7 @@ const Balance: React.FC<BalanceProps> = () => {
});
}

assert(
newToToken.coinGeckoId === from.coinGeckoId,
`From token ${from.coinGeckoId} is different from to token ${newToToken.coinGeckoId}`
);

let [isSolToOraichain, isOraichainToSol, isBTCToOraichain, isBtcBridge] = checkTransfer(
const [isSolToOraichain, isOraichainToSol, isBTCToOraichain, isBtcBridge] = checkTransfer(
from.chainId,
newToToken.chainId
);
Expand All @@ -682,7 +653,6 @@ const Balance: React.FC<BalanceProps> = () => {
transferAmount: fromAmount
});
}

if (isSolToOraichain || isOraichainToSol) {
if (isOraichainToSol) {
return handleTransferOraichainToSol({ fromToken: from, toToken: newToToken, transferAmount: fromAmount });
Expand Down
4 changes: 2 additions & 2 deletions src/pages/UniversalSwap/Swap/components/AddressBook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const AddressBook = ({ tokenTo, onSelected }: { tokenTo: TokenItemType; onSelect
>
{IconToken ? (
<div className={styles.tokenIcon}>
<IconToken />
<img src={IconToken} width={30} height={30} />
</div>
) : (
<div className={styles.selectTokenIcon}>
Expand Down Expand Up @@ -155,7 +155,7 @@ const AddressBook = ({ tokenTo, onSelected }: { tokenTo: TokenItemType; onSelect
<div className={styles.content}>
{IconToken ? (
<div className={styles.tokenIcon}>
<IconToken />
<img src={IconToken} width={30} height={30} />
</div>
) : (
<div className={styles.selectTokenIcon}>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/UniversalSwap/Swap/components/AddressForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const AddressBookForm = ({ tokenTo }: { tokenTo: TokenItemType }) => {

return (
<div className={styles.label}>
<div>{Icon ? <Icon /> : <DefaultIcon />}</div>
<div>{Icon ? <img src={Icon} width={30} height={30} /> : <DefaultIcon />}</div>
<span>{token?.name}</span>
</div>
);
Expand Down Expand Up @@ -165,7 +165,7 @@ const AddressBookForm = ({ tokenTo }: { tokenTo: TokenItemType }) => {
prefix={
CurrentTokenIcon ? (
<div className={styles.tokenIcon}>
<CurrentTokenIcon />
<img src={CurrentTokenIcon} width={30} height={30} />
</div>
) : (
<div className={styles.selectTokenIcon}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/UniversalSwap/Swap/hooks/useCalculateDataSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const useCalculateDataSwap = ({ originalFromToken, originalToToken, fromToken, t
useIbcWasm,
protocols,
maxSplits: useAlphaIbcWasm ? 1 : 10,
dontAllowSwapAfter: useAlphaIbcWasm ? [''] : undefined
dontAllowSwapAfter: useAlphaIbcWasm ? [''] : undefined,
keepPreviousData: true
};

const { relayerFee, relayerFeeInOraiToAmount: relayerFeeToken } = useRelayerFeeToken(
Expand Down
3 changes: 2 additions & 1 deletion src/pages/UniversalSwap/Swap/hooks/useSimulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const useSimulate = (
dontAllowSwapAfter?: string[];
maxSplits?: number;
ignoreFee?: boolean;
keepPreviousData?: boolean;
}
) => {
const [[fromAmountToken, toAmountToken], setSwapAmount] = useState([initAmount || null, 0]);
Expand Down Expand Up @@ -92,7 +93,7 @@ export const useSimulate = (
}
},
{
keepPreviousData: true,
keepPreviousData: !simulateOption.keepPreviousData,
refetchInterval: 5000,
staleTime: 2000,
enabled,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const getTokenIcon = (token: TokenItemType, theme: string) => {
const tokenInfo = oraichainTokensWithIcon.find((e) => e.coinGeckoId === token?.coinGeckoId);

if (tokenInfo && Object.keys(tokenInfo.IconLight || tokenInfo.Icon || {}).length > 0) {
tokenIcon = theme === 'light' ? tokenInfo?.IconLight || tokenInfo?.Icon : tokenInfo?.Icon;
tokenIcon = theme === 'light' ? tokenInfo?.iconLight : tokenInfo?.icon;
}
return tokenIcon;
};
Expand Down
87 changes: 18 additions & 69 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3805,36 +3805,10 @@
resolved "https://registry.yarnpkg.com/@oraichain/common-contracts-sdk/-/common-contracts-sdk-1.0.31.tgz#595f93b168438d69d64896909b37855c9afc92fb"
integrity sha512-s8H20RXy5gCnu3DnM7L5ClQyj2mdQpbSBpZrXCpIAX9qY0LKsDdZG3sYaDQ8+VN333jz9Pp/qGWdFSYD+6PBsg==

"@oraichain/common@1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.4.tgz#1a28dc288f3ada9d802541454585839e5c275deb"
integrity sha512-/2TIpqDrJKgh/gb50s+sz5lhsffsj6QOVrJh1QrlIsRlup3yQnahm06vwsiVOX75rbdAMO5c7tJiXjKkHbfkww==
dependencies:
"@keplr-wallet/types" "0.12.141"
axios "0.21.4"
axios-extensions "3.1.6"
bech32 "^1.1.4"
cosmjs-types "^0.9.0"
ethers "^5.5.1"
lodash "^4.17.21"

"@oraichain/common@1.2.6":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.6.tgz#7b2f4bed1a7a93e54190a8409e289f6ebab7ba06"
integrity sha512-Ten4zmHnunmXtE4zBPO2e4zENvr/Iv1nOzDpZcdCoFJHd7Xe4JuKMWuDBfDy9FWW9AlMbnkcKB7jqaLq4uyP3A==
dependencies:
"@keplr-wallet/types" "0.12.141"
axios "0.21.4"
axios-extensions "3.1.6"
bech32 "^1.1.4"
cosmjs-types "^0.9.0"
ethers "^5.5.1"
lodash "^4.17.21"

"@oraichain/common@1.2.7":
version "1.2.7"
resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.7.tgz#5063b20967eac14b5fc94e75f02afa6685565507"
integrity sha512-yOaEpjxtYwGkOxzSiqYwULfK0KSGdBj0ziQLZjQhM6yhW3MzTK70nAORW64ATKomSlBQFy9I/6MFsGkQBHiv3w==
"@oraichain/common@1.2.8":
version "1.2.8"
resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.8.tgz#af1e5766d78a4c8b080b7b0544eaceecf852996e"
integrity sha512-g01foLXdpdAPR6bFzos96P3juGf5EGCiKMx5/Ld6RcY2m6ibyVZK5tIpXdn+G67da5w9vhdqHOspL38La1l+yA==
dependencies:
"@keplr-wallet/types" "0.12.141"
axios "0.21.4"
Expand Down Expand Up @@ -3990,10 +3964,10 @@
react-use "^17.4.0"
react-use-websocket "^4.5.0"

"@oraichain/oraidex-common@2.0.5", "@oraichain/oraidex-common@2.0.6", "@oraichain/oraidex-common@^1.1.6":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-2.0.6.tgz#948acc4f93fd51365f2015be55a2d8a9dedb6309"
integrity sha512-S8Qtu6ajmrGQemPjcO2BzUx1zs0eqRKcxG17pnZXpZOX4mbI4GefwCTSUyBliSOms7ltMmZp9Xes/su7nVkhPg==
"@oraichain/oraidex-common@2.0.5", "@oraichain/oraidex-common@2.0.8", "@oraichain/oraidex-common@^1.1.6":
version "2.0.8"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-2.0.8.tgz#4e2682bc03d909e4e02e6a83fe348f90b78b7ee0"
integrity sha512-6LKwgkwsaN5KxwlTngNyVqeGWqO5xc2H0FuebLr3hA1O72gICMmmqD3/pCB2c7nITQucuu59aX07frnHamgkAQ==
dependencies:
"@cosmjs/amino" "^0.32.4"
"@cosmjs/cosmwasm-stargate" "^0.32.4"
Expand All @@ -4004,7 +3978,7 @@
"@ethersproject/providers" "^5.0.10"
"@injectivelabs/sdk-ts" "1.12.1"
"@keplr-wallet/types" "^0.11.38"
"@oraichain/common" "1.2.7"
"@oraichain/common" "1.2.8"
"@oraichain/oraidex-contracts-sdk" latest
"@ton/core" "0.56.3"
"@ton/crypto" "3.3.0"
Expand Down Expand Up @@ -4035,13 +4009,13 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.45.tgz#42dae0fdd9e005f920ba305b987009f791acc365"
integrity sha512-/nYztdxEX5LQM4DMJQmi9HvZrBVoY3nLAmYqSKZGZ0U1h1SxU7O/o22R3/pQwB+sAJdcibaI8ygC0ov7jC8paA==

"@oraichain/oraidex-universal-swap@1.2.0-beta28":
version "1.2.0-beta28"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.2.0-beta28.tgz#3014aa77279c646a8c116846c16d90da22134ff3"
integrity sha512-GiY7v1lFuAkt/TKt8fQJQSTEpRJtggDKD892hqdfFY5mN9Cjb+E6wdJEFfE56vXmin2EzHVWjfO/PqVteq4hHg==
"@oraichain/oraidex-universal-swap@1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.3.1.tgz#d5f952d9a117d78d9281547493c716915b8ef160"
integrity sha512-HiYISG6oZWBYVJrXS6enYVBFOSdgQu2hUT1kBDeLACu/86LJjSPPs/3ztBhMTDuEP6yKfR1ZnTBVz5U9XwsUzA==
dependencies:
"@oraichain/common" "1.2.6"
"@oraichain/oraidex-common" "2.0.5"
"@oraichain/common" "1.2.8"
"@oraichain/oraidex-common" "2.0.8"
"@oraichain/oraidex-contracts-sdk" "^1.0.49"
"@oraichain/osor-api-contracts-sdk" "^1.0.2"
bech32 "1.1.4"
Expand Down Expand Up @@ -16830,7 +16804,7 @@ string-env-interpolation@^1.0.1:
resolved "https://registry.yarnpkg.com/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz#ad4397ae4ac53fe6c91d1402ad6f6a52862c7152"
integrity sha512-78lwMoCcn0nNu8LszbP1UA7g55OeE4v7rCeWnM5B453rnNr4aq+5it3FEYtZrSEiMvHZOZ9Jlqb0OD0M2VInqg==

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -16848,15 +16822,6 @@ string-width@^3.0.0, string-width@^3.1.0:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -16885,7 +16850,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -16906,13 +16871,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -18316,7 +18274,7 @@ wordwrapjs@^5.1.0:
resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-5.1.0.tgz#4c4d20446dcc670b14fa115ef4f8fd9947af2b3a"
integrity sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -18343,15 +18301,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading