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

Optimize/ton #1077

Merged
merged 2 commits into from
Dec 12, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@oraichain/orai-bitcoin": "2.0.0",
"@oraichain/oraidex-common-ui": "1.0.11",
"@oraichain/oraidex-contracts-sdk": "1.0.55",
"@oraichain/oraidex-universal-swap": "1.1.24",
"@oraichain/oraidex-universal-swap": "1.1.25",
"@oraichain/ton-bridge-contracts": "^0.15.8",
"@oraichain/tonbridge-contracts-sdk": "^1.3.1",
"@oraichain/tonbridge-sdk": "^1.3.6",
Expand Down
7 changes: 2 additions & 5 deletions src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,18 @@ export const getAddressTransferForEvm = async (walletByNetworks: WalletsByNetwor
export const getAddressTransfer = async (network: CustomChainInfo, walletByNetworks: WalletsByNetwork) => {
try {
let address = '';
if (network.networkType === 'ton') {
if (network.networkType === 'ton' && walletByNetworks.ton) {
address =
JSON.parse(JSON.parse(localStorage.getItem('persist:root'))?.config)?.tonAddress ||
toUserFriendlyAddress(window.Ton?.account?.address);

console.log('addressTON', address);
// address = useTonAddress();
} else if (network.networkType === 'evm') {
address = await getAddressTransferForEvm(walletByNetworks, network);
} else if (network.networkType == ('svm' as any)) {
} else if (network.networkType == 'svm' && walletByNetworks.solana) {
let provider = window?.solana;
if (walletByNetworks.solana === 'owallet') {
provider = window?.owalletSolana;
}

const { publicKey } = await provider.connect();
address = publicKey.toBase58();
} else if (!['evm', 'svm'].includes(network.networkType) && isConnectSpecificNetwork(walletByNetworks.cosmos)) {
Expand Down
50 changes: 0 additions & 50 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -684,56 +684,6 @@ const Balance: React.FC<BalanceProps> = () => {
);

if (findRelayerFee) relayerFee.relayerAmount = findRelayerFee.amount;

//-------------------------------------------------------
// FIXME: need remove after fix ibc hooks
if (from.cosmosBased && from.chainId !== 'noble-1' && to.chainId === 'Oraichain') {
const ibcInfo = UniversalSwapHelper.getIbcInfo(from.chainId as CosmosChainId, to.chainId);
if (!ibcInfo)
throw generateError(`Could not find the ibc info given the from token with coingecko id ${from.coinGeckoId}`);

const offlineSigner = await collectWallet(from.chainId);
const client = await connectWithSigner(
from.rpc,
offlineSigner as any,
from.chainId === 'injective-1' ? 'injective' : 'cosmwasm',
{
gasPrice: GasPrice.fromString(
`${getCosmosGasPrice(from.gasPriceStep)}${from.feeCurrencies[0].coinMinimalDenom}`
),
broadcastPollIntervalMs: 600
}
);

const receiver = await handleCheckAddress(to.chainId);
const msgTransferObj = {
sourcePort: ibcInfo.source,
receiver,
sourceChannel: ibcInfo.channel,
token: coin(toAmount(fromAmount, from.decimals).toString(), from.denom),
sender: cosmosAddress,
memo: '',
timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout))
};

let msgTransfer: any = MsgTransfer.fromPartial(msgTransferObj);
if (from.chainId === 'injective-1') {
msgTransfer = MsgTransferInjective.fromPartial({
...msgTransferObj,
timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout)
});
}

const msgTransferEncodeObj = {
typeUrl: '/ibc.applications.transfer.v1.MsgTransfer',
value: msgTransfer
};

result = await client.signAndBroadcast(cosmosAddress, [msgTransferEncodeObj], 'auto');
return processTxResult(from.rpc, result, getTransactionUrl(from.chainId, result.transactionHash));
}
//-------------------------------------------------------

const universalSwapHandler = new UniversalSwapHandler(
{
sender: { cosmos: cosmosAddress, evm: latestEvmAddress, tron: tronAddress },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
TokenItemType,
truncDecimals,
HMSTR_ORAICHAIN_DENOM,
DOGE_BNB_ORAICHAIN_DENOM
DOGE_BNB_ORAICHAIN_DENOM,
MAX_ORAICHAIN_DENOM
} from '@oraichain/oraidex-common';
import IconoirCancel from 'assets/icons/iconoir_cancel.svg?react';
import NoResultDark from 'assets/images/no-result-dark.svg?react';
Expand Down Expand Up @@ -84,6 +85,7 @@ export default function SelectToken({
(textSearch ? item.name.toLowerCase().includes(textSearch.toLowerCase()) : true)
);

const prioritizeToken = MAX_ORAICHAIN_DENOM;
return (
<>
<div className={`${styles.selectToken} ${isSelectToken ? styles.active : ''}`}>
Expand Down Expand Up @@ -156,10 +158,10 @@ export default function SelectToken({
})
.sort((a, b) => {
const balanceDelta = Number(b.usd) - Number(a.usd);
if (a.denom === DOGE_BNB_ORAICHAIN_DENOM && b.denom !== DOGE_BNB_ORAICHAIN_DENOM) {
return -1; // Push PepePoolKey elements to the top
if (a.denom === prioritizeToken && b.denom !== prioritizeToken) {
return -1; // Push max elements to the top
}
if (a.denom !== DOGE_BNB_ORAICHAIN_DENOM && b.denom === DOGE_BNB_ORAICHAIN_DENOM) {
if (a.denom !== prioritizeToken && b.denom === prioritizeToken) {
return 1; // Keep non-'a' elements below 'a'
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3895,10 +3895,10 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.45.tgz#42dae0fdd9e005f920ba305b987009f791acc365"
integrity sha512-/nYztdxEX5LQM4DMJQmi9HvZrBVoY3nLAmYqSKZGZ0U1h1SxU7O/o22R3/pQwB+sAJdcibaI8ygC0ov7jC8paA==

"@oraichain/[email protected].24":
version "1.1.24"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.24.tgz#9426b498dbc24493627f47ee9ee102e115841202"
integrity sha512-dhRy5ZC/ieverax4wJBuOBcziFWMgfunrkEo0pI3dMHyDAbcnAQojrUXhJpjXPPXtDhnvl1Jk5xlE+XE3FDzWA==
"@oraichain/[email protected].25":
version "1.1.25"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.25.tgz#0533d07ec69ded862152d2376d8bd42b08588b7b"
integrity sha512-1XbRS/OvI+I0dx45okOsQAqNiuRaD2n5omO1xvitQFtv6bZ1NW3wJRdgI10Y7pTz6FE7DPlvP6CB4aj24W8fbQ==
dependencies:
"@oraichain/common" "^1.2.4"
"@oraichain/oraidex-common" "^1.1.27"
Expand Down
Loading