@zodiac-os/sdk 1.1.1 → 1.3.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.
- package/README.md +171 -10
- package/dist/allow/index.d.mts +2 -0
- package/dist/allow/index.mjs +3 -0
- package/dist/allow-Dzh6t_l8.mjs +122 -0
- package/dist/allow-Dzh6t_l8.mjs.map +1 -0
- package/dist/api-D6ee2Q2b.mjs +113 -0
- package/dist/api-D6ee2Q2b.mjs.map +1 -0
- package/dist/cli/config.d.mts +35 -0
- package/dist/cli/config.mjs +31 -0
- package/dist/cli/config.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +370 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index-DTBaxN7b.d.mts +63 -0
- package/dist/index.d.mts +212 -0
- package/dist/index.mjs +208 -0
- package/dist/index.mjs.map +1 -0
- package/dist/networks-BTW1qAAa.mjs +77 -0
- package/dist/networks-BTW1qAAa.mjs.map +1 -0
- package/dist/zodiac-os-codegen.d.ts +52 -0
- package/package.json +32 -19
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -143
- package/dist/index.js.map +0 -1
- package/lib/index.cjs +0 -228
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as ApiClient } from "./api-D6ee2Q2b.mjs";
|
|
3
|
+
import { a as walkContracts, i as readAbi, n as chainIdFor, o as writeAbi, r as abiFilePath } from "./networks-BTW1qAAa.mjs";
|
|
4
|
+
import { loadConfig, resolveAbisDir, resolveTypesDir } from "./cli/config.mjs";
|
|
5
|
+
import { invariant } from "@epic-web/invariant";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { Command } from "commander";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
import { ModuleKind, Project, ScriptTarget, VariableDeclarationKind } from "ts-morph";
|
|
12
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
13
|
+
//#region src/cli/commands/pullOrg.ts
|
|
14
|
+
function resolveNodeModulesDir() {
|
|
15
|
+
const match = fileURLToPath(import.meta.url).match(/^(.+[/\\]node_modules)[/\\]/);
|
|
16
|
+
if (match) return match[1];
|
|
17
|
+
return join(process.cwd(), "node_modules");
|
|
18
|
+
}
|
|
19
|
+
const toLiteral = (value, indent = 0) => {
|
|
20
|
+
const pad = " ".repeat(indent);
|
|
21
|
+
const childPad = " ".repeat(indent + 1);
|
|
22
|
+
if (value === null) return "null";
|
|
23
|
+
if (typeof value === "bigint") return `${value}n`;
|
|
24
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
25
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
if (value.length === 0) return "[]";
|
|
28
|
+
return `[\n${value.map((v) => `${childPad}${toLiteral(v, indent + 1)}`).join(",\n")},\n${pad}]`;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === "object") {
|
|
31
|
+
const entries = Object.entries(value);
|
|
32
|
+
if (entries.length === 0) return "{}";
|
|
33
|
+
return `{\n${entries.map(([k, v]) => `${childPad}${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) ? k : JSON.stringify(k)}: ${toLiteral(v, indent + 1)}`).join(",\n")},\n${pad}}`;
|
|
34
|
+
}
|
|
35
|
+
return String(value);
|
|
36
|
+
};
|
|
37
|
+
const pullOrg = async (config) => {
|
|
38
|
+
const client = new ApiClient({ apiKey: config.apiKey });
|
|
39
|
+
const [users, workspaceVaults] = await Promise.all([client.listUsers(), client.listVaults()]);
|
|
40
|
+
const allRawVaults = workspaceVaults.flatMap((ws) => ws.vaults);
|
|
41
|
+
const { result: accounts } = await client.resolveConstellation(workspaceVaults[0].workspaceId, { specification: allRawVaults.map((vault) => ({
|
|
42
|
+
type: "SAFE",
|
|
43
|
+
chain: vault.chain,
|
|
44
|
+
address: vault.address
|
|
45
|
+
})) });
|
|
46
|
+
let accountIndex = 0;
|
|
47
|
+
const vaultsRecord = {};
|
|
48
|
+
for (const ws of workspaceVaults) {
|
|
49
|
+
const wsVaults = {};
|
|
50
|
+
for (const vault of ws.vaults) {
|
|
51
|
+
const account = accounts[accountIndex++];
|
|
52
|
+
invariant(account.type === "SAFE", `Expected SAFE account for vault ${vault.id}`);
|
|
53
|
+
wsVaults[vault.label] = {
|
|
54
|
+
id: vault.id,
|
|
55
|
+
label: vault.label,
|
|
56
|
+
address: account.address,
|
|
57
|
+
chain: vault.chain,
|
|
58
|
+
threshold: account.threshold,
|
|
59
|
+
owners: [...account.owners],
|
|
60
|
+
modules: [...account.modules]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
vaultsRecord[ws.workspaceName] = {
|
|
64
|
+
workspaceId: ws.workspaceId,
|
|
65
|
+
workspaceName: ws.workspaceName,
|
|
66
|
+
vaults: wsVaults
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const nameCount = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const user of users) nameCount.set(user.fullName, (nameCount.get(user.fullName) ?? 0) + 1);
|
|
71
|
+
const usersRecord = {};
|
|
72
|
+
for (const user of users) {
|
|
73
|
+
const handle = nameCount.get(user.fullName) > 1 ? `${user.fullName} (${user.id})` : user.fullName;
|
|
74
|
+
usersRecord[handle] = {
|
|
75
|
+
id: user.id,
|
|
76
|
+
fullName: user.fullName,
|
|
77
|
+
personalSafes: user.personalSafes
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const outDir = join(resolveNodeModulesDir(), ".zodiac-os");
|
|
81
|
+
mkdirSync(outDir, { recursive: true });
|
|
82
|
+
writeFileSync(join(outDir, "package.json"), JSON.stringify({
|
|
83
|
+
name: ".zodiac-os",
|
|
84
|
+
type: "module",
|
|
85
|
+
main: "index.js",
|
|
86
|
+
types: "index.d.ts"
|
|
87
|
+
}, null, 2));
|
|
88
|
+
const sourceFile = new Project({
|
|
89
|
+
compilerOptions: {
|
|
90
|
+
declaration: true,
|
|
91
|
+
module: ModuleKind.ESNext,
|
|
92
|
+
target: ScriptTarget.ESNext,
|
|
93
|
+
outDir
|
|
94
|
+
},
|
|
95
|
+
useInMemoryFileSystem: true
|
|
96
|
+
}).createSourceFile("index.ts", "");
|
|
97
|
+
sourceFile.addVariableStatement({
|
|
98
|
+
isExported: true,
|
|
99
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
100
|
+
declarations: [{
|
|
101
|
+
name: "users",
|
|
102
|
+
initializer: `${toLiteral(usersRecord)} as const`
|
|
103
|
+
}]
|
|
104
|
+
});
|
|
105
|
+
sourceFile.addVariableStatement({
|
|
106
|
+
isExported: true,
|
|
107
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
108
|
+
declarations: [{
|
|
109
|
+
name: "vaults",
|
|
110
|
+
initializer: `${toLiteral(vaultsRecord)} as const`
|
|
111
|
+
}]
|
|
112
|
+
});
|
|
113
|
+
const emitResult = sourceFile.getEmitOutput();
|
|
114
|
+
for (const outputFile of emitResult.getOutputFiles()) writeFileSync(join(outDir, outputFile.getFilePath().includes(".d.ts") ? "index.d.ts" : "index.js"), outputFile.getText());
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/allow/fetch.ts
|
|
118
|
+
async function fetchAbi(chainId, address) {
|
|
119
|
+
const url = `https://api.abi.pub/v1/chains/${chainId}/etherscan?module=contract&action=getabi&address=${address}`;
|
|
120
|
+
let body;
|
|
121
|
+
try {
|
|
122
|
+
const resp = await fetch(url);
|
|
123
|
+
if (!resp.ok) return null;
|
|
124
|
+
body = await resp.json();
|
|
125
|
+
} catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (body.status !== "1" || typeof body.result !== "string") return null;
|
|
129
|
+
try {
|
|
130
|
+
const parsed = JSON.parse(body.result);
|
|
131
|
+
if (!Array.isArray(parsed) || parsed.length === 0) return null;
|
|
132
|
+
return parsed;
|
|
133
|
+
} catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/allow/codegen.ts
|
|
139
|
+
function generateAllowTypes(abisDir, contractsConfig) {
|
|
140
|
+
const root = /* @__PURE__ */ new Map();
|
|
141
|
+
for (const node of walkContracts(contractsConfig)) {
|
|
142
|
+
const abi = readAbi(abisDir, node);
|
|
143
|
+
if (!abi) continue;
|
|
144
|
+
insertIntoTree(root, [node.chain, ...node.segments], {
|
|
145
|
+
node,
|
|
146
|
+
abi
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const out = [];
|
|
150
|
+
out.push("// AUTO-GENERATED by `zodiac-os pull-contracts`. Do not edit.");
|
|
151
|
+
out.push("/* eslint-disable */");
|
|
152
|
+
out.push("");
|
|
153
|
+
out.push(`import type { FunctionPermission, TargetPermission } from "zodiac-roles-sdk";`);
|
|
154
|
+
out.push(`import type { Scoping, Options, EVERYTHING } from "@zodiac-os/sdk/allow";`);
|
|
155
|
+
out.push("");
|
|
156
|
+
out.push("declare global {");
|
|
157
|
+
out.push(" interface AllowKit " + renderTree(root, " "));
|
|
158
|
+
out.push("}");
|
|
159
|
+
out.push("");
|
|
160
|
+
out.push("export {};");
|
|
161
|
+
out.push("");
|
|
162
|
+
return out.join("\n");
|
|
163
|
+
}
|
|
164
|
+
function insertIntoTree(tree, segments, leaf) {
|
|
165
|
+
const [first, ...rest] = segments;
|
|
166
|
+
if (!first) throw new Error("empty segments");
|
|
167
|
+
if (rest.length === 0) {
|
|
168
|
+
tree.set(first, leaf);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
let child = tree.get(first);
|
|
172
|
+
if (!child || child.node) {
|
|
173
|
+
child = /* @__PURE__ */ new Map();
|
|
174
|
+
tree.set(first, child);
|
|
175
|
+
}
|
|
176
|
+
insertIntoTree(child, rest, leaf);
|
|
177
|
+
}
|
|
178
|
+
function renderTree(tree, indent) {
|
|
179
|
+
const lines = ["{"];
|
|
180
|
+
for (const [key, value] of tree) {
|
|
181
|
+
const safeKey = renderPropKey(key);
|
|
182
|
+
if (value instanceof Map) lines.push(`${indent} ${safeKey}: ${renderTree(value, indent + " ")};`);
|
|
183
|
+
else {
|
|
184
|
+
const { node, abi } = value;
|
|
185
|
+
lines.push(`${indent} ${safeKey}: ${renderContractType(node, abi, indent + " ")};`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
lines.push(`${indent}}`);
|
|
189
|
+
return lines.join("\n");
|
|
190
|
+
}
|
|
191
|
+
function renderPropKey(name) {
|
|
192
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name);
|
|
193
|
+
}
|
|
194
|
+
function renderContractType(node, abi, indent) {
|
|
195
|
+
const members = [];
|
|
196
|
+
const seen = /* @__PURE__ */ new Set();
|
|
197
|
+
members.push(`${indent} [EVERYTHING]: (options?: Options) => TargetPermission;`);
|
|
198
|
+
for (const fragment of abi) {
|
|
199
|
+
if (fragment.type !== "function") continue;
|
|
200
|
+
if (fragment.stateMutability === "view" || fragment.stateMutability === "pure") continue;
|
|
201
|
+
const name = fragment.name;
|
|
202
|
+
if (!name || seen.has(name)) continue;
|
|
203
|
+
seen.add(name);
|
|
204
|
+
members.push(renderFunctionSignature(fragment, indent + " "));
|
|
205
|
+
}
|
|
206
|
+
return [
|
|
207
|
+
"{",
|
|
208
|
+
...members,
|
|
209
|
+
`${indent}}`
|
|
210
|
+
].join("\n");
|
|
211
|
+
}
|
|
212
|
+
function renderFunctionSignature(fragment, indent) {
|
|
213
|
+
const name = renderPropKey(fragment.name);
|
|
214
|
+
const params = [];
|
|
215
|
+
for (const input of fragment.inputs ?? []) {
|
|
216
|
+
const paramName = sanitizeParamName(input.name || `arg${params.length}`, params.length);
|
|
217
|
+
params.push(`${paramName}?: Scoping<${tsTypeFor(input)}>`);
|
|
218
|
+
}
|
|
219
|
+
params.push(`options?: Options`);
|
|
220
|
+
return `${indent}${name}: (${params.join(", ")}) => FunctionPermission;`;
|
|
221
|
+
}
|
|
222
|
+
function sanitizeParamName(name, index) {
|
|
223
|
+
const cleaned = name.replace(/[^A-Za-z0-9_$]/g, "_");
|
|
224
|
+
if (!cleaned || /^[0-9]/.test(cleaned)) return `arg${index}`;
|
|
225
|
+
return new Set([
|
|
226
|
+
"function",
|
|
227
|
+
"class",
|
|
228
|
+
"new",
|
|
229
|
+
"number",
|
|
230
|
+
"string",
|
|
231
|
+
"object",
|
|
232
|
+
"boolean",
|
|
233
|
+
"symbol",
|
|
234
|
+
"default",
|
|
235
|
+
"return",
|
|
236
|
+
"this",
|
|
237
|
+
"void",
|
|
238
|
+
"delete",
|
|
239
|
+
"in",
|
|
240
|
+
"of",
|
|
241
|
+
"for",
|
|
242
|
+
"while",
|
|
243
|
+
"switch",
|
|
244
|
+
"case",
|
|
245
|
+
"if",
|
|
246
|
+
"else",
|
|
247
|
+
"null",
|
|
248
|
+
"true",
|
|
249
|
+
"false",
|
|
250
|
+
"undefined",
|
|
251
|
+
"any",
|
|
252
|
+
"never",
|
|
253
|
+
"unknown"
|
|
254
|
+
]).has(cleaned) ? `_${cleaned}` : cleaned;
|
|
255
|
+
}
|
|
256
|
+
function tsTypeFor(fragment) {
|
|
257
|
+
const type = fragment.type;
|
|
258
|
+
const arrayMatch = /^(.*)\[(\d*)\]$/.exec(type);
|
|
259
|
+
if (arrayMatch) return `readonly (${tsTypeFor({
|
|
260
|
+
...fragment,
|
|
261
|
+
type: arrayMatch[1]
|
|
262
|
+
})})[]`;
|
|
263
|
+
if (type === "tuple") {
|
|
264
|
+
const components = fragment.components ?? [];
|
|
265
|
+
if (components.length === 0) return "Record<string, unknown>";
|
|
266
|
+
return `{ ${components.map((c, i) => {
|
|
267
|
+
return `${renderPropKey(sanitizeParamName(c.name || `f${i}`, i))}: ${tsTypeFor(c)}`;
|
|
268
|
+
}).join("; ")} }`;
|
|
269
|
+
}
|
|
270
|
+
if (type === "address") return "`0x${string}`";
|
|
271
|
+
if (type === "bool") return "boolean";
|
|
272
|
+
if (type === "string") return "string";
|
|
273
|
+
if (type === "bytes") return "import(\"ethers\").BytesLike";
|
|
274
|
+
if (/^bytes\d+$/.test(type)) return "`0x${string}`";
|
|
275
|
+
if (/^u?int\d*$/.test(type)) return "import(\"ethers\").BigNumberish";
|
|
276
|
+
return "unknown";
|
|
277
|
+
}
|
|
278
|
+
function writeGenerated(outFile, source) {
|
|
279
|
+
fs.mkdirSync(path.dirname(outFile), { recursive: true });
|
|
280
|
+
fs.writeFileSync(outFile, source, "utf8");
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/cli/commands/pullContracts.ts
|
|
284
|
+
const pullContracts = async (config) => {
|
|
285
|
+
if (!config.contracts || Object.keys(config.contracts).length === 0) {
|
|
286
|
+
console.log("No contracts defined in config, skipping.");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const abisDir = resolveAbisDir(config);
|
|
290
|
+
const generatedFile = path.join(resolveTypesDir(config), "allow.d.ts");
|
|
291
|
+
let missing = 0;
|
|
292
|
+
let fetched = 0;
|
|
293
|
+
let existing = 0;
|
|
294
|
+
for (const node of walkContracts(config.contracts)) {
|
|
295
|
+
const file = abiFilePath(abisDir, node);
|
|
296
|
+
if (fs.existsSync(file)) {
|
|
297
|
+
existing++;
|
|
298
|
+
report(node.chain, node.segments, node.address, "ok", file);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
let chainId;
|
|
302
|
+
try {
|
|
303
|
+
chainId = chainIdFor(node.chain);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
missing++;
|
|
306
|
+
report(node.chain, node.segments, node.address, "missing", file, error.message);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const abi = await fetchAbi(chainId, node.address);
|
|
310
|
+
if (!abi) {
|
|
311
|
+
missing++;
|
|
312
|
+
report(node.chain, node.segments, node.address, "missing", file, `api.abi.pub returned no ABI for chain ${chainId}`);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
writeAbi(abisDir, node, abi);
|
|
316
|
+
fetched++;
|
|
317
|
+
report(node.chain, node.segments, node.address, "fetched", file);
|
|
318
|
+
}
|
|
319
|
+
console.log("");
|
|
320
|
+
console.log(`Contracts summary: ${existing} existing, ${fetched} fetched, ${missing} missing.`);
|
|
321
|
+
if (missing > 0) {
|
|
322
|
+
console.log("");
|
|
323
|
+
console.log("Missing ABIs must be provided manually. Paste the contract");
|
|
324
|
+
console.log("ABI JSON at the paths listed above and re-run `zodiac-os pull-contracts`.");
|
|
325
|
+
}
|
|
326
|
+
writeGenerated(generatedFile, generateAllowTypes(abisDir, config.contracts));
|
|
327
|
+
console.log("");
|
|
328
|
+
console.log(`Wrote typings to ${path.relative(process.cwd(), generatedFile)}`);
|
|
329
|
+
if (missing > 0) process.exit(1);
|
|
330
|
+
};
|
|
331
|
+
function report(chain, segments, address, status, file, reason) {
|
|
332
|
+
const label = `${chain}.${segments.join(".")}`.padEnd(40, " ");
|
|
333
|
+
const tag = {
|
|
334
|
+
ok: " cached ",
|
|
335
|
+
fetched: " fetched ",
|
|
336
|
+
missing: " MISSING "
|
|
337
|
+
}[status];
|
|
338
|
+
const suffix = reason ? ` — ${reason}` : "";
|
|
339
|
+
console.log(`${tag} ${label} ${address}${suffix}`);
|
|
340
|
+
if (status === "missing") console.log(` → paste ABI at ${file}`);
|
|
341
|
+
}
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/cli/run.ts
|
|
344
|
+
const run = async (argv = process.argv) => {
|
|
345
|
+
const program = new Command();
|
|
346
|
+
program.name("zodiac-os").description("Zodiac OS SDK CLI – pull org data and contract ABIs").version("1.0.0").option("-c, --config <path>", "path to the config file", "zodiac.config.ts");
|
|
347
|
+
program.command("pull-org").description("Fetch Zodiac users and vaults, generate TypeScript types").action(async (_opts, cmd) => {
|
|
348
|
+
await pullOrg(await loadConfig(cmd.optsWithGlobals().config));
|
|
349
|
+
});
|
|
350
|
+
program.command("pull-contracts").description("Fetch contract ABIs, generate typed permissions kit").action(async (_opts, cmd) => {
|
|
351
|
+
await pullContracts(await loadConfig(cmd.optsWithGlobals().config));
|
|
352
|
+
});
|
|
353
|
+
program.command("pull").description("Fetch Zodiac org and contracts ABI, generate SDK functions").action(async (_opts, cmd) => {
|
|
354
|
+
const config = await loadConfig(cmd.optsWithGlobals().config);
|
|
355
|
+
await Promise.all([pullOrg(config), pullContracts(config)]);
|
|
356
|
+
});
|
|
357
|
+
await program.parseAsync(argv);
|
|
358
|
+
};
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/cli/index.ts
|
|
361
|
+
run().then(() => {
|
|
362
|
+
process.exit(0);
|
|
363
|
+
}, (error) => {
|
|
364
|
+
if (error) console.error(error);
|
|
365
|
+
process.exit(1);
|
|
366
|
+
});
|
|
367
|
+
//#endregion
|
|
368
|
+
export {};
|
|
369
|
+
|
|
370
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli/commands/pullOrg.ts","../src/allow/fetch.ts","../src/allow/codegen.ts","../src/cli/commands/pullContracts.ts","../src/cli/run.ts","../src/cli/index.ts"],"sourcesContent":["import type { ZodiacConfig } from '../config'\nimport { ApiClient } from '../../api'\nimport { invariant } from '@epic-web/invariant'\nimport {\n ModuleKind,\n Project,\n ScriptTarget,\n VariableDeclarationKind,\n} from 'ts-morph'\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { join } from 'path'\nimport { fileURLToPath } from 'url'\n\nfunction resolveNodeModulesDir(): string {\n const selfPath = fileURLToPath(import.meta.url)\n const match = selfPath.match(/^(.+[/\\\\]node_modules)[/\\\\]/)\n if (match) return match[1]\n // Fallback for development (running from source, not from node_modules)\n return join(process.cwd(), 'node_modules')\n}\n\nconst toLiteral = (value: unknown, indent = 0): string => {\n const pad = ' '.repeat(indent)\n const childPad = ' '.repeat(indent + 1)\n\n if (value === null) return 'null'\n if (typeof value === 'bigint') return `${value}n`\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value)\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]'\n return `[\\n${value.map((v) => `${childPad}${toLiteral(v, indent + 1)}`).join(',\\n')},\\n${pad}]`\n }\n if (typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n if (entries.length === 0) return '{}'\n const props = entries.map(\n ([k, v]) =>\n `${childPad}${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) ? k : JSON.stringify(k)}: ${toLiteral(v, indent + 1)}`\n )\n return `{\\n${props.join(',\\n')},\\n${pad}}`\n }\n return String(value)\n}\n\nexport const pullOrg = async (config: ZodiacConfig) => {\n const client = new ApiClient({\n apiKey: config.apiKey,\n })\n\n const [users, workspaceVaults] = await Promise.all([\n client.listUsers(),\n client.listVaults(),\n ])\n\n const allRawVaults = workspaceVaults.flatMap((ws) => ws.vaults)\n\n const { result: accounts } = await client.resolveConstellation(\n workspaceVaults[0].workspaceId, // can just use any workspace to resolve\n {\n specification: allRawVaults.map((vault) => ({\n type: 'SAFE',\n chain: vault.chain,\n address: vault.address,\n })),\n }\n )\n\n let accountIndex = 0\n const vaultsRecord: Record<string, unknown> = {}\n for (const ws of workspaceVaults) {\n const wsVaults: Record<string, unknown> = {}\n for (const vault of ws.vaults) {\n const account = accounts[accountIndex++]\n invariant(\n account.type === 'SAFE',\n `Expected SAFE account for vault ${vault.id}`\n )\n wsVaults[vault.label] = {\n id: vault.id,\n label: vault.label,\n address: account.address,\n chain: vault.chain,\n threshold: account.threshold,\n owners: [...account.owners],\n modules: [...account.modules],\n }\n }\n vaultsRecord[ws.workspaceName] = {\n workspaceId: ws.workspaceId,\n workspaceName: ws.workspaceName,\n vaults: wsVaults,\n }\n }\n\n const nameCount = new Map<string, number>()\n for (const user of users) {\n nameCount.set(user.fullName, (nameCount.get(user.fullName) ?? 0) + 1)\n }\n\n const usersRecord: Record<string, unknown> = {}\n for (const user of users) {\n const handle =\n nameCount.get(user.fullName)! > 1\n ? `${user.fullName} (${user.id})`\n : user.fullName\n usersRecord[handle] = {\n id: user.id,\n fullName: user.fullName,\n personalSafes: user.personalSafes,\n }\n }\n\n const outDir = join(resolveNodeModulesDir(), '.zodiac-os')\n\n mkdirSync(outDir, { recursive: true })\n\n // Write package.json so .zodiac-os is importable\n writeFileSync(\n join(outDir, 'package.json'),\n JSON.stringify(\n {\n name: '.zodiac-os',\n type: 'module',\n main: 'index.js',\n types: 'index.d.ts',\n },\n null,\n 2\n )\n )\n\n // Use ts-morph to generate TS, then emit JS + d.ts\n const project = new Project({\n compilerOptions: {\n declaration: true,\n module: ModuleKind.ESNext,\n target: ScriptTarget.ESNext,\n outDir,\n },\n useInMemoryFileSystem: true,\n })\n\n const sourceFile = project.createSourceFile('index.ts', '')\n\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'users',\n initializer: `${toLiteral(usersRecord)} as const`,\n },\n ],\n })\n\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'vaults',\n initializer: `${toLiteral(vaultsRecord)} as const`,\n },\n ],\n })\n\n const emitResult = sourceFile.getEmitOutput()\n for (const outputFile of emitResult.getOutputFiles()) {\n const filePath = outputFile.getFilePath()\n const fileName = filePath.includes('.d.ts') ? 'index.d.ts' : 'index.js'\n writeFileSync(join(outDir, fileName), outputFile.getText())\n }\n}\n","import { chainIdFor, type ChainPrefix } from './networks'\n\nexport type AbiFragment = Record<string, any>\nexport type Abi = AbiFragment[]\n\n// Returns null on any failure so callers can fall back to a manual ABI file.\nexport async function fetchAbi(\n chainId: number,\n address: `0x${string}`\n): Promise<Abi | null> {\n const url = `https://api.abi.pub/v1/chains/${chainId}/etherscan?module=contract&action=getabi&address=${address}`\n let body: { status?: string; message?: string; result?: string }\n try {\n const resp = await fetch(url)\n if (!resp.ok) return null\n body = (await resp.json()) as typeof body\n } catch {\n return null\n }\n if (body.status !== '1' || typeof body.result !== 'string') return null\n try {\n const parsed = JSON.parse(body.result)\n if (!Array.isArray(parsed) || parsed.length === 0) return null\n return parsed as Abi\n } catch {\n return null\n }\n}\n\nexport const fetchAbiForPrefix = (\n prefix: ChainPrefix,\n address: `0x${string}`\n) => fetchAbi(chainIdFor(prefix), address)\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport { walkContracts, readAbi, type ContractNode } from './abi'\nimport type { Abi, AbiFragment } from './fetch'\n\n// Emits named tuple elements per ABI input — this is the reason we don't rely\n// on viem/abitype, which produces unnamed tuples (microsoft/TypeScript#44939).\nexport function generateAllowTypes(\n abisDir: string,\n contractsConfig: Record<string, any>\n): string {\n type Tree = Map<string, Tree | { node: ContractNode; abi: Abi }>\n\n const root: Tree = new Map()\n for (const node of walkContracts(contractsConfig)) {\n const abi = readAbi(abisDir, node)\n if (!abi) continue\n insertIntoTree(root, [node.chain, ...node.segments], { node, abi })\n }\n\n const out: string[] = []\n out.push('// AUTO-GENERATED by `zodiac-os pull-contracts`. Do not edit.')\n out.push('/* eslint-disable */')\n out.push('')\n out.push(\n `import type { FunctionPermission, TargetPermission } from \"zodiac-roles-sdk\";`\n )\n out.push(\n `import type { Scoping, Options, EVERYTHING } from \"@zodiac-os/sdk/allow\";`\n )\n out.push('')\n out.push('declare global {')\n out.push(' interface AllowKit ' + renderTree(root, ' '))\n out.push('}')\n out.push('')\n out.push('export {};')\n out.push('')\n return out.join('\\n')\n}\n\nfunction insertIntoTree(\n tree: Map<string, any>,\n segments: string[],\n leaf: { node: ContractNode; abi: Abi }\n): void {\n const [first, ...rest] = segments\n if (!first) throw new Error('empty segments')\n if (rest.length === 0) {\n tree.set(first, leaf)\n return\n }\n let child = tree.get(first)\n if (!child || child.node) {\n child = new Map()\n tree.set(first, child)\n }\n insertIntoTree(child, rest, leaf)\n}\n\nfunction renderTree(tree: Map<string, any>, indent: string): string {\n const lines: string[] = ['{']\n for (const [key, value] of tree) {\n const safeKey = renderPropKey(key)\n if (value instanceof Map) {\n lines.push(`${indent} ${safeKey}: ${renderTree(value, indent + ' ')};`)\n } else {\n const { node, abi } = value as { node: ContractNode; abi: Abi }\n lines.push(\n `${indent} ${safeKey}: ${renderContractType(node, abi, indent + ' ')};`\n )\n }\n }\n lines.push(`${indent}}`)\n return lines.join('\\n')\n}\n\nfunction renderPropKey(name: string): string {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name)\n}\n\nfunction renderContractType(\n node: ContractNode,\n abi: Abi,\n indent: string\n): string {\n const members: string[] = []\n const seen = new Set<string>()\n members.push(\n `${indent} [EVERYTHING]: (options?: Options) => TargetPermission;`\n )\n for (const fragment of abi) {\n if (fragment.type !== 'function') continue\n if (\n fragment.stateMutability === 'view' ||\n fragment.stateMutability === 'pure'\n ) {\n continue\n }\n const name = fragment.name as string\n if (!name || seen.has(name)) continue\n seen.add(name)\n members.push(renderFunctionSignature(fragment, indent + ' '))\n }\n return ['{', ...members, `${indent}}`].join('\\n')\n}\n\nfunction renderFunctionSignature(\n fragment: AbiFragment,\n indent: string\n): string {\n const name = renderPropKey(fragment.name as string)\n const params: string[] = []\n for (const input of (fragment.inputs as AbiFragment[]) ?? []) {\n const paramName = sanitizeParamName(\n input.name || `arg${params.length}`,\n params.length\n )\n params.push(`${paramName}?: Scoping<${tsTypeFor(input)}>`)\n }\n params.push(`options?: Options`)\n return `${indent}${name}: (${params.join(', ')}) => FunctionPermission;`\n}\n\nfunction sanitizeParamName(name: string, index: number): string {\n const cleaned = name.replace(/[^A-Za-z0-9_$]/g, '_')\n if (!cleaned || /^[0-9]/.test(cleaned)) return `arg${index}`\n // Named tuple element labels can't collide with TS reserved words.\n const reserved = new Set([\n 'function',\n 'class',\n 'new',\n 'number',\n 'string',\n 'object',\n 'boolean',\n 'symbol',\n 'default',\n 'return',\n 'this',\n 'void',\n 'delete',\n 'in',\n 'of',\n 'for',\n 'while',\n 'switch',\n 'case',\n 'if',\n 'else',\n 'null',\n 'true',\n 'false',\n 'undefined',\n 'any',\n 'never',\n 'unknown',\n ])\n return reserved.has(cleaned) ? `_${cleaned}` : cleaned\n}\n\nfunction tsTypeFor(fragment: AbiFragment): string {\n const type = fragment.type as string\n\n const arrayMatch = /^(.*)\\[(\\d*)\\]$/.exec(type)\n if (arrayMatch) {\n const inner: AbiFragment = { ...fragment, type: arrayMatch[1] }\n return `readonly (${tsTypeFor(inner)})[]`\n }\n\n if (type === 'tuple') {\n const components = (fragment.components as AbiFragment[]) ?? []\n if (components.length === 0) return 'Record<string, unknown>'\n const fields = components.map((c, i) => {\n const key = sanitizeParamName(c.name || `f${i}`, i)\n return `${renderPropKey(key)}: ${tsTypeFor(c)}`\n })\n return `{ ${fields.join('; ')} }`\n }\n\n if (type === 'address') return '`0x${string}`'\n if (type === 'bool') return 'boolean'\n if (type === 'string') return 'string'\n if (type === 'bytes') return 'import(\"ethers\").BytesLike'\n if (/^bytes\\d+$/.test(type)) return '`0x${string}`'\n if (/^u?int\\d*$/.test(type)) return 'import(\"ethers\").BigNumberish'\n return 'unknown'\n}\n\nexport function writeGenerated(outFile: string, source: string): void {\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, source, 'utf8')\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { ZodiacConfig } from '../config'\nimport { resolveAbisDir, resolveTypesDir } from '../config'\nimport { abiFilePath, walkContracts, writeAbi } from '../../allow/abi'\nimport { fetchAbi } from '../../allow/fetch'\nimport { chainIdFor } from '../../allow/networks'\nimport { generateAllowTypes, writeGenerated } from '../../allow/codegen'\n\ntype Status = 'ok' | 'fetched' | 'missing'\n\nexport const pullContracts = async (config: ZodiacConfig) => {\n if (!config.contracts || Object.keys(config.contracts).length === 0) {\n console.log('No contracts defined in config, skipping.')\n return\n }\n\n const abisDir = resolveAbisDir(config)\n const generatedFile = path.join(resolveTypesDir(config), 'allow.d.ts')\n\n let missing = 0\n let fetched = 0\n let existing = 0\n\n for (const node of walkContracts(config.contracts)) {\n const file = abiFilePath(abisDir, node)\n\n if (fs.existsSync(file)) {\n existing++\n report(node.chain, node.segments, node.address, 'ok', file)\n continue\n }\n\n let chainId: number\n try {\n chainId = chainIdFor(node.chain)\n } catch (error) {\n missing++\n report(\n node.chain,\n node.segments,\n node.address,\n 'missing',\n file,\n (error as Error).message\n )\n continue\n }\n\n const abi = await fetchAbi(chainId, node.address)\n if (!abi) {\n missing++\n report(\n node.chain,\n node.segments,\n node.address,\n 'missing',\n file,\n `api.abi.pub returned no ABI for chain ${chainId}`\n )\n continue\n }\n writeAbi(abisDir, node, abi)\n fetched++\n report(node.chain, node.segments, node.address, 'fetched', file)\n }\n\n console.log('')\n console.log(\n `Contracts summary: ${existing} existing, ${fetched} fetched, ${missing} missing.`\n )\n if (missing > 0) {\n console.log('')\n console.log('Missing ABIs must be provided manually. Paste the contract')\n console.log(\n 'ABI JSON at the paths listed above and re-run `zodiac-os pull-contracts`.'\n )\n }\n\n const source = generateAllowTypes(abisDir, config.contracts)\n writeGenerated(generatedFile, source)\n console.log('')\n console.log(`Wrote typings to ${path.relative(process.cwd(), generatedFile)}`)\n\n if (missing > 0) process.exit(1)\n}\n\nfunction report(\n chain: string,\n segments: string[],\n address: string,\n status: Status,\n file: string,\n reason?: string\n) {\n const label = `${chain}.${segments.join('.')}`.padEnd(40, ' ')\n const tag = {\n ok: ' cached ',\n fetched: ' fetched ',\n missing: ' MISSING ',\n }[status]\n const suffix = reason ? ` — ${reason}` : ''\n console.log(`${tag} ${label} ${address}${suffix}`)\n if (status === 'missing') {\n console.log(` → paste ABI at ${file}`)\n }\n}\n","import { Command } from 'commander'\nimport { loadConfig } from './config'\nimport { pullOrg } from './commands/pullOrg'\nimport { pullContracts } from './commands/pullContracts'\n\nexport const run = async (argv: string[] = process.argv) => {\n const program = new Command()\n\n program\n .name('zodiac-os')\n .description('Zodiac OS SDK CLI – pull org data and contract ABIs')\n .version('1.0.0')\n .option(\n '-c, --config <path>',\n 'path to the config file',\n 'zodiac.config.ts'\n )\n\n program\n .command('pull-org')\n .description('Fetch Zodiac users and vaults, generate TypeScript types')\n .action(async (_opts, cmd) => {\n const config = await loadConfig(cmd.optsWithGlobals().config)\n await pullOrg(config)\n })\n\n program\n .command('pull-contracts')\n .description('Fetch contract ABIs, generate typed permissions kit')\n .action(async (_opts, cmd) => {\n const config = await loadConfig(cmd.optsWithGlobals().config)\n await pullContracts(config)\n })\n\n program\n .command('pull')\n .description('Fetch Zodiac org and contracts ABI, generate SDK functions')\n .action(async (_opts, cmd) => {\n const config = await loadConfig(cmd.optsWithGlobals().config)\n await Promise.all([pullOrg(config), pullContracts(config)])\n })\n\n await program.parseAsync(argv)\n}\n","#!/usr/bin/env node\nimport { run } from './run'\n\nrun().then(\n () => {\n process.exit(0)\n },\n (error: unknown) => {\n if (error) console.error(error)\n process.exit(1)\n }\n)\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,wBAAgC;CAEvC,MAAM,QADW,cAAc,OAAO,KAAK,IAAI,CACxB,MAAM,8BAA8B;AAC3D,KAAI,MAAO,QAAO,MAAM;AAExB,QAAO,KAAK,QAAQ,KAAK,EAAE,eAAe;;AAG5C,MAAM,aAAa,OAAgB,SAAS,MAAc;CACxD,MAAM,MAAM,KAAK,OAAO,OAAO;CAC/B,MAAM,WAAW,KAAK,OAAO,SAAS,EAAE;AAExC,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,MAAM;AAC3D,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,QAAO,OAAO,MAAM;AACtB,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,MAAM,MAAM,KA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S,MAAM,WAAW,IAAI,iBAAiB,CAAC,OAAO;AAC7D,QAAM,QAAQ,IAAI,CAAC,QAAQ,OAAO,EAAE,cAAc,OAAO,CAAC,CAAC;GAC3D;AAEJ,OAAM,QAAQ,WAAW,KAAK;;;;ACvChC,KAAK,CAAC,WACE;AACJ,SAAQ,KAAK,EAAE;IAEhB,UAAmB;AAClB,KAAI,MAAO,SAAQ,MAAM,MAAM;AAC/B,SAAQ,KAAK,EAAE;EAElB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Condition, FunctionPermission, TargetPermission } from "zodiac-roles-sdk";
|
|
2
|
+
import { BigNumberish, BytesLike, ParamType } from "ethers";
|
|
3
|
+
|
|
4
|
+
//#region src/allow/runtime.d.ts
|
|
5
|
+
declare function buildAllowKit(abisDir: string, contractsConfig: Record<string, any>): Record<string, any>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/allow/types.d.ts
|
|
8
|
+
type Options = {
|
|
9
|
+
send?: boolean;
|
|
10
|
+
delegatecall?: boolean;
|
|
11
|
+
etherWithinAllowance?: `0x${string}`;
|
|
12
|
+
callWithinAllowance?: `0x${string}`;
|
|
13
|
+
};
|
|
14
|
+
type PrimitiveValue = BigNumberish | BytesLike | string | boolean;
|
|
15
|
+
type ConditionFunction<T = unknown> = (abiType: ParamType, _?: T) => Condition;
|
|
16
|
+
type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>> }[keyof T];
|
|
17
|
+
type ArrayElement<T extends readonly unknown[]> = T extends readonly (infer U)[] ? U : never;
|
|
18
|
+
type PrimitiveScoping<T extends PrimitiveValue> = T | ConditionFunction<T>;
|
|
19
|
+
type ArrayScoping<T extends readonly any[]> = readonly Scoping<ArrayElement<T>>[] | ConditionFunction<T>;
|
|
20
|
+
type StructScoping<T extends {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}> = RequireAtLeastOne<{ [K in keyof T]?: Scoping<T[K]> }> | ConditionFunction<T>;
|
|
23
|
+
type Scoping<T> = T extends PrimitiveValue ? PrimitiveScoping<T> : T extends readonly any[] ? ArrayScoping<T> : T extends {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} ? StructScoping<T> : unknown;
|
|
26
|
+
declare const EVERYTHING: unique symbol;
|
|
27
|
+
type EVERYTHING = typeof EVERYTHING;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/allow/networks.d.ts
|
|
30
|
+
declare const CHAIN_IDS: {
|
|
31
|
+
readonly eth: 1;
|
|
32
|
+
readonly oeth: 10;
|
|
33
|
+
readonly gno: 100;
|
|
34
|
+
readonly sep: 11155111;
|
|
35
|
+
readonly matic: 137;
|
|
36
|
+
readonly zkevm: 1101;
|
|
37
|
+
readonly arb1: 42161;
|
|
38
|
+
readonly avax: 43114;
|
|
39
|
+
readonly base: 8453;
|
|
40
|
+
readonly basesep: 84532;
|
|
41
|
+
readonly bnb: 56;
|
|
42
|
+
readonly celo: 42220;
|
|
43
|
+
readonly sonic: 146;
|
|
44
|
+
readonly berachain: 80094;
|
|
45
|
+
readonly unichain: 130;
|
|
46
|
+
readonly worldchain: 480;
|
|
47
|
+
readonly bob: 60808;
|
|
48
|
+
readonly mantle: 5000;
|
|
49
|
+
readonly hemi: 43111;
|
|
50
|
+
readonly katana: 747474;
|
|
51
|
+
readonly linea: 59144;
|
|
52
|
+
readonly ink: 57073;
|
|
53
|
+
readonly hyperevm: 999;
|
|
54
|
+
readonly flare: 14;
|
|
55
|
+
readonly scroll: 534352;
|
|
56
|
+
readonly plasma: 9745;
|
|
57
|
+
readonly megaeth: 4326;
|
|
58
|
+
};
|
|
59
|
+
type ChainPrefix = keyof typeof CHAIN_IDS;
|
|
60
|
+
declare const chainIdFor: (prefix: string) => number;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { EVERYTHING as a, Scoping as c, ConditionFunction as i, TargetPermission as l, ChainPrefix as n, FunctionPermission as o, chainIdFor as r, Options as s, CHAIN_IDS as t, buildAllowKit as u };
|
|
63
|
+
//# sourceMappingURL=index-DTBaxN7b.d.mts.map
|