Skip to content

Commit

Permalink
Add support for addedTokens in initializeOraidexCommon function (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
trungbach authored Jan 9, 2025
1 parent b6f605e commit 47cc015
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/initCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ while (!oraidexCommonOg) {
}
export const oraidexCommon = oraidexCommonOg;

export const initializeOraidexCommon = async (dispatch: Dispatch<AnyAction>, allOraichainTokens: TokenItemType[]) => {
export const initializeOraidexCommon = async (
dispatch: Dispatch<AnyAction>,
allOraichainTokens: TokenItemType[],
addedTokens: TokenItemType[]
) => {
const oraichainTokens = oraidexCommonOg.oraichainTokens;
const otherChainTokens = oraidexCommonOg.otherChainTokens;
if (arraysAreDifferent(oraichainTokens, allOraichainTokens)) {
dispatch(updateAllOraichainTokens(oraichainTokens));

const allVerifiedOraichainTokens = allOraichainTokens.filter(
(token) => !addedTokens.find((addedToken) => addedToken.denom === token.denom)
);
if (arraysAreDifferent(oraichainTokens, allVerifiedOraichainTokens)) {
dispatch(updateAllOraichainTokens([...oraichainTokens, ...addedTokens]));
}

if (otherChainTokens.length > 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const App = () => {
const { tron, evm } = walletByNetworks;
const ethOwallet = window.eth_owallet;
const allOraichainTokens = useSelector((state: RootState) => state.token.allOraichainTokens || []);
const addedTokens = useSelector((state: RootState) => state.token.addedTokens || []);
const dispatch = useDispatch();
const solanaWallet = useWallet();

Expand All @@ -67,7 +68,7 @@ const App = () => {
});

useEffect(() => {
initializeOraidexCommon(dispatch, allOraichainTokens);
initializeOraidexCommon(dispatch, allOraichainTokens, addedTokens);
}, [allOraichainTokens]);

useEffect(() => {
Expand Down

0 comments on commit 47cc015

Please sign in to comment.