@artblocks/abx-cli 0.1.0-alpha.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/assets/renderer-scaffold/README.md +59 -0
  3. package/assets/renderer-scaffold/foundry.toml +15 -0
  4. package/assets/renderer-scaffold/remappings.txt +3 -0
  5. package/assets/renderer-scaffold/script/Deploy.s.sol +23 -0
  6. package/assets/renderer-scaffold/src/MyRenderer.sol +123 -0
  7. package/assets/renderer-scaffold/src/MyTraits.sol +75 -0
  8. package/assets/renderer-scaffold/src/interfaces/IAbxFieldRenderer.sol +32 -0
  9. package/assets/renderer-scaffold/src/interfaces/IAbxParams.sol +26 -0
  10. package/assets/renderer-scaffold/test/MyRenderer.t.sol +110 -0
  11. package/dist/config.d.ts +69 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +184 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/deps.d.ts +46 -0
  16. package/dist/deps.d.ts.map +1 -0
  17. package/dist/deps.js +90 -0
  18. package/dist/deps.js.map +1 -0
  19. package/dist/flags.d.ts +25 -0
  20. package/dist/flags.d.ts.map +1 -0
  21. package/dist/flags.js +34 -0
  22. package/dist/flags.js.map +1 -0
  23. package/dist/inspect.d.ts +48 -0
  24. package/dist/inspect.d.ts.map +1 -0
  25. package/dist/inspect.js +184 -0
  26. package/dist/inspect.js.map +1 -0
  27. package/dist/main.d.ts +3 -0
  28. package/dist/main.d.ts.map +1 -0
  29. package/dist/main.js +5102 -0
  30. package/dist/main.js.map +1 -0
  31. package/dist/migrate.d.ts +65 -0
  32. package/dist/migrate.d.ts.map +1 -0
  33. package/dist/migrate.js +180 -0
  34. package/dist/migrate.js.map +1 -0
  35. package/dist/mintpage.d.ts +46 -0
  36. package/dist/mintpage.d.ts.map +1 -0
  37. package/dist/mintpage.js +461 -0
  38. package/dist/mintpage.js.map +1 -0
  39. package/dist/onchain-uri.d.ts +97 -0
  40. package/dist/onchain-uri.d.ts.map +1 -0
  41. package/dist/onchain-uri.js +243 -0
  42. package/dist/onchain-uri.js.map +1 -0
  43. package/dist/ownerops.d.ts +195 -0
  44. package/dist/ownerops.d.ts.map +1 -0
  45. package/dist/ownerops.js +1270 -0
  46. package/dist/ownerops.js.map +1 -0
  47. package/dist/provision.d.ts +86 -0
  48. package/dist/provision.d.ts.map +1 -0
  49. package/dist/provision.js +372 -0
  50. package/dist/provision.js.map +1 -0
  51. package/dist/remote.d.ts +58 -0
  52. package/dist/remote.d.ts.map +1 -0
  53. package/dist/remote.js +54 -0
  54. package/dist/remote.js.map +1 -0
  55. package/dist/schema.d.ts +15 -0
  56. package/dist/schema.d.ts.map +1 -0
  57. package/dist/schema.js +125 -0
  58. package/dist/schema.js.map +1 -0
  59. package/dist/series-traits.d.ts +30 -0
  60. package/dist/series-traits.d.ts.map +1 -0
  61. package/dist/series-traits.js +103 -0
  62. package/dist/series-traits.js.map +1 -0
  63. package/dist/signer.d.ts +80 -0
  64. package/dist/signer.d.ts.map +1 -0
  65. package/dist/signer.js +520 -0
  66. package/dist/signer.js.map +1 -0
  67. package/dist/upload.d.ts +28 -0
  68. package/dist/upload.d.ts.map +1 -0
  69. package/dist/upload.js +41 -0
  70. package/dist/upload.js.map +1 -0
  71. package/package.json +55 -0
  72. package/skill/SKILL.md +304 -0
  73. package/skill/reference/code-projects.md +211 -0
  74. package/skill/reference/hosting.md +138 -0
  75. package/skill/reference/operating.md +116 -0
  76. package/skill/reference/setup.md +36 -0
  77. package/skill/reference/troubleshooting.md +28 -0
package/dist/config.js ADDED
@@ -0,0 +1,184 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { arweaveAddress, generateArweaveJwk, } from '@artblocks/abx-storage';
4
+ import { resolveChain, DEFAULT_CHAIN_KEY, resolveFactory, resolveSeriesFactory, resolveRenderer, resolveChunkStore, resolveFixedPriceMinter, envSigningKey, } from '@artblocks/abx-sdk';
5
+ /**
6
+ * Runtime resolution for the CLI — deliberately **stateless about decisions**. There is no
7
+ * tool-written config file: every choice is resolved fresh per invocation from explicit flags,
8
+ * the operator's environment, and shipped constants, so a command's behavior is a pure function
9
+ * of its inputs (nothing a previous command silently mutated feeds a later one).
10
+ *
11
+ * - Canonical infra (factory / renderer / chunk store): resolved from the SDK's shipped
12
+ * {@link resolveFactory} manifest, overridable by flag or env. See `@artblocks/abx-sdk` deployments.
13
+ * - Storage backend + non-secret settings: resolved here as **override → env → default**.
14
+ * - Secrets (signing keys, S3 creds, the Pinata JWT, the Arweave key): env / the key file only.
15
+ *
16
+ * The only thing that persists on disk is the project-local, chain-rebuildable projection
17
+ * (the indexer's SQLite store under the data dir) — that's DATA, not config.
18
+ */
19
+ const CHAIN = process.env.ABX_CHAIN ?? DEFAULT_CHAIN_KEY;
20
+ const chainId = () => resolveChain(CHAIN).id;
21
+ export function dataDir() {
22
+ return process.env.ABX_DATA_DIR ?? resolve(process.cwd(), '.abx-self-host');
23
+ }
24
+ /**
25
+ * Whether `baseUrl` is a localhost/loopback address — a URL that, once baked into an on-chain
26
+ * `tokenURI`/`contractURI`, resolves for NO ONE off this machine. The single source of truth for
27
+ * the off-chain-deploy refusal shared by `deploy`, `deploy-series`, and `deploy-code` (previously
28
+ * duplicated inline — that drift is exactly how `deploy-code` shipped without the guard).
29
+ */
30
+ export function loopbackBaseUrl(baseUrl) {
31
+ return /^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?:[:/]|$)/i.test(baseUrl);
32
+ }
33
+ // ── canonical infrastructure (shipped manifest → env → flag) ─────────────────
34
+ // Thin CLI wrappers over the SDK resolvers, pinned to the active chain. Return null (not
35
+ // undefined) to read cleanly at call sites (`factoryAddress() ?? 'none'`). `null` means the
36
+ // chain isn't shipped and nothing was declared — the deploy/owner-ops path deploys + prints one.
37
+ /** Canonical clone factory for the active chain — flag override → `ABX_FACTORY` → manifest. */
38
+ export function factoryAddress(override) {
39
+ return resolveFactory(chainId(), override) ?? null;
40
+ }
41
+ /** Canonical Series clone factory — flag override → `ABX_SERIES_FACTORY` → manifest. */
42
+ export function seriesFactoryAddress(override) {
43
+ return resolveSeriesFactory(chainId(), override) ?? null;
44
+ }
45
+ /** Canonical on-chain metadata renderer — flag override → `ABX_RENDERER` → manifest. */
46
+ export function rendererAddress(override) {
47
+ return resolveRenderer(chainId(), override) ?? null;
48
+ }
49
+ /** Canonical multi-chunk on-chain content store — flag override → `ABX_CHUNK_STORE` → manifest. */
50
+ export function chunkStoreAddress(override) {
51
+ return resolveChunkStore(chainId(), override) ?? null;
52
+ }
53
+ /** Canonical shared fixed-price minter — flag override → `ABX_FIXED_PRICE_MINTER` → manifest. */
54
+ export function fixedPriceMinterAddress(override) {
55
+ return resolveFixedPriceMinter(chainId(), override) ?? null;
56
+ }
57
+ /** Resolve the storage-signer lane: flag → `ABX_STORAGE_SIGNER` → default `arweave`. */
58
+ export function storageSignerChoice(ov = {}) {
59
+ const v = ov.storageSigner ?? process.env.ABX_STORAGE_SIGNER;
60
+ return v === 'eth' ? 'eth' : 'arweave';
61
+ }
62
+ /**
63
+ * Build the storage backend options the SDK needs, resolving **explicit override → env →
64
+ * default** for non-secret values; secrets come from env only. No persisted config layer — a
65
+ * flag or a declared env var is the only way to choose a backend, so nothing is hidden.
66
+ */
67
+ export function storageOptions(ov = {}) {
68
+ const backend = ov.backend ?? process.env.ABX_STORAGE_BACKEND ?? 'fs';
69
+ const opts = { backend, dataDir: dataDir() };
70
+ if (backend === 'cloud' || backend === 's3') {
71
+ opts.cloud = {
72
+ endpoint: ov.endpoint ?? process.env.ABX_S3_ENDPOINT ?? '',
73
+ bucket: ov.bucket ?? process.env.ABX_S3_BUCKET ?? '',
74
+ region: ov.region ?? process.env.ABX_S3_REGION ?? 'auto',
75
+ prefix: ov.prefix ?? process.env.ABX_S3_PREFIX ?? 'abx/content/',
76
+ accessKeyId: process.env.ABX_S3_ACCESS_KEY_ID ?? '', // secret: env only
77
+ secretAccessKey: process.env.ABX_S3_SECRET_ACCESS_KEY ?? '', // secret: env only
78
+ service: 's3',
79
+ publicBase: ov.publicBase ?? process.env.ABX_S3_PUBLIC_BASE,
80
+ };
81
+ }
82
+ else if (backend === 'ipfs') {
83
+ const mode = (ov.mode ?? process.env.ABX_IPFS_MODE ?? (process.env.PINATA_JWT ? 'pinata' : 'kubo'));
84
+ opts.ipfs = {
85
+ mode,
86
+ gateway: ov.gateway ?? process.env.ABX_IPFS_GATEWAY ?? (mode === 'pinata' ? 'https://gateway.pinata.cloud' : 'http://127.0.0.1:8080'),
87
+ apiUrl: ov.apiUrl ?? process.env.ABX_IPFS_API_URL ?? 'http://127.0.0.1:5001',
88
+ pinataEndpoint: process.env.ABX_PINATA_ENDPOINT ?? 'https://api.pinata.cloud',
89
+ pinataJwt: process.env.PINATA_JWT, // secret: env only
90
+ };
91
+ }
92
+ else if (backend === 'arweave') {
93
+ const uploadUrl = ov.uploadUrl ?? process.env.ABX_ARWEAVE_UPLOAD_URL;
94
+ // Default to Turbo (free <100 KiB, fiat top-up above); an explicit upload endpoint implies
95
+ // the http-bundler escape hatch. Explicit --provider always wins.
96
+ const provider = (ov.provider ?? process.env.ABX_ARWEAVE_PROVIDER ?? (uploadUrl ? 'http-bundler' : 'turbo'));
97
+ // Turbo identity: default the CLI-managed Arweave key; `--storage-signer eth` reuses the .env
98
+ // EVM signing key so credits funded on that wallet's Turbo balance are spendable here. The eth
99
+ // key takes precedence in the storage layer, so only set it when that lane is chosen.
100
+ const useEth = provider === 'turbo' && storageSignerChoice(ov) === 'eth';
101
+ const managedTurbo = provider === 'turbo' && !useEth;
102
+ opts.arweave = {
103
+ provider,
104
+ gateway: ov.gateway ?? process.env.ABX_ARWEAVE_GATEWAY ?? 'https://arweave.net',
105
+ uploadUrl,
106
+ token: process.env.ARWEAVE_UPLOAD_TOKEN, // secret: env only (http-bundler)
107
+ jwk: managedTurbo ? loadArweaveJwk() : undefined, // secret: LOAD-only (reads/serve must never mint a key)
108
+ // Mint-on-first-WRITE: the backend invokes this ONLY when an upload actually runs and no key
109
+ // exists yet — so `deploy-code --backend arweave` (and any upload) "just works" with no setup
110
+ // step, while serve/verify/doctor never create a key. Prints one notice on creation.
111
+ ensureJwk: managedTurbo ? ensureManagedArweaveJwk : undefined,
112
+ ethSignerKey: useEth ? envSigningKey() : undefined, // secret: env only (the hot signing key)
113
+ };
114
+ }
115
+ return opts;
116
+ }
117
+ /** The active backend id, for display (no secrets, no construction). */
118
+ export function activeBackendId() {
119
+ return process.env.ABX_STORAGE_BACKEND ?? 'fs';
120
+ }
121
+ /** Resolve the active backend id + where it came from — for transparent readouts. */
122
+ export function backendResolution(ov = {}) {
123
+ if (ov.backend)
124
+ return { backend: ov.backend, source: 'flag' };
125
+ if (process.env.ABX_STORAGE_BACKEND)
126
+ return { backend: process.env.ABX_STORAGE_BACKEND, source: 'env' };
127
+ return { backend: 'fs', source: 'default' };
128
+ }
129
+ // ── Arweave (Turbo) identity ─────────────────────────────────────────────────
130
+ // The Turbo provider signs uploads with — and holds prepaid credits on — a single persistent
131
+ // Arweave key. It's the one wallet reused across every upload and project, so leftover credits
132
+ // are always there next time. We keep it next to the projection (gitignored), never collected in
133
+ // chat. A managed key is the default; bring your own with ARWEAVE_JWK (inline secret) or
134
+ // ABX_ARWEAVE_KEY_FILE (a path to your own JWK).
135
+ function arweaveKeyFile() {
136
+ return process.env.ABX_ARWEAVE_KEY_FILE ?? resolve(dataDir(), 'arweave-key.json');
137
+ }
138
+ /** Where the managed Turbo identity lives — for display ("back this up"). */
139
+ export function arweaveKeyFilePath() {
140
+ return arweaveKeyFile();
141
+ }
142
+ function parseJwk(raw) {
143
+ const text = raw.trim().startsWith('{') ? raw : Buffer.from(raw, 'base64').toString('utf8');
144
+ return JSON.parse(text);
145
+ }
146
+ /**
147
+ * Load the Turbo identity if one exists — env inline secret, an explicit key-file path, or the
148
+ * managed location. **Never creates** (read-only paths like `serve`/`status` must not mint a key)
149
+ * and **never silently replaces** a corrupt key (that would strand its credits) — a bad key throws.
150
+ */
151
+ export function loadArweaveJwk() {
152
+ if (process.env.ARWEAVE_JWK)
153
+ return parseJwk(process.env.ARWEAVE_JWK);
154
+ const p = arweaveKeyFile();
155
+ if (existsSync(p))
156
+ return JSON.parse(readFileSync(p, 'utf8'));
157
+ return undefined;
158
+ }
159
+ /** Load or CREATE the managed Turbo identity, persisting a fresh key (0600) to the data dir. */
160
+ export function ensureArweaveJwk() {
161
+ const p = arweaveKeyFile();
162
+ const existing = loadArweaveJwk();
163
+ if (existing)
164
+ return { jwk: existing, address: arweaveAddress(existing), created: false, path: p };
165
+ const jwk = generateArweaveJwk();
166
+ mkdirSync(dirname(p), { recursive: true });
167
+ writeFileSync(p, JSON.stringify(jwk), { mode: 0o600 });
168
+ return { jwk, address: arweaveAddress(jwk), created: true, path: p };
169
+ }
170
+ /**
171
+ * The write-path mint hook the Arweave backend calls on a first upload with no identity yet (wired
172
+ * into {@link storageOptions} as `arweave.ensureJwk`). Mints + persists the managed key and prints
173
+ * ONE notice on creation — the key holds the prepaid Turbo upload credits, so it's worth backing up.
174
+ * Read paths (serve/verify/doctor) never reach this — the backend only calls it inside `put`.
175
+ */
176
+ function ensureManagedArweaveJwk() {
177
+ const r = ensureArweaveJwk();
178
+ if (r.created) {
179
+ console.log(` created a managed Arweave upload identity ${r.address}\n` +
180
+ ` ${r.path} — it holds your Turbo upload credits; back it up: \`abx storage backup-key --out <path>\``);
181
+ }
182
+ return r.jwk;
183
+ }
184
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,cAAc,EAC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,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;IACjC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IACzC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;IACrD,OAAO,EAAC,GAAG,EAAE,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC;AACrE,CAAC;AAED;;;;;GAKG;AACH,SAAS,uBAAuB;IAC9B,MAAM,CAAC,GAAG,gBAAgB,EAAE,CAAC;IAC7B,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CACT,+CAA+C,CAAC,CAAC,OAAO,IAAI;YAC1D,OAAO,CAAC,CAAC,IAAI,4FAA4F,CAC5G,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC,GAAG,CAAC;AACf,CAAC"}
package/dist/deps.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { type Address, type DependencyReadClient, type Hex, type ParsedDependencyRef, type RegistryDependencyDetails } from '@artblocks/abx-sdk';
2
+ /**
3
+ * Parse the accumulated `--dep` flag value (repeats comma-join — see flags.ts — and each
4
+ * value may itself be comma-separated) into ordered refs. Order is load-bearing: the first
5
+ * ref becomes dependency index 0 — the runtime, by convention.
6
+ */
7
+ export declare function parseDepFlag(value: string | undefined): ParsedDependencyRef[];
8
+ /**
9
+ * The registry pointer a deploy with ≥1 Registry-resolution dep should set: an explicit
10
+ * `--dep-registry` wins (validated), else the chain's known AB registry (env-overridable),
11
+ * else none — the caller WARNS and skips the leg (soft pointer; the resolver falls back to
12
+ * its built-in CDN map). Never a blocker.
13
+ */
14
+ export declare function resolveDepRegistryPointer(flagValue: string | undefined, chainId: number): {
15
+ registry: Address | null;
16
+ source: 'flag' | 'default' | 'none';
17
+ };
18
+ /**
19
+ * The dependency legs of the setup multicall: one `setDependency(i, resolution, ref)` per
20
+ * dep in index order, plus the `setDependencyRegistry` leg when a pointer resolved. These
21
+ * ride the SAME atomic setup multicall as script chunks/schemas/mints, in every signing lane.
22
+ */
23
+ export declare function dependencySetupCalls(deps: ParsedDependencyRef[], registry: Address | null): Hex[];
24
+ /** One dep's selection-time verdict (Registry-resolution deps only — OnChain refs never touch a registry). */
25
+ export type DepCheck = {
26
+ dep: string;
27
+ status: 'found';
28
+ details: RegistryDependencyDetails;
29
+ } | {
30
+ dep: string;
31
+ status: 'not-found';
32
+ } | {
33
+ dep: string;
34
+ status: 'skipped';
35
+ };
36
+ /**
37
+ * Best-effort existence/on-chain-ness check of every Registry-resolution dep against the
38
+ * pointer registry. A revert or an empty record ⇒ `not-found` (a warning — the owner may
39
+ * intend a custom registry). A transport failure ⇒ the remaining checks are `skipped` and
40
+ * `rpcOk: false` — one info line, never an error: the deploy proceeds regardless.
41
+ */
42
+ export declare function checkRegistryDeps(client: DependencyReadClient, registry: Address, deps: ParsedDependencyRef[]): Promise<{
43
+ checks: DepCheck[];
44
+ rpcOk: boolean;
45
+ }>;
46
+ //# sourceMappingURL=deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAOA,OAAO,EAML,KAAK,OAAO,EACZ,KAAK,oBAAoB,EACzB,KAAK,GAAG,EACR,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC/B,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB,EAAE,CAW7E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,GACd;IAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAA;CAAC,CASjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,GAAG,GAAG,EAAE,CAQjG;AAED,8GAA8G;AAC9G,MAAM,MAAM,QAAQ,GAChB;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,yBAAyB,CAAA;CAAC,GAClE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,GAClC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,CAAC;AAErC;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,mBAAmB,EAAE,GAC1B,OAAO,CAAC;IAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAC,CAAC,CAyB/C"}
package/dist/deps.js ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The deploy-time dependency lane for `abx deploy-code` — pure flag parsing, registry-pointer
3
+ * defaulting, and setup-multicall leg composition (all unit-testable, no network), plus the
4
+ * BEST-EFFORT selection-time registry check (an eth_call per Registry dep; never blocks a
5
+ * deploy). See specs/protocol/dependency-registry.md — the pointer is soft and non-validating.
6
+ */
7
+ import { encodeFunctionData } from 'viem';
8
+ import { DEP_RESOLUTION, parseDependencyRef, readRegistryDependency, resolveDependencyRegistry, seriesCodeAbi, } from '@artblocks/abx-sdk';
9
+ /**
10
+ * Parse the accumulated `--dep` flag value (repeats comma-join — see flags.ts — and each
11
+ * value may itself be comma-separated) into ordered refs. Order is load-bearing: the first
12
+ * ref becomes dependency index 0 — the runtime, by convention.
13
+ */
14
+ export function parseDepFlag(value) {
15
+ if (value === 'true')
16
+ throw new Error('--dep needs a ref: name@version (e.g. p5@1.0.0) or 0x… (an on-chain data contract)');
17
+ // `--dep none` (or empty) means ZERO dependencies — the explicit "no libraries" sentinel (a
18
+ // dependency-free vanilla-JS or renderer-only drop). Without this, "none" was parsed as a registry
19
+ // ref literally named "none" → a bogus setDependency leg + a "not found on registry" warning.
20
+ if (value === 'none')
21
+ return [];
22
+ return String(value ?? '')
23
+ .split(',')
24
+ .map((s) => s.trim())
25
+ .filter((s) => s && s.toLowerCase() !== 'none')
26
+ .map(parseDependencyRef);
27
+ }
28
+ /**
29
+ * The registry pointer a deploy with ≥1 Registry-resolution dep should set: an explicit
30
+ * `--dep-registry` wins (validated), else the chain's known AB registry (env-overridable),
31
+ * else none — the caller WARNS and skips the leg (soft pointer; the resolver falls back to
32
+ * its built-in CDN map). Never a blocker.
33
+ */
34
+ export function resolveDepRegistryPointer(flagValue, chainId) {
35
+ if (flagValue !== undefined) {
36
+ if (flagValue === 'true' || !/^0x[0-9a-fA-F]{40}$/.test(flagValue)) {
37
+ throw new Error(`--dep-registry must be an address (0x + 40 hex); got '${flagValue}'`);
38
+ }
39
+ return { registry: flagValue, source: 'flag' };
40
+ }
41
+ const known = resolveDependencyRegistry(chainId);
42
+ return known ? { registry: known, source: 'default' } : { registry: null, source: 'none' };
43
+ }
44
+ /**
45
+ * The dependency legs of the setup multicall: one `setDependency(i, resolution, ref)` per
46
+ * dep in index order, plus the `setDependencyRegistry` leg when a pointer resolved. These
47
+ * ride the SAME atomic setup multicall as script chunks/schemas/mints, in every signing lane.
48
+ */
49
+ export function dependencySetupCalls(deps, registry) {
50
+ const calls = deps.map((d, i) => encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setDependency', args: [BigInt(i), d.resolution, d.ref] }));
51
+ if (deps.length && registry) {
52
+ calls.push(encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setDependencyRegistry', args: [registry] }));
53
+ }
54
+ return calls;
55
+ }
56
+ /**
57
+ * Best-effort existence/on-chain-ness check of every Registry-resolution dep against the
58
+ * pointer registry. A revert or an empty record ⇒ `not-found` (a warning — the owner may
59
+ * intend a custom registry). A transport failure ⇒ the remaining checks are `skipped` and
60
+ * `rpcOk: false` — one info line, never an error: the deploy proceeds regardless.
61
+ */
62
+ export async function checkRegistryDeps(client, registry, deps) {
63
+ const registryDeps = deps.filter((d) => d.resolution === DEP_RESOLUTION.registry);
64
+ const checks = [];
65
+ let rpcOk = true;
66
+ for (const d of registryDeps) {
67
+ if (!rpcOk) {
68
+ checks.push({ dep: d.display, status: 'skipped' });
69
+ continue;
70
+ }
71
+ try {
72
+ const details = await readRegistryDependency(client, registry, d.ref);
73
+ checks.push(details ? { dep: d.display, status: 'found', details } : { dep: d.display, status: 'not-found' });
74
+ }
75
+ catch (e) {
76
+ // A contract revert means the registry answered "no such dependency"; anything else
77
+ // (DNS, timeout, HTTP) means we couldn't ask — degrade to skipped, not failed.
78
+ const msg = `${e.name ?? ''} ${e.message ?? ''}`;
79
+ if (/ContractFunction|revert|returned no data/i.test(msg)) {
80
+ checks.push({ dep: d.display, status: 'not-found' });
81
+ }
82
+ else {
83
+ rpcOk = false;
84
+ checks.push({ dep: d.display, status: 'skipped' });
85
+ }
86
+ }
87
+ }
88
+ return { checks, rpcOk };
89
+ }
90
+ //# sourceMappingURL=deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAC,kBAAkB,EAAC,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,aAAa,GAMd,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,IAAI,KAAK,KAAK,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC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EAAC,CAAC,CAAC;QAC5G,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,oFAAoF;YACpF,+EAA+E;YAC/E,MAAM,GAAG,GAAG,GAAI,CAAW,CAAC,IAAI,IAAI,EAAE,IAAK,CAAW,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACvE,IAAI,2CAA2C,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1D,MAAM,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAC,CAAC,CAAC;YACrD,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * CLI flag parsing — `--k v` / `--k=v` / bare `--k` (→ 'true'). Extracted from main.ts so
3
+ * the parse rules are unit-testable (importing main executes the CLI).
4
+ *
5
+ * Repeated flags normally overwrite (last one wins); the flags in {@link REPEATABLE_FLAGS}
6
+ * instead ACCUMULATE comma-joined, so `--dep a --dep b` ≡ `--dep a,b` — order preserved
7
+ * (load-bearing for dependencies: index 0 = the runtime). `--schema` accumulates too, so
8
+ * `--schema a --schema b` ≡ `--schema a,b` — without this a second `--schema` silently drops
9
+ * the first (a real footgun on a multi-param drop; a Select's options use `|` not `,`, so the
10
+ * comma-join never collides with an option list).
11
+ */
12
+ export type Flags = Record<string, string | undefined>;
13
+ /** Flags where every occurrence counts (values comma-join, in argv order). */
14
+ export declare const REPEATABLE_FLAGS: ReadonlySet<string>;
15
+ export declare function parseFlags(args: string[]): Flags;
16
+ /**
17
+ * The flag keys in `flags` that are NOT in `allowed` — for a non-fatal "unrecognized flag"
18
+ * notice at a command's entry. {@link parseFlags} keeps any `--k` it sees, so a typo'd or
19
+ * unsupported flag otherwise no-ops INVISIBLY (a creator who passes `--description` to a
20
+ * command that doesn't take it walks away believing it worked). Warn, don't throw: the
21
+ * allowlist could be incomplete, and a false warning on a valid flag must never break a
22
+ * scripted deploy (owner's stateless/scriptable line — see cli-ux-decisions).
23
+ */
24
+ export declare function unknownFlags(flags: Flags, allowed: Iterable<string>): string[];
25
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEvD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAA8B,CAAC;AAEhF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAchD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAG9E"}
package/dist/flags.js ADDED
@@ -0,0 +1,34 @@
1
+ /** Flags where every occurrence counts (values comma-join, in argv order). */
2
+ export const REPEATABLE_FLAGS = new Set(['dep', 'schema']);
3
+ export function parseFlags(args) {
4
+ const out = {};
5
+ const set = (k, v) => {
6
+ out[k] = REPEATABLE_FLAGS.has(k) && out[k] !== undefined ? `${out[k]},${v}` : v;
7
+ };
8
+ for (let i = 0; i < args.length; i++) {
9
+ const a = args[i];
10
+ if (!a.startsWith('--'))
11
+ continue;
12
+ const eq = a.indexOf('=');
13
+ if (eq !== -1)
14
+ set(a.slice(2, eq), a.slice(eq + 1));
15
+ else if (args[i + 1] && !args[i + 1].startsWith('--'))
16
+ set(a.slice(2), args[++i]);
17
+ else
18
+ set(a.slice(2), 'true');
19
+ }
20
+ return out;
21
+ }
22
+ /**
23
+ * The flag keys in `flags` that are NOT in `allowed` — for a non-fatal "unrecognized flag"
24
+ * notice at a command's entry. {@link parseFlags} keeps any `--k` it sees, so a typo'd or
25
+ * unsupported flag otherwise no-ops INVISIBLY (a creator who passes `--description` to a
26
+ * command that doesn't take it walks away believing it worked). Warn, don't throw: the
27
+ * allowlist could be incomplete, and a false warning on a valid flag must never break a
28
+ * scripted deploy (owner's stateless/scriptable line — see cli-ux-decisions).
29
+ */
30
+ export function unknownFlags(flags, allowed) {
31
+ const ok = new Set(allowed);
32
+ return Object.keys(flags).filter((k) => !ok.has(k));
33
+ }
34
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACnC,GAAG,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC;IACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAClC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;aAC/C,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;YAC7E,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY,EAAE,OAAyB;IAClE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `abx inspect <script.js>` — static analysis of a generative script, BEFORE picking a lane.
3
+ *
4
+ * The membrane fix behind this: an agent (or creator) should DERIVE the deployment lane from what
5
+ * the script actually needs — are there traits? are they reproducible on-chain? how big is the
6
+ * assembled document (does a single `tokenURI` eth_call even fit)? — instead of guessing "fully
7
+ * on-chain!" and walking it back. This module is the pure analysis; `cmdInspect` formats it.
8
+ *
9
+ * Static only — it never executes the script (that's the resolver/runner's job, and executing
10
+ * untrusted art in the CLI would be a footgun). Everything here is regex/heuristic over the source.
11
+ */
12
+ export type TraitFeasibility = 'none' | 'exact-likely' | 'careful' | 'infeasible' | 'unknown';
13
+ export interface ScriptAnalysis {
14
+ bytes: number;
15
+ estChunks: number;
16
+ traits: {
17
+ present: boolean;
18
+ keys: string[];
19
+ };
20
+ paramHints: string[];
21
+ prng: {
22
+ seeded: boolean;
23
+ usesBareRandom: boolean;
24
+ usesMathRandom: boolean;
25
+ usesNoise: boolean;
26
+ };
27
+ depHints: string[];
28
+ looksP5: boolean;
29
+ feasibility: {
30
+ verdict: TraitFeasibility;
31
+ reason: string;
32
+ };
33
+ doc: {
34
+ estBytes: number;
35
+ deps: string[];
36
+ fitsSingleCall: boolean;
37
+ unknownDepSizes: boolean;
38
+ };
39
+ runtime: {
40
+ readsTokenData: boolean;
41
+ reportsTraits: boolean;
42
+ wrongGlobal: string | null;
43
+ };
44
+ }
45
+ export declare function analyzeScript(source: string, declaredDeps?: string[]): ScriptAnalysis;
46
+ /** A one-line lane recommendation derived from the analysis (the decision-tree output). */
47
+ export declare function recommendLane(a: ScriptAnalysis): string;
48
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgBH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9F,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC;IAC3C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,OAAO,CAAC;QAAC,cAAc,EAA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