Skip to content

Commit

Permalink
Enhance token comparison logic and update prioritizeToken array in Se…
Browse files Browse the repository at this point in the history
…lectToken component
  • Loading branch information
trungbach committed Jan 9, 2025
1 parent 439f2d3 commit d18da43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/initCommon.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { OraidexCommon, TokenItemType } from '@oraichain/oraidex-common';
import { AnyAction, Dispatch } from '@reduxjs/toolkit';
import { updateAllOraichainTokens, updateAllOtherChainTokens } from 'reducer/token';
import { store } from 'store/configure';

const arraysAreDifferent = (arr1: TokenItemType[], arr2: TokenItemType[]): boolean => {
const sortedArr1 = JSON.stringify([...arr1].sort());
const sortedArr2 = JSON.stringify([...arr2].sort());
return sortedArr1 !== sortedArr2;
};

let oraidexCommonOg = await OraidexCommon.load();
while (!oraidexCommonOg) {
Expand All @@ -12,9 +19,10 @@ export const oraidexCommon = oraidexCommonOg;
export const initializeOraidexCommon = async (dispatch: Dispatch<AnyAction>, allOraichainTokens: TokenItemType[]) => {
const oraichainTokens = oraidexCommonOg.oraichainTokens;
const otherChainTokens = oraidexCommonOg.otherChainTokens;
if (oraichainTokens.length > (allOraichainTokens || []).length) {
if (arraysAreDifferent(oraichainTokens, allOraichainTokens)) {
dispatch(updateAllOraichainTokens(oraichainTokens));
}

if (otherChainTokens.length > 0) {
dispatch(updateAllOtherChainTokens(otherChainTokens));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export default function SelectToken({

const RACKS_ORAICHAIN_DENOM =
'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/D7yP4ycfsRWUGYionGpi64sLF2ddZ2JXxuRAti2M7uck';
// const prioritizeToken = RACKS_ORAICHAIN_DENOM;
const prioritizeToken = [MAX_ORAICHAIN_DENOM, RACKS_ORAICHAIN_DENOM];
const GNRT_ORAICHAIN_DENOM =
'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraiJP7H3LAt57DkFXNLDbLdBFNRRPvS8jg2j5AZkd9';
const prioritizeToken = [MAX_ORAICHAIN_DENOM, RACKS_ORAICHAIN_DENOM, GNRT_ORAICHAIN_DENOM];

return (
<div className={`${styles.selectToken} ${isSelectToken ? styles.active : ''}`}>
Expand Down

0 comments on commit d18da43

Please sign in to comment.