diff --git a/.gitignore b/.gitignore index d4dfc4c9..6c3efb44 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,10 @@ node_modules/ /broadcast/*/31337/ /broadcast/**/dry-run/ +# Ignore local chain deployment output files +!script/output/31337 +script/output/31337/** + # Docs docs/ diff --git a/foundry.toml b/foundry.toml index 25b918f9..9430db16 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,5 +2,6 @@ src = "src" out = "out" libs = ["lib"] +fs_permissions = [{ access = "read-write", path = "./" }] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/script/DeploySharedContracts.s.sol b/script/DeploySharedContracts.s.sol new file mode 100644 index 00000000..347f14fe --- /dev/null +++ b/script/DeploySharedContracts.s.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity =0.8.12; + +import "../src/BLSPublicKeyCompendium.sol"; +import "../src/BLSOperatorStateRetriever.sol"; + +import "forge-std/Script.sol"; +import "forge-std/Test.sol"; + +// # To load the variables in the .env file +// source .env + +// # To deploy and verify our contract +// forge script script/DeploySharedContracts.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast +contract DeploySharedContracts is Script, Test { + Vm cheats = Vm(HEVM_ADDRESS); + + BLSPublicKeyCompendium public blsPublicKeyCompendium; + BLSOperatorStateRetriever public blsOperatorStateRetriever; + + function run() external { + vm.startBroadcast(); + blsPublicKeyCompendium = new BLSPublicKeyCompendium(); + blsOperatorStateRetriever = new BLSOperatorStateRetriever(); + vm.stopBroadcast(); + + string memory deployed_addresses = "addresses"; + vm.serializeAddress( + deployed_addresses, + "blsOperatorStateRetriever", + address(blsOperatorStateRetriever) + ); + string memory finalJson = vm.serializeAddress( + deployed_addresses, + "blsPublicKeyCompendium", + address(blsPublicKeyCompendium) + ); + vm.writeJson(finalJson, outputFileName()); + } + + function outputFileName() internal view returns (string memory) { + return + string.concat( + vm.projectRoot(), + "/script/output/", + vm.toString(block.chainid), + "/shared_contracts_deployment_data.json" + ); + } +}