@artblocks/abx-cli 0.1.0-alpha.16 → 0.1.0-alpha.18
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/CHANGELOG.md +385 -0
- package/dist/commands/deploy.d.ts +181 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +2974 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/project.d.ts +134 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +919 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/reads.d.ts +64 -0
- package/dist/commands/reads.d.ts.map +1 -0
- package/dist/commands/reads.js +635 -0
- package/dist/commands/reads.js.map +1 -0
- package/dist/commands/scaffold.d.ts +55 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/scaffold.js +470 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/commands/service.d.ts +41 -0
- package/dist/commands/service.d.ts.map +1 -0
- package/dist/commands/service.js +572 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/storage.d.ts +37 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +335 -0
- package/dist/commands/storage.js.map +1 -0
- package/dist/config.d.ts +72 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +201 -4
- package/dist/config.js.map +1 -1
- package/dist/deps.d.ts +6 -39
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +4 -68
- package/dist/deps.js.map +1 -1
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/flags.d.ts +34 -0
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +74 -0
- package/dist/flags.js.map +1 -1
- package/dist/jsonout.d.ts +37 -0
- package/dist/jsonout.d.ts.map +1 -0
- package/dist/jsonout.js +68 -0
- package/dist/jsonout.js.map +1 -0
- package/dist/main.js +133 -6223
- package/dist/main.js.map +1 -1
- package/dist/mintpage.d.ts.map +1 -1
- package/dist/mintpage.js +34 -40
- package/dist/mintpage.js.map +1 -1
- package/dist/output.d.ts +137 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +504 -0
- package/dist/output.js.map +1 -0
- package/dist/ownerops.d.ts +37 -44
- package/dist/ownerops.d.ts.map +1 -1
- package/dist/ownerops.js +274 -233
- package/dist/ownerops.js.map +1 -1
- package/dist/preview.d.ts +8 -4
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +8 -17
- package/dist/preview.js.map +1 -1
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +10 -7
- package/dist/provision.js.map +1 -1
- package/dist/remote.d.ts +72 -7
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +211 -9
- package/dist/remote.js.map +1 -1
- package/dist/riskgate.d.ts +29 -0
- package/dist/riskgate.d.ts.map +1 -0
- package/dist/riskgate.js +91 -0
- package/dist/riskgate.js.map +1 -0
- package/dist/schema.d.ts +6 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +12 -16
- package/dist/schema.js.map +1 -1
- package/dist/served.d.ts +30 -0
- package/dist/served.d.ts.map +1 -0
- package/dist/served.js +112 -0
- package/dist/served.js.map +1 -0
- package/dist/signer.d.ts +13 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +42 -19
- package/dist/signer.js.map +1 -1
- package/dist/update-check.d.ts +27 -0
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +30 -0
- package/dist/update-check.js.map +1 -1
- package/package.json +6 -6
- package/skill/SKILL.md +9 -13
- package/skill/reference/code-projects.md +7 -6
- package/skill/reference/hosting.md +6 -6
- package/skill/reference/operating.md +2 -5
- package/skill/reference/setup.md +4 -3
- package/skill/reference/troubleshooting.md +14 -1
- package/dist/gas.d.ts +0 -63
- package/dist/gas.d.ts.map +0 -1
- package/dist/gas.js +0 -76
- package/dist/gas.js.map +0 -1
- package/dist/inspect.d.ts +0 -48
- package/dist/inspect.d.ts.map +0 -1
- package/dist/inspect.js +0 -290
- package/dist/inspect.js.map +0 -1
- package/dist/migrate.d.ts +0 -65
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -180
- package/dist/migrate.js.map +0 -1
- package/dist/onchain-uri.d.ts +0 -81
- package/dist/onchain-uri.d.ts.map +0 -1
- package/dist/onchain-uri.js +0 -251
- package/dist/onchain-uri.js.map +0 -1
- package/dist/upload.d.ts +0 -28
- package/dist/upload.d.ts.map +0 -1
- package/dist/upload.js +0 -41
- package/dist/upload.js.map +0 -1
package/dist/onchain-uri.d.ts
DELETED
|
@@ -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,KAA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C1F,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAC,GACzD;QAAC,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,GAC1B;QAAC,IAAI,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,MAAM,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"}
|
package/dist/onchain-uri.js
DELETED
|
@@ -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
|
package/dist/onchain-uri.js.map
DELETED
|
@@ -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,MA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AAE,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,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/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
|
package/dist/upload.d.ts.map
DELETED
|
@@ -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
|
package/dist/upload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAWnD,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAuB,EAAE,IAAY,EAAE,OAAsB;IACjG,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,EAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAC,CAAC;IACxF,CAAC;IACD,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,C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