11import { task } from "hardhat/config" ;
22import assert from "assert" ;
3- import { CHAIN_IDs , MAINNET_CHAIN_IDs , TOKEN_SYMBOLS_MAP } from "../utils/constants" ;
3+ import { CHAIN_IDs , MAINNET_CHAIN_IDs , TESTNET_CHAIN_IDs , TOKEN_SYMBOLS_MAP } from "../utils/constants" ;
44import { askYesNoQuestion , resolveTokenOnChain , isTokenSymbol , minimalSpokePoolInterface } from "./utils" ;
55import { TokenSymbol } from "./types" ;
66
@@ -9,13 +9,13 @@ const NO_SYMBOL = "----";
99const NO_ADDRESS = "------------------------------------------" ;
1010
1111// Supported mainnet chain IDs.
12- const enabledChainIds = Object . values ( MAINNET_CHAIN_IDs )
13- . map ( Number )
14- . filter ( ( chainId ) => chainId !== CHAIN_IDs . BOBA )
15- . sort ( ( x , y ) => x - y ) ;
16-
17- const chainPadding = enabledChainIds [ enabledChainIds . length - 1 ] . toString ( ) . length ;
18- const formatChainId = ( chainId : number ) : string => chainId . toString ( ) . padStart ( chainPadding , " " ) ;
12+ const enabledChainIds = ( hubChainId : number ) => {
13+ const chainIds = hubChainId === CHAIN_IDs . MAINNET ? MAINNET_CHAIN_IDs : TESTNET_CHAIN_IDs ;
14+ return Object . values ( chainIds )
15+ . map ( Number )
16+ . filter ( ( chainId ) => chainId !== CHAIN_IDs . BOBA )
17+ . sort ( ( x , y ) => x - y ) ;
18+ } ;
1919
2020const getChainsFromList = ( taskArgInput : string ) : number [ ] =>
2121 taskArgInput
@@ -65,18 +65,19 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent
6565 const [ signer ] = await hre . ethers . getSigners ( ) ;
6666
6767 // Remove chainIds that are in the ignore list.
68+ const _enabledChainIds = enabledChainIds ( hubChainId ) ;
6869 let inputChains : number [ ] = [ ] ;
6970 try {
70- inputChains = ( chains ?. split ( "," ) ?? enabledChainIds ) . map ( Number ) ;
71+ inputChains = ( chains ?. split ( "," ) ?? _enabledChainIds ) . map ( Number ) ;
7172 console . log ( `\nParsed 'chains' argument:` , inputChains ) ;
7273 } catch ( error ) {
7374 throw new Error ( `Failed to parse 'chains' argument ${ chains } as a comma-separated list of numbers.` ) ;
7475 }
75- if ( inputChains . length === 0 ) inputChains = enabledChainIds ;
76+ if ( inputChains . length === 0 ) inputChains = _enabledChainIds ;
7677 else if ( inputChains . some ( ( chain ) => isNaN ( chain ) || ! Number . isInteger ( chain ) || chain < 0 ) ) {
7778 throw new Error ( `Invalid chains list: ${ inputChains } ` ) ;
7879 }
79- const chainIds = enabledChainIds . filter ( ( chainId ) => inputChains . includes ( chainId ) ) ;
80+ const chainIds = _enabledChainIds . filter ( ( chainId ) => inputChains . includes ( chainId ) ) ;
8081
8182 console . log ( "\nLoading L2 companion token address for provided L1 token." ) ;
8283 const tokens = Object . fromEntries (
@@ -121,9 +122,11 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent
121122 let i = 0 ; // counter for logging.
122123 const skipped : { [ originChainId : number ] : number [ ] } = { } ;
123124 const routeChainIds = Object . keys ( tokens ) . map ( Number ) ;
125+ const chainPadding = _enabledChainIds [ enabledChainIds . length - 1 ] . toString ( ) . length ;
126+ const formatChainId = ( chainId : number ) : string => chainId . toString ( ) . padStart ( chainPadding , " " ) ;
124127 routeChainIds . forEach ( ( fromId ) => {
125128 const formattedFromId = formatChainId ( fromId ) ;
126- const { symbol , address : inputToken } = tokens [ fromId ] ;
129+ const { address : inputToken } = tokens [ fromId ] ;
127130 skipped [ fromId ] = [ ] ;
128131 routeChainIds . forEach ( ( toId ) => {
129132 if ( fromId === toId || [ fromId , toId ] . some ( ( chainId ) => tokens [ chainId ] . symbol === NO_SYMBOL ) ) {
0 commit comments