Skip to content

Commit c27b13b

Browse files
Merge pull request #7600 from BitGo/WIN-7914-1
refactor: code optimisation for erc20
2 parents 5184d45 + 647eae1 commit c27b13b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
TaoTokenConfig,
3939
PolyxTokenConfig,
4040
JettonTokenConfig,
41+
NetworkType,
4142
} from '@bitgo/statics';
4243
import {
4344
Ada,
@@ -903,8 +904,26 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine
903904
}
904905
}
905906

907+
export const buildEthLikeChainToTestnetMap = (): Record<string, string> => {
908+
const map: Record<string, string> = {};
909+
910+
const enabledEvmCoins = ['ip'];
911+
912+
// TODO: remove ip coin here and remove other evm coins from switch block, once changes are tested (Ticket: https://bitgoinc.atlassian.net/browse/WIN-7835)
913+
coins.forEach((coin) => {
914+
if (coin.network.type === NetworkType.TESTNET && !coin.isToken && enabledEvmCoins.includes(coin.family)) {
915+
if (coins.get(coin.family)?.features.includes(CoinFeature.SUPPORTS_ERC20)) {
916+
map[coin.family] = `${coin.name}`;
917+
}
918+
}
919+
});
920+
921+
return map;
922+
};
923+
906924
// TODO: add IP token here and test changes (Ticket: https://bitgoinc.atlassian.net/browse/WIN-7835)
907-
const ethLikeChainToTestnetMap: Record<string, string> = {};
925+
const ethLikeChainToTestnetMap: Record<string, string> = buildEthLikeChainToTestnetMap();
926+
908927
export function getTokenConstructor(tokenConfig: TokenConfig): CoinConstructor | undefined {
909928
if (tokenConfig.coin in ethLikeChainToTestnetMap) {
910929
return EthLikeErc20Token.createTokenConstructor(tokenConfig as EthLikeTokenConfig, {

0 commit comments

Comments
 (0)