@artblocks/abx-cli 0.1.0-alpha.17 → 0.1.0-alpha.19

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 (121) hide show
  1. package/CHANGELOG.md +218 -0
  2. package/dist/commands/deploy.d.ts +181 -0
  3. package/dist/commands/deploy.d.ts.map +1 -0
  4. package/dist/commands/deploy.js +2974 -0
  5. package/dist/commands/deploy.js.map +1 -0
  6. package/dist/commands/project.d.ts +134 -0
  7. package/dist/commands/project.d.ts.map +1 -0
  8. package/dist/commands/project.js +919 -0
  9. package/dist/commands/project.js.map +1 -0
  10. package/dist/commands/reads.d.ts +64 -0
  11. package/dist/commands/reads.d.ts.map +1 -0
  12. package/dist/commands/reads.js +635 -0
  13. package/dist/commands/reads.js.map +1 -0
  14. package/dist/commands/scaffold.d.ts +69 -0
  15. package/dist/commands/scaffold.d.ts.map +1 -0
  16. package/dist/commands/scaffold.js +508 -0
  17. package/dist/commands/scaffold.js.map +1 -0
  18. package/dist/commands/service.d.ts +41 -0
  19. package/dist/commands/service.d.ts.map +1 -0
  20. package/dist/commands/service.js +618 -0
  21. package/dist/commands/service.js.map +1 -0
  22. package/dist/commands/storage.d.ts +37 -0
  23. package/dist/commands/storage.d.ts.map +1 -0
  24. package/dist/commands/storage.js +335 -0
  25. package/dist/commands/storage.js.map +1 -0
  26. package/dist/config.d.ts +72 -2
  27. package/dist/config.d.ts.map +1 -1
  28. package/dist/config.js +201 -4
  29. package/dist/config.js.map +1 -1
  30. package/dist/conformance.d.ts +31 -0
  31. package/dist/conformance.d.ts.map +1 -0
  32. package/dist/conformance.js +371 -0
  33. package/dist/conformance.js.map +1 -0
  34. package/dist/deps.d.ts +6 -39
  35. package/dist/deps.d.ts.map +1 -1
  36. package/dist/deps.js +4 -68
  37. package/dist/deps.js.map +1 -1
  38. package/dist/errors.d.ts +20 -0
  39. package/dist/errors.d.ts.map +1 -0
  40. package/dist/errors.js +25 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/flags.d.ts +34 -0
  43. package/dist/flags.d.ts.map +1 -1
  44. package/dist/flags.js +74 -0
  45. package/dist/flags.js.map +1 -1
  46. package/dist/main.js +220 -6905
  47. package/dist/main.js.map +1 -1
  48. package/dist/mintpage.d.ts +3 -1
  49. package/dist/mintpage.d.ts.map +1 -1
  50. package/dist/mintpage.js +48 -48
  51. package/dist/mintpage.js.map +1 -1
  52. package/dist/output.d.ts +137 -0
  53. package/dist/output.d.ts.map +1 -0
  54. package/dist/output.js +504 -0
  55. package/dist/output.js.map +1 -0
  56. package/dist/ownerops.d.ts +23 -44
  57. package/dist/ownerops.d.ts.map +1 -1
  58. package/dist/ownerops.js +151 -233
  59. package/dist/ownerops.js.map +1 -1
  60. package/dist/preview.d.ts +8 -4
  61. package/dist/preview.d.ts.map +1 -1
  62. package/dist/preview.js +8 -17
  63. package/dist/preview.js.map +1 -1
  64. package/dist/provision.d.ts.map +1 -1
  65. package/dist/provision.js +10 -7
  66. package/dist/provision.js.map +1 -1
  67. package/dist/remote.d.ts +72 -7
  68. package/dist/remote.d.ts.map +1 -1
  69. package/dist/remote.js +211 -9
  70. package/dist/remote.js.map +1 -1
  71. package/dist/riskgate.d.ts +29 -0
  72. package/dist/riskgate.d.ts.map +1 -0
  73. package/dist/riskgate.js +91 -0
  74. package/dist/riskgate.js.map +1 -0
  75. package/dist/schema.d.ts +6 -0
  76. package/dist/schema.d.ts.map +1 -1
  77. package/dist/schema.js +12 -16
  78. package/dist/schema.js.map +1 -1
  79. package/dist/served.d.ts +1 -17
  80. package/dist/served.d.ts.map +1 -1
  81. package/dist/served.js +47 -0
  82. package/dist/served.js.map +1 -1
  83. package/dist/signer.d.ts +13 -0
  84. package/dist/signer.d.ts.map +1 -1
  85. package/dist/signer.js +42 -19
  86. package/dist/signer.js.map +1 -1
  87. package/dist/update-check.d.ts +27 -0
  88. package/dist/update-check.d.ts.map +1 -1
  89. package/dist/update-check.js +30 -0
  90. package/dist/update-check.js.map +1 -1
  91. package/package.json +6 -6
  92. package/skill/SKILL.md +7 -11
  93. package/skill/reference/code-projects.md +3 -3
  94. package/skill/reference/hosting.md +6 -6
  95. package/skill/reference/operating.md +2 -5
  96. package/skill/reference/setup.md +2 -2
  97. package/skill/reference/troubleshooting.md +1 -1
  98. package/dist/gas.d.ts +0 -63
  99. package/dist/gas.d.ts.map +0 -1
  100. package/dist/gas.js +0 -76
  101. package/dist/gas.js.map +0 -1
  102. package/dist/inspect.d.ts +0 -48
  103. package/dist/inspect.d.ts.map +0 -1
  104. package/dist/inspect.js +0 -290
  105. package/dist/inspect.js.map +0 -1
  106. package/dist/migrate.d.ts +0 -65
  107. package/dist/migrate.d.ts.map +0 -1
  108. package/dist/migrate.js +0 -180
  109. package/dist/migrate.js.map +0 -1
  110. package/dist/onchain-uri.d.ts +0 -81
  111. package/dist/onchain-uri.d.ts.map +0 -1
  112. package/dist/onchain-uri.js +0 -251
  113. package/dist/onchain-uri.js.map +0 -1
  114. package/dist/resume.d.ts +0 -96
  115. package/dist/resume.d.ts.map +0 -1
  116. package/dist/resume.js +0 -95
  117. package/dist/resume.js.map +0 -1
  118. package/dist/upload.d.ts +0 -28
  119. package/dist/upload.d.ts.map +0 -1
  120. package/dist/upload.js +0 -41
  121. package/dist/upload.js.map +0 -1
@@ -1,81 +0,0 @@
1
- import { type Address, type GeneratorReadClient, type GeneratorStatus, type Hex, type ParsedDependencyRef, type ProjectState } from '@artblocks/abx-sdk';
2
- import type { DepCheck } from './deps.js';
3
- /**
4
- * The `--onchain-uri` legs of the setup multicall, in order:
5
- * 1. collection-scope `animation_url` field → representation `renderer`,
6
- * value `abi.encode(generator)` (the canonical generator computes the live view on-chain);
7
- * 2. `setTokenURIRenderer(metadataRenderer)` — tokenURI resolves ON-CHAIN from here on;
8
- * 3. `setContractURIRenderer(metadataRenderer)` — contractURI too (parity with the 1/1 lane).
9
- * Placed BEFORE the mint legs so every token is born with the on-chain lane fully configured.
10
- *
11
- * There is no param leg: the generator enumerates the param surface from the token itself
12
- * (`contractParamKeys` / `tokenParamKeys`), so there is nothing for a deploy to declare.
13
- */
14
- export declare function onchainUriSetupCalls(args: {
15
- generator: Address;
16
- metadataRenderer: Address;
17
- }): Hex[];
18
- /** The SET param keys: `contractParamKeys()`, plus `tokenParamKeys(tokenId)` when a token is named.
19
- * Null when the getters are absent — a LEGACY project deployed before enumeration shipped (or a
20
- * token type with no Params extension at all). */
21
- export declare function readSetParamKeys(client: GeneratorReadClient, contract: Address, tokenId?: bigint): Promise<{
22
- contract: string[];
23
- token: string[];
24
- } | null>;
25
- /** The DECLARED (governed) keys: `paramSchemaKeys()`, append-only — including keys declared but
26
- * never yet written, which are otherwise undiscoverable. Null on a legacy project. */
27
- export declare function readParamSchemaKeys(client: GeneratorReadClient, contract: Address): Promise<string[] | null>;
28
- /** Does this token expose the enumeration surface at all? The one-call probe behind the repoint
29
- * guard: the canonical generator reads params from chain, so pointing a token that lacks these
30
- * getters at it makes every param silently invisible. */
31
- export declare function hasParamEnumeration(client: GeneratorReadClient, contract: Address): Promise<boolean>;
32
- /** What the deploy can honestly promise about the generator's template branch, derived from
33
- * the selection-time dependency report (never a new RPC): chain-complete iff every registry
34
- * dep has proven ON-CHAIN bytes (OnChain refs read their data contract directly, so they
35
- * count as on-chain; `abx verify` is the from-chain confirmation either way). */
36
- export declare function expectedChainComplete(deps: ParsedDependencyRef[], checks: DepCheck[]): {
37
- expected: boolean | null;
38
- detail: string;
39
- };
40
- /** The generator this project's on-chain lane actually uses: the collection `animation_url`
41
- * field's `renderer` value when set (that address is what the metadata renderer staticcalls),
42
- * else the chain's canonical generator. Null when neither exists. */
43
- export declare function generatorFor(state: ProjectState, override?: string): Address | null;
44
- /** Whether verify should run the on-chain-URI report: the tokenURIRenderer toggle is on, or
45
- * the collection `animation` field points at a field renderer (the generator). */
46
- export declare function hasOnChainUriLane(state: ProjectState): boolean;
47
- export interface TokenUriProbe {
48
- tokenId: string;
49
- /** tokenURI(id) is a `data:application/json;base64,` URI (resolves on-chain, any RPC). */
50
- onChainJson: boolean;
51
- uriPrefix: string;
52
- animation: {
53
- form: 'data-html';
54
- bytes: number;
55
- marker: string | null;
56
- } | {
57
- form: 'url';
58
- url: string;
59
- } | {
60
- form: 'data-other';
61
- prefix: string;
62
- } | {
63
- form: 'missing';
64
- };
65
- }
66
- export interface OnChainUriReport {
67
- generator: Address;
68
- status: GeneratorStatus;
69
- /** Null when no token is minted yet (tokenURI would revert). */
70
- probe: TokenUriProbe | null;
71
- }
72
- /**
73
- * The verify-time on-chain-URI report: `generator.onChainStatus(token)` (branch ·
74
- * chain-completeness · unresolved refs · URL budget) plus a `tokenURI` probe of the lowest
75
- * minted token — decoded, with the `animation_url` form checked against the branch.
76
- */
77
- export declare function onChainUriReport(client: GeneratorReadClient, state: ProjectState, generatorOverride?: string): Promise<OnChainUriReport>;
78
- /** Read a legacy project's `params.keys` CSV from chain (literal or data-backed); null when unset.
79
- * Best-effort — callers must treat a throw as "no legacy list". */
80
- export declare function readLegacyParamsKeys(client: GeneratorReadClient, contract: Address): Promise<string[] | null>;
81
- //# sourceMappingURL=onchain-uri.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onchain-uri.d.ts","sourceRoot":"","sources":["../src/onchain-uri.ts"],"names":[],"mappings":"AAkBA,OAAO,EAUL,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,GAAG,EACR,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AAExC;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,OAAO,CAAA;CAAC,GAAG,GAAG,EAAE,CAqBjG;AAQD;;mDAEmD;AACnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,mBAAmB,EAC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CAAA;KAAC,GACpC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAC,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;IACxB,gEAAgE;IAChE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7B;AAmBD;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAgC3B;AAUD;oEACoE;AACpE,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAoBnH"}
@@ -1,251 +0,0 @@
1
- /**
2
- * The on-chain tokenURI lane for code projects (`abx deploy-code --onchain-uri`) — pure leg
3
- * composition + the verify-time honesty reads, all unit-testable with a mocked client.
4
- *
5
- * The lane (specs/protocol/code-projects.md → "The canonical generator — AbxGenerator" +
6
- * specs/protocol/onchain-metadata.md → "URI resolution"): the collection-scope `animation_url`
7
- * field points at the canonical generator via the `renderer` representation
8
- * (`abi.encode(address)`), and the token's `tokenURIRenderer` toggles tokenURI to the canonical
9
- * on-chain metadata renderer (`setContractURIRenderer` does the same for contractURI). Both ride
10
- * the EXISTING setup multicall, before the mints.
11
- *
12
- * The param surface is NOT part of that wiring: params enumerate ON-CHAIN (`contractParamKeys` /
13
- * `tokenParamKeys`, maintained by the write paths themselves), so the generator reads the key set
14
- * straight from the token. The old `params.keys` CSV convention is retired — nothing writes it any
15
- * more; the only thing left here is a read-only lane for LEGACY projects deployed before
16
- * enumeration shipped.
17
- */
18
- import { encodeFunctionData, zeroAddress } from 'viem';
19
- import { decodeFieldRenderer, decodeTag, encodeFieldRenderer, encodeTag, readGeneratorStatus, resolveGenerator, seriesCodeAbi, METADATA_FIELD as F, METADATA_REPRESENTATION as R, DEP_RESOLUTION, } from '@artblocks/abx-sdk';
20
- /**
21
- * The `--onchain-uri` legs of the setup multicall, in order:
22
- * 1. collection-scope `animation_url` field → representation `renderer`,
23
- * value `abi.encode(generator)` (the canonical generator computes the live view on-chain);
24
- * 2. `setTokenURIRenderer(metadataRenderer)` — tokenURI resolves ON-CHAIN from here on;
25
- * 3. `setContractURIRenderer(metadataRenderer)` — contractURI too (parity with the 1/1 lane).
26
- * Placed BEFORE the mint legs so every token is born with the on-chain lane fully configured.
27
- *
28
- * There is no param leg: the generator enumerates the param surface from the token itself
29
- * (`contractParamKeys` / `tokenParamKeys`), so there is nothing for a deploy to declare.
30
- */
31
- export function onchainUriSetupCalls(args) {
32
- const calls = [];
33
- // The `animation_url` leg points at the generator (which computes the doc from a PROGRAM). A
34
- // renderer-only drop (in-chain SVG, no program) has no generator — and baking this leg at a ZERO
35
- // generator would make the metadata renderer staticcall a codeless address and REVERT every
36
- // tokenURI. So emit it only when there's a real generator; otherwise there's simply no animation_url
37
- // (optional by spec — the metadata renderer omits an unset field).
38
- if (args.generator !== zeroAddress) {
39
- calls.push(encodeFunctionData({
40
- abi: seriesCodeAbi,
41
- functionName: 'setContractField',
42
- args: [encodeTag(F.animationUrl), encodeTag(R.renderer), encodeFieldRenderer(args.generator)],
43
- }));
44
- }
45
- calls.push(encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setTokenURIRenderer', args: [args.metadataRenderer] }), encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setContractURIRenderer', args: [args.metadataRenderer] }));
46
- return calls;
47
- }
48
- // ── the param surface, enumerated FROM CHAIN ──────────────────────────────────
49
- // `key ∈ list ⟺ the param isSet` — the contract maintains both key lists inside the write paths
50
- // themselves, so nothing off-chain has to be kept in step. `seed` is deliberately never listed
51
- // (every consumer reads it as a tokenData coordinate). Enumeration order is unspecified; the
52
- // canonical serialization sorts.
53
- /** The SET param keys: `contractParamKeys()`, plus `tokenParamKeys(tokenId)` when a token is named.
54
- * Null when the getters are absent — a LEGACY project deployed before enumeration shipped (or a
55
- * token type with no Params extension at all). */
56
- export async function readSetParamKeys(client, contract, tokenId) {
57
- try {
58
- const contractKeys = (await client.readContract({
59
- address: contract,
60
- abi: seriesCodeAbi,
61
- functionName: 'contractParamKeys',
62
- args: [],
63
- }));
64
- const tokenKeys = tokenId === undefined
65
- ? []
66
- : (await client.readContract({
67
- address: contract,
68
- abi: seriesCodeAbi,
69
- functionName: 'tokenParamKeys',
70
- args: [tokenId],
71
- }));
72
- return { contract: contractKeys.map(decodeTag), token: tokenKeys.map(decodeTag) };
73
- }
74
- catch {
75
- return null;
76
- }
77
- }
78
- /** The DECLARED (governed) keys: `paramSchemaKeys()`, append-only — including keys declared but
79
- * never yet written, which are otherwise undiscoverable. Null on a legacy project. */
80
- export async function readParamSchemaKeys(client, contract) {
81
- try {
82
- const keys = (await client.readContract({
83
- address: contract,
84
- abi: seriesCodeAbi,
85
- functionName: 'paramSchemaKeys',
86
- args: [],
87
- }));
88
- return keys.map(decodeTag);
89
- }
90
- catch {
91
- return null;
92
- }
93
- }
94
- /** Does this token expose the enumeration surface at all? The one-call probe behind the repoint
95
- * guard: the canonical generator reads params from chain, so pointing a token that lacks these
96
- * getters at it makes every param silently invisible. */
97
- export async function hasParamEnumeration(client, contract) {
98
- try {
99
- await client.readContract({ address: contract, abi: seriesCodeAbi, functionName: 'tokenParamKeys', args: [0n] });
100
- return true;
101
- }
102
- catch {
103
- return false;
104
- }
105
- }
106
- // ── the chain-complete expectation (deploy-time, from the P1 dependency report) ──
107
- /** What the deploy can honestly promise about the generator's template branch, derived from
108
- * the selection-time dependency report (never a new RPC): chain-complete iff every registry
109
- * dep has proven ON-CHAIN bytes (OnChain refs read their data contract directly, so they
110
- * count as on-chain; `abx verify` is the from-chain confirmation either way). */
111
- export function expectedChainComplete(deps, checks) {
112
- if (deps.length === 0)
113
- return { expected: true, detail: 'no dependencies — the document assembles from the script chunks alone' };
114
- const registryDeps = deps.filter((d) => d.resolution === DEP_RESOLUTION.registry);
115
- if (registryDeps.length === 0) {
116
- return { expected: true, detail: 'all dependencies are on-chain data contracts (read directly)' };
117
- }
118
- const byDep = new Map(checks.map((c) => [c.dep, c]));
119
- const cdnOnly = [];
120
- const missing = [];
121
- let unknown = false;
122
- for (const d of registryDeps) {
123
- const chk = byDep.get(d.display);
124
- if (!chk || chk.status === 'skipped')
125
- unknown = true;
126
- else if (chk.status === 'not-found')
127
- missing.push(d.display);
128
- else if (!chk.details.availableOnChain)
129
- cdnOnly.push(d.display);
130
- }
131
- if (missing.length)
132
- return { expected: false, detail: `${missing.join(', ')} not on the registry — the generator will emit an unresolved marker` };
133
- if (cdnOnly.length)
134
- return { expected: false, detail: `${cdnOnly.join(', ')} CDN-served (the normal production path) — serves fine, NOT chain-complete` };
135
- if (unknown)
136
- return { expected: null, detail: 'registry check was skipped (RPC unreachable) — `abx verify` reads the truth from chain' };
137
- return { expected: true, detail: 'every dependency has ON-CHAIN bytes — no server, gateway, or CDN in the graph' };
138
- }
139
- // ── verify: the honesty reads (`onChainStatus` + a tokenURI probe) ─────────────
140
- /** The generator this project's on-chain lane actually uses: the collection `animation_url`
141
- * field's `renderer` value when set (that address is what the metadata renderer staticcalls),
142
- * else the chain's canonical generator. Null when neither exists. */
143
- export function generatorFor(state, override) {
144
- const field = state.collectionFields.find((f) => f.field === F.animationUrl && f.representation === R.renderer);
145
- if (field) {
146
- try {
147
- return decodeFieldRenderer(field.value);
148
- }
149
- catch {
150
- /* malformed value — fall through to the manifest */
151
- }
152
- }
153
- return resolveGenerator(state.chainId, override) ?? null;
154
- }
155
- /** Whether verify should run the on-chain-URI report: the tokenURIRenderer toggle is on, or
156
- * the collection `animation` field points at a field renderer (the generator). */
157
- export function hasOnChainUriLane(state) {
158
- const rendererSet = !!state.tokenURIRenderer && state.tokenURIRenderer !== zeroAddress;
159
- const animationRenderer = state.collectionFields.some((f) => f.field === F.animationUrl && f.representation === R.renderer);
160
- return rendererSet || animationRenderer;
161
- }
162
- const erc721TokenUriAbi = [
163
- {
164
- type: 'function',
165
- name: 'tokenURI',
166
- stateMutability: 'view',
167
- inputs: [{ name: 'id', type: 'uint256' }],
168
- outputs: [{ name: '', type: 'string' }],
169
- },
170
- ];
171
- /** An HTML comment marker the generator emits on degradation (`<!-- abx:… -->`), or null. */
172
- function degradationMarker(html) {
173
- const m = /<!--\s*abx:[^>]*-->/.exec(html);
174
- return m ? m[0] : null;
175
- }
176
- function probeAnimation(animationUrl) {
177
- if (!animationUrl)
178
- return { form: 'missing' };
179
- const dataHtml = /^data:text\/html;base64,(.*)$/.exec(animationUrl);
180
- if (dataHtml) {
181
- const html = Buffer.from(dataHtml[1], 'base64').toString('utf8');
182
- return { form: 'data-html', bytes: Buffer.byteLength(html), marker: degradationMarker(html) };
183
- }
184
- if (animationUrl.startsWith('data:'))
185
- return { form: 'data-other', prefix: animationUrl.slice(0, 40) };
186
- return { form: 'url', url: animationUrl };
187
- }
188
- /**
189
- * The verify-time on-chain-URI report: `generator.onChainStatus(token)` (branch ·
190
- * chain-completeness · unresolved refs · URL budget) plus a `tokenURI` probe of the lowest
191
- * minted token — decoded, with the `animation_url` form checked against the branch.
192
- */
193
- export async function onChainUriReport(client, state, generatorOverride) {
194
- const generator = generatorFor(state, generatorOverride);
195
- if (!generator) {
196
- throw new Error(`no AbxGenerator known for chain ${state.chainId} — set ABX_GENERATOR=0x… (or update @artblocks/abx-sdk's deployments manifest)`);
197
- }
198
- const status = await readGeneratorStatus(client, generator, state.address);
199
- const minted = state.tokens.filter((t) => t.minted).map((t) => BigInt(t.tokenId));
200
- let probe = null;
201
- if (minted.length) {
202
- const tokenId = minted.reduce((a, b) => (b < a ? b : a));
203
- const uri = (await client.readContract({
204
- address: state.address,
205
- abi: erc721TokenUriAbi,
206
- functionName: 'tokenURI',
207
- args: [tokenId],
208
- }));
209
- const m = /^data:application\/json;base64,(.*)$/.exec(uri);
210
- let animation = { form: 'missing' };
211
- if (m) {
212
- try {
213
- const json = JSON.parse(Buffer.from(m[1], 'base64').toString('utf8'));
214
- animation = probeAnimation(typeof json.animation_url === 'string' ? json.animation_url : undefined);
215
- }
216
- catch {
217
- /* undecodable JSON — reported as onChainJson with a missing animation */
218
- }
219
- }
220
- probe = { tokenId: tokenId.toString(), onChainJson: !!m, uriPrefix: uri.slice(0, 48), animation };
221
- }
222
- return { generator, status, probe };
223
- }
224
- // ── LEGACY: the retired `params.keys` convention, READ-ONLY ───────────────────
225
- // Projects deployed before on-chain enumeration declared their param surface in a `params.keys`
226
- // contract param, and their (old) generator read that CSV. Nothing writes it any more — this reader
227
- // exists purely so `abx state` still describes those live testnet projects. A `params.keys` value
228
- // written on a NEW project is just an ordinary param: enumerated and emitted like any other.
229
- const LEGACY_PARAMS_KEYS = 'params.keys';
230
- /** Read a legacy project's `params.keys` CSV from chain (literal or data-backed); null when unset.
231
- * Best-effort — callers must treat a throw as "no legacy list". */
232
- export async function readLegacyParamsKeys(client, contract) {
233
- const [value, valueIsHash, isSet] = (await client.readContract({
234
- address: contract,
235
- abi: seriesCodeAbi,
236
- functionName: 'contractParam',
237
- args: [encodeTag(LEGACY_PARAMS_KEYS)],
238
- }));
239
- if (!isSet)
240
- return null;
241
- const csv = valueIsHash
242
- ? Buffer.from((await client.readContract({
243
- address: contract,
244
- abi: seriesCodeAbi,
245
- functionName: 'contractParamData',
246
- args: [encodeTag(LEGACY_PARAMS_KEYS)],
247
- })).slice(2), 'hex').toString('utf8')
248
- : decodeTag(value);
249
- return csv.split(',').map((k) => k.trim()).filter((k) => k && k !== LEGACY_PARAMS_KEYS);
250
- }
251
- //# sourceMappingURL=onchain-uri.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onchain-uri.js","sourceRoot":"","sources":["../src/onchain-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EACL,mBAAm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C,MAAM,MAAM,CAAC,YAAY,CAAC;QAC7D,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,aAAa;QAClB,YAAY,EAAE,eAAe;QAC7B,IAAI,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;KACtC,CAAC,CAA4B,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,GAAG,GAAG,WAAW;QACrB,CAAC,CAAC,MAAM,CAAC,IAAI,CACR,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,QAAQ;YACjB,GAAG,EAAE,aAAa;YAClB,YAAY,EAAE,mBAAmB;YACjC,IAAI,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;SACtC,CAAC,CAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EACpB,KAAK,CACN,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC,CAAC;AAC1F,CAAC"}
package/dist/resume.d.ts DELETED
@@ -1,96 +0,0 @@
1
- import type { Address, Hex } from 'viem';
2
- /**
3
- * Finish a `deploy-code` whose **setup transaction** never landed.
4
- *
5
- * A code project deploys in two transactions: create the clone, then one atomic `multicall` carrying
6
- * the script chunks, the PostParam schemas, the dependency declarations, the on-chain-URI legs, and
7
- * any reserve mints. There is no rollback. When the second one fails you own a live-but-unusable
8
- * contract, and the CREATE2 salt reserved for that address is spent — so the dry run's pinned-salt
9
- * reproduce command can never be run again. One reporter session produced three orphaned contracts
10
- * from three attempts; another produced five.
11
- *
12
- * The useful half of that report is that those contracts were **recoverable, not lost**: resending the
13
- * setup with an adequate gas limit completed one, after which `abx verify` reported chain-complete.
14
- * The tester did it by hand with `cast`. We deliberately do not document that as a recipe — telling a
15
- * creator to hand-assemble a multicall is worse than telling them nothing — so this is the verb.
16
- *
17
- * **Why it diffs instead of just re-sending everything.** The setup multicall is atomic, so in the
18
- * common case every leg is absent and the diff finds nothing to skip. But two cases make the diff
19
- * earn its keep: a creator who already repaired part of it by hand (which is exactly what happened),
20
- * and the gas cost of re-storing script chunks that already landed — EVM code deposit is 200 gas per
21
- * byte, so blindly re-sending a large program is the most expensive way to be safe. Every leg is also
22
- * idempotent by construction (index-addressed chunks and dependencies, an upsert for schemas), so the
23
- * diff is an optimisation on top of a safe operation rather than the thing that makes it safe.
24
- *
25
- * The one leg that is NOT idempotent is `mint`, which is why it is computed as a **shortfall** against
26
- * current supply rather than re-sent: minting again would mint more tokens, and a token cannot be
27
- * un-minted.
28
- */
29
- /** The reads the plan needs. An interface, not a client, so the diff is testable without a chain. */
30
- export interface ResumeReader {
31
- scriptChunkCount(): Promise<number>;
32
- /** The stored bytes at `index`, or `null` when unset/unreadable. */
33
- scriptChunk(index: number): Promise<Hex | null>;
34
- schemaExists(key: string): Promise<boolean>;
35
- dependencyCount(): Promise<number>;
36
- dependencyRegistry(): Promise<Address | null>;
37
- tokenURIRenderer(): Promise<Address | null>;
38
- contractURIRenderer(): Promise<Address | null>;
39
- /** Whether a collection-scope field has any active representation. */
40
- contractFieldSet(field: string): Promise<boolean>;
41
- totalSupply(): Promise<number>;
42
- }
43
- /** The intended setup, grouped so each group can be skipped independently. */
44
- export interface SetupLegs {
45
- /** One entry per script chunk, in index order. `hex` is the intended content, for comparison. */
46
- chunks: Array<{
47
- index: number;
48
- hex: Hex;
49
- data: Hex;
50
- }>;
51
- schemas: Array<{
52
- key: string;
53
- data: Hex;
54
- }>;
55
- /** Dependency legs ride as one group — `count` is how many `setDependency` calls it carries. */
56
- deps: {
57
- count: number;
58
- registry: Address | null;
59
- calls: Hex[];
60
- };
61
- /** The on-chain-URI legs. `animationField` names the collection field they set, when they set one. */
62
- uri: {
63
- calls: Hex[];
64
- animationField: string | null;
65
- };
66
- /** Reserve mints as an INTENDED TOTAL SUPPLY, not a count to add — see the shortfall note above. */
67
- mints: {
68
- intendedTotal: number;
69
- data: Hex;
70
- };
71
- }
72
- export interface ResumePlan {
73
- /** The calls to send, in the original setup's order. Empty ⇒ nothing is missing. */
74
- calls: Hex[];
75
- /** Human lines for what is already on-chain — the reassurance half of the readout. */
76
- done: string[];
77
- /** Human lines for what this will send. */
78
- todo: string[];
79
- /**
80
- * What the selected calls actually consist of, so the caller can label the transaction and compute
81
- * its gas floor without re-deriving the selection (matching call bytes back to legs would be both
82
- * fragile and quadratic).
83
- */
84
- sending: {
85
- chunkIndices: number[];
86
- /** Byte length of each chunk being stored — the 200-gas-per-byte deposit floor. */
87
- chunkBytes: number[];
88
- schemaKeys: string[];
89
- deps: boolean;
90
- uri: boolean;
91
- mints: number;
92
- };
93
- }
94
- /** Diff the intended setup against what the contract already holds. */
95
- export declare function planResume(read: ResumeReader, legs: SetupLegs): Promise<ResumePlan>;
96
- //# sourceMappingURL=resume.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../src/resume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qGAAqG;AACrG,MAAM,WAAW,YAAY;IAC3B,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,oEAAoE;IACpE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAChD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC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AE;QACP,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,mFAAmF;QACnF,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC;QACd,GAAG,EAAE,OAAO,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,uEAAuE;AACvE,wBAAsB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAwFzF"}
package/dist/resume.js DELETED
@@ -1,95 +0,0 @@
1
- /** Diff the intended setup against what the contract already holds. */
2
- export async function planResume(read, legs) {
3
- const calls = [];
4
- const done = [];
5
- const todo = [];
6
- const sending = { chunkIndices: [], chunkBytes: [], schemaKeys: [], deps: false, uri: false, mints: 0 };
7
- // ── script chunks ───────────────────────────────────────────────────────────
8
- // Compared by CONTENT, not by count. A count check would call a chunk "present" when a hand-repair
9
- // wrote different bytes at that index, and re-sending is the cheap, correct answer to any doubt.
10
- if (legs.chunks.length) {
11
- const count = await read.scriptChunkCount();
12
- const missing = [];
13
- for (const chunk of legs.chunks) {
14
- const stored = chunk.index < count ? await read.scriptChunk(chunk.index) : null;
15
- if (stored !== null && stored.toLowerCase() === chunk.hex.toLowerCase())
16
- continue;
17
- missing.push(chunk.index);
18
- calls.push(chunk.data);
19
- sending.chunkIndices.push(chunk.index);
20
- sending.chunkBytes.push((chunk.hex.length - 2) / 2);
21
- }
22
- if (missing.length === 0)
23
- done.push(`script: all ${legs.chunks.length} chunk(s) already stored on-chain`);
24
- else if (missing.length === legs.chunks.length)
25
- todo.push(`script: store ${missing.length} chunk(s)`);
26
- else
27
- todo.push(`script: store ${missing.length} of ${legs.chunks.length} chunk(s) (indices ${missing.join(', ')} — the rest already match)`);
28
- }
29
- // ── PostParam schemas ───────────────────────────────────────────────────────
30
- // `exists` is the whole test. A schema cannot have landed with different content than the leg that
31
- // wrote it (the multicall is atomic), so present ⇒ correct — and re-writing one is an upsert with
32
- // real value-stranding risk, which belongs to `set-schema` and its guard, never to a resume.
33
- if (legs.schemas.length) {
34
- const absent = [];
35
- for (const s of legs.schemas) {
36
- if (await read.schemaExists(s.key))
37
- continue;
38
- absent.push(s.key);
39
- calls.push(s.data);
40
- sending.schemaKeys.push(s.key);
41
- }
42
- if (absent.length === 0)
43
- done.push(`params: all ${legs.schemas.length} schema(s) already declared`);
44
- else
45
- todo.push(`params: declare ${absent.join(', ')}`);
46
- }
47
- // ── dependencies ────────────────────────────────────────────────────────────
48
- // One group: the legs are index-addressed and the registry pointer rides with them, so "as many as
49
- // intended, pointing at the intended registry" is the honest test.
50
- if (legs.deps.calls.length) {
51
- const count = await read.dependencyCount();
52
- const registry = await read.dependencyRegistry();
53
- const registryOk = legs.deps.registry === null || (registry ?? '').toLowerCase() === legs.deps.registry.toLowerCase();
54
- if (count >= legs.deps.count && registryOk) {
55
- done.push(`dependencies: ${count} already declared${legs.deps.registry ? ' (registry matches)' : ''}`);
56
- }
57
- else {
58
- calls.push(...legs.deps.calls);
59
- sending.deps = true;
60
- todo.push(`dependencies: declare ${legs.deps.count}${registryOk ? '' : ' + re-point the registry'}`);
61
- }
62
- }
63
- // ── the on-chain URI legs ───────────────────────────────────────────────────
64
- // All-or-nothing as a group: a token whose renderers are set but whose animation field is not is
65
- // the half-wired state this verb exists to finish, and the legs are all idempotent setters.
66
- if (legs.uri.calls.length) {
67
- const [tokenR, contractR] = await Promise.all([read.tokenURIRenderer(), read.contractURIRenderer()]);
68
- const animationOk = legs.uri.animationField === null || (await read.contractFieldSet(legs.uri.animationField));
69
- if (tokenR && contractR && animationOk) {
70
- done.push('on-chain URI: renderers wired and the animation field is set');
71
- }
72
- else {
73
- calls.push(...legs.uri.calls);
74
- sending.uri = true;
75
- todo.push('on-chain URI: wire the metadata renderers + the animation field');
76
- }
77
- }
78
- // ── reserve mints ───────────────────────────────────────────────────────────
79
- // A SHORTFALL, never a re-send: mint is the one non-idempotent leg, and a token cannot be un-minted.
80
- if (legs.mints.intendedTotal > 0) {
81
- const supply = await read.totalSupply();
82
- const shortfall = Math.max(0, legs.mints.intendedTotal - supply);
83
- if (shortfall === 0) {
84
- done.push(`mints: ${supply} token(s) already minted (intended ${legs.mints.intendedTotal})`);
85
- }
86
- else {
87
- for (let i = 0; i < shortfall; i++)
88
- calls.push(legs.mints.data);
89
- sending.mints = shortfall;
90
- todo.push(`mints: mint ${shortfall} more token(s) — ${supply} of ${legs.mints.intendedTotal} exist`);
91
- }
92
- }
93
- return { calls, done, todo, sending };
94
- }
95
- //# sourceMappingURL=resume.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resume.js","sourceRoot":"","sources":["../src/resume.ts"],"names":[],"mappings":"AAiFA,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAkB,EAAE,IAAe;IAClE,MAAM,KAAK,GAAU,EAAE,CAAC;IACxB,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,OAAO,GAA0B,EAAC,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAE7H,+EAA+E;IAC/E,mGAAmG;IACnG,iGAAiG;IACjG,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,C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,IAAI,CAAC,UAAU,MAAM,sCAAsC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC;QAC/F,CAAC;aAAM,CAAC;YACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,eAAe,SAAS,oBAAoB,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAED,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;AACtC,CAAC"}
package/dist/upload.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * `abx storage upload` core — upload ONE file and return a public locator that PRESERVES the
3
- * filename, so the declared mimeType survives when the locator is later attached (`abx attach`).
4
- * The on-chain metadata field has no MIME slot: the URL extension IS the type declaration, so a
5
- * bare content-addressed locator (`ar://<txid>`, `<gw>/ipfs/<cid>`) — which has no extension —
6
- * would make the attached artifact `application/octet-stream`. Extracted from main.ts so the
7
- * capability-based branch (the exact bug this guards) is unit-testable with fake backends.
8
- */
9
- import type { StorageBackend, StoredContent } from '@artblocks/abx-storage';
10
- export interface UploadResult {
11
- /** A fetchable public URL for the file. */
12
- locator: string;
13
- /** True when `locator` carries the filename (extension → correct declared type on attach). */
14
- filenamePreserved: boolean;
15
- /** Set when we had to fall back to a bare (extension-less) locator — the caller warns. */
16
- fallbackReason?: string;
17
- }
18
- /**
19
- * Store `content` under `name` and return the best available public locator. Preference order:
20
- * 1. path-addressed host (cloud/S3/R2): the object key IS the filename → `<publicBase>/<name>`.
21
- * 2. content-addressed host with directory support (ipfs/arweave): wrap the single file in a
22
- * one-entry directory → `<base>/<name>` (filename preserved).
23
- * 3. bare content-addressed locator (e.g. kubo IPFS with no dir-add): `<gw>/ipfs/<cid>` — no
24
- * extension; `filenamePreserved: false` so the caller can warn about the octet-stream type.
25
- * Throws for a backend that can't produce any public URL (e.g. `fs`).
26
- */
27
- export declare function uploadAndLocate(backend: StorageBackend, name: string, content: StoredContent): Promise<UploadResult>;
28
- //# sourceMappingURL=upload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,8FAA8F;IAC9F,iBAAiB,EAAE,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAyB1H"}
package/dist/upload.js DELETED
@@ -1,41 +0,0 @@
1
- import { hashContent } from '@artblocks/abx-storage';
2
- const trimSlash = (s) => s.replace(/\/+$/, '');
3
- /**
4
- * Store `content` under `name` and return the best available public locator. Preference order:
5
- * 1. path-addressed host (cloud/S3/R2): the object key IS the filename → `<publicBase>/<name>`.
6
- * 2. content-addressed host with directory support (ipfs/arweave): wrap the single file in a
7
- * one-entry directory → `<base>/<name>` (filename preserved).
8
- * 3. bare content-addressed locator (e.g. kubo IPFS with no dir-add): `<gw>/ipfs/<cid>` — no
9
- * extension; `filenamePreserved: false` so the caller can warn about the octet-stream type.
10
- * Throws for a backend that can't produce any public URL (e.g. `fs`).
11
- */
12
- export async function uploadAndLocate(backend, name, content) {
13
- if (backend.publicBase && backend.putObject) {
14
- await backend.putObject(name, content);
15
- return { locator: `${trimSlash(backend.publicBase)}/${name}`, filenamePreserved: true };
16
- }
17
- if (backend.putDirectory && backend.locator) {
18
- try {
19
- const { base } = await backend.putDirectory([{ name, bytes: content.bytes, contentType: content.contentType }]);
20
- return { locator: `${trimSlash(base)}/${name}`, filenamePreserved: true };
21
- }
22
- catch (e) {
23
- const hash = hashContent(content.bytes);
24
- await backend.put(hash, content);
25
- const loc = await backend.locator(hash);
26
- if (!loc)
27
- throw e;
28
- return { locator: loc, filenamePreserved: false, fallbackReason: e.message };
29
- }
30
- }
31
- if (backend.locator) {
32
- const hash = hashContent(content.bytes);
33
- await backend.put(hash, content);
34
- const loc = await backend.locator(hash);
35
- if (!loc)
36
- throw new Error(`backend '${backend.id}' stored the file but returned no durable locator`);
37
- return { locator: loc, filenamePreserved: false };
38
- }
39
- throw new Error(`backend '${backend.id}' can't produce a public URL for an attached file — use ipfs, arweave, or cloud (with a public base).`);
40
- }
41
- //# sourceMappingURL=upload.js.map