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
82500aa5
Commit
82500aa5
authored
Jun 23, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: cleanup
parent
a05054d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
28 deletions
+39
-28
DeployConfig.s.sol
packages/contracts-bedrock/scripts/DeployConfig.s.sol
+7
-8
Deployer.sol
packages/contracts-bedrock/scripts/Deployer.sol
+21
-20
Executables.sol
packages/contracts-bedrock/scripts/Executables.sol
+11
-0
No files found.
packages/contracts-bedrock/scripts/DeployConfig.s.sol
View file @
82500aa5
...
...
@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";
import { console2 as console } from "forge-std/console2.sol";
import { stdJson } from "forge-std/StdJson.sol";
import { Executables } from "./Executables.sol";
/// @title DeployConfig
/// @notice Represents the configuration required to deploy the system. It is expected
...
...
@@ -92,21 +93,19 @@ contract DeployConfig is Script {
} catch {
try vm.parseJsonUint(_json, "$.l1StartingBlockTag") returns (uint256 tag) {
return _getBlockByTag(vm.toString(tag));
} catch {
revert("cannot fetch l1StartingBlockTag");
}
} catch {}
}
}
revert("l1StartingBlockTag must be a bytes32, string or uint256");
revert("l1StartingBlockTag must be a bytes32, string or uint256
or cannot fetch l1StartingBlockTag
");
}
function l2OutputOracleStartingTimestamp() public returns (uint256) {
if (_l2OutputOracleStartingTimestamp < 0) {
bytes32 tag = l1StartingBlockTag();
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat("cast block ", vm.toString(tag), " --json |
jq
.timestamp");
cmd[2] = string.concat("cast block ", vm.toString(tag), " --json |
", Executables.jq, "
.timestamp");
bytes memory res = vm.ffi(cmd);
return stdJson.readUint(string(res), "");
}
...
...
@@ -115,9 +114,9 @@ contract DeployConfig is Script {
function _getBlockByTag(string memory _tag) internal returns (bytes32) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat("cast block ", _tag, " --json |
jq
-r .hash");
cmd[2] = string.concat("cast block ", _tag, " --json |
", Executables.jq, "
-r .hash");
bytes memory res = vm.ffi(cmd);
return abi.decode(res, (bytes32));
}
...
...
packages/contracts-bedrock/scripts/Deployer.sol
View file @
82500aa5
...
...
@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";
import { stdJson } from "forge-std/StdJson.sol";
import { console2 as console } from "forge-std/console2.sol";
import { Executables } from "./Executables.sol";
/// @notice store the new deployment to be saved
struct Deployment {
...
...
@@ -232,9 +233,9 @@ abstract contract Deployer is Script {
function _getTempDeployments() internal returns (Deployment[] memory) {
string memory json = vm.readFile(tempDeploymentsPath);
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
'keys' <<< '", json, "'");
cmd[2] = string.concat(
Executables.jq, "
'keys' <<< '", json, "'");
bytes memory res = vm.ffi(cmd);
string[] memory names = stdJson.readStringArray(string(res), "");
...
...
@@ -253,9 +254,9 @@ abstract contract Deployer is Script {
/// @notice Returns the json of the deployment transaction given a contract address.
function _getDeployTransactionByContractAddress(address _addr) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.transactions[] | select(.contractAddress == ", '"', vm.toString(_addr), '"', ") | select(.transactionType == ", '"CREATE"', ")' < ", deployPath);
cmd[2] = string.concat(
Executables.jq, "
-r '.transactions[] | select(.contractAddress == ", '"', vm.toString(_addr), '"', ") | select(.transactionType == ", '"CREATE"', ")' < ", deployPath);
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
@@ -263,9 +264,9 @@ abstract contract Deployer is Script {
/// @notice Returns the constructor arguent of a deployment transaction given a transaction json.
function getDeployTransactionConstructorArguments(string memory _transaction) internal returns (string[] memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.arguments' <<< '", _transaction, "'");
cmd[2] = string.concat(
Executables.jq, "
-r '.arguments' <<< '", _transaction, "'");
bytes memory res = vm.ffi(cmd);
string[] memory args = new string[](0);
...
...
@@ -285,9 +286,9 @@ abstract contract Deployer is Script {
/// file matches the name of the contract.
function _getForgeArtifactPath(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] =
"forge config --json | jq -r .out"
;
cmd[2] =
string.concat(Executables.forge, " config --json | ", Executables.jq, "-r .out")
;
bytes memory res = vm.ffi(cmd);
string memory forgeArtifactPath = string.concat(vm.projectRoot(), "/", string(res), "/", _name, ".sol/", _name, ".json");
return forgeArtifactPath;
...
...
@@ -303,9 +304,9 @@ abstract contract Deployer is Script {
/// @notice Returns the receipt of a deployment transaction.
function _getDeployReceiptByContractAddress(address addr) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.receipts[] | select(.contractAddress == ", '"', vm.toString(addr), '"', ")' < ", deployPath);
cmd[2] = string.concat(
Executables.jq, "
-r '.receipts[] | select(.contractAddress == ", '"', vm.toString(addr), '"', ")' < ", deployPath);
bytes memory res = vm.ffi(cmd);
string memory receipt = string(res);
return receipt;
...
...
@@ -314,9 +315,9 @@ abstract contract Deployer is Script {
/// @notice Returns the devdoc for a deployed contract.
function getDevDoc(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.devdoc' < ", _getForgeArtifactPath(_name));
cmd[2] = string.concat(
Executables.jq, "
-r '.devdoc' < ", _getForgeArtifactPath(_name));
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
@@ -324,9 +325,9 @@ abstract contract Deployer is Script {
/// @notice Returns the storage layout for a deployed contract.
function getStorageLayout(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.storageLayout' < ", _getForgeArtifactPath(_name));
cmd[2] = string.concat(
Executables.jq, "
-r '.storageLayout' < ", _getForgeArtifactPath(_name));
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
@@ -334,9 +335,9 @@ abstract contract Deployer is Script {
/// @notice Returns the abi for a deployed contract.
function getAbi(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.abi' < ", _getForgeArtifactPath(_name));
cmd[2] = string.concat(
Executables.jq, "
-r '.abi' < ", _getForgeArtifactPath(_name));
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
@@ -344,9 +345,9 @@ abstract contract Deployer is Script {
/// @notice Returns the userdoc for a deployed contract.
function getUserDoc(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
-r '.userdoc' < ", _getForgeArtifactPath(_name));
cmd[2] = string.concat(
Executables.jq, "
-r '.userdoc' < ", _getForgeArtifactPath(_name));
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
@@ -354,9 +355,9 @@ abstract contract Deployer is Script {
/// @notice
function getMetadata(string memory _name) internal returns (string memory) {
string[] memory cmd = new string[](3);
cmd[0] =
"/usr/bin/bash"
;
cmd[0] =
Executables.bash
;
cmd[1] = "-c";
cmd[2] = string.concat(
"jq
'.metadata | tostring' < ", _getForgeArtifactPath(_name));
cmd[2] = string.concat(
Executables.jq, "
'.metadata | tostring' < ", _getForgeArtifactPath(_name));
bytes memory res = vm.ffi(cmd);
return string(res);
}
...
...
packages/contracts-bedrock/scripts/Executables.sol
0 → 100644
View file @
82500aa5
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice The executables used in ffi commands. These are set here
/// to have a single source of truth in case absolute paths
/// need to be used.
library Executables {
string internal constant bash = "bash";
string internal constant jq = "jq";
string internal constant forge = "forge";
}
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