Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
c561e1da
Unverified
Commit
c561e1da
authored
Dec 08, 2023
by
Maurelian
Committed by
GitHub
Dec 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8428 from ethereum-optimism/ctb/flexible-deploy-addresses
contracts-bedrock: flexible deploy script addresses
parents
c74620d4
d981ae87
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
README.md
packages/contracts-bedrock/README.md
+5
-0
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+3
-0
Deployer.sol
packages/contracts-bedrock/scripts/Deployer.sol
+26
-0
No files found.
packages/contracts-bedrock/README.md
View file @
c561e1da
...
@@ -59,6 +59,11 @@ For all information about working on and contributing to Optimism's smart contra
...
@@ -59,6 +59,11 @@ For all information about working on and contributing to Optimism's smart contra
The smart contracts are deployed using
`foundry`
with a
`hardhat-deploy`
compatibility layer. When the contracts are deployed,
The smart contracts are deployed using
`foundry`
with a
`hardhat-deploy`
compatibility layer. When the contracts are deployed,
they will write a temp file to disk that can then be formatted into a
`hardhat-deploy`
style artifact by calling another script.
they will write a temp file to disk that can then be formatted into a
`hardhat-deploy`
style artifact by calling another script.
The addresses in the
`deployments`
directory will be read into the script based on the backend's chain id.
To manually define the set of addresses used in the script, set the
`CONTRACT_ADDRESSES_PATH`
env var to a path on the local
filesystem that points to a JSON file full of key value pairs where the keys are names of contracts and the
values are addresses. This works well with the JSON files in
`superchain-ops`
.
### Configuration
### Configuration
Create or modify a file
`<network-name>.json`
inside of the
[
`deploy-config`
](
./deploy-config/
)
folder.
Create or modify a file
`<network-name>.json`
inside of the
[
`deploy-config`
](
./deploy-config/
)
folder.
...
...
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
c561e1da
...
@@ -54,6 +54,9 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol";
...
@@ -54,6 +54,9 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol";
/// To add a new contract to the system, add a public function that deploys that individual contract.
/// To add a new contract to the system, add a public function that deploys that individual contract.
/// Then add a call to that function inside of `run`. Be sure to call the `save` function after each
/// Then add a call to that function inside of `run`. Be sure to call the `save` function after each
/// deployment so that hardhat-deploy style artifacts can be generated using a call to `sync()`.
/// deployment so that hardhat-deploy style artifacts can be generated using a call to `sync()`.
/// The `CONTRACT_ADDRESSES_PATH` environment variable can be set to a path that contains a JSON file full of
/// contract name to address pairs. That enables this script to be much more flexible in the way
/// it is used.
contract Deploy is Deployer {
contract Deploy is Deployer {
DeployConfig public cfg;
DeployConfig public cfg;
...
...
packages/contracts-bedrock/scripts/Deployer.sol
View file @
c561e1da
...
@@ -116,6 +116,32 @@ abstract contract Deployer is Script {
...
@@ -116,6 +116,32 @@ abstract contract Deployer is Script {
vm.writeJson("{}", tempDeploymentsPath);
vm.writeJson("{}", tempDeploymentsPath);
}
}
console.log("Storing temp deployment data in %s", tempDeploymentsPath);
console.log("Storing temp deployment data in %s", tempDeploymentsPath);
// Load addresses from a JSON file if the CONTRACT_ADDRESSES_PATH environment variable
// is set. Great for loading addresses from `superchain-registry`.
string memory addresses = vm.envOr("CONTRACT_ADDRESSES_PATH", string(""));
if (bytes(addresses).length > 0) {
console.log("Loading addresses from %s", addresses);
_loadAddresses(addresses);
}
}
/// @notice Populates the addresses to be used in a script based on a JSON file.
/// The format of the JSON file is the same that it output by this script
/// as well as the JSON files that contain addresses in the `superchain-ops`
/// repo. The JSON key is the name of the contract and the value is an address.
function _loadAddresses(string memory _path) internal {
string[] memory commands = new string[](3);
commands[0] = "bash";
commands[1] = "-c";
commands[2] = string.concat("jq -cr < ", _path);
string memory json = string(vm.ffi(commands));
string[] memory keys = vm.parseJsonKeys(json, "");
for (uint256 i; i < keys.length; i++) {
string memory key = keys[i];
address addr = stdJson.readAddress(json, string.concat("$.", key));
save(key, addr);
}
}
}
/// @notice Call this function to sync the deployment artifacts such that
/// @notice Call this function to sync the deployment artifacts such that
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment