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

add deployer script for factory and implementation #614

Merged
merged 2 commits into from
May 30, 2024
Merged
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ node_modules/
.env
cairo_project.toml

ethereum/broadcast/

build/
cache/
out/
Expand Down
44 changes: 44 additions & 0 deletions ethereum/script/Deployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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();
}
}
Loading