Skip to content
Open
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
20 changes: 14 additions & 6 deletions packages/bridge-controller/src/utils/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export const isNativeAddress = (address?: string | null) =>
(reference) => address.includes(reference) || reference.endsWith(address),
));

const SOLANA_MAINNET_CHAIN_ID_STRING = SolScope.Mainnet.toString();
const SOLANA_CHAIN_ID_STRING = ChainId.SOLANA.toString();
/**
* Checks whether the chainId matches Solana in CaipChainId or number format
*
Expand All @@ -178,25 +180,31 @@ export const isSolanaChainId = (
chainId: Hex | number | CaipChainId | string,
) => {
if (isCaipChainId(chainId)) {
return chainId === SolScope.Mainnet.toString();
return chainId === SOLANA_MAINNET_CHAIN_ID_STRING;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to convert these chain IDs to strings at all? Shouldn't they already be strings? (If the reason is because we're getting a lint error due to enums, we should be able to bypass that.)

}
return chainId.toString() === ChainId.SOLANA.toString();
return chainId.toString() === SOLANA_CHAIN_ID_STRING;
};

const BITCOIN_MAINNET_CHAIN_ID_STRING = BtcScope.Mainnet.toString();
const BITCOIN_CHAIN_ID_STRING = ChainId.BTC.toString();

export const isBitcoinChainId = (
chainId: Hex | number | CaipChainId | string,
) => {
if (isCaipChainId(chainId)) {
return chainId === BtcScope.Mainnet.toString();
return chainId === BITCOIN_MAINNET_CHAIN_ID_STRING;
}
return chainId.toString() === ChainId.BTC.toString();
return chainId.toString() === BITCOIN_CHAIN_ID_STRING;
};

const TRON_MAINNET_CHAIN_ID_STRING = TrxScope.Mainnet.toString();
const TRON_CHAIN_ID_STRING = ChainId.TRON.toString();

export const isTronChainId = (chainId: Hex | number | CaipChainId | string) => {
if (isCaipChainId(chainId)) {
return chainId === TrxScope.Mainnet.toString();
return chainId === TRON_MAINNET_CHAIN_ID_STRING;
}
return chainId.toString() === ChainId.TRON.toString();
return chainId.toString() === TRON_CHAIN_ID_STRING;
};

/**
Expand Down