@gnosis-guild/zodiac 4.2.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +107 -4
  2. package/dist/cjs/abis/bridge/1.0.0.js +385 -0
  3. package/dist/cjs/abis/circulatingSupplyERC20/1.0.0.js +248 -0
  4. package/dist/cjs/abis/circulatingSupplyERC20/1.1.0.js +248 -0
  5. package/dist/cjs/abis/circulatingSupplyERC20/1.2.0.js +248 -0
  6. package/dist/cjs/abis/circulatingSupplyERC721/1.1.0.js +248 -0
  7. package/dist/cjs/abis/circulatingSupplyERC721/1.2.0.js +248 -0
  8. package/dist/cjs/abis/connext/1.0.0.js +496 -0
  9. package/dist/cjs/abis/delay/1.0.0.js +731 -0
  10. package/dist/cjs/abis/delay/1.0.1.js +731 -0
  11. package/dist/cjs/abis/delay/1.1.0.js +941 -0
  12. package/dist/cjs/abis/delay/1.1.1.js +941 -0
  13. package/dist/cjs/abis/erc20Votes/1.0.0.js +800 -0
  14. package/dist/cjs/abis/erc721Votes/1.0.0.js +795 -0
  15. package/dist/cjs/abis/exit/1.0.0.js +403 -0
  16. package/dist/cjs/abis/exit/1.1.0.js +422 -0
  17. package/dist/cjs/abis/exit/1.2.0.js +422 -0
  18. package/dist/cjs/abis/exitERC721/1.1.0.js +422 -0
  19. package/dist/cjs/abis/exitERC721/1.2.0.js +422 -0
  20. package/dist/cjs/abis/factory/1.0.0.js +53 -0
  21. package/dist/cjs/abis/factory/1.1.0.js +80 -0
  22. package/dist/cjs/abis/factory/1.2.0.js +91 -0
  23. package/dist/cjs/abis/index.js +101 -0
  24. package/dist/cjs/abis/metaGuard/1.0.0.js +474 -0
  25. package/dist/cjs/abis/multisendEncoder/1.0.0.js +64 -0
  26. package/dist/cjs/abis/ozGovernor/1.0.0.js +1066 -0
  27. package/dist/cjs/abis/realityERC20/2.0.0.js +874 -0
  28. package/dist/cjs/abis/realityETH/2.0.0.js +874 -0
  29. package/dist/cjs/abis/roles/1.0.0.js +993 -0
  30. package/dist/cjs/abis/roles/1.1.0.js +993 -0
  31. package/dist/cjs/abis/roles/2.1.0.js +1411 -0
  32. package/dist/cjs/abis/roles/2.1.1.js +1411 -0
  33. package/dist/cjs/abis/scopeGuard/1.0.0.js +595 -0
  34. package/dist/cjs/contracts.js +145 -0
  35. package/dist/cjs/explorer.js +264 -0
  36. package/dist/cjs/extract.js +117 -0
  37. package/dist/cjs/index.js +16 -0
  38. package/dist/cjs/mastercopies.js +34 -0
  39. package/dist/cjs/networks.js +233 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/rpc.js +36 -0
  42. package/dist/cjs/singleton.js +42 -0
  43. package/dist/cjs/types.js +7 -0
  44. package/dist/cjs/ui.js +64 -0
  45. package/dist/cjs/zodiacModule.js +61 -0
  46. package/dist/esm/abis/bridge/1.0.0.d.ts +297 -0
  47. package/dist/esm/abis/bridge/1.0.0.js +382 -0
  48. package/dist/esm/abis/circulatingSupplyERC20/1.0.0.d.ts +188 -0
  49. package/dist/esm/abis/circulatingSupplyERC20/1.0.0.js +245 -0
  50. package/dist/esm/abis/circulatingSupplyERC20/1.1.0.d.ts +188 -0
  51. package/dist/esm/abis/circulatingSupplyERC20/1.1.0.js +245 -0
  52. package/dist/esm/abis/circulatingSupplyERC20/1.2.0.d.ts +188 -0
  53. package/dist/esm/abis/circulatingSupplyERC20/1.2.0.js +245 -0
  54. package/dist/esm/abis/circulatingSupplyERC721/1.1.0.d.ts +188 -0
  55. package/dist/esm/abis/circulatingSupplyERC721/1.1.0.js +245 -0
  56. package/dist/esm/abis/circulatingSupplyERC721/1.2.0.d.ts +188 -0
  57. package/dist/esm/abis/circulatingSupplyERC721/1.2.0.js +245 -0
  58. package/dist/esm/abis/connext/1.0.0.d.ts +383 -0
  59. package/dist/esm/abis/connext/1.0.0.js +493 -0
  60. package/dist/esm/abis/delay/1.0.0.d.ts +562 -0
  61. package/dist/esm/abis/delay/1.0.0.js +728 -0
  62. package/dist/esm/abis/delay/1.0.1.d.ts +562 -0
  63. package/dist/esm/abis/delay/1.0.1.js +728 -0
  64. package/dist/esm/abis/delay/1.1.0.d.ts +720 -0
  65. package/dist/esm/abis/delay/1.1.0.js +938 -0
  66. package/dist/esm/abis/delay/1.1.1.d.ts +720 -0
  67. package/dist/esm/abis/delay/1.1.1.js +938 -0
  68. package/dist/esm/abis/erc20Votes/1.0.0.d.ts +613 -0
  69. package/dist/esm/abis/erc20Votes/1.0.0.js +797 -0
  70. package/dist/esm/abis/erc721Votes/1.0.0.d.ts +610 -0
  71. package/dist/esm/abis/erc721Votes/1.0.0.js +792 -0
  72. package/dist/esm/abis/exit/1.0.0.d.ts +309 -0
  73. package/dist/esm/abis/exit/1.0.0.js +400 -0
  74. package/dist/esm/abis/exit/1.1.0.d.ts +323 -0
  75. package/dist/esm/abis/exit/1.1.0.js +419 -0
  76. package/dist/esm/abis/exit/1.2.0.d.ts +323 -0
  77. package/dist/esm/abis/exit/1.2.0.js +419 -0
  78. package/dist/esm/abis/exitERC721/1.1.0.d.ts +323 -0
  79. package/dist/esm/abis/exitERC721/1.1.0.js +419 -0
  80. package/dist/esm/abis/exitERC721/1.2.0.d.ts +323 -0
  81. package/dist/esm/abis/exitERC721/1.2.0.js +419 -0
  82. package/dist/esm/abis/factory/1.0.0.d.ts +38 -0
  83. package/dist/esm/abis/factory/1.0.0.js +50 -0
  84. package/dist/esm/abis/factory/1.1.0.d.ts +58 -0
  85. package/dist/esm/abis/factory/1.1.0.js +77 -0
  86. package/dist/esm/abis/factory/1.2.0.d.ts +66 -0
  87. package/dist/esm/abis/factory/1.2.0.js +88 -0
  88. package/dist/esm/abis/index.d.ts +13970 -0
  89. package/dist/esm/abis/index.js +98 -0
  90. package/dist/esm/abis/metaGuard/1.0.0.d.ts +363 -0
  91. package/dist/esm/abis/metaGuard/1.0.0.js +471 -0
  92. package/dist/esm/abis/multisendEncoder/1.0.0.d.ts +47 -0
  93. package/dist/esm/abis/multisendEncoder/1.0.0.js +61 -0
  94. package/dist/esm/abis/ozGovernor/1.0.0.d.ts +821 -0
  95. package/dist/esm/abis/ozGovernor/1.0.0.js +1063 -0
  96. package/dist/esm/abis/realityERC20/2.0.0.d.ts +674 -0
  97. package/dist/esm/abis/realityERC20/2.0.0.js +871 -0
  98. package/dist/esm/abis/realityETH/2.0.0.d.ts +674 -0
  99. package/dist/esm/abis/realityETH/2.0.0.js +871 -0
  100. package/dist/esm/abis/roles/1.0.0.d.ts +770 -0
  101. package/dist/esm/abis/roles/1.0.0.js +990 -0
  102. package/dist/esm/abis/roles/1.1.0.d.ts +770 -0
  103. package/dist/esm/abis/roles/1.1.0.js +990 -0
  104. package/dist/esm/abis/roles/2.1.0.d.ts +1094 -0
  105. package/dist/esm/abis/roles/2.1.0.js +1408 -0
  106. package/dist/esm/abis/roles/2.1.1.d.ts +1094 -0
  107. package/dist/esm/abis/roles/2.1.1.js +1408 -0
  108. package/dist/esm/abis/scopeGuard/1.0.0.d.ts +457 -0
  109. package/dist/esm/abis/scopeGuard/1.0.0.js +592 -0
  110. package/dist/esm/contracts.d.ts +66 -0
  111. package/dist/esm/contracts.js +142 -0
  112. package/dist/esm/explorer.d.ts +81 -0
  113. package/dist/esm/explorer.js +256 -0
  114. package/dist/esm/extract.d.ts +15 -0
  115. package/dist/esm/extract.js +114 -0
  116. package/dist/esm/index.d.ts +3 -0
  117. package/dist/esm/index.js +3 -0
  118. package/dist/esm/mastercopies.d.ts +21 -0
  119. package/dist/esm/mastercopies.js +27 -0
  120. package/dist/esm/networks.d.ts +37 -0
  121. package/dist/esm/networks.js +229 -0
  122. package/dist/esm/package.json +1 -0
  123. package/dist/esm/rpc.d.ts +6 -0
  124. package/dist/esm/rpc.js +33 -0
  125. package/dist/esm/singleton.d.ts +24 -0
  126. package/dist/esm/singleton.js +38 -0
  127. package/dist/esm/types.d.ts +43 -0
  128. package/dist/esm/types.js +6 -0
  129. package/dist/esm/ui.d.ts +16 -0
  130. package/dist/esm/ui.js +53 -0
  131. package/dist/esm/zodiacModule.d.ts +4 -0
  132. package/dist/esm/zodiacModule.js +56 -0
  133. package/package.json +29 -74
  134. package/contracts/core/GuardableModifier.sol +0 -96
  135. package/contracts/core/GuardableModule.sol +0 -95
  136. package/contracts/core/Modifier.sol +0 -204
  137. package/contracts/core/Module.sol +0 -73
  138. package/contracts/factory/FactoryFriendly.sol +0 -10
  139. package/contracts/factory/ModuleProxyFactory.sol +0 -51
  140. package/contracts/guard/BaseGuard.sol +0 -36
  141. package/contracts/guard/Guardable.sol +0 -32
  142. package/contracts/interfaces/IAvatar.sol +0 -71
  143. package/contracts/interfaces/IGuard.sol +0 -22
  144. package/contracts/signature/ExecutionTracker.sol +0 -17
  145. package/contracts/signature/IERC1271.sol +0 -19
  146. package/contracts/signature/SignatureChecker.sol +0 -154
  147. package/contracts/test/TestAvatar.sol +0 -64
  148. package/contracts/test/TestGuard.sol +0 -82
  149. package/contracts/test/TestGuardableModifier.sol +0 -82
  150. package/contracts/test/TestModifier.sol +0 -88
  151. package/contracts/test/TestModule.sol +0 -66
  152. package/contracts/test/TestSignature.sol +0 -71
  153. package/dist/index.d.mts +0 -16332
  154. package/dist/index.d.ts +0 -16332
  155. package/dist/index.js +0 -24880
  156. package/dist/index.js.map +0 -1
  157. package/dist/index.mjs +0 -24845
  158. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Source-of-truth network registry.
3
+ *
4
+ * One entry per chain referenced across the Zodiac repos (the in-repo chain
5
+ * list plus the chains served by `ser` and `rolesSubgraph`). Each entry carries:
6
+ *
7
+ * - `chainId` the canonical chain id
8
+ * - `alchemyRpcUrl` Alchemy JSON-RPC endpoint, or null when Alchemy does
9
+ * not serve the chain. The key is read from `ALCHEMY_KEY`.
10
+ * - `publicRpc` public JSON-RPC endpoint, or null when no public
11
+ * fallback is configured.
12
+ * - `etherscanApiUrl` Etherscan V2 multichain explorer API endpoint (with
13
+ * `?chainid=`), or null when the chain is not supported
14
+ * by Etherscan V2. V2 support was checked against
15
+ * api.etherscan.io/v2/chainlist.
16
+ *
17
+ * Entries are sorted by `chainId`.
18
+ *
19
+ * Not wired into anything yet — this is a config drop, intentionally standalone.
20
+ */
21
+ export interface NetworkConfig {
22
+ name: string;
23
+ chainId: number;
24
+ /** Alchemy JSON-RPC URL, or null when Alchemy does not serve this chain. */
25
+ alchemyRpcUrl: string | null;
26
+ /** Public JSON-RPC endpoint, or null when no fallback is configured. */
27
+ publicRpc: string | null;
28
+ /** Etherscan V2 multichain API URL, or null when V2 does not support it. */
29
+ etherscanApiUrl: string | null;
30
+ }
31
+ export declare const networks: NetworkConfig[];
32
+ /**
33
+ * Resolve a network name or chain id (string or number) to its config. An
34
+ * unknown name throws; an unknown numeric chain id resolves to an Etherscan V2
35
+ * entry only when that chain is listed by Etherscan V2.
36
+ */
37
+ export declare function resolveNetwork(networkOrChainId: string | number): NetworkConfig;
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Source-of-truth network registry.
3
+ *
4
+ * One entry per chain referenced across the Zodiac repos (the in-repo chain
5
+ * list plus the chains served by `ser` and `rolesSubgraph`). Each entry carries:
6
+ *
7
+ * - `chainId` the canonical chain id
8
+ * - `alchemyRpcUrl` Alchemy JSON-RPC endpoint, or null when Alchemy does
9
+ * not serve the chain. The key is read from `ALCHEMY_KEY`.
10
+ * - `publicRpc` public JSON-RPC endpoint, or null when no public
11
+ * fallback is configured.
12
+ * - `etherscanApiUrl` Etherscan V2 multichain explorer API endpoint (with
13
+ * `?chainid=`), or null when the chain is not supported
14
+ * by Etherscan V2. V2 support was checked against
15
+ * api.etherscan.io/v2/chainlist.
16
+ *
17
+ * Entries are sorted by `chainId`.
18
+ *
19
+ * Not wired into anything yet — this is a config drop, intentionally standalone.
20
+ */
21
+ const ETHERSCAN_V2_API = "https://api.etherscan.io/v2/api";
22
+ const alchemyKey = typeof process !== "undefined" ? process.env.ALCHEMY_KEY ?? "" : "";
23
+ const ETHERSCAN_V2_CHAIN_IDS = new Set([
24
+ 1, 10, 50, 51, 56, 100, 130, 143, 146, 199, 204, 252, 480, 988, 999, 1029,
25
+ 1284, 1285, 1287, 1328, 1329, 2201, 2523, 2741, 4326, 4352, 5000, 5611, 6343,
26
+ 8453, 9745, 9746, 10143, 11124, 33111, 33139, 42161, 42220, 43114, 43522,
27
+ 59144, 80069, 80094, 81457, 167000, 167013, 560048, 737373, 747474, 11155111,
28
+ 168587773,
29
+ ]);
30
+ /** Build an Alchemy RPC URL from its endpoint subdomain. */
31
+ const alchemy = (subdomain) => `https://${subdomain}.g.alchemy.com/v2/${alchemyKey}`;
32
+ /** Build the Etherscan V2 multichain API URL for a chain. */
33
+ const etherscanV2 = (chainId) => ETHERSCAN_V2_CHAIN_IDS.has(chainId)
34
+ ? `${ETHERSCAN_V2_API}?chainid=${chainId}`
35
+ : null;
36
+ export const networks = [
37
+ {
38
+ name: "mainnet",
39
+ chainId: 1,
40
+ alchemyRpcUrl: alchemy("eth-mainnet"),
41
+ publicRpc: null,
42
+ etherscanApiUrl: etherscanV2(1),
43
+ },
44
+ {
45
+ name: "optimism",
46
+ chainId: 10,
47
+ alchemyRpcUrl: alchemy("opt-mainnet"),
48
+ publicRpc: null,
49
+ etherscanApiUrl: etherscanV2(10),
50
+ },
51
+ {
52
+ name: "flare",
53
+ chainId: 14,
54
+ alchemyRpcUrl: null,
55
+ publicRpc: "https://flare-api.flare.network/ext/C/rpc",
56
+ etherscanApiUrl: null,
57
+ },
58
+ {
59
+ name: "bnb",
60
+ chainId: 56,
61
+ alchemyRpcUrl: alchemy("bnb-mainnet"),
62
+ publicRpc: "https://bsc-dataseed.bnbchain.org",
63
+ etherscanApiUrl: etherscanV2(56),
64
+ },
65
+ {
66
+ name: "gnosis",
67
+ chainId: 100,
68
+ alchemyRpcUrl: null,
69
+ publicRpc: "https://rpc.gnosischain.com",
70
+ etherscanApiUrl: etherscanV2(100),
71
+ },
72
+ {
73
+ name: "unichain",
74
+ chainId: 130,
75
+ alchemyRpcUrl: alchemy("unichain-mainnet"),
76
+ publicRpc: "https://mainnet.unichain.org",
77
+ etherscanApiUrl: etherscanV2(130),
78
+ },
79
+ {
80
+ name: "polygon",
81
+ chainId: 137,
82
+ alchemyRpcUrl: alchemy("polygon-mainnet"),
83
+ publicRpc: null,
84
+ etherscanApiUrl: etherscanV2(137),
85
+ },
86
+ {
87
+ name: "sonic",
88
+ chainId: 146,
89
+ alchemyRpcUrl: null,
90
+ publicRpc: "https://rpc.soniclabs.com",
91
+ etherscanApiUrl: etherscanV2(146),
92
+ },
93
+ {
94
+ name: "worldchain",
95
+ chainId: 480,
96
+ alchemyRpcUrl: null,
97
+ publicRpc: "https://worldchain-mainnet.g.alchemy.com/public",
98
+ etherscanApiUrl: etherscanV2(480),
99
+ },
100
+ {
101
+ name: "hyperevm",
102
+ chainId: 999,
103
+ alchemyRpcUrl: null, //alchemy("hyperliquid-mainnet"),
104
+ publicRpc: null,
105
+ etherscanApiUrl: etherscanV2(999),
106
+ },
107
+ {
108
+ name: "megaeth",
109
+ chainId: 4326,
110
+ alchemyRpcUrl: alchemy("megaeth-mainnet"),
111
+ publicRpc: null,
112
+ etherscanApiUrl: etherscanV2(4326),
113
+ },
114
+ {
115
+ name: "mantle",
116
+ chainId: 5000,
117
+ alchemyRpcUrl: alchemy("mantle-mainnet"),
118
+ publicRpc: null,
119
+ etherscanApiUrl: etherscanV2(5000),
120
+ },
121
+ {
122
+ name: "base",
123
+ chainId: 8453,
124
+ alchemyRpcUrl: alchemy("base-mainnet"),
125
+ publicRpc: null,
126
+ etherscanApiUrl: etherscanV2(8453),
127
+ },
128
+ {
129
+ name: "plasma",
130
+ chainId: 9745,
131
+ alchemyRpcUrl: null,
132
+ publicRpc: "https://rpc.plasma.to",
133
+ etherscanApiUrl: etherscanV2(9745),
134
+ },
135
+ {
136
+ name: "arbitrum",
137
+ chainId: 42161,
138
+ alchemyRpcUrl: alchemy("arb-mainnet"),
139
+ publicRpc: null,
140
+ etherscanApiUrl: etherscanV2(42161),
141
+ },
142
+ {
143
+ name: "celo",
144
+ chainId: 42220,
145
+ alchemyRpcUrl: alchemy("celo-mainnet"),
146
+ publicRpc: null,
147
+ etherscanApiUrl: etherscanV2(42220),
148
+ },
149
+ {
150
+ name: "avalanche",
151
+ chainId: 43114,
152
+ alchemyRpcUrl: alchemy("avax-mainnet"),
153
+ publicRpc: null,
154
+ etherscanApiUrl: etherscanV2(43114),
155
+ },
156
+ {
157
+ name: "ink",
158
+ chainId: 57073,
159
+ alchemyRpcUrl: alchemy("ink-mainnet"),
160
+ publicRpc: "https://rpc-gel.inkonchain.com",
161
+ etherscanApiUrl: null,
162
+ },
163
+ {
164
+ name: "linea",
165
+ chainId: 59144,
166
+ alchemyRpcUrl: alchemy("linea-mainnet"),
167
+ publicRpc: null,
168
+ etherscanApiUrl: etherscanV2(59144),
169
+ },
170
+ {
171
+ name: "bob",
172
+ chainId: 60808,
173
+ alchemyRpcUrl: null,
174
+ publicRpc: "https://rpc.gobob.xyz",
175
+ etherscanApiUrl: null,
176
+ },
177
+ {
178
+ name: "berachain",
179
+ chainId: 80094,
180
+ alchemyRpcUrl: null,
181
+ publicRpc: "https://rpc.berachain.com",
182
+ etherscanApiUrl: etherscanV2(80094),
183
+ },
184
+ {
185
+ name: "scroll",
186
+ chainId: 534352,
187
+ alchemyRpcUrl: alchemy("scroll-mainnet"),
188
+ publicRpc: null,
189
+ etherscanApiUrl: null,
190
+ },
191
+ {
192
+ name: "katana",
193
+ chainId: 747474,
194
+ alchemyRpcUrl: null,
195
+ publicRpc: "https://rpc.katana.network",
196
+ etherscanApiUrl: etherscanV2(747474),
197
+ },
198
+ {
199
+ name: "sepolia",
200
+ chainId: 11155111,
201
+ alchemyRpcUrl: alchemy("eth-sepolia"),
202
+ publicRpc: null,
203
+ etherscanApiUrl: etherscanV2(11155111),
204
+ },
205
+ ];
206
+ /**
207
+ * Resolve a network name or chain id (string or number) to its config. An
208
+ * unknown name throws; an unknown numeric chain id resolves to an Etherscan V2
209
+ * entry only when that chain is listed by Etherscan V2.
210
+ */
211
+ export function resolveNetwork(networkOrChainId) {
212
+ const key = String(networkOrChainId).toLowerCase();
213
+ const found = networks.find((n) => n.name.toLowerCase() === key || String(n.chainId) === key);
214
+ if (found)
215
+ return found;
216
+ if (/^\d+$/.test(key)) {
217
+ const chainId = Number(key);
218
+ return {
219
+ name: key,
220
+ chainId,
221
+ alchemyRpcUrl: null,
222
+ publicRpc: null,
223
+ etherscanApiUrl: etherscanV2(chainId),
224
+ };
225
+ }
226
+ throw new Error(`Unknown network "${networkOrChainId}". Known networks: ${networks
227
+ .map((n) => n.name)
228
+ .join(", ")} (or pass a numeric chain id).`);
229
+ }
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Perform a raw JSON-RPC eth_getCode call using fetch.
3
+ * This is used for fast, low-overhead status checks across many networks
4
+ * without initializing a full Ethers provider.
5
+ */
6
+ export declare function getCode(rpcUrl: string, address: string): Promise<string>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Perform a raw JSON-RPC eth_getCode call using fetch.
3
+ * This is used for fast, low-overhead status checks across many networks
4
+ * without initializing a full Ethers provider.
5
+ */
6
+ export async function getCode(rpcUrl, address) {
7
+ const controller = new AbortController();
8
+ const timeout = setTimeout(() => controller.abort(), 5_000);
9
+ try {
10
+ const response = await fetch(rpcUrl, {
11
+ method: "POST",
12
+ headers: { "content-type": "application/json" },
13
+ body: JSON.stringify({
14
+ jsonrpc: "2.0",
15
+ id: 1,
16
+ method: "eth_getCode",
17
+ params: [address, "latest"],
18
+ }),
19
+ signal: controller.signal,
20
+ });
21
+ if (!response.ok) {
22
+ throw new Error(`RPC returned HTTP ${response.status}`);
23
+ }
24
+ const payload = (await response.json());
25
+ if (payload.error || typeof payload.result !== "string") {
26
+ throw new Error("RPC returned an invalid eth_getCode response");
27
+ }
28
+ return payload.result;
29
+ }
30
+ finally {
31
+ clearTimeout(timeout);
32
+ }
33
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Known CREATE2 singleton factories used across the Zodiac ecosystem. Both
3
+ * yield identical addresses on every chain, which is what makes mastercopy
4
+ * replication address-stable.
5
+ */
6
+ export declare const ERC2470_FACTORY = "0xce0042B868300000d44A59004Da54A005ffdcf9f";
7
+ export declare const NICK_FACTORY = "0x4e59b44847b379578588920cA78FbF26c0B4956C";
8
+ export interface RecoveredDeployment {
9
+ factory: string;
10
+ initCode: string;
11
+ salt: string;
12
+ }
13
+ /**
14
+ * Recover the init code and salt from a singleton-factory deployment
15
+ * transaction. Supports the ERC-2470 factory (an abi-encoded `deploy` call)
16
+ * and Nick's factory (raw `salt ++ initCode` calldata).
17
+ *
18
+ * Returns undefined when the transaction does not target a known factory, in
19
+ * which case the deployment cannot be replicated address-stably.
20
+ */
21
+ export declare function recoverDeployment({ to, input, }: {
22
+ to: string | null;
23
+ input: string;
24
+ }): RecoveredDeployment | undefined;
@@ -0,0 +1,38 @@
1
+ import { Interface, getAddress, dataSlice, hexlify } from "ethers";
2
+ /**
3
+ * Known CREATE2 singleton factories used across the Zodiac ecosystem. Both
4
+ * yield identical addresses on every chain, which is what makes mastercopy
5
+ * replication address-stable.
6
+ */
7
+ export const ERC2470_FACTORY = "0xce0042B868300000d44A59004Da54A005ffdcf9f";
8
+ export const NICK_FACTORY = "0x4e59b44847b379578588920cA78FbF26c0B4956C";
9
+ const erc2470Interface = new Interface([
10
+ "function deploy(bytes _initCode, bytes32 _salt) returns (address)",
11
+ ]);
12
+ /**
13
+ * Recover the init code and salt from a singleton-factory deployment
14
+ * transaction. Supports the ERC-2470 factory (an abi-encoded `deploy` call)
15
+ * and Nick's factory (raw `salt ++ initCode` calldata).
16
+ *
17
+ * Returns undefined when the transaction does not target a known factory, in
18
+ * which case the deployment cannot be replicated address-stably.
19
+ */
20
+ export function recoverDeployment({ to, input, }) {
21
+ const factory = to ? getAddress(to) : null;
22
+ if (factory === getAddress(ERC2470_FACTORY)) {
23
+ try {
24
+ const [initCode, salt] = erc2470Interface.decodeFunctionData("deploy", input);
25
+ return { factory: ERC2470_FACTORY, initCode: hexlify(initCode), salt };
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ }
31
+ if (factory === getAddress(NICK_FACTORY)) {
32
+ // Nick's factory: calldata is salt (32 bytes) followed by the init code.
33
+ const salt = dataSlice(input, 0, 32);
34
+ const initCode = dataSlice(input, 32);
35
+ return { factory: NICK_FACTORY, initCode, salt };
36
+ }
37
+ return undefined;
38
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Artifacts written for a single asset (the main contract or a linked library)
3
+ * under `mastercopies/<module>/<version>/<asset>/`. Each field maps to one file:
4
+ * `abi.json`, `sourcecode.json`, `bytecode.json`.
5
+ */
6
+ /** Contents of `sourcecode.json`. */
7
+ export interface SourceCodeFile {
8
+ contractName: string;
9
+ sourceName: string;
10
+ compilerVersion: string;
11
+ /** abi-encoded constructor arguments (hex, no leading 0x). */
12
+ constructorArguments?: string;
13
+ /** Solidity standard-JSON compiler input (verified source + settings). */
14
+ input: any;
15
+ }
16
+ /** Contents of `bytecode.json` — reproducible factory deployment metadata. */
17
+ export interface BytecodeFile {
18
+ /** CREATE2 address. Reproduces on every chain from factory + salt + creationBytecode. */
19
+ address: string;
20
+ /** CREATE2 singleton factory the creation bytecode was relayed through. */
21
+ factory: string;
22
+ /** Salt recovered from the singleton-factory deployment transaction. */
23
+ salt: string;
24
+ /**
25
+ * Creation bytecode: the exact init code (creation code + abi-encoded
26
+ * constructor args, with any libraries linked). Relay this, with the same
27
+ * factory + salt, to redeploy at `address` on any other network.
28
+ */
29
+ creationBytecode: string;
30
+ /**
31
+ * Deployed (runtime) bytecode stored at `address` (`eth_getCode`). Not used
32
+ * to deploy — it's the on-chain identity, for comparison/verification.
33
+ */
34
+ bytecode: string;
35
+ }
36
+ /** A single extracted asset: one folder, three files. */
37
+ export interface Asset {
38
+ /** Folder name: the main contract name or a linked-library name. */
39
+ name: string;
40
+ abi: any;
41
+ sourceCode: SourceCodeFile;
42
+ bytecode: BytecodeFile;
43
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Artifacts written for a single asset (the main contract or a linked library)
3
+ * under `mastercopies/<module>/<version>/<asset>/`. Each field maps to one file:
4
+ * `abi.json`, `sourcecode.json`, `bytecode.json`.
5
+ */
6
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const CHECK = "\u2713";
2
+ export declare const CROSS = "\u2717";
3
+ export declare const QUESTION = "?";
4
+ export declare function color(value: string, colorName: "green" | "red" | "yellow"): string;
5
+ export declare function visibleLength(value: string): number;
6
+ export declare function formatRow(row: string[], widths: number[]): string;
7
+ export declare function printTable(headers: string[], rows: {
8
+ network: string;
9
+ cells: {
10
+ label: string;
11
+ }[];
12
+ }[], caption: string[]): void;
13
+ export declare function renderProgress(completed: number, total: number, label?: string): void;
14
+ export declare function clearProgress(): void;
15
+ export declare function showTransient(message: string): void;
16
+ export declare function printStatusLine(message: string): void;
package/dist/esm/ui.js ADDED
@@ -0,0 +1,53 @@
1
+ import { clearLine, cursorTo } from "readline";
2
+ export const CHECK = "✓";
3
+ export const CROSS = "✗";
4
+ export const QUESTION = "?";
5
+ export function color(value, colorName) {
6
+ const code = colorName === "green" ? 32 : colorName === "red" ? 31 : 33;
7
+ return `\u001b[${code}m${value}\u001b[0m`;
8
+ }
9
+ export function visibleLength(value) {
10
+ return value.replace(/\u001b\[[0-9;]*m/g, "").length;
11
+ }
12
+ export function formatRow(row, widths) {
13
+ return row
14
+ .map((value, index) => value + " ".repeat(widths[index] - visibleLength(value)))
15
+ .join(" ");
16
+ }
17
+ export function printTable(headers, rows, caption) {
18
+ const body = rows.map((row) => [
19
+ row.network,
20
+ ...row.cells.map((c) => c.label),
21
+ ]);
22
+ const widths = headers.map((header, index) => Math.max(header.length, ...body.map((row) => visibleLength(row[index]))));
23
+ console.log(formatRow(headers, widths));
24
+ console.log(widths.map((width) => "-".repeat(width)).join(" "));
25
+ for (const row of body) {
26
+ console.log(formatRow(row, widths));
27
+ }
28
+ console.log();
29
+ console.log(caption.join(" "));
30
+ }
31
+ export function renderProgress(completed, total, label = "Checking deployments") {
32
+ if (!process.stderr.isTTY)
33
+ return;
34
+ cursorTo(process.stderr, 0);
35
+ process.stderr.write(`${label}: ${completed}/${total} requests`);
36
+ }
37
+ export function clearProgress() {
38
+ if (!process.stderr.isTTY)
39
+ return;
40
+ cursorTo(process.stderr, 0);
41
+ clearLine(process.stderr, 0);
42
+ }
43
+ export function showTransient(message) {
44
+ if (!process.stderr.isTTY)
45
+ return;
46
+ clearProgress();
47
+ cursorTo(process.stderr, 0);
48
+ process.stderr.write(message);
49
+ }
50
+ export function printStatusLine(message) {
51
+ clearProgress();
52
+ console.log(message);
53
+ }
@@ -0,0 +1,4 @@
1
+ import { KnownContracts } from "./contracts.js";
2
+ export declare function getZodiacModuleAbi(name: KnownContracts, versionRange?: string): readonly unknown[];
3
+ export declare function getZodiacModuleAddress(name: KnownContracts, versionRange?: string): string;
4
+ export declare function sanityCheckZodiacModuleAddress(address: string): void;
@@ -0,0 +1,56 @@
1
+ import { compare, satisfies, valid } from "semver";
2
+ import { ABIs } from "./abis/index.js";
3
+ import { CanonicalAddresses, FAULTY } from "./contracts.js";
4
+ export function getZodiacModuleAbi(name, versionRange = "*") {
5
+ const versions = ABIs[name];
6
+ if (!versions) {
7
+ throw new Error(`No ABI registry for ${name}`);
8
+ }
9
+ const version = matchingVersion(versions, versionRange);
10
+ if (!version) {
11
+ throw new Error(`No ABI for ${name}@${versionRange}`);
12
+ }
13
+ const address = CanonicalAddresses[name]?.[version];
14
+ if (!address) {
15
+ throw new Error(`No address for ${name}@${version}`);
16
+ }
17
+ sanityCheckZodiacModuleAddress(address);
18
+ return versions[version];
19
+ }
20
+ export function getZodiacModuleAddress(name, versionRange = "*") {
21
+ const versions = CanonicalAddresses[name];
22
+ if (!versions) {
23
+ throw new Error(`No address registry for ${name}`);
24
+ }
25
+ const version = matchingVersion(versions, versionRange, Boolean);
26
+ if (!version) {
27
+ throw new Error(`No address for ${name}@${versionRange}`);
28
+ }
29
+ sanityCheckZodiacModuleAddress(versions[version]);
30
+ return versions[version];
31
+ }
32
+ export function sanityCheckZodiacModuleAddress(address) {
33
+ const normalizedAddress = address.toLowerCase();
34
+ const canonicalAddresses = flattenAddresses(CanonicalAddresses);
35
+ const faultyAddresses = flattenAddresses(FAULTY);
36
+ if (!canonicalAddresses.has(normalizedAddress)) {
37
+ throw new Error(`Unknown Zodiac module address: ${address}`);
38
+ }
39
+ if (faultyAddresses.has(normalizedAddress)) {
40
+ throw new Error(`Faulty Zodiac module address: ${address}`);
41
+ }
42
+ }
43
+ function matchingVersion(versions, versionRange, predicate = () => true) {
44
+ return Object.entries(versions)
45
+ .filter(([, value]) => predicate(value))
46
+ .map(([entry]) => entry)
47
+ .sort(compare)
48
+ .reverse()
49
+ .find((entry) => satisfies(entry, valid(versionRange) ? `=${versionRange}` : versionRange));
50
+ }
51
+ function flattenAddresses(addresses) {
52
+ return new Set(Object.values(addresses)
53
+ .flatMap((versions) => Object.values(versions ?? {}))
54
+ .filter(Boolean)
55
+ .map((address) => address.toLowerCase()));
56
+ }