Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into develop #421

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Next version

# 1.5.7

- Fix: New publish workflow with foundry

# 1.5.6
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions script/lib/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
47 changes: 41 additions & 6 deletions test/lib/forks/Generic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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/<chain>.json and deployed/<chain>.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/<chain>.json and deployed/<chain>.json, and make sure you are doing fork.set(name,address) for all your deployed contracts."
)
);
}
}
Expand All @@ -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));
Expand Down
Loading