@zodiaceco/sdk 1.12.1

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/dist/index.mjs ADDED
@@ -0,0 +1,214 @@
1
+ import { n as resolveZodiacDir, t as ApiClient } from "./api-C49DoaPC.mjs";
2
+ import { n as EVERYTHING, t as buildAllowKit } from "./allow-CzPpzclq.mjs";
3
+ import { createRequire } from "module";
4
+ import { invariant } from "@epic-web/invariant";
5
+ import { c, forAll, processPermissions } from "zodiac-roles-sdk";
6
+ //#region src/constellation.ts
7
+ function loadCodegen() {
8
+ return createRequire(import.meta.url)(resolveZodiacDir());
9
+ }
10
+ /**
11
+ * Creates a constellation scoped to a workspace and chain.
12
+ *
13
+ * Use bracket access to reference existing accounts (vaults and other
14
+ * applied constellation nodes) or define new ones:
15
+ * ```ts
16
+ * const eth = constellation({ workspace: 'GG', label: 'my constellation', chain: 1 })
17
+ *
18
+ * const dao = eth.safe['GG DAO'] // existing account ref
19
+ * const roles = eth.roles['GG DAO'] // existing roles ref
20
+ * const newSafe = eth.safe['New Safe']({ nonce: 0n, threshold: 2, owners: [...], modules: [...] })
21
+ * ```
22
+ */
23
+ function constellation(opts, internal) {
24
+ const codegen = internal?.codegen ?? loadCodegen();
25
+ const ws = codegen.accounts[opts.workspace];
26
+ const safesByLabel = {};
27
+ const rolesByLabel = {};
28
+ if (ws) {
29
+ for (const [label, account] of Object.entries(ws.safes)) safesByLabel[label] = account;
30
+ for (const [label, account] of Object.entries(ws.rolesMods)) rolesByLabel[label] = account;
31
+ }
32
+ const meta = {
33
+ label: opts.label,
34
+ chain: opts.chain,
35
+ workspaceId: ws?.workspaceId ?? ""
36
+ };
37
+ function makeNodeRef(data) {
38
+ return Object.freeze({
39
+ ...data,
40
+ chain: opts.chain,
41
+ _constellation: meta
42
+ });
43
+ }
44
+ function entityAccessor(registry, type) {
45
+ const cache = /* @__PURE__ */ new Map();
46
+ return new Proxy({}, { get(_target, name) {
47
+ if (typeof name !== "string") return void 0;
48
+ const cached = cache.get(name);
49
+ if (cached) return cached;
50
+ const existing = registry[name];
51
+ const specLabel = existing?.label ?? name;
52
+ const fn = (overrides) => makeNodeRef({
53
+ type,
54
+ ...existing || {},
55
+ ...overrides,
56
+ label: specLabel
57
+ });
58
+ Object.assign(fn, {
59
+ type,
60
+ ...existing || {},
61
+ label: specLabel,
62
+ chain: opts.chain,
63
+ _constellation: meta
64
+ });
65
+ cache.set(name, fn);
66
+ return fn;
67
+ } });
68
+ }
69
+ function userAccessor() {
70
+ return new Proxy({}, { get(_target, name) {
71
+ const user = codegen.users[name];
72
+ if (!user) throw new Error(`Unknown user: ${name}`);
73
+ const personalSafe = user.personalSafes[opts.chain];
74
+ if (!personalSafe) throw new Error(`User ${name} has no personal safe on chain ${opts.chain}`);
75
+ return personalSafe.address;
76
+ } });
77
+ }
78
+ return {
79
+ safe: entityAccessor(safesByLabel, "SAFE"),
80
+ roles: entityAccessor(rolesByLabel, "ROLES"),
81
+ user: userAccessor()
82
+ };
83
+ }
84
+ //#endregion
85
+ //#region src/push.ts
86
+ /**
87
+ * Resolves node references and pushes the constellation specification to the API.
88
+ *
89
+ *
90
+ * ```ts
91
+ * const eth = constellation({ workspace: 'GG', label: 'my constellation', chain: 1 })
92
+ * const dao = eth.safe['GG DAO']
93
+ * const roles = eth.roles['New Roles']({ nonce: 0n, target: dao, owner: dao, avatar: dao })
94
+ *
95
+ * await push([dao, roles])
96
+ * ```
97
+ */
98
+ async function push(nodes, opts) {
99
+ const api = opts?.api ?? new ApiClient();
100
+ const refs = deriveRefs(nodes);
101
+ const groups = /* @__PURE__ */ new Map();
102
+ for (const node of refs.byIdentity.keys()) {
103
+ const meta = node._constellation;
104
+ invariant(meta, `Node "${node.label}" is not associated with a constellation`);
105
+ const key = `${meta.workspaceId}:${meta.chain}:${meta.label}`;
106
+ let group = groups.get(key);
107
+ if (!group) {
108
+ group = {
109
+ meta,
110
+ nodes: []
111
+ };
112
+ groups.set(key, group);
113
+ }
114
+ group.nodes.push(node);
115
+ }
116
+ const results = [];
117
+ for (const { meta, nodes: groupNodes } of groups.values()) {
118
+ const specification = await Promise.all(groupNodes.map((n) => nodeToSpec(n, refs)));
119
+ const result = await api.applyConstellation(meta.workspaceId, {
120
+ label: meta.label,
121
+ chain: meta.chain,
122
+ specification
123
+ });
124
+ results.push(result);
125
+ }
126
+ return results;
127
+ }
128
+ function labelKey(node) {
129
+ return `${node._constellation.workspaceId}:${node.type}:${node.label}`;
130
+ }
131
+ function deriveRefs(nodes) {
132
+ const byIdentity = /* @__PURE__ */ new Map();
133
+ const byLabel = /* @__PURE__ */ new Map();
134
+ const register = (node, ref) => {
135
+ byIdentity.set(node, ref);
136
+ byLabel.set(labelKey(node), ref);
137
+ };
138
+ if (Array.isArray(nodes)) for (let i = 0; i < nodes.length; i++) {
139
+ const node = nodes[i];
140
+ invariant(isConstellationNode(node), `unexpected node input at index: ${i}`);
141
+ register(node, `${i}`);
142
+ }
143
+ else for (const [key, node] of Object.entries(nodes)) {
144
+ invariant(isConstellationNode(node), `unexpected node input under key: ${key}`);
145
+ register(node, key);
146
+ }
147
+ return {
148
+ byIdentity,
149
+ byLabel
150
+ };
151
+ }
152
+ async function nodeToSpec(node, refs) {
153
+ const { id, _constellation, ...rest } = node;
154
+ const spec = {};
155
+ for (const [key, value] of Object.entries(rest)) {
156
+ if (node.type === "ROLES" && key === "roles" && value != null) {
157
+ spec.roles = await expandRoles(value, refs);
158
+ continue;
159
+ }
160
+ spec[key] = resolveRefs(value, refs);
161
+ }
162
+ spec.ref = refs.byIdentity.get(node);
163
+ invariant(spec.ref != null, "ref not found");
164
+ return stringifyBigints(spec);
165
+ }
166
+ async function expandRoles(roles, refs) {
167
+ const entries = await Promise.all(Object.entries(roles).map(async ([key, def]) => {
168
+ if (def == null) return [key, null];
169
+ const { targets, annotations } = processPermissions(await Promise.all(def.permissions.map((p) => Promise.resolve(p))));
170
+ return [key, {
171
+ key,
172
+ members: resolveRefs(def.members, refs),
173
+ targets,
174
+ annotations: [...def.annotations ?? [], ...annotations]
175
+ }];
176
+ }));
177
+ return Object.fromEntries(entries);
178
+ }
179
+ function resolveRefs(value, refs) {
180
+ if (isConstellationNode(value)) {
181
+ const ref = refs.byIdentity.get(value) ?? refs.byLabel.get(labelKey(value));
182
+ invariant(ref != null, `Node "${value.label}" is referenced not included in the push() call`);
183
+ return `$${ref}`;
184
+ }
185
+ if (Array.isArray(value)) return value.map((v) => resolveRefs(v, refs));
186
+ if (typeof value === "object" && value !== null) {
187
+ const resolved = {};
188
+ for (const [k, v] of Object.entries(value)) resolved[k] = resolveRefs(v, refs);
189
+ return resolved;
190
+ }
191
+ if (typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value)) return value.toLowerCase();
192
+ return value;
193
+ }
194
+ function stringifyBigints(value) {
195
+ if (typeof value === "bigint") return value.toString();
196
+ if (Array.isArray(value)) return value.map(stringifyBigints);
197
+ if (typeof value === "object" && value !== null) {
198
+ const result = {};
199
+ for (const [k, v] of Object.entries(value)) result[k] = stringifyBigints(v);
200
+ return result;
201
+ }
202
+ return value;
203
+ }
204
+ function isConstellationNode(value) {
205
+ if (typeof value === "function" || typeof value === "object") {
206
+ const obj = value;
207
+ return obj != null && typeof obj.type === "string" && typeof obj.chain === "number" && typeof obj._constellation === "object";
208
+ }
209
+ return false;
210
+ }
211
+ //#endregion
212
+ export { EVERYTHING, buildAllowKit, c, constellation, forAll, push };
213
+
214
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/constellation.ts","../src/push.ts"],"sourcesContent":["/// <reference path=\"./zodiac-os-codegen.d.ts\" />\nimport type { Address, ChainId } from '@zodiaceco/api-types'\nimport type { AllowanceSpec } from './types'\nimport type { Annotation, Permission, PermissionSet } from 'zodiac-roles-sdk'\nimport { createRequire } from 'module'\nimport { resolveZodiacDir } from './paths'\nimport { UUID } from 'crypto'\n\n/**\n * A role definition keyed by role name. Permissions are expanded into\n * `{ targets, annotations }` via `processPermissions` at `push()` time.\n */\nexport type RoleDef = {\n members: readonly AddressOrRef[]\n permissions: readonly (Permission | PermissionSet | Promise<PermissionSet>)[]\n annotations?: readonly Annotation[]\n}\n\ntype User = {\n id: UUID\n fullName: string\n personalSafes: Record<\n number,\n { address: Lowercase<Address>; active: boolean }\n >\n}\n\ntype Account = {\n id: UUID\n label: string\n address: Lowercase<Address>\n chain: ChainId\n /** True for accounts promoted to a workspace vault. */\n vault: boolean\n}\n\n/**\n * Accounts grouped by node type within a workspace. Per-type maps keep\n * bracket-accessor namespaces separate: a SAFE and a ROLES mod sharing a\n * label don't collide, and `eth.safe[...]` IntelliSense doesn't suggest\n * ROLES mod labels (and vice versa).\n */\ntype WorkspaceAccounts = {\n workspaceId: UUID\n workspaceName: string\n safes: Readonly<Record<string, Account>>\n rolesMods: Readonly<Record<string, Account>>\n delays: Readonly<Record<string, Account>>\n}\n\n/** Shape of the codegen data produced by `zodiac pull-org`. */\nexport type CodegenData = {\n users: Readonly<Record<string, User>>\n accounts: Readonly<Record<string, WorkspaceAccounts>>\n}\n\n// If `pull-org` has been run, the consumer's `.zodiac/index.d.ts` augments\n// `ZodiacGeneratedCodegen` with literal `users`/`accounts` shapes. Otherwise\n// the interface is empty and we fall back to the wide `CodegenData`.\ntype GeneratedCodegen = ZodiacGeneratedCodegen extends CodegenData\n ? ZodiacGeneratedCodegen\n : CodegenData\n\ntype ConstellationOpts<C extends CodegenData> = {\n /** Workspace to scope accounts and roles to. */\n workspace: keyof C['accounts'] & string\n /** Human-readable label for this constellation. */\n label: string\n /** Target chain for all nodes in this constellation. */\n chain: ChainId\n}\n\ntype ConstellationInternalOpts<C extends CodegenData> = {\n /** Injected codegen data (used for testing). */\n codegen?: C\n}\n\ntype Prettify<T> = { readonly [K in keyof T]: T[K] } & {}\n\ntype SafeEntries<\n C extends CodegenData,\n W extends keyof C['accounts'],\n> = C['accounts'][W]['safes']\n\ntype RolesEntries<\n C extends CodegenData,\n W extends keyof C['accounts'],\n> = C['accounts'][W]['rolesMods']\n\ntype NodeType = 'SAFE' | 'ROLES' | 'DELAY'\n\n/** A reference to a node used in `owners`, `modules`, `target`, etc. */\ntype NodeRef = Readonly<{ type: NodeType; label: string; chain: ChainId }>\n\n/** A blockchain address (checksummed or lowercase) or a reference to another\n * node in the constellation. Values are normalized to lowercase before being\n * sent to the API. */\ntype AddressOrRef = Address | NodeRef\n\ntype NodeBase = Readonly<{\n /** Human-readable identifier, unique within the constellation. */\n label: string\n /** Chain the node is deployed on. */\n chain: ChainId\n /** Set for existing nodes (from codegen or bound by address), absent for new\n * nodes. Accepts checksummed or lowercase; normalized to lowercase on push. */\n address?: Address\n /** Deployment nonce — required for new nodes, optional for existing. */\n nonce?: bigint\n}>\n\n/** A safe node spec — existing vault ref or new safe with required config. */\nexport type SafeNode = NodeBase &\n Readonly<{\n /** Discriminator identifying this node as a Safe. */\n type: 'SAFE'\n /** Number of owner signatures required to execute a transaction. */\n threshold: number\n /** Safe owner addresses or node references. */\n owners: readonly (string | NodeRef)[]\n /** Module addresses or node references enabled on the safe. */\n modules?: readonly (string | NodeRef)[]\n /** Whether this safe shall appear as a vault in the workspace. @default false */\n vault?: boolean\n }>\n\n/** A roles modifier node spec — existing vault ref or new roles with modifier config. */\nexport type RolesNode = NodeBase &\n Readonly<{\n /** Discriminator identifying this node as a Roles modifier. */\n type: 'ROLES'\n /** The safe that this roles modifier controls. */\n target?: AddressOrRef\n /** The account that is allowed to update the configuration of the Roles mod. */\n owner?: AddressOrRef\n /** The account that calls will be executed from. */\n avatar?: AddressOrRef\n /** MultiSend contract addresses for batched transactions. */\n multisend?: readonly Address[]\n /** Role definitions configured on this modifier. Pass `null` for a key to\n * clear that role; unmentioned roles are left untouched. */\n roles?: Record<string, RoleDef | null>\n /** Spending allowances configured on this modifier, keyed by name. Pass\n * `null` for a key to clear that allowance; unmentioned allowances are\n * left untouched. */\n allowances?: Record<string, AllowanceSpec | null>\n }>\n\n/** Any complete node that can be passed to `push()`. */\nexport type ConstellationNode = SafeNode | RolesNode\nexport type ConstellationNodeInternal = ConstellationNode & {\n _constellation: ConstellationMeta\n}\n\ntype NewSafeProps = {\n /** Deployment nonce for CREATE2 address derivation. */\n nonce: bigint\n /** Number of owner signatures required to execute a transaction. */\n threshold: number\n /** Safe owner addresses or node references. */\n owners: readonly AddressOrRef[]\n /** Module addresses or node references to enable on the safe. */\n modules?: readonly AddressOrRef[]\n /** Whether this safe is a workspace vault. @default false */\n vault?: boolean\n}\n\n/** Configuration shared by both ways of declaring a roles modifier. */\ntype RolesConfig = {\n /** The safe that this roles modifier controls. Defaults to the new safe with the same label, when one exists. */\n target?: AddressOrRef\n /** The account that calls will be executed from. Defaults to `target` value */\n avatar?: AddressOrRef\n /** The account that is allowed to update the configuration of the Roles Mod. Defaults to `target` value */\n owner?: AddressOrRef\n /** MultiSend contract addresses for batched transactions. Defaults to `['0x38869bf66a61cf6bdb996a6ae40d5853fd43b526', '0x9641d764fc13c8b624c04430c7356c1c7c8102e2']` */\n multisend?: readonly Address[]\n /** Role definitions to configure on this modifier. Pass `null` for a key to\n * clear that role; unmentioned roles are left untouched. */\n roles?: Record<string, RoleDef | null>\n /** Spending allowances to configure on this modifier, keyed by name. Pass\n * `null` for a key to clear that allowance; unmentioned allowances are\n * left untouched. */\n allowances?: Record<string, AllowanceSpec | null>\n}\n\n/** Declare a brand-new roles modifier (address derived via CREATE2 from `nonce`). */\ntype NewRolesByNonce = RolesConfig & {\n /** Deployment nonce for CREATE2 address derivation. */\n nonce: bigint\n}\n\n/** Bind to a roles modifier already deployed on-chain at a known address, to\n * reconfigure its roles/allowances. Use this for mods not (yet) imported into\n * the workspace — pass the address instead of a deployment `nonce`. */\ntype ExistingRolesByAddress = RolesConfig & {\n /** Address of the existing Roles mod to bind to and reconfigure. */\n address: Address\n}\n\ntype NewRolesProps = NewRolesByNonce | ExistingRolesByAddress\n\ntype ExistingNodeAccessor<\n Type extends string,\n K extends string,\n E,\n Ch extends ChainId,\n NP extends Record<string, any>,\n> = Readonly<Prettify<E & { type: Type; label: K; chain: Ch }>> &\n (<\n O extends {\n [P in Exclude<keyof E & string, 'id' | 'label'>]?: any\n } & Partial<NP> = {},\n >(\n overrides?: {\n [P in Exclude<keyof E & string, 'id' | 'label'>]?: any\n } & Partial<NP> &\n O\n ) => Readonly<\n Prettify<\n Omit<E, keyof O> & O & Partial<NP> & { type: Type; label: K; chain: Ch }\n >\n >)\n\ntype NewNodeAccessor<\n Type extends string,\n Ch extends ChainId,\n NP extends Record<string, any>,\n> = Readonly<Prettify<{ type: Type; label: string; chain: Ch }>> &\n (<P extends NP>(\n props: P\n ) => Readonly<Prettify<P & { type: Type; label: string; chain: Ch }>>)\n\ntype EntityAccessor<\n Type extends string,\n Entries extends Record<string, any>,\n Ch extends ChainId = ChainId,\n NP extends Record<string, any> = Record<string, any>,\n> = {\n readonly [K in keyof Entries & string]: ExistingNodeAccessor<\n Type,\n K,\n Entries[K],\n Ch,\n NP\n >\n} & {\n readonly [key: string]: NewNodeAccessor<Type, Ch, NP>\n}\n\ntype UserAccessor<C extends CodegenData, Ch extends number> = {\n readonly [K in keyof C['users'] &\n string]: C['users'][K]['personalSafes'][Ch]['address']\n}\n\ntype ConstellationResult<\n C extends CodegenData,\n W extends keyof C['accounts'] = keyof C['accounts'],\n Ch extends ChainId = ChainId,\n> = {\n /** Access existing safes by label or create new ones with a new label.\n * Only SAFE-typed accounts are suggested in IntelliSense. */\n safe: EntityAccessor<'SAFE', SafeEntries<C, W>, Ch, NewSafeProps>\n /** Access existing roles modifiers by label or create new ones with a\n * new label. Only ROLES-typed accounts are suggested in IntelliSense. */\n roles: EntityAccessor<'ROLES', RolesEntries<C, W>, Ch, NewRolesProps>\n /** Resolve a user's personal safe address on the constellation's chain. */\n user: UserAccessor<C, Ch>\n}\n\n/** @internal */\nexport type ConstellationMeta = {\n label: string\n chain: ChainId\n workspaceId: UUID\n}\n\nfunction loadCodegen(): CodegenData {\n const require = createRequire(import.meta.url)\n return require(resolveZodiacDir()) as CodegenData\n}\n\n/**\n * Creates a constellation scoped to a workspace and chain.\n *\n * Use bracket access to reference existing accounts (vaults and other\n * applied constellation nodes) or define new ones:\n * ```ts\n * const eth = constellation({ workspace: 'GG', label: 'my constellation', chain: 1 })\n *\n * const dao = eth.safe['GG DAO'] // existing account ref\n * const roles = eth.roles['GG DAO'] // existing roles ref\n * const newSafe = eth.safe['New Safe']({ nonce: 0n, threshold: 2, owners: [...], modules: [...] })\n * ```\n */\nexport function constellation<\n const C extends CodegenData = GeneratedCodegen,\n const W extends keyof C['accounts'] & string = keyof C['accounts'] & string,\n const Ch extends ChainId = ChainId,\n>(\n opts: ConstellationOpts<C> & { workspace: W; chain: Ch },\n internal?: ConstellationInternalOpts<C>\n): ConstellationResult<C, W, Ch> {\n const codegen: CodegenData = internal?.codegen ?? loadCodegen()\n\n const ws = codegen.accounts[opts.workspace]\n const safesByLabel: Record<string, Account> = {}\n const rolesByLabel: Record<string, Account> = {}\n if (ws) {\n for (const [label, account] of Object.entries(ws.safes)) {\n safesByLabel[label] = account\n }\n for (const [label, account] of Object.entries(ws.rolesMods)) {\n rolesByLabel[label] = account\n }\n }\n\n const meta: ConstellationMeta = {\n label: opts.label,\n chain: opts.chain,\n workspaceId: (ws?.workspaceId ?? '') as UUID,\n }\n\n function makeNodeRef(\n data: Record<string, any>\n ): Readonly<Record<string, any>> {\n return Object.freeze({\n ...data,\n chain: opts.chain,\n _constellation: meta,\n })\n }\n\n function entityAccessor(\n registry: Record<string, Record<string, any>>,\n type: string\n ) {\n const cache = new Map<string, Record<string, any>>()\n return new Proxy({} as Record<string, any>, {\n get(_target: any, name: string) {\n if (typeof name !== 'string') return undefined\n const cached = cache.get(name)\n if (cached) return cached\n const existing = registry[name]\n // Bracket-access keys in the generated codegen carry a\n // ` (0xChecksummed…)` suffix when multiple workspace accounts share\n // a label. The label sent in the push spec should be the clean\n // original, so prefer `existing.label` when it's available.\n const specLabel: string = existing?.label ?? name\n const fn = (overrides?: Record<string, any>) =>\n makeNodeRef({\n type,\n ...(existing || {}),\n ...overrides,\n label: specLabel,\n })\n Object.assign(fn, {\n type,\n ...(existing || {}),\n label: specLabel,\n chain: opts.chain,\n _constellation: meta,\n })\n cache.set(name, fn)\n return fn\n },\n })\n }\n\n function userAccessor() {\n return new Proxy(\n {},\n {\n get(_target: any, name: string) {\n const user = codegen.users[name]\n if (!user) throw new Error(`Unknown user: ${name}`)\n const personalSafe = user.personalSafes[opts.chain]\n if (!personalSafe) {\n throw new Error(\n `User ${name} has no personal safe on chain ${opts.chain}`\n )\n }\n return personalSafe.address\n },\n }\n )\n }\n\n const safe = entityAccessor(safesByLabel, 'SAFE')\n const roles = entityAccessor(rolesByLabel, 'ROLES')\n\n return {\n safe,\n roles,\n user: userAccessor(),\n } as ConstellationResult<C, W, Ch>\n}\n","import type {\n ApplyConstellationPayload,\n ApplyConstellationResult,\n} from '@zodiaceco/api-types'\nimport { invariant } from '@epic-web/invariant'\nimport { processPermissions } from 'zodiac-roles-sdk'\nimport type { PermissionSet } from 'zodiac-roles-sdk'\nimport { ApiClient } from './api'\nimport type {\n ConstellationMeta,\n ConstellationNode,\n ConstellationNodeInternal,\n RoleDef,\n} from './constellation'\n\ntype PushOpts = {\n /** API client instance. Defaults to a client configured from environment variables. */\n api?: ApiClient\n}\n\n/**\n * Resolves node references and pushes the constellation specification to the API.\n *\n *\n * ```ts\n * const eth = constellation({ workspace: 'GG', label: 'my constellation', chain: 1 })\n * const dao = eth.safe['GG DAO']\n * const roles = eth.roles['New Roles']({ nonce: 0n, target: dao, owner: dao, avatar: dao })\n *\n * await push([dao, roles])\n * ```\n */\nexport async function push(\n nodes: ConstellationNode[] | { [key: string]: ConstellationNode },\n opts?: PushOpts\n): Promise<ApplyConstellationResult[]> {\n const api = opts?.api ?? new ApiClient()\n const refs = deriveRefs(nodes)\n\n // Group nodes by constellation (multiple constellations can be applied with a single call)\n const groups = new Map<\n string,\n { meta: ConstellationMeta; nodes: ConstellationNodeInternal[] }\n >()\n\n for (const node of refs.byIdentity.keys()) {\n const meta = node._constellation\n invariant(\n meta,\n `Node \"${node.label}\" is not associated with a constellation`\n )\n const key = `${meta.workspaceId}:${meta.chain}:${meta.label}`\n let group = groups.get(key)\n if (!group) {\n group = { meta, nodes: [] }\n groups.set(key, group)\n }\n group.nodes.push(node)\n }\n\n const results: ApplyConstellationResult[] = []\n for (const { meta, nodes: groupNodes } of groups.values()) {\n const specification = await Promise.all(\n groupNodes.map((n) => nodeToSpec(n, refs))\n )\n const result = await api.applyConstellation(meta.workspaceId, {\n label: meta.label,\n chain: meta.chain,\n specification,\n })\n results.push(result)\n }\n\n return results\n}\n\ntype RefsIndex = {\n byIdentity: Map<ConstellationNodeInternal, string>\n byLabel: Map<string, string>\n}\n\nfunction labelKey(node: ConstellationNodeInternal): string {\n return `${node._constellation.workspaceId}:${node.type}:${node.label}`\n}\n\nfunction deriveRefs(\n nodes: ConstellationNode[] | { [key: string]: ConstellationNode }\n): RefsIndex {\n const byIdentity = new Map<ConstellationNodeInternal, string>()\n const byLabel = new Map<string, string>()\n\n const register = (node: ConstellationNodeInternal, ref: string) => {\n byIdentity.set(node, ref)\n byLabel.set(labelKey(node), ref)\n }\n\n if (Array.isArray(nodes)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]\n invariant(\n isConstellationNode(node),\n `unexpected node input at index: ${i}`\n )\n register(node, `${i}`)\n }\n } else {\n for (const [key, node] of Object.entries(nodes)) {\n invariant(\n isConstellationNode(node),\n `unexpected node input under key: ${key}`\n )\n register(node, key)\n }\n }\n\n return { byIdentity, byLabel }\n}\n\nasync function nodeToSpec(\n node: ConstellationNodeInternal,\n refs: RefsIndex\n): Promise<ApplyConstellationPayload['specification'][number]> {\n const { id, _constellation, ...rest } = node as Record<string, any>\n const spec: Record<string, any> = {}\n\n for (const [key, value] of Object.entries(rest)) {\n if (node.type === 'ROLES' && key === 'roles' && value != null) {\n spec.roles = await expandRoles(\n value as Record<string, RoleDef | null>,\n refs\n )\n continue\n }\n spec[key] = resolveRefs(value, refs)\n }\n\n spec.ref = refs.byIdentity.get(node)\n invariant(spec.ref != null, 'ref not found')\n\n return stringifyBigints(\n spec\n ) as ApplyConstellationPayload['specification'][number]\n}\n\nasync function expandRoles(\n roles: Record<string, RoleDef | null>,\n refs: RefsIndex\n): Promise<Record<string, unknown>> {\n const entries = await Promise.all(\n Object.entries(roles).map(async ([key, def]) => {\n if (def == null) {\n return [key, null] as const\n }\n const resolvedPermissions = (await Promise.all(\n def.permissions.map((p) => Promise.resolve(p))\n )) as Parameters<typeof processPermissions>[0][number][]\n const { targets, annotations } = processPermissions(resolvedPermissions)\n return [\n key,\n {\n key,\n members: resolveRefs(def.members, refs),\n targets,\n annotations: [...(def.annotations ?? []), ...annotations],\n },\n ] as const\n })\n )\n return Object.fromEntries(entries)\n}\n\nfunction resolveRefs(value: unknown, refs: RefsIndex): unknown {\n if (isConstellationNode(value)) {\n const ref = refs.byIdentity.get(value) ?? refs.byLabel.get(labelKey(value))\n invariant(\n ref != null,\n `Node \"${value.label}\" is referenced not included in the push() call`\n )\n return `$${ref}`\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => resolveRefs(v, refs))\n }\n\n if (typeof value === 'object' && value !== null) {\n const resolved: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) {\n resolved[k] = resolveRefs(v, refs)\n }\n return resolved\n }\n\n // API expects lowercase addresses\n if (typeof value === 'string' && /^0x[0-9a-fA-F]{40}$/.test(value)) {\n return value.toLowerCase()\n }\n\n return value\n}\n\nfunction stringifyBigints(value: unknown): unknown {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n if (Array.isArray(value)) {\n return value.map(stringifyBigints)\n }\n\n if (typeof value === 'object' && value !== null) {\n const result: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) {\n result[k] = stringifyBigints(v)\n }\n return result\n }\n\n return value\n}\n\nfunction isConstellationNode(\n value: unknown\n): value is ConstellationNodeInternal {\n if (typeof value === 'function' || typeof value === 'object') {\n const obj = value as any\n return (\n obj != null &&\n typeof obj.type === 'string' &&\n typeof obj.chain === 'number' &&\n typeof obj._constellation === 'object'\n )\n }\n return false\n}\n"],"mappings":";;;;;;AAqRA,SAAS,cAA2B;AAElC,QADgB,cAAc,OAAO,KAAK,IAAI,CAC/B,kBAAkB,CAAC;;;;;;;;;;;;;;;AAgBpC,SAAgB,cAKd,MACA,UAC+B;CAC/B,MAAM,UAAuB,UAAU,WAAW,aAAa;CAE/D,MAAM,KAAK,QAAQ,SAAS,KAAK;CACjC,MAAM,eAAwC,EAAE;CAChD,MAAM,eAAwC,EAAE;AAChD,KAAI,IAAI;AACN,OAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,GAAG,MAAM,CACrD,cAAa,SAAS;AAExB,OAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,GAAG,UAAU,CACzD,cAAa,SAAS;;CAI1B,MAAM,OAA0B;EAC9B,OAAO,KAAK;EACZ,OAAO,KAAK;EACZ,aAAc,IAAI,eAAe;EAClC;CAED,SAAS,YACP,MAC+B;AAC/B,SAAO,OAAO,OAAO;GACnB,GAAG;GACH,OAAO,KAAK;GACZ,gBAAgB;GACjB,CAAC;;CAGJ,SAAS,eACP,UACA,MACA;EACA,MAAM,wBAAQ,IAAI,KAAkC;AACpD,SAAO,IAAI,MAAM,EAAE,EAAyB,EAC1C,IAAI,SAAc,MAAc;AAC9B,OAAI,OAAO,SAAS,SAAU,QAAO,KAAA;GACrC,MAAM,SAAS,MAAM,IAAI,KAAK;AAC9B,OAAI,OAAQ,QAAO;GACnB,MAAM,WAAW,SAAS;GAK1B,MAAM,YAAoB,UAAU,SAAS;GAC7C,MAAM,MAAM,cACV,YAAY;IACV;IACA,GAAI,YAAY,EAAE;IAClB,GAAG;IACH,OAAO;IACR,CAAC;AACJ,UAAO,OAAO,IAAI;IAChB;IACA,GAAI,YAAY,EAAE;IAClB,OAAO;IACP,OAA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QAAO,KAAK,iBAAiB,EAAE;AAEjC,SAAO;;AAGT,QAAO;;AAGT,SAAS,oBACP,OACoC;AACpC,KAAI,OAAO,UAAU,cAAc,OAAO,UAAU,UAAU;EAC5D,MAAM,MAAM;AACZ,SACE,OAAO,QACP,OAAO,IAAI,SAAS,YACpB,OAAO,IAAI,UAAU,YACrB,OAAO,IAAI,mBAAmB;;AAGlC,QAAO"}
@@ -0,0 +1,77 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ //#region src/allow/abi.ts
4
+ function* walkContracts(config) {
5
+ for (const [chain, contracts] of Object.entries(config)) yield* walkLevel(chain, [], contracts);
6
+ }
7
+ function* walkLevel(chain, segments, node) {
8
+ if (typeof node === "string") {
9
+ if (segments.length === 0) throw new Error(`Contract at ${chain} is missing a name`);
10
+ if (!node.startsWith("0x")) throw new Error(`Invalid address for ${chain}.${segments.join(".")}: ${node}`);
11
+ yield {
12
+ chain,
13
+ segments,
14
+ address: node
15
+ };
16
+ return;
17
+ }
18
+ if (node && typeof node === "object") {
19
+ for (const [key, value] of Object.entries(node)) yield* walkLevel(chain, [...segments, key], value);
20
+ return;
21
+ }
22
+ throw new Error(`Invalid contracts entry at ${chain}.${segments.join(".")}: ${JSON.stringify(node)}`);
23
+ }
24
+ const abiFilePath = (abisDir, node) => path.join(abisDir, node.chain, ...node.segments) + ".json";
25
+ const readAbi = (abisDir, node) => {
26
+ const file = abiFilePath(abisDir, node);
27
+ if (!fs.existsSync(file)) return null;
28
+ const raw = fs.readFileSync(file, "utf8");
29
+ const parsed = JSON.parse(raw);
30
+ if (!Array.isArray(parsed)) throw new Error(`ABI at ${file} is not a JSON array`);
31
+ return parsed;
32
+ };
33
+ const writeAbi = (abisDir, node, abi) => {
34
+ const file = abiFilePath(abisDir, node);
35
+ fs.mkdirSync(path.dirname(file), { recursive: true });
36
+ fs.writeFileSync(file, JSON.stringify(abi, null, 2) + "\n", "utf8");
37
+ };
38
+ //#endregion
39
+ //#region src/allow/networks.ts
40
+ const CHAIN_IDS = {
41
+ eth: 1,
42
+ oeth: 10,
43
+ gno: 100,
44
+ sep: 11155111,
45
+ matic: 137,
46
+ zkevm: 1101,
47
+ arb1: 42161,
48
+ avax: 43114,
49
+ base: 8453,
50
+ basesep: 84532,
51
+ bnb: 56,
52
+ celo: 42220,
53
+ sonic: 146,
54
+ berachain: 80094,
55
+ unichain: 130,
56
+ worldchain: 480,
57
+ bob: 60808,
58
+ mantle: 5e3,
59
+ hemi: 43111,
60
+ katana: 747474,
61
+ linea: 59144,
62
+ ink: 57073,
63
+ hyperevm: 999,
64
+ flare: 14,
65
+ scroll: 534352,
66
+ plasma: 9745,
67
+ megaeth: 4326
68
+ };
69
+ const chainIdFor = (prefix) => {
70
+ const id = CHAIN_IDS[prefix];
71
+ if (id === void 0) throw new Error(`Unknown chain prefix: ${prefix}`);
72
+ return id;
73
+ };
74
+ //#endregion
75
+ export { walkContracts as a, readAbi as i, chainIdFor as n, writeAbi as o, abiFilePath as r, CHAIN_IDS as t };
76
+
77
+ //# sourceMappingURL=networks-BTW1qAAa.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networks-BTW1qAAa.mjs","names":[],"sources":["../src/allow/abi.ts","../src/allow/networks.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { Abi } from './fetch'\n\nexport type ContractAddress = `0x${string}`\n\nexport type ContractNode = {\n chain: string\n segments: string[]\n address: ContractAddress\n}\n\nexport function* walkContracts(\n config: Record<string, any>\n): Generator<ContractNode> {\n for (const [chain, contracts] of Object.entries(config)) {\n yield* walkLevel(chain, [], contracts)\n }\n}\n\nfunction* walkLevel(\n chain: string,\n segments: string[],\n node: unknown\n): Generator<ContractNode> {\n if (typeof node === 'string') {\n if (segments.length === 0) {\n throw new Error(`Contract at ${chain} is missing a name`)\n }\n if (!node.startsWith('0x')) {\n throw new Error(\n `Invalid address for ${chain}.${segments.join('.')}: ${node}`\n )\n }\n yield { chain, segments, address: node as ContractAddress }\n return\n }\n if (node && typeof node === 'object') {\n for (const [key, value] of Object.entries(node as Record<string, any>)) {\n yield* walkLevel(chain, [...segments, key], value)\n }\n return\n }\n throw new Error(\n `Invalid contracts entry at ${chain}.${segments.join('.')}: ${JSON.stringify(node)}`\n )\n}\n\nexport const abiFilePath = (abisDir: string, node: ContractNode): string =>\n path.join(abisDir, node.chain, ...node.segments) + '.json'\n\nexport const readAbi = (abisDir: string, node: ContractNode): Abi | null => {\n const file = abiFilePath(abisDir, node)\n if (!fs.existsSync(file)) return null\n const raw = fs.readFileSync(file, 'utf8')\n const parsed = JSON.parse(raw)\n if (!Array.isArray(parsed)) {\n throw new Error(`ABI at ${file} is not a JSON array`)\n }\n return parsed as Abi\n}\n\nexport const writeAbi = (\n abisDir: string,\n node: ContractNode,\n abi: Abi\n): void => {\n const file = abiFilePath(abisDir, node)\n fs.mkdirSync(path.dirname(file), { recursive: true })\n fs.writeFileSync(file, JSON.stringify(abi, null, 2) + '\\n', 'utf8')\n}\n","export const CHAIN_IDS = {\n eth: 1,\n oeth: 10,\n gno: 100,\n sep: 11155111,\n matic: 137,\n zkevm: 1101,\n arb1: 42161,\n avax: 43114,\n base: 8453,\n basesep: 84532,\n bnb: 56,\n celo: 42220,\n sonic: 146,\n berachain: 80094,\n unichain: 130,\n worldchain: 480,\n bob: 60808,\n mantle: 5000,\n hemi: 43111,\n katana: 747474,\n linea: 59144,\n ink: 57073,\n hyperevm: 999,\n flare: 14,\n scroll: 534352,\n plasma: 9745,\n megaeth: 4326,\n} as const satisfies Record<string, number>\n\nexport type ChainPrefix = keyof typeof CHAIN_IDS\n\nexport const chainIdFor = (prefix: string): number => {\n const id = (CHAIN_IDS as Record<string, number>)[prefix]\n if (id === undefined) {\n throw new Error(`Unknown chain prefix: ${prefix}`)\n }\n return id\n}\n"],"mappings":";;;AAYA,UAAiB,cACf,QACyB;AACzB,MAAK,MAAM,CAAC,OAAO,cAAc,OAAO,QAAQ,OAAO,CACrD,QAAO,UAAU,OAAO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AAK;CACL,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,MAAM;CACN,SAAS;CACT,KAAK;CACL,MAAM;CACN,OAAO;CACP,WAAW;CACX,UAAU;CACV,YAAY;CACZ,KAAK;CACL,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,OAAO;CACP,KAAK;CACL,UAAU;CACV,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACV;AAID,MAAa,cAAc,WAA2B;CACpD,MAAM,KAAM,UAAqC;AACjD,KAAI,OAAO,KAAA,EACT,OAAM,IAAI,MAAM,yBAAyB,SAAS;AAEpD,QAAO"}
@@ -0,0 +1,14 @@
1
+ // Ambient fallbacks. Script file (no imports / exports), so top-level
2
+ // interface declarations are implicitly global. Consumers augment these
3
+ // via files generated into `<cwd>/.zodiac/` by `zodiac pull-org` /
4
+ // `pull-contracts`.
5
+
6
+ // Augmented by `<cwd>/.zodiac/allow.d.ts` (from `pull-contracts`) with
7
+ // narrow per-chain contract typings.
8
+ interface AllowKit {}
9
+
10
+ // Augmented by `<cwd>/.zodiac/index.d.ts` (from `pull-org`) with the
11
+ // workspace's users and vaults as literal types. Remains `{}` until
12
+ // `pull-org` has been run; `constellation()` falls back to the wide
13
+ // `CodegenData` shape in that case.
14
+ interface ZodiacGeneratedCodegen {}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@zodiaceco/sdk",
3
+ "version": "1.12.1",
4
+ "author": "Gnosis Guild",
5
+ "license": "LGPL-3.0-only",
6
+ "homepage": "https://github.com/gnosisguild/zodiac-sdk",
7
+ "packageManager": "bun@1.3.12",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/gnosisguild/zodiac-sdk.git"
11
+ },
12
+ "type": "module",
13
+ "module": "dist/index.mjs",
14
+ "types": "dist/index.d.mts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.mts",
18
+ "import": "./dist/index.mjs"
19
+ },
20
+ "./allow": {
21
+ "types": "./dist/allow/index.d.mts",
22
+ "import": "./dist/allow/index.mjs"
23
+ },
24
+ "./cli/config": {
25
+ "types": "./dist/cli/config.d.mts",
26
+ "import": "./dist/cli/config.mjs"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "bin": {
35
+ "zodiac": "./dist/cli.mjs"
36
+ },
37
+ "scripts": {
38
+ "clean": "rimraf dist",
39
+ "prebuild": "bun clean",
40
+ "build": "tsdown && cp src/zodiac-os-codegen.d.ts dist/ && printf '/// <reference path=\"./zodiac-os-codegen.d.ts\" />\\n' | cat - dist/index.d.mts > dist/index.d.mts.tmp && mv dist/index.d.mts.tmp dist/index.d.mts",
41
+ "prepublishOnly": "bun run build",
42
+ "check:format": "prettier --list-different .",
43
+ "check:types": "tsc -p tsconfig.json",
44
+ "fix:format": "prettier --write .",
45
+ "test": "bun test",
46
+ "install-local-api-types": "cd ../zodiac-os/public-packages/api-types && pnpm pack-tmp && cd ../../../zodiac-sdk && tar -xzf /tmp/zodiac-os-api-types.tgz --strip-components=1 -C node_modules/@zodiaceco/api-types"
47
+ },
48
+ "dependencies": {
49
+ "@epic-web/invariant": "1.0.0",
50
+ "@zodiaceco/api-types": "^1.7.0",
51
+ "commander": "^14.0.3",
52
+ "dotenv": "^17.4.2",
53
+ "open": "^11.0.0",
54
+ "ts-morph": "^27.0.2",
55
+ "zodiac-roles-sdk": "^4.0.0"
56
+ },
57
+ "peerDependencies": {
58
+ "ethers": "^6.13.0"
59
+ },
60
+ "devDependencies": {
61
+ "@types/bun": "^1.2.21",
62
+ "ethers": "^6.13.0",
63
+ "prettier": "^3.6.2",
64
+ "rimraf": "^6.1.0",
65
+ "tsdown": "~0.21.9",
66
+ "typescript": "^5.9.2"
67
+ }
68
+ }