@@ -29,10 +29,10 @@ import {
2929 erc20Token ,
3030} from './account' ;
3131import { ofcToken } from './ofc' ;
32- import { BaseCoin } from './base' ;
32+ import { BaseCoin , CoinFeature } from './base' ;
3333import { AmsTokenConfig , TrimmedAmsTokenConfig } from './tokenConfig' ;
3434import { CoinMap } from './map' ;
35- import { Networks } from './networks' ;
35+ import { Networks , NetworkType } from './networks' ;
3636import { networkFeatureMapForTokens } from './networkFeatureMapForTokens' ;
3737import { ofcErc20Coins , tOfcErc20Coins } from './coins/ofcErc20Coins' ;
3838import { ofcCoins } from './coins/ofcCoins' ;
@@ -47,6 +47,23 @@ export const coins = CoinMap.fromCoins([
4747 ...botOfcTokens ,
4848] ) ;
4949
50+ // Build a map of ERC20-supporting chain family names to their mainnet coin names
51+ // Maps family -> coin name (e.g., 'ip' -> 'ip')
52+ const erc20ChainToNameMap : Record < string , string > = { } ;
53+
54+ // 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)
55+ const enabledEvmCoins = [ 'ip' ] ;
56+ allCoinsAndTokens . forEach ( ( coin ) => {
57+ if (
58+ coin . features . includes ( CoinFeature . SUPPORTS_ERC20 ) &&
59+ coin . network . type === NetworkType . MAINNET &&
60+ ! coin . isToken &&
61+ enabledEvmCoins . includes ( coin . family )
62+ ) {
63+ erc20ChainToNameMap [ coin . family ] = coin . name ;
64+ }
65+ } ) ;
66+
5067export function createToken ( token : AmsTokenConfig ) : Readonly < BaseCoin > | undefined {
5168 const initializerMap : Record < string , unknown > = {
5269 algo : algoToken ,
@@ -83,6 +100,11 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
83100 ton : jettonToken ,
84101 } ;
85102
103+ // dynamically add erc20 token initializers for eth like chains to the initializer map
104+ Object . keys ( erc20ChainToNameMap ) . forEach ( ( key ) => {
105+ initializerMap [ erc20ChainToNameMap [ key ] ] = erc20Token ;
106+ } ) ;
107+
86108 //return the BaseCoin from default coin map if present
87109 if ( isCoinPresentInCoinMap ( { ...token } ) ) {
88110 if ( coins . has ( token . name ) ) {
@@ -130,6 +152,7 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
130152 case 'opeth' :
131153 case 'polygon' :
132154 case 'trx' :
155+ case erc20ChainToNameMap [ family ] :
133156 return initializer (
134157 ...commonArgs . slice ( 0 , 4 ) , // id, name, fullName, decimalPlaces
135158 token . contractAddress || token . tokenAddress , // contractAddress
0 commit comments