Skip to content

Commit 059f572

Browse files
committed
foo
1 parent 9b3f007 commit 059f572

File tree

6 files changed

+238
-7
lines changed

6 files changed

+238
-7
lines changed

deployments/11155111.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"broadcastEOA": "0x0000000000000000000000000000000000000000",
3+
"chainId": 11155111,
4+
"deployments": {
5+
"registry": {
6+
"address": "0x00000000001f94125E19c325de435194Ab444430",
7+
"deployer": "0x0000000000000000000000000000000000000000",
8+
"factory": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
9+
"salt": "0x00000000000000000000000000000000000000000a210f813700a000b6a48d8f"
10+
},
11+
"resolver": {
12+
"implementation": {
13+
"address": "0xA36c0074cf3edD9c7B4f35F396D2b821086023BA",
14+
"deployer": "0x0000000000000000000000000000000000000000",
15+
"factory": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
16+
"salt": "0x7109709ecfa91a80626ff3989d68f67f5b1dd12d000000000000000000000000"
17+
},
18+
"proxy": {
19+
"address": "0x0000000000000000000000000000000000000000",
20+
"deployer": "0x0000000000000000000000000000000000000000",
21+
"factory": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
22+
"salt": "0x7109709ecfa91a80626ff3989d68f67f5b1dd12d000000000000000000000000"
23+
}
24+
},
25+
"schemaValidator": {
26+
"implementation": {
27+
"address": "0xEE154819e57f9FeB0872644878A9f64CB5a29bA6",
28+
"deployer": "0x0000000000000000000000000000000000000000",
29+
"factory": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
30+
"salt": "0x7109709ecfa91a80626ff3989d68f67f5b1dd12d000000000000000000000000"
31+
},
32+
"proxy": {
33+
"address": "0x0000000000000000000000000000000000000000",
34+
"deployer": "0x0000000000000000000000000000000000000000",
35+
"factory": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
36+
"salt": "0x7109709ecfa91a80626ff3989d68f67f5b1dd12d000000000000000000000000"
37+
}
38+
},
39+
"timestamp": 1720807020
40+
}
41+
}

foundry.toml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ src = 'src'
44
out = 'out'
55
libs = ['lib']
66
evm_version = 'cancun'
7+
fs_permissions = [{ access = "read", path = "out" }, { access = "read-write", path = "deployments" }, { access = "read", path = "node_modules" }]
8+
allow_paths = ["*", "/", "./node_modules/"]
79

810

911
# Compile only the production code and the test mocks with via IR

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"cspell": "^8.6.0",
3535
"ds-test": "github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0",
3636
"solhint": "^4.5.2",
37+
"safe-singleton-deployer": "github:wilsoncusack/safe-singleton-deployer-sol",
3738
"solmate": "github:transmissions11/solmate#c892309933b25c03d32b1b0d674df7ae292ba925",
3839
"@rhinestone/erc4337-validation": "github:rhinestonewtf/erc4337-validation"
3940
},

pnpm-lock.yaml

+16-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remappings.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ erc4337-validation/=node_modules/@rhinestone/erc4337-validation/src/
77
account-abstraction/=node_modules/account-abstraction/contracts/
88
account-abstraction-v0.6/=node_modules/account-abstraction-v0.6/contracts/
99
@openzeppelin/=node_modules/@openzeppelin/
10+
safe-singleton-deployer/=node_modules/safe-singleton-deployer/src/

script/Deploy.s.sol

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import { Script, console2 } from "forge-std/Script.sol";
5+
import { SafeSingletonDeployer } from "safe-singleton-deployer/SafeSingletonDeployer.sol";
6+
import { Registry } from "src/Registry.sol";
7+
import "@openzeppelin/contracts/utils/Strings.sol";
8+
import { MockResolver } from "test/mocks/MockResolver.sol";
9+
import { MockSchemaValidator } from "test/mocks/MockSchemaValidator.sol";
10+
11+
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
12+
13+
struct Proxy {
14+
address implementation;
15+
address proxy;
16+
}
17+
18+
struct EnvironmentSingletons {
19+
address deployer;
20+
address registry;
21+
Proxy schemaValidator;
22+
Proxy resolver;
23+
}
24+
25+
contract DeployAll is Script {
26+
address constant SAFE_PROXY_FACTORY = address(0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67);
27+
address constant SAFE_SINGLETON = address(0x29fcB43b46531BcA003ddC8FCB67FFE91900C762);
28+
address constant MULTI_SEND = address(0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526);
29+
address constant ENTRYPOINT = address(0x0000000071727De22E5E9d8BAf0edAc6f37da032);
30+
31+
function run() public virtual {
32+
console2.log("Deployment on chainId:", block.chainid);
33+
34+
uint256 privKey = vm.envUint("PRIVATE_KEY");
35+
console2.log("Deployer Addr: ", vm.addr(privKey));
36+
EnvironmentSingletons memory env;
37+
env.registry = _registry(privKey);
38+
39+
env.schemaValidator.implementation = _schemaValidator(privKey);
40+
env.resolver.implementation = _resolver(privKey, env.registry);
41+
// env.schemaValidator.proxy = _proxy({
42+
// pKey: privKey,
43+
// implementation: env.schemaValidator.implementation,
44+
// admin: env.attesterSafe,
45+
// salt: vm.envBytes32("SCHEMA_VALIDATOR_PROXY_SALT"),
46+
// initializer: ""
47+
// });
48+
// env.resolver.proxy = _proxy({
49+
// pKey: privKey,
50+
// implementation: env.resolver.implementation,
51+
// admin: env.attesterSafe,
52+
// salt: vm.envBytes32("RESOLVER_PROXY_SALT"),
53+
// initializer: ""
54+
// });
55+
56+
_logJson(env);
57+
_print(env);
58+
}
59+
60+
function _registry(uint256 pKey) internal returns (address registry) {
61+
registry = SafeSingletonDeployer.broadcastDeploy({
62+
deployerPrivateKey: pKey,
63+
creationCode: type(Registry).creationCode,
64+
salt: vm.envBytes32("REGISTRY_SALT")
65+
});
66+
_initCode("Registry", type(Registry).creationCode, "");
67+
}
68+
69+
function _schemaValidator(uint256 pKey) internal returns (address schemaValidator) {
70+
schemaValidator = SafeSingletonDeployer.broadcastDeploy({
71+
deployerPrivateKey: pKey,
72+
creationCode: type(MockSchemaValidator).creationCode,
73+
args: abi.encode(true),
74+
salt: vm.envBytes32("SCHEMA_VALIDATOR_SALT")
75+
});
76+
}
77+
78+
function _proxy(
79+
uint256 pKey,
80+
address implementation,
81+
address admin,
82+
bytes32 salt,
83+
bytes memory initializer
84+
)
85+
internal
86+
returns (address proxy)
87+
{
88+
proxy = SafeSingletonDeployer.broadcastDeploy({
89+
deployerPrivateKey: pKey,
90+
creationCode: type(TransparentUpgradeableProxy).creationCode,
91+
args: abi.encode(implementation, admin, initializer),
92+
salt: salt
93+
});
94+
}
95+
96+
function _resolver(uint256 pKey, address registry) internal returns (address resolver) {
97+
resolver = SafeSingletonDeployer.broadcastDeploy({
98+
deployerPrivateKey: pKey,
99+
creationCode: type(MockResolver).creationCode,
100+
args: abi.encode(true),
101+
salt: vm.envBytes32("RESOLVER_SALT")
102+
});
103+
}
104+
105+
function _logJson(EnvironmentSingletons memory env) internal {
106+
string memory root = "some key";
107+
vm.serializeUint(root, "chainId", block.chainid);
108+
vm.serializeAddress(root, "broadcastEOA", env.deployer);
109+
110+
string memory deployments = "deployments";
111+
112+
string memory item = "registry";
113+
vm.serializeAddress(item, "address", env.registry);
114+
vm.serializeBytes32(item, "salt", vm.envBytes32("REGISTRY_SALT"));
115+
vm.serializeAddress(item, "deployer", env.deployer);
116+
item = vm.serializeAddress(item, "factory", SafeSingletonDeployer.SAFE_SINGLETON_FACTORY);
117+
vm.serializeString(deployments, "registry", item);
118+
119+
string memory schemaValidator = "schemaValidator";
120+
string memory implementation = "schemaValidator implementation";
121+
vm.serializeAddress(implementation, "address", env.schemaValidator.implementation);
122+
vm.serializeBytes32(implementation, "salt", vm.envBytes32("SCHEMA_VALIDATOR_SALT"));
123+
vm.serializeAddress(implementation, "deployer", env.deployer);
124+
implementation = vm.serializeAddress(implementation, "factory", SafeSingletonDeployer.SAFE_SINGLETON_FACTORY);
125+
vm.serializeString(schemaValidator, "implementation", implementation);
126+
127+
string memory schemaValidatorProxy = "schemaValidator proxy";
128+
vm.serializeAddress(schemaValidatorProxy, "address", env.schemaValidator.proxy);
129+
vm.serializeBytes32(schemaValidatorProxy, "salt", vm.envBytes32("SCHEMA_VALIDATOR_PROXY_SALT"));
130+
vm.serializeAddress(schemaValidatorProxy, "deployer", env.deployer);
131+
schemaValidatorProxy = vm.serializeAddress(schemaValidatorProxy, "factory", SafeSingletonDeployer.SAFE_SINGLETON_FACTORY);
132+
schemaValidator = vm.serializeString(schemaValidator, "proxy", schemaValidatorProxy);
133+
134+
vm.serializeString(deployments, "schemaValidator", schemaValidator);
135+
136+
string memory resolver = "resolver";
137+
string memory resolverImplementation = "resolver implementation";
138+
vm.serializeAddress(resolverImplementation, "address", env.resolver.implementation);
139+
vm.serializeBytes32(resolverImplementation, "salt", vm.envBytes32("SCHEMA_VALIDATOR_SALT"));
140+
vm.serializeAddress(resolverImplementation, "deployer", env.deployer);
141+
resolverImplementation = vm.serializeAddress(resolverImplementation, "factory", SafeSingletonDeployer.SAFE_SINGLETON_FACTORY);
142+
vm.serializeString(resolver, "implementation", resolverImplementation);
143+
144+
string memory resolverProxy = "resolverProxy proxy";
145+
vm.serializeAddress(resolverProxy, "address", env.resolver.proxy);
146+
vm.serializeBytes32(resolverProxy, "salt", vm.envBytes32("SCHEMA_VALIDATOR_PROXY_SALT"));
147+
vm.serializeAddress(resolverProxy, "deployer", env.deployer);
148+
resolverProxy = vm.serializeAddress(resolverProxy, "factory", SafeSingletonDeployer.SAFE_SINGLETON_FACTORY);
149+
resolver = vm.serializeString(resolver, "proxy", resolverProxy);
150+
151+
vm.serializeString(deployments, "resolver", resolver);
152+
153+
string memory output = vm.serializeUint(deployments, "timestamp", block.timestamp);
154+
string memory finalJson = vm.serializeString(root, "deployments", output);
155+
156+
string memory fileName = string(abi.encodePacked("./deployments/", Strings.toString(block.chainid), ".json"));
157+
console2.log("Writing to file: ", fileName);
158+
159+
vm.writeJson(finalJson, fileName);
160+
}
161+
162+
function _print(EnvironmentSingletons memory env) internal pure {
163+
console2.log("-------------------------------------------------------");
164+
console2.log("registry:", env.registry);
165+
console2.log("schemaValidator:", env.schemaValidator.implementation);
166+
console2.log("schemaValidatorProxy:", env.schemaValidator.proxy);
167+
console2.log("resolver:", env.resolver.implementation);
168+
console2.log("resolverProxy:", env.resolver.proxy);
169+
console2.log("-------------------------------------------------------");
170+
}
171+
172+
function _initCode(string memory component, bytes memory creationCode, bytes memory args) private pure {
173+
console2.log("InitCodeHash: ", component);
174+
console2.logBytes32(keccak256(abi.encodePacked(creationCode, args)));
175+
console2.log("\n");
176+
}
177+
}

0 commit comments

Comments
 (0)