Skip to content

Commit

Permalink
revert: make getTokenAddress as wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Sep 20, 2024
1 parent 1603d30 commit 93a288a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/constants/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const L2_TOKENS_BY_NETWORK: {
},
};

export const getTokenAddress = (chainId: CHAINS, token: TOKENS): string => {
export const getL1TokenAddress = (chainId: CHAINS, token: TOKENS): string => {
const tokens = TOKENS_BY_NETWORK[chainId];
invariant(tokens, 'Chain is not supported');

Expand All @@ -68,3 +68,15 @@ export const getL2TokenAddress = (chainId: CHAINS, token: TOKENS): string => {

return address;
};

export const getTokenAddress = (chainId: CHAINS, token: TOKENS): string => {
if (token === TOKENS.LDO) {
const _chainId =
chainId === CHAINS.OptimismSepolia ? CHAINS.Sepolia : chainId;
return getL1TokenAddress(_chainId, token);
} else {
return chainId === CHAINS.OptimismSepolia
? getL2TokenAddress(chainId, token)
: getL1TokenAddress(chainId, token);
}
};

0 comments on commit 93a288a

Please sign in to comment.