From aa0b7afc6a89baf8a10c607be1c70d893ae54694 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Tue, 28 May 2024 14:49:16 +0200 Subject: [PATCH 1/2] add deployer script for factory and implementation --- .gitignore | 2 ++ ethereum/script/Deployer.sol | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 ethereum/script/Deployer.sol diff --git a/.gitignore b/.gitignore index ea5243fa9..7c7c2071a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ node_modules/ .env cairo_project.toml +ethereum/broadcast/ + build/ cache/ out/ diff --git a/ethereum/script/Deployer.sol b/ethereum/script/Deployer.sol new file mode 100644 index 000000000..44fb91799 --- /dev/null +++ b/ethereum/script/Deployer.sol @@ -0,0 +1,53 @@ +pragma solidity ^0.8.19; + +import { Script } from "forge-std/Script.sol"; +import {L1AvatarExecutionStrategy} from "../src/execution-strategies/L1AvatarExecutionStrategy.sol"; +import {L1AvatarExecutionStrategyFactory} from "../src/execution-strategies/L1AvatarExecutionStrategyFactory.sol"; +import { stdJson } from "forge-std/StdJson.sol"; + +contract Deployer is Script { + string internal deployments; + string internal deploymentsPath; + + error ImplementationInitializationFailed(); + + function run() public { + + vm.startBroadcast(); + L1AvatarExecutionStrategy implementation = new L1AvatarExecutionStrategy(); + address owner = vm.addr(vm.envUint("PRIVATE_KEY")); + + + // If the master space is not initialized, initialize it + address target = address(1); + address starknetCore = address(2); + uint256 executionRelayer = 3; + uint256 quorum = 5; + if (implementation.owner() == address(0x0)) { + uint256[] memory starknetSpaces = new uint256[](1); + starknetSpaces[0] = 4; + implementation.setUp( + owner, + target, + starknetCore, + executionRelayer, + starknetSpaces, + quorum + ); + } + + if (implementation.owner() != owner + || implementation.target() != address(0x1) + || implementation.starknetCore() != address(2) + || implementation.executionRelayer() != 3 + || implementation.quorum() != 5) { + // Initialization failed (e.g. got frontran) + revert ImplementationInitializationFailed(); + } + + implementation.renounceOwnership(); + + L1AvatarExecutionStrategyFactory factory = new L1AvatarExecutionStrategyFactory(address(implementation)); + vm.stopBroadcast(); + } +} From 31d0b52b31aa324d8a8f331eeb4655016a6525b3 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Tue, 28 May 2024 15:13:17 +0200 Subject: [PATCH 2/2] format --- ethereum/script/Deployer.sol | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/ethereum/script/Deployer.sol b/ethereum/script/Deployer.sol index 44fb91799..0bab8b5a6 100644 --- a/ethereum/script/Deployer.sol +++ b/ethereum/script/Deployer.sol @@ -1,9 +1,9 @@ pragma solidity ^0.8.19; -import { Script } from "forge-std/Script.sol"; +import {Script} from "forge-std/Script.sol"; import {L1AvatarExecutionStrategy} from "../src/execution-strategies/L1AvatarExecutionStrategy.sol"; import {L1AvatarExecutionStrategyFactory} from "../src/execution-strategies/L1AvatarExecutionStrategyFactory.sol"; -import { stdJson } from "forge-std/StdJson.sol"; +import {stdJson} from "forge-std/StdJson.sol"; contract Deployer is Script { string internal deployments; @@ -12,12 +12,10 @@ contract Deployer is Script { error ImplementationInitializationFailed(); function run() public { - vm.startBroadcast(); L1AvatarExecutionStrategy implementation = new L1AvatarExecutionStrategy(); address owner = vm.addr(vm.envUint("PRIVATE_KEY")); - // If the master space is not initialized, initialize it address target = address(1); address starknetCore = address(2); @@ -26,21 +24,14 @@ contract Deployer is Script { if (implementation.owner() == address(0x0)) { uint256[] memory starknetSpaces = new uint256[](1); starknetSpaces[0] = 4; - implementation.setUp( - owner, - target, - starknetCore, - executionRelayer, - starknetSpaces, - quorum - ); + implementation.setUp(owner, target, starknetCore, executionRelayer, starknetSpaces, quorum); } - if (implementation.owner() != owner - || implementation.target() != address(0x1) - || implementation.starknetCore() != address(2) - || implementation.executionRelayer() != 3 - || implementation.quorum() != 5) { + if ( + implementation.owner() != owner || implementation.target() != address(0x1) + || implementation.starknetCore() != address(2) || implementation.executionRelayer() != 3 + || implementation.quorum() != 5 + ) { // Initialization failed (e.g. got frontran) revert ImplementationInitializationFailed(); }