From e60cbae9da61f2b651ca173bc98f3ba4bdddff06 Mon Sep 17 00:00:00 2001 From: Peter <105609241+peterMangrove@users.noreply.github.com> Date: Fri, 28 Jul 2023 09:18:37 +0200 Subject: [PATCH 1/2] feat: read addresses from node_modules/mangrovedao/mangrove-core (#418) --- script/lib/Deployer.sol | 6 ++--- test/lib/forks/Generic.sol | 47 +++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/script/lib/Deployer.sol b/script/lib/Deployer.sol index d83033841..0d12d82f3 100644 --- a/script/lib/Deployer.sol +++ b/script/lib/Deployer.sol @@ -206,10 +206,10 @@ abstract contract Deployer is Script2 { line(end ? " }" : " },"); } line("]"); - string memory latestBackupFile = fork.addressesFile("deployed.backup", "-latest"); + string memory latestBackupFile = fork.addressesFileRoot("deployed.backup", "-latest"); string memory timestampedBackupFile = - fork.addressesFile("deployed.backup", string.concat("-", vm.toString(block.timestamp), ".backup")); - string memory mainFile = fork.addressesFile("deployed"); + fork.addressesFileRoot("deployed.backup", string.concat("-", vm.toString(block.timestamp), ".backup")); + string memory mainFile = fork.addressesFileRoot("deployed"); vm.writeFile(latestBackupFile, out); vm.writeFile(timestampedBackupFile, out); if (writeDeploy) { diff --git a/test/lib/forks/Generic.sol b/test/lib/forks/Generic.sol index a42e1d794..ea2af7763 100644 --- a/test/lib/forks/Generic.sol +++ b/test/lib/forks/Generic.sol @@ -55,7 +55,11 @@ contract GenericFork is Script { addr = getNoRevert(name); if (addr == address(0)) { revert( - "Fork::get(string name): no contract found for name argument, either in context nor in deployed addresses. Check the appropriate context/.json and deployed/.json, and make sure you are doing fork.set(name,address) for all your deployed contracts." + string.concat( + "Fork::get(string name)", + name, + ": no contract found for name argument, either in context nor in deployed addresses. Check the appropriate context/.json and deployed/.json, and make sure you are doing fork.set(name,address) for all your deployed contracts." + ) ); } } @@ -70,16 +74,47 @@ contract GenericFork is Script { /* Read addresses from JSON files */ - function addressesFile(string memory category, string memory suffix) public view returns (string memory) { - return string.concat(vm.projectRoot(), "/addresses/", category, "/", NETWORK, suffix, ".json"); + function addressesFile(string memory root, string memory category, string memory suffix) + public + view + returns (string memory) + { + return string.concat(root, "/addresses/", category, "/", NETWORK, suffix, ".json"); } - function addressesFile(string memory category) public view returns (string memory) { - return addressesFile(category, ""); + function addressesFileNodeModules(string memory category, string memory suffix) public view returns (string memory) { + return addressesFile(string.concat(vm.projectRoot(), "/node_modules/@mangrovedao/mangrove-core"), category, suffix); + } + + function addressesFileRoot(string memory category, string memory suffix) public view returns (string memory) { + return addressesFile(vm.projectRoot(), category, suffix); + } + + function addressesFileNodeModules(string memory category) public view returns (string memory) { + return addressesFileNodeModules(category, ""); + } + + function addressesFileRoot(string memory category) public view returns (string memory) { + return addressesFileRoot(category, ""); } function readAddresses(string memory category) internal returns (Record[] memory) { - string memory fileName = addressesFile(category); + string memory fileNameNodeModules = addressesFileNodeModules(category); + Record[] memory recordsFromNodeModules = readAddressesFromFileName(fileNameNodeModules); + string memory fileNameRoot = addressesFileRoot(category); + Record[] memory recordsFromRoot = readAddressesFromFileName(fileNameRoot); + Record[] memory records = new Record[](recordsFromNodeModules.length + recordsFromRoot.length); + uint i = 0; + for (; i < recordsFromNodeModules.length; i++) { + records[i] = recordsFromNodeModules[i]; + } + for (uint j = 0; j < recordsFromRoot.length; j++) { + records[i + j] = recordsFromRoot[j]; + } + return records; + } + + function readAddressesFromFileName(string memory fileName) internal returns (Record[] memory) { try vm.readFile(fileName) returns (string memory addressesRaw) { if (bytes(addressesRaw).length == 0) { return (new Record[](0)); From 7cc0b89152e9862f36fc89981444462f824f1ce8 Mon Sep 17 00:00:00 2001 From: Mangrove Automation Bot <134297173+mangrove-automation@users.noreply.github.com> Date: Fri, 28 Jul 2023 09:53:58 +0200 Subject: [PATCH 2/2] Merge publish/v1.5.7 to master Published by GitHub user: peterMangrove --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d5c99000..60cf2ce8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Next version +# 1.5.7 + - Fix: New publish workflow with foundry # 1.5.6 diff --git a/package.json b/package.json index 6b17c3a67..8e126532c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mangrovedao/mangrove-core", - "version": "1.5.6", + "version": "1.5.7", "author": "Mangrove DAO", "license": "SEE LICENSE IN LICENSE", "main": "index.js",