Skip to content

Commit

Permalink
fix fee sol bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Jan 15, 2025
1 parent 71678b6 commit a642926
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 84 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@oraichain/kawaiiverse-txs": "^0.0.3",
"@oraichain/orai-bitcoin": "2.0.0",
"@oraichain/oraidex-common": "2.0.6",
"@oraichain/orai-token-inspector": "^0.2.7",
"@oraichain/orai-token-inspector": "^0.2.8",
"@oraichain/oraidex-common-ui": "1.0.11",
"@oraichain/oraidex-contracts-sdk": "1.0.55",
"@oraichain/oraidex-universal-swap": "1.3.1",
Expand Down Expand Up @@ -170,7 +170,7 @@
"axios": "0.26.1",
"@sentry/react": "7.99.0",
"@cosmjs/amino": "0.32.4",
"@oraichain/oraidex-common": "2.0.9",
"@oraichain/oraidex-common": "2.0.10",
"@oraichain/common": "1.2.8"
},
"overrides": {
Expand Down
2 changes: 1 addition & 1 deletion src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const getTransactionUrl = (chainId: NetworkChainId, transactionHash: stri
case 'kawaii_6886-1':
return `${KWT_SCAN}/tx/${transactionHash}`;
case 'Oraichain':
return `${network.explorer}/txs/${transactionHash}`;
return `${network.explorer}/tx/${transactionHash}`;
}
return null;
}
Expand Down
16 changes: 2 additions & 14 deletions src/pages/Balance/TransferConvertToken/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,8 @@ const TransferConvertToken: FC<TransferConvertProps> = ({
if (!isValid) return;
setTransferLoading(true);

// if on the same kwt network => we convert between native & erc20 tokens
if (token.chainId === 'kawaii_6886-1') {
// [KWT, MILKY] from Kawaiiverse => [KWT, MILKY] Oraichain
if (toNetworkChainId === 'Oraichain') {
return await onClickTransfer(convertAmount, toNetworkChainId);
}
await convertKwt(convertAmount, token);
return;
}
// [KWT, MILKY] from ORAICHAIN -> KWT_CHAIN || from EVM token -> ORAICHAIN.
if (
evmChains.find((chain) => chain.chainId === token.chainId) ||
(token.chainId === 'Oraichain' && toNetworkChainId === 'kawaii_6886-1')
) {
// from EVM token -> ORAICHAIN.
if (evmChains.find((chain) => chain.chainId === token.chainId)) {
await onClickTransfer(convertAmount, toNetworkChainId);
return;
}
Expand Down
18 changes: 14 additions & 4 deletions src/pages/Balance/hooks/useGetFeeSol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigDecimal, solChainId, toAmount, toDisplay, TokenItemType } from '@oraichain/oraidex-common';
import axios from 'axios';
import { useDebounce } from 'hooks/useDebounce';
import { flattenTokens } from 'initCommon';
import { flattenTokens, solTokens } from 'initCommon';
import { useEffect, useState } from 'react';

export enum Direction {
Expand All @@ -11,7 +11,12 @@ export enum Direction {

export enum SUPPORT_TOKEN {
ORAI = 'orai',
MAX = 'max'
MAX = 'max',
RACKS = 'racks',
GNRT = 'gnrt',
LEE = 'lee',
MOOBS = 'moobs',
CRISIS = 'crisis'
}

const useGetFeeSol = ({
Expand All @@ -38,6 +43,10 @@ const useGetFeeSol = ({

const [solFee, setSolFee] = useState(defaultSolFee);

const getSupportToken = (denom) => {
return denom?.toLowerCase();
};

useEffect(() => {
(async () => {
try {
Expand All @@ -50,8 +59,9 @@ const useGetFeeSol = ({

const amount: string = toAmount(debouncedAmountToken, originalFromToken.decimals).toString();
const direction: Direction = toChainId === solChainId ? Direction.ORAI_TO_SOLANA : Direction.SOLANA_TO_ORAI;
const supportedToken: SUPPORT_TOKEN =
originalFromToken.coinGeckoId === 'oraichain-token' ? SUPPORT_TOKEN.ORAI : SUPPORT_TOKEN.MAX;
// const supportedToken: SUPPORT_TOKEN =
// originalFromToken.coinGeckoId === 'oraichain-token' ? SUPPORT_TOKEN.ORAI : SUPPORT_TOKEN.MAX;
const supportedToken: SUPPORT_TOKEN = getSupportToken(originalFromToken.name);

const baseURL = `https://solana-relayer.orai.io`;
const url: string = `${baseURL}/fee?direction=${direction}&amount=${amount}&supportedToken=${supportedToken}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const AddLiquidityModal: FC<ModalProps> = ({ isOpen, close, onLiquidityCh

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
}
};
Expand Down Expand Up @@ -225,7 +225,7 @@ export const AddLiquidityModal: FC<ModalProps> = ({ isOpen, close, onLiquidityCh

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

const amountUsdt = Number(toAmount(getUsd(baseAmount, token1, prices) * 2));
Expand Down Expand Up @@ -294,7 +294,7 @@ export const AddLiquidityModal: FC<ModalProps> = ({ isOpen, close, onLiquidityCh

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

const amountUsdt = Number(toAmount(getUsd(baseAmount, token1, prices) * 2));
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Pools/components/Earning/Earning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const Earning = ({ onLiquidityChange }: { onLiquidityChange: () => void }

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
onBondingAction();
}
Expand Down
22 changes: 11 additions & 11 deletions src/pages/Pools/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export const useGetOraiPrice = () => {
(pool) =>
pool.firstAssetInfo === JSON.stringify(ORAI_INFO) &&
pool.secondAssetInfo ===
JSON.stringify({
token: {
contract_addr: USDT_CONTRACT
}
})
JSON.stringify({
token: {
contract_addr: USDT_CONTRACT
}
})
);
if (!oraiUsdtPool) return;

Expand Down Expand Up @@ -99,11 +99,11 @@ export const Header: FC<{ dataSource: PoolInfoResponse[] }> = ({ dataSource }) =
.filter((rewardInfo) => rewardInfo.pending_reward !== '0' || rewardInfo.pending_withdraw?.length > 0)
.map(
(rewardInfo) =>
({
contractAddress: network.staking,
msg: { withdraw: { staking_token: rewardInfo.staking_token } },
funds: null
} as ExecuteInstruction)
({
contractAddress: network.staking,
msg: { withdraw: { staking_token: rewardInfo.staking_token } },
funds: null
} as ExecuteInstruction)
);

const result = await CosmJs.executeMultiple({
Expand All @@ -114,7 +114,7 @@ export const Header: FC<{ dataSource: PoolInfoResponse[] }> = ({ dataSource }) =

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
refetchRewardInfo();
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Pools/components/StakeLPModal/StakeLPModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const StakeLPModal: FC<ModalProps> = ({ isOpen, close, open, myLpBalance,
});
if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
onBonedSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const UnstakeLPModal: FC<ModalProps> = ({ isOpen, close, open, onLiquidit
});
if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
onUnbonedSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const WithdrawLiquidityModal: FC<ModalProps> = ({

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
setLpAmountBurn(0n);
onLiquidityChange(-lpAmountBurnUsdt);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Staking/components/StakeInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const StakeInfo = () => {

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
loadOraichainToken(address, [USDC_TOKEN_INFO.contractAddress]);
refetchMyStakeRewardInfo();
Expand Down Expand Up @@ -150,7 +150,7 @@ const StakeInfo = () => {
if (result) {
console.log('in correct result');
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

loadOraichainToken(address, [USDC_TOKEN_INFO.contractAddress, ORAIX_TOKEN_INFO.contractAddress]);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Staking/components/StakeTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const StakeTab = () => {
});
if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

refetchMyStakeRewardInfo();
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Staking/components/UnStakeTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const UnStakeTab = () => {

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});
refetchStakeInfo();
refetchMyStakeRewardInfo();
Expand Down Expand Up @@ -97,7 +97,7 @@ const UnStakeTab = () => {

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

refetchStakeInfo();
Expand Down Expand Up @@ -125,7 +125,7 @@ const UnStakeTab = () => {

if (result) {
displayToast(TToastType.TX_SUCCESSFUL, {
customLink: `${network.explorer}/txs/${result.transactionHash}`
customLink: `${network.explorer}/tx/${result.transactionHash}`
});

refetchStakeInfo();
Expand Down Expand Up @@ -252,7 +252,7 @@ const UnStakeTab = () => {
}
Icon={theme === 'light' ? ConfirmIconLight : ConfirmIcon}
title="Unstaking confirmation"
// showIcon={false}
// showIcon={false}
/>
</div>
);
Expand Down
5 changes: 3 additions & 2 deletions src/tests/bridge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
ETHEREUM_SCAN,
getEncodedExecuteContractMsgs,
IBC_WASM_CONTRACT,
ibcInfos, ibcInfosOld,
ibcInfos,
ibcInfosOld,
INJECTIVE_ORAICHAIN_DENOM,
KWT_BSC_CONTRACT,
KWT_DENOM,
Expand Down Expand Up @@ -180,7 +181,7 @@ describe('bridge', () => {
['0x38', '0x', `${BSC_SCAN}/tx/0x`],
['0x01', '0x', `${ETHEREUM_SCAN}/tx/0x`],
['0x2b6653dc', '0x1234', `${TRON_SCAN}/#/transaction/1234`],
['Oraichain', '0x', `${network.explorer}/txs/0x`]
['Oraichain', '0x', `${network.explorer}/tx/0x`]
])(
'bridge-test-get-transaciton-url given chainId %s should give expected URL %s',
(chainId: NetworkChainId, transactionHash: any, expectedUrl: string) => {
Expand Down
47 changes: 11 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3924,10 +3924,10 @@
serialize-error "^8.1.0"
varuint-bitcoin "^1.1.2"

"@oraichain/orai-token-inspector@^0.2.7":
version "0.2.7"
resolved "https://registry.yarnpkg.com/@oraichain/orai-token-inspector/-/orai-token-inspector-0.2.7.tgz#df68625065c702a4e6d8e52c91786e8d5cfbf325"
integrity sha512-TAPqrNtu+lj9l8EtWEMGtmNXZ6JYjm/QTa4NhbzjDQtH6UH6PkziRLD+WWnynxq0pnLfXd+Kvsn1Mm7LjyHERQ==
"@oraichain/orai-token-inspector@^0.2.8":
version "0.2.8"
resolved "https://registry.yarnpkg.com/@oraichain/orai-token-inspector/-/orai-token-inspector-0.2.8.tgz#98165d55c99ed3d891c966a49f7d0ab8edb8e135"
integrity sha512-CBTebtuJbjadDMrpqO0iwaXcq3RWWWpmRWNuwfHx2AWI74TbgUScri+k9tB2t7YQoIPtYjGidh5pnsESV5ImMg==
dependencies:
"@keplr-wallet/types" "0.12.141"
"@metaplex-foundation/mpl-token-metadata" "^3.3.0"
Expand Down Expand Up @@ -3960,10 +3960,10 @@
react-use "^17.4.0"
react-use-websocket "^4.5.0"

"@oraichain/[email protected].5", "@oraichain/[email protected].8", "@oraichain/[email protected].9", "@oraichain/oraidex-common@^1.1.6":
version "2.0.9"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-2.0.9.tgz#5edbcd5f74dc3490df95428248ddecbae2a73a70"
integrity sha512-07LeP7E4SFhVG4dv6Nf1TT8s8ECfXe3bSt+dNGa1sLo58gDGcBKNPZjDxPhwwYdaugeq8rXuuyEhrUFCX1PzZA==
"@oraichain/[email protected].10", "@oraichain/[email protected].5", "@oraichain/[email protected].8", "@oraichain/oraidex-common@^1.1.6":
version "2.0.10"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-2.0.10.tgz#eb718634bdb88a15ffa0dac241ffd77b06d0911c"
integrity sha512-1JGYuW/A/l0qLL+px1MTXh2zkfvQ877p7rE40zqQh7pddI5xX2WYrUfD/ZgrKuHzgX/RRE4Rv/fSUqRSRj9wbQ==
dependencies:
"@cosmjs/amino" "^0.32.4"
"@cosmjs/cosmwasm-stargate" "^0.32.4"
Expand Down Expand Up @@ -16836,7 +16836,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 @@ -16854,15 +16854,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 @@ -16891,7 +16882,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 @@ -16912,13 +16903,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 @@ -18322,7 +18306,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 @@ -18349,15 +18333,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

0 comments on commit a642926

Please sign in to comment.