diff --git a/addresses/context/matic.json b/addresses/context/137.json similarity index 100% rename from addresses/context/matic.json rename to addresses/context/137.json diff --git a/addresses/context/arbitrum.json b/addresses/context/42161.json similarity index 100% rename from addresses/context/arbitrum.json rename to addresses/context/42161.json diff --git a/addresses/context/goerli.json b/addresses/context/5.json similarity index 100% rename from addresses/context/goerli.json rename to addresses/context/5.json diff --git a/addresses/context/maticmum.json b/addresses/context/80001.json similarity index 100% rename from addresses/context/maticmum.json rename to addresses/context/80001.json diff --git a/copyDeploymentAddresses.js b/copyDeploymentAddresses.js index 30931ce35..799c9aae1 100644 --- a/copyDeploymentAddresses.js +++ b/copyDeploymentAddresses.js @@ -12,16 +12,6 @@ if (!config.copyDeployments) { console.groupEnd(); } -// This is a hack to get the network names because the addresses -// file names use non-canonical network names from ethers.js -const networkNames = { - 1: "mainnet", - 5: "goerli", - 137: "matic", - 42161: "arbitrum", - 80001: "maticmum", -}; - // Query deployments based on the configuration in config.js const mangroveVersionDeployments = deployments.getMangroveVersionDeployments({ version: config.coreDeploymentVersionRangePattern, @@ -48,17 +38,16 @@ const contractsDeployments = [ mgvReaderVersionDeployments, ...allTestErc20VersionDeployments, ].filter((x) => x !== undefined); -const deployedAddresses = {}; // network name => { name: string, address: string }[] +const deployedAddresses = {}; // network ID => { name: string, address: string }[] // Iterate over each contract deployment and add the addresses to the deployedAddresses object for (const contractDeployments of contractsDeployments) { for (const [networkId, networkDeployments] of Object.entries( contractDeployments.networkAddresses, )) { - const networkName = networkNames[+networkId]; - let networkAddresses = deployedAddresses[networkName]; + let networkAddresses = deployedAddresses[networkId]; if (networkAddresses === undefined) { networkAddresses = []; - deployedAddresses[networkName] = networkAddresses; + deployedAddresses[networkId] = networkAddresses; } networkAddresses.push({ name: @@ -69,11 +58,11 @@ for (const contractDeployments of contractsDeployments) { } // Replace the addresses files with the loaded deployment addresses -for (const networkName in deployedAddresses) { - let addressesToWrite = deployedAddresses[networkName]; +for (const networkId in deployedAddresses) { + let addressesToWrite = deployedAddresses[networkId]; const networkAddressesFilePath = path.join( __dirname, - `./addresses/deployed/${networkName}.json`, + `./addresses/deployed/${networkId}.json`, ); fs.writeFileSync( networkAddressesFilePath, diff --git a/test/lib/forks/Arbitrum.sol b/test/lib/forks/Arbitrum.sol index 45f7f01ec..3a8da67c4 100644 --- a/test/lib/forks/Arbitrum.sol +++ b/test/lib/forks/Arbitrum.sol @@ -7,7 +7,6 @@ contract ArbitrumFork is GenericFork { constructor() { CHAIN_ID = 42161; NAME = "arbitrum"; // must be id used in foundry.toml for rpc_endpoint & etherscan - NETWORK = "arbitrum"; // must be network name inferred by ethers.js } } diff --git a/test/lib/forks/Ethereum.sol b/test/lib/forks/Ethereum.sol index 6984dfb1a..1c0881353 100644 --- a/test/lib/forks/Ethereum.sol +++ b/test/lib/forks/Ethereum.sol @@ -7,7 +7,6 @@ contract EthereumFork is GenericFork { constructor() { CHAIN_ID = 1; NAME = "ethereum"; - NETWORK = "mainnet"; } } diff --git a/test/lib/forks/Generic.sol b/test/lib/forks/Generic.sol index 6a6c2f53f..561899d9c 100644 --- a/test/lib/forks/Generic.sol +++ b/test/lib/forks/Generic.sol @@ -20,9 +20,8 @@ Note: when you add a *Fork contract, to have it available in deployment scripts, remember to add it to the initialized forks in Deployer.sol.*/ contract GenericFork is Script { uint public INTERNAL_FORK_ID; - uint public CHAIN_ID; + uint public CHAIN_ID; // used as .json filename string public NAME = "genericName"; - string public NETWORK = "genericNetwork"; // common network name, used as .json filename uint public BLOCK_NUMBER; // context addresses (aave, gas update bot, etc) @@ -84,7 +83,7 @@ contract GenericFork is Script { view returns (string memory) { - return string.concat(vm.projectRoot(), "/", pathFromRoot, category, "/", NETWORK, suffix, ".json"); + return string.concat(vm.projectRoot(), "/", pathFromRoot, category, "/", vm.toString(CHAIN_ID), suffix, ".json"); } function readMgvConfig() public view returns (MgvConfig memory) { @@ -114,9 +113,7 @@ contract GenericFork is Script { } Record[] memory mgvConfigRecords = new Record[](0); - if (readMgvConfigPaths) { - mgvConfigRecords = readMgvConfigAddresses(category); - } + mgvConfigRecords = readMgvConfigAddresses(category); Record[] memory allRecords = new Record[](envRecords.length + mgvConfigRecords.length); for (uint i = 0; i < envRecords.length; i++) { diff --git a/test/lib/forks/Goerli.sol b/test/lib/forks/Goerli.sol index 039182848..1b6afa756 100644 --- a/test/lib/forks/Goerli.sol +++ b/test/lib/forks/Goerli.sol @@ -7,6 +7,5 @@ contract GoerliFork is GenericFork { constructor() { CHAIN_ID = 5; NAME = "goerli"; - NETWORK = "goerli"; } } diff --git a/test/lib/forks/Local.sol b/test/lib/forks/Local.sol index 6e96601e4..d0ec88970 100644 --- a/test/lib/forks/Local.sol +++ b/test/lib/forks/Local.sol @@ -8,6 +8,5 @@ contract LocalFork is GenericFork { constructor() { CHAIN_ID = 31337; NAME = "local"; - NETWORK = "local"; } } diff --git a/test/lib/forks/Mumbai.sol b/test/lib/forks/Mumbai.sol index 15c2446cd..42dd356f1 100644 --- a/test/lib/forks/Mumbai.sol +++ b/test/lib/forks/Mumbai.sol @@ -7,6 +7,5 @@ contract MumbaiFork is GenericFork { constructor() { CHAIN_ID = 80001; NAME = "mumbai"; - NETWORK = "maticmum"; } } diff --git a/test/lib/forks/Polygon.sol b/test/lib/forks/Polygon.sol index 86f350319..e4921bf14 100644 --- a/test/lib/forks/Polygon.sol +++ b/test/lib/forks/Polygon.sol @@ -7,7 +7,6 @@ contract PolygonFork is GenericFork { constructor() { CHAIN_ID = 137; NAME = "polygon"; // must be id used in foundry.toml for rpc_endpoint & etherscan - NETWORK = "matic"; // must be network name inferred by ethers.js } } diff --git a/test/lib/forks/TestnetZkevm.sol b/test/lib/forks/TestnetZkevm.sol index 7948f16b7..c1b2fad52 100644 --- a/test/lib/forks/TestnetZkevm.sol +++ b/test/lib/forks/TestnetZkevm.sol @@ -7,6 +7,5 @@ contract TestnetZkevmFork is GenericFork { constructor() { CHAIN_ID = 1442; NAME = "testnet_zkevm"; - NETWORK = "testnet_zkevm"; } } diff --git a/test/lib/forks/Zkevm.sol b/test/lib/forks/Zkevm.sol index 17ae27c4e..211e4d0d8 100644 --- a/test/lib/forks/Zkevm.sol +++ b/test/lib/forks/Zkevm.sol @@ -7,6 +7,5 @@ contract ZkevmFork is GenericFork { constructor() { CHAIN_ID = 1101; NAME = "zkevm"; - NETWORK = "zkevm"; } }