@@ -218,61 +218,39 @@ contract Constants is Script {
218218 }
219219
220220 // Circle domain IDs mapping
221- function getCircleDomainId (uint256 chainId ) public view returns (uint32 ) {
222- return uint32 (vm.parseJsonUint (file, string .concat (".CIRCLE_DOMAIN_IDs. " , vm.toString (chainId))));
221+ function getCircleDomainId (uint256 chainId ) public view returns (uint256 ) {
222+ // return uint32(vm.parseJsonUint(file, string.concat(".CIRCLE_DOMAIN_IDs.", vm.toString(chainId))));
223+ int256 cctpDomain = vm.parseJsonInt (
224+ file,
225+ string .concat (".PUBLIC_NETWORKS. " , vm.toString (chainId), ".cctpDomain " )
226+ );
227+ if (cctpDomain == - 1 ) {
228+ revert ("Circle domain ID not found " );
229+ }
230+ return uint256 (cctpDomain);
231+ }
232+
233+ function getOftEid (uint256 chainId ) public view returns (uint256 ) {
234+ int256 oftEid = vm.parseJsonInt (file, string .concat (".PUBLIC_NETWORKS. " , vm.toString (chainId), ".oftEid " ));
235+ if (oftEid == - 1 ) {
236+ revert ("OFT EID not found " );
237+ }
238+ return uint256 (oftEid);
223239 }
224240
225241 // Get WETH address for any supported chain
226242 function getWETHAddress (uint256 chainId ) public view returns (address ) {
227243 return vm.parseJsonAddress (file, string .concat (".WETH. " , vm.toString (chainId)));
228244 }
229245
230- // Helper function to convert chain ID to chain name
231- function _getChainName (uint256 chainId ) internal view returns (string memory ) {
232- if (chainId == getChainId ("MAINNET " )) return "MAINNET " ;
233- if (chainId == getChainId ("SEPOLIA " )) return "SEPOLIA " ;
234- if (chainId == getChainId ("ARBITRUM " )) return "ARBITRUM " ;
235- if (chainId == getChainId ("ARBITRUM_SEPOLIA " )) return "ARBITRUM_SEPOLIA " ;
236- if (chainId == getChainId ("BSC " )) return "BSC " ;
237- if (chainId == getChainId ("POLYGON " )) return "POLYGON " ;
238- if (chainId == getChainId ("POLYGON_AMOY " )) return "POLYGON_AMOY " ;
239- if (chainId == getChainId ("ZK_SYNC " )) return "ZK_SYNC " ;
240- if (chainId == getChainId ("OPTIMISM " )) return "OPTIMISM " ;
241- if (chainId == getChainId ("OPTIMISM_SEPOLIA " )) return "OPTIMISM_SEPOLIA " ;
242- if (chainId == getChainId ("BASE " )) return "BASE " ;
243- if (chainId == getChainId ("BASE_SEPOLIA " )) return "BASE_SEPOLIA " ;
244- if (chainId == getChainId ("LENS " )) return "LENS " ;
245- if (chainId == getChainId ("LENS_SEPOLIA " )) return "LENS_SEPOLIA " ;
246- if (chainId == getChainId ("LINEA " )) return "LINEA " ;
247- if (chainId == getChainId ("SCROLL_SEPOLIA " )) return "SCROLL_SEPOLIA " ;
248- if (chainId == getChainId ("SCROLL " )) return "SCROLL " ;
249- if (chainId == getChainId ("UNICHAIN " )) return "UNICHAIN " ;
250- if (chainId == getChainId ("UNICHAIN_SEPOLIA " )) return "UNICHAIN_SEPOLIA " ;
251- if (chainId == getChainId ("ALEPH_ZERO " )) return "ALEPH_ZERO " ;
252- if (chainId == getChainId ("BLAST " )) return "BLAST " ;
253- if (chainId == getChainId ("BLAST_SEPOLIA " )) return "BLAST_SEPOLIA " ;
254- if (chainId == getChainId ("BOBA " )) return "BOBA " ;
255- if (chainId == getChainId ("INK " )) return "INK " ;
256- if (chainId == getChainId ("LISK " )) return "LISK " ;
257- if (chainId == getChainId ("LISK_SEPOLIA " )) return "LISK_SEPOLIA " ;
258- if (chainId == getChainId ("MODE " )) return "MODE " ;
259- if (chainId == getChainId ("MODE_SEPOLIA " )) return "MODE_SEPOLIA " ;
260- if (chainId == getChainId ("REDSTONE " )) return "REDSTONE " ;
261- if (chainId == getChainId ("SONEIUM " )) return "SONEIUM " ;
262- if (chainId == getChainId ("WORLD_CHAIN " )) return "WORLD_CHAIN " ;
263- if (chainId == getChainId ("ZORA " )) return "ZORA " ;
264- revert ("Unsupported chain ID " );
265- }
266-
267246 /**
268247 * @notice Get L2 address from constants.json
269248 * @param chainId The chain ID to get the address for
270249 * @param addressType The type of address to get (e.g., "l2GatewayRouter", "cctpTokenMessenger")
271250 * @return The L2 address
272251 */
273252 function getL2Address (uint256 chainId , string memory addressType ) public view returns (address ) {
274- string memory chainName = _getChainName (chainId);
275- string memory jsonPath = string (abi.encodePacked (".L2_ADDRESS_MAP. " , chainName, ". " , addressType));
253+ string memory jsonPath = string (abi.encodePacked (".L2_ADDRESS_MAP. " , vm.toString (chainId), ". " , addressType));
276254 return vm.parseJsonAddress (file, jsonPath);
277255 }
278256
@@ -282,8 +260,7 @@ contract Constants is Script {
282260 * @return The USDC address
283261 */
284262 function getUSDCAddress (uint256 chainId ) public view returns (address ) {
285- string memory chainName = _getChainName (chainId);
286- string memory jsonPath = string (abi.encodePacked (".USDC. " , chainName));
263+ string memory jsonPath = string (abi.encodePacked (".USDC. " , vm.toString (chainId)));
287264 return vm.parseJsonAddress (file, jsonPath);
288265 }
289266
@@ -293,8 +270,7 @@ contract Constants is Script {
293270 * @return The USDC.e address
294271 */
295272 function getUSDCeAddress (uint256 chainId ) public view returns (address ) {
296- string memory chainName = _getChainName (chainId);
297- string memory jsonPath = string (abi.encodePacked (".USDCe. " , chainName));
273+ string memory jsonPath = string (abi.encodePacked (".USDCe. " , vm.toString (chainId)));
298274 return vm.parseJsonAddress (file, jsonPath);
299275 }
300276
@@ -304,13 +280,7 @@ contract Constants is Script {
304280 * @return The WGHO address
305281 */
306282 function getWghoAddress (uint256 chainId ) public view returns (address ) {
307- string memory chainName = _getChainName (chainId);
308- string memory jsonPath = string (abi.encodePacked (".WGHO. " , chainName));
283+ string memory jsonPath = string (abi.encodePacked (".WGHO. " , vm.toString (chainId)));
309284 return vm.parseJsonAddress (file, jsonPath);
310285 }
311-
312- function getOftEid (uint256 chainId ) public view returns (uint256 ) {
313- string memory chainName = _getChainName (chainId);
314- return vm.parseJsonUint (file, string .concat (".OFT_EIDs. " , chainName));
315- }
316286}
0 commit comments