forked from erc6900/reference-implementation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeployAllowlistModule.s.sol
More file actions
51 lines (39 loc) · 1.87 KB
/
DeployAllowlistModule.s.sol
File metadata and controls
51 lines (39 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Script, console} from "forge-std/Script.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {AllowlistModule} from "../src/modules/permissions/AllowlistModule.sol";
contract DeployAllowlistModuleScript is Script {
address public allowlistModule = vm.envOr("ALLOWLIST_MODULE", address(0));
bytes32 public allowlistModuleSalt = bytes32(vm.envOr("ALLOWLIST_MODULE_SALT", uint256(0)));
function run() public {
console.log("******** Deploying AllowlistModule ********");
console.log("Chain: ", block.chainid);
vm.startBroadcast();
_deployAllowlistModule(allowlistModuleSalt, allowlistModule);
vm.stopBroadcast();
}
function _deployAllowlistModule(bytes32 salt, address expected) internal {
console.log(string.concat("Deploying AllowlistModule with salt: ", vm.toString(salt)));
address addr = Create2.computeAddress(salt, keccak256(type(AllowlistModule).creationCode), CREATE2_FACTORY);
if (addr != expected) {
console.log("Expected address mismatch");
console.log("Expected: ", expected);
console.log("Actual: ", addr);
revert();
}
if (addr.code.length == 0) {
console.log("No code found at expected address, deploying...");
AllowlistModule deployed = new AllowlistModule{salt: salt}();
if (address(deployed) != expected) {
console.log("Deployed address mismatch");
console.log("Expected: ", expected);
console.log("Actual: ", address(deployed));
revert();
}
console.log("Deployed AllowlistModule at: ", address(deployed));
} else {
console.log("Code found at expected address, skipping deployment");
}
}
}