@artblocks/abx-sdk 0.1.0-alpha.3 → 0.1.0-alpha.31
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 +79 -0
- package/README.md +130 -0
- package/dist/abi/generated.d.ts +8502 -129
- package/dist/abi/generated.d.ts.map +1 -1
- package/dist/abi/generated.js +40 -22
- package/dist/abi/generated.js.map +1 -1
- package/dist/abi/index.d.ts +2645 -168
- package/dist/abi/index.d.ts.map +1 -1
- package/dist/abi/index.js +34 -7
- package/dist/abi/index.js.map +1 -1
- package/dist/anchors.d.ts +318 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +701 -0
- package/dist/anchors.js.map +1 -0
- package/dist/chains.d.ts +19 -9
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +31 -15
- package/dist/chains.js.map +1 -1
- package/dist/chunks.d.ts +123 -27
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +124 -9
- package/dist/chunks.js.map +1 -1
- package/dist/clients.d.ts +23 -11
- package/dist/clients.d.ts.map +1 -1
- package/dist/clients.js +17 -18
- package/dist/clients.js.map +1 -1
- package/dist/create2.d.ts +84 -1
- package/dist/create2.d.ts.map +1 -1
- package/dist/create2.js +158 -2
- package/dist/create2.js.map +1 -1
- package/dist/creator-token.d.ts +132 -0
- package/dist/creator-token.d.ts.map +1 -0
- package/dist/creator-token.js +183 -0
- package/dist/creator-token.js.map +1 -0
- package/dist/deploy.d.ts +234 -14
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +289 -111
- package/dist/deploy.js.map +1 -1
- package/dist/deployments.d.ts +85 -5
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +159 -30
- package/dist/deployments.js.map +1 -1
- package/dist/deps.d.ts +123 -6
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +249 -7
- package/dist/deps.js.map +1 -1
- package/dist/env.d.ts +5 -4
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -5
- package/dist/env.js.map +1 -1
- package/dist/errors.d.ts +109 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +148 -0
- package/dist/errors.js.map +1 -0
- package/dist/execute.d.ts +118 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +159 -0
- package/dist/execute.js.map +1 -0
- package/dist/gateways.d.ts +79 -0
- package/dist/gateways.d.ts.map +1 -0
- package/dist/gateways.js +156 -0
- package/dist/gateways.js.map +1 -0
- package/dist/generator-document.d.ts +57 -0
- package/dist/generator-document.d.ts.map +1 -0
- package/dist/generator-document.js +123 -0
- package/dist/generator-document.js.map +1 -0
- package/dist/generator.d.ts +44 -2
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +29 -0
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +48 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +295 -0
- package/dist/inspect.js.map +1 -0
- package/dist/migrate.d.ts +41 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +142 -0
- package/dist/migrate.js.map +1 -0
- package/dist/mime.d.ts +11 -0
- package/dist/mime.d.ts.map +1 -0
- package/dist/mime.js +40 -0
- package/dist/mime.js.map +1 -0
- package/dist/node.d.ts +69 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +92 -0
- package/dist/node.js.map +1 -0
- package/dist/onchain-uri.d.ts +110 -0
- package/dist/onchain-uri.d.ts.map +1 -0
- package/dist/onchain-uri.js +276 -0
- package/dist/onchain-uri.js.map +1 -0
- package/dist/ops.d.ts +507 -14
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +850 -34
- package/dist/ops.js.map +1 -1
- package/dist/policy.d.ts +57 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +35 -0
- package/dist/policy.js.map +1 -0
- package/dist/probe.d.ts +58 -0
- package/dist/probe.d.ts.map +1 -1
- package/dist/probe.js +190 -9
- package/dist/probe.js.map +1 -1
- package/dist/reconstruct.d.ts +141 -3
- package/dist/reconstruct.d.ts.map +1 -1
- package/dist/reconstruct.js +479 -100
- package/dist/reconstruct.js.map +1 -1
- package/dist/resume.d.ts +140 -0
- package/dist/resume.d.ts.map +1 -0
- package/dist/resume.js +146 -0
- package/dist/resume.js.map +1 -0
- package/dist/script-chunks.d.ts +105 -0
- package/dist/script-chunks.d.ts.map +1 -0
- package/dist/script-chunks.js +158 -0
- package/dist/script-chunks.js.map +1 -0
- package/dist/service.d.ts +151 -9
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +103 -11
- package/dist/service.js.map +1 -1
- package/dist/spine.d.ts +47 -4
- package/dist/spine.d.ts.map +1 -1
- package/dist/spine.js +0 -0
- package/dist/spine.js.map +1 -1
- package/dist/staging.d.ts +139 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +139 -0
- package/dist/staging.js.map +1 -0
- package/dist/token.d.ts +11 -1
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +32 -1
- package/dist/token.js.map +1 -1
- package/dist/tokendata.d.ts +63 -3
- package/dist/tokendata.d.ts.map +1 -1
- package/dist/tokendata.js +81 -19
- package/dist/tokendata.js.map +1 -1
- package/dist/tokens.d.ts +119 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +317 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +107 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts +74 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +106 -0
- package/dist/util.js.map +1 -0
- package/package.json +15 -6
package/dist/tokendata.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { type Hex, type PublicClient } from 'viem';
|
|
2
|
-
import type { MetadataField, ProjectState, TokenState } from './types.js';
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
import type { MetadataField, ParamSchema, ParamValue, ProjectState, TokenState } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The canonical `tokenData` assembly — the off-chain serializer the spec names as
|
|
5
|
+
* authoritative (`site/content/docs/protocol/code-projects.mdx`). One flat object: the reserved
|
|
6
|
+
* coordinates + every param (contract ∪ token scope, token wins) + the augment hook's
|
|
7
|
+
* entries (augment wins per key), every value its canonical string (`chainId` alone is
|
|
8
|
+
* a number). The serialization is canonical because it is *hashed*: an effect's
|
|
9
|
+
* `inputsHash` commits to it, so this exact byte shape is what makes render outputs
|
|
10
|
+
* addressable and self-invalidating.
|
|
11
|
+
*
|
|
12
|
+
* Decode rules: a schema'd param decodes per its type (`Select` → the option string,
|
|
13
|
+
* `DecimalRange` ÷ 1e10, …); a schema-less literal stays the raw `bytes32` hex (a
|
|
14
|
+
* schema is what buys a human decode — `seed` is the canonical example); a data-backed
|
|
15
|
+
* value reads its blob (`String` → UTF-8, `Bytes`/schema-less → base64).
|
|
16
|
+
*/
|
|
17
|
+
/** The tokenData coordinates — never enumerable as params (the on-chain params store excludes
|
|
18
|
+
* `seed` from its key lists, and the generator/renderer skip the other three defensively).
|
|
19
|
+
* Exported because every off-chain surface that enumerates params must exclude exactly this
|
|
20
|
+
* set: two lists that have to agree are one list. */
|
|
21
|
+
export declare const RESERVED_TOKEN_DATA_KEYS: ReadonlySet<string>;
|
|
3
22
|
export interface TokenDataResult {
|
|
4
23
|
/** The flat object (values are canonical strings; `chainId` is a number). */
|
|
5
24
|
data: Record<string, string | number>;
|
|
@@ -30,7 +49,7 @@ export declare function buildTokenData(client: PublicClient | null, state: Proje
|
|
|
30
49
|
/** The canonical serialization: lexicographically sorted keys, compact JSON, UTF-8. */
|
|
31
50
|
export declare function canonicalTokenDataJson(data: Record<string, string | number>): string;
|
|
32
51
|
/**
|
|
33
|
-
* The effect run identity (`
|
|
52
|
+
* The effect run identity (`site/content/docs/protocol/effects.mdx`):
|
|
34
53
|
* `keccak256(contentDigest ‖ canonical tokenData ‖ environmentId)`. Deterministic across
|
|
35
54
|
* producers and consumers — the resolver computes the CURRENT hash and looks up exactly
|
|
36
55
|
* that artifact, so a param change re-addresses output and stale renders are never served.
|
|
@@ -47,4 +66,45 @@ export declare function contentDigestOf(state: ProjectState): Hex | null;
|
|
|
47
66
|
* resolver) agree on where a run's artifacts live, over any storage backend.
|
|
48
67
|
*/
|
|
49
68
|
export declare function renderArtifactKey(chainId: number, address: string, tokenId: string, hash: Hex, outputKey?: string, effectKey?: string): Hex;
|
|
69
|
+
/**
|
|
70
|
+
* The **bound** effect outputs — `site/content/docs/protocol/effects.mdx → Bound vs referenced`. An output is
|
|
71
|
+
* bound iff a binding stitches its *content* into the metadata JSON, which is what decides who holds
|
|
72
|
+
* its bytes:
|
|
73
|
+
*
|
|
74
|
+
* - **bound** (`render/traits` → `attributes`): the serving node holds the content, capped at
|
|
75
|
+
* {@link BOUND_ARTIFACT_MAX_BYTES} and servable only at the current settled `inputsHash`. A
|
|
76
|
+
* locator here cannot work — the content is assembled into `tokenURI`, so a locator would put a
|
|
77
|
+
* third-party fetch on the hottest read the resolver serves.
|
|
78
|
+
* - **referenced** (everything else — `render/image` projects a *URL*, a `video`/`model` only
|
|
79
|
+
* appears in the manifest): the PRODUCER holds the bytes and the node stores a locator. Holding
|
|
80
|
+
* these bytes buys a node no capability (it redirects either way) and costs it an object store.
|
|
81
|
+
*
|
|
82
|
+
* This is the wire rule for `POST /v1/effect-artifacts` in both directions: bytes for a referenced
|
|
83
|
+
* output and a locator for a bound one are each a `400`. Growing this set is an interface change —
|
|
84
|
+
* every serving node must be able to stitch a bound output's content.
|
|
85
|
+
*/
|
|
86
|
+
export declare const BOUND_EFFECT_OUTPUTS: ReadonlySet<string>;
|
|
87
|
+
/** The cap a serving node MUST accept per bound output and MUST refuse above (~100× a real traits
|
|
88
|
+
* payload — generous for JSON, far too small to become blob storage). */
|
|
89
|
+
export declare const BOUND_ARTIFACT_MAX_BYTES: number;
|
|
90
|
+
/** Is `{effectKey}/{outputKey}` a bound output — content the serving node must hold and stitch?
|
|
91
|
+
* Unknown effects answer `false`: an output a node can't stitch is referenced by definition, since
|
|
92
|
+
* bytes it can't stitch are bytes it could only redirect to. */
|
|
93
|
+
export declare function isBoundOutput(effectKey: string, outputKey: string): boolean;
|
|
94
|
+
/** One param's canonical decode, with the blob's SIZE alongside. */
|
|
95
|
+
export interface DecodedParam {
|
|
96
|
+
/** The canonical string — what tokenData carries for this key. */
|
|
97
|
+
value: string;
|
|
98
|
+
/** A data-backed param's full content length in bytes; `null` for a literal, and for a blob
|
|
99
|
+
* that didn't read (the value degraded to the hash). Callers that bound inline content —
|
|
100
|
+
* the off-chain resolver's params handling (spec v8 removed the `abx_params` projection from both lanes), mirroring the renderer's former inline ceiling (removed with the projection) —
|
|
101
|
+
* measure THIS, the same length the chain measures. */
|
|
102
|
+
contentBytes: number | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The canonical per-param decode — the one implementation every off-chain surface shares
|
|
106
|
+
* (tokenData assembly here, `abx_params` in the resolver), so a value reads the same
|
|
107
|
+
* everywhere and stays byte-parallel with the on-chain generator and renderer.
|
|
108
|
+
*/
|
|
109
|
+
export declare function decodeParam(client: PublicClient | null, token: Address, tokenId: string, p: ParamValue, tokenScope: boolean, schema: ParamSchema | undefined): Promise<DecodedParam>;
|
|
50
110
|
//# sourceMappingURL=tokendata.d.ts.map
|
package/dist/tokendata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokendata.d.ts","sourceRoot":"","sources":["../src/tokendata.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"tokendata.d.ts","sourceRoot":"","sources":["../src/tokendata.ts"],"names":[],"mappings":"AAAA,OAAO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F,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,GAAG,IAAI,CAI/D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EACT,SAAS,GAAE,MAAgB,EAC3B,SAAS,SAAW,GACnB,GAAG,CAIL;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAA8B,CAAC;AAEpF;0EAC0E;AAC1E,eAAO,MAAM,wBAAwB,QAAY,CAAC;AAElD;;iEAEiE;AACjE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3E;AAID,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd;;;4DAGwD;IACxD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,UAAU,EACb,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
|
package/dist/tokendata.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { concat, hexToBytes, keccak256, parseAbi, stringToBytes, } from 'viem';
|
|
1
|
+
import { bytesToHex, concat, hexToBytes, keccak256, parseAbi, stringToBytes, } from 'viem';
|
|
2
2
|
import { seriesCodeAbi } from './abi/index.js';
|
|
3
3
|
import { decodeScalarParam } from './spine.js';
|
|
4
|
+
import { bytesToBase64 } from './util.js';
|
|
4
5
|
/**
|
|
5
6
|
* The canonical `tokenData` assembly — the off-chain serializer the spec names as
|
|
6
|
-
* authoritative (`
|
|
7
|
+
* authoritative (`site/content/docs/protocol/code-projects.mdx`). One flat object: the reserved
|
|
7
8
|
* coordinates + every param (contract ∪ token scope, token wins) + the augment hook's
|
|
8
9
|
* entries (augment wins per key), every value its canonical string (`chainId` alone is
|
|
9
10
|
* a number). The serialization is canonical because it is *hashed*: an effect's
|
|
@@ -15,7 +16,16 @@ import { decodeScalarParam } from './spine.js';
|
|
|
15
16
|
* schema is what buys a human decode — `seed` is the canonical example); a data-backed
|
|
16
17
|
* value reads its blob (`String` → UTF-8, `Bytes`/schema-less → base64).
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
/** The tokenData coordinates — never enumerable as params (the on-chain params store excludes
|
|
20
|
+
* `seed` from its key lists, and the generator/renderer skip the other three defensively).
|
|
21
|
+
* Exported because every off-chain surface that enumerates params must exclude exactly this
|
|
22
|
+
* set: two lists that have to agree are one list. */
|
|
23
|
+
export const RESERVED_TOKEN_DATA_KEYS = new Set([
|
|
24
|
+
'chainId',
|
|
25
|
+
'contractAddress',
|
|
26
|
+
'tokenId',
|
|
27
|
+
'seed',
|
|
28
|
+
]);
|
|
19
29
|
const augmentHookAbi = parseAbi([
|
|
20
30
|
'function augmentTokenParams(address token, uint256 tokenId) view returns ((bytes32 key, string value)[])',
|
|
21
31
|
]);
|
|
@@ -60,9 +70,16 @@ export async function buildTokenData(client, state, token, opts = {}) {
|
|
|
60
70
|
for (const p of token.params ?? [])
|
|
61
71
|
merged.set(p.key, { p, tokenScope: true });
|
|
62
72
|
for (const [key, { p, tokenScope }] of merged) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
// Coordinates win. `seed` is the one reserved key allowed through — but only from TOKEN
|
|
74
|
+
// scope, matching the on-chain document exactly: `TokenDataLib.begin` reads
|
|
75
|
+
// `tokenParam(tokenId, "seed")` and never falls back to contract scope. Letting a
|
|
76
|
+
// contract-scope `seed` through here (the merged map holds both scopes) meant an unseeded
|
|
77
|
+
// token carried a seed off-chain that the on-chain generator did not have — the two lanes
|
|
78
|
+
// disagreeing about what a token's seed is, which is the one value they must agree on.
|
|
79
|
+
// Contract-scope `seed` remains settable on-chain by design; it simply is not a token's seed.
|
|
80
|
+
if (RESERVED_TOKEN_DATA_KEYS.has(key) && !(key === 'seed' && tokenScope))
|
|
81
|
+
continue;
|
|
82
|
+
data[key] = (await decodeParam(client, state.address, token.tokenId, p, tokenScope, schemas.get(key))).value;
|
|
66
83
|
}
|
|
67
84
|
// augment hook — last, wins per key (except the reserved coordinates). Skipped for the
|
|
68
85
|
// SETTLED form (opts.augment false): live data belongs in the live view, never in the
|
|
@@ -78,7 +95,7 @@ export async function buildTokenData(client, state, token, opts = {}) {
|
|
|
78
95
|
}));
|
|
79
96
|
for (const e of entries) {
|
|
80
97
|
const key = decodeBytes32Key(e.key);
|
|
81
|
-
if (
|
|
98
|
+
if (RESERVED_TOKEN_DATA_KEYS.has(key))
|
|
82
99
|
continue;
|
|
83
100
|
data[key] = e.value;
|
|
84
101
|
}
|
|
@@ -97,7 +114,7 @@ export function canonicalTokenDataJson(data) {
|
|
|
97
114
|
return JSON.stringify(sorted);
|
|
98
115
|
}
|
|
99
116
|
/**
|
|
100
|
-
* The effect run identity (`
|
|
117
|
+
* The effect run identity (`site/content/docs/protocol/effects.mdx`):
|
|
101
118
|
* `keccak256(contentDigest ‖ canonical tokenData ‖ environmentId)`. Deterministic across
|
|
102
119
|
* producers and consumers — the resolver computes the CURRENT hash and looks up exactly
|
|
103
120
|
* that artifact, so a param change re-addresses output and stale renders are never served.
|
|
@@ -127,20 +144,63 @@ export function contentDigestOf(state) {
|
|
|
127
144
|
export function renderArtifactKey(chainId, address, tokenId, hash, outputKey = 'image', effectKey = 'render') {
|
|
128
145
|
return keccak256(stringToBytes(`${chainId}/${address.toLowerCase()}/${tokenId}/${effectKey}/${hash}/${outputKey}`));
|
|
129
146
|
}
|
|
130
|
-
|
|
131
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The **bound** effect outputs — `site/content/docs/protocol/effects.mdx → Bound vs referenced`. An output is
|
|
149
|
+
* bound iff a binding stitches its *content* into the metadata JSON, which is what decides who holds
|
|
150
|
+
* its bytes:
|
|
151
|
+
*
|
|
152
|
+
* - **bound** (`render/traits` → `attributes`): the serving node holds the content, capped at
|
|
153
|
+
* {@link BOUND_ARTIFACT_MAX_BYTES} and servable only at the current settled `inputsHash`. A
|
|
154
|
+
* locator here cannot work — the content is assembled into `tokenURI`, so a locator would put a
|
|
155
|
+
* third-party fetch on the hottest read the resolver serves.
|
|
156
|
+
* - **referenced** (everything else — `render/image` projects a *URL*, a `video`/`model` only
|
|
157
|
+
* appears in the manifest): the PRODUCER holds the bytes and the node stores a locator. Holding
|
|
158
|
+
* these bytes buys a node no capability (it redirects either way) and costs it an object store.
|
|
159
|
+
*
|
|
160
|
+
* This is the wire rule for `POST /v1/effect-artifacts` in both directions: bytes for a referenced
|
|
161
|
+
* output and a locator for a bound one are each a `400`. Growing this set is an interface change —
|
|
162
|
+
* every serving node must be able to stitch a bound output's content.
|
|
163
|
+
*/
|
|
164
|
+
export const BOUND_EFFECT_OUTPUTS = new Set(['render/traits']);
|
|
165
|
+
/** The cap a serving node MUST accept per bound output and MUST refuse above (~100× a real traits
|
|
166
|
+
* payload — generous for JSON, far too small to become blob storage). */
|
|
167
|
+
export const BOUND_ARTIFACT_MAX_BYTES = 64 * 1024;
|
|
168
|
+
/** Is `{effectKey}/{outputKey}` a bound output — content the serving node must hold and stitch?
|
|
169
|
+
* Unknown effects answer `false`: an output a node can't stitch is referenced by definition, since
|
|
170
|
+
* bytes it can't stitch are bytes it could only redirect to. */
|
|
171
|
+
export function isBoundOutput(effectKey, outputKey) {
|
|
172
|
+
return BOUND_EFFECT_OUTPUTS.has(`${effectKey}/${outputKey}`);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The canonical per-param decode — the one implementation every off-chain surface shares
|
|
176
|
+
* (tokenData assembly here, `abx_params` in the resolver), so a value reads the same
|
|
177
|
+
* everywhere and stays byte-parallel with the on-chain generator and renderer.
|
|
178
|
+
*/
|
|
179
|
+
export async function decodeParam(client, token, tokenId, p, tokenScope, schema) {
|
|
180
|
+
const literal = (value) => ({ value, contentBytes: null });
|
|
132
181
|
if (!p.valueIsHash) {
|
|
182
|
+
// `seed`'s wire format is INVARIANT: always the raw 32-byte hex, schema or no schema. The
|
|
183
|
+
// on-chain side (`TokenDataLib.begin`) emits `toHexString(seed, 32)` unconditionally and never
|
|
184
|
+
// consults a schema, so consulting one here would fork the work. Concretely: a project that
|
|
185
|
+
// lets an authorized party choose the seed value declares a `seed` schema (typically
|
|
186
|
+
// `Uint256Range` — note this is "pick the value", not a re-roll: the caller supplies it), and this
|
|
187
|
+
// decode would then hand the work `"777"` where the on-chain generator hands it
|
|
188
|
+
// `"0x00…0309"` — the same token rendering differently depending on which surface served it.
|
|
189
|
+
// A `seed` schema governs WHO may write it and within what bounds; it does not change how it
|
|
190
|
+
// reads. Checked before the schema branch for exactly that reason.
|
|
191
|
+
if (p.key === 'seed')
|
|
192
|
+
return literal(p.value);
|
|
133
193
|
if (!schema)
|
|
134
|
-
return
|
|
194
|
+
return literal(decodeTagLoose(p.value));
|
|
135
195
|
if (schema.paramType === 'Select') {
|
|
136
196
|
const idx = Number(BigInt(p.value));
|
|
137
|
-
return schema.selectOptions[idx] ?? String(idx);
|
|
197
|
+
return literal(schema.selectOptions[idx] ?? String(idx));
|
|
138
198
|
}
|
|
139
|
-
return decodeScalarParam(schema.paramType, p.value);
|
|
199
|
+
return literal(decodeScalarParam(schema.paramType, p.value));
|
|
140
200
|
}
|
|
141
201
|
// data-backed: read the blob (token scope falls back to contract scope by construction)
|
|
142
202
|
if (!client)
|
|
143
|
-
return p.value; // best-effort floor: the hash itself
|
|
203
|
+
return literal(p.value); // best-effort floor: the hash itself
|
|
144
204
|
try {
|
|
145
205
|
const blob = (await client.readContract({
|
|
146
206
|
address: token,
|
|
@@ -149,14 +209,16 @@ async function decodeParam(client, token, tokenId, p, tokenScope, schema) {
|
|
|
149
209
|
args: tokenScope ? [BigInt(tokenId), keyToBytes32(p.key)] : [keyToBytes32(p.key)],
|
|
150
210
|
}));
|
|
151
211
|
const bytes = hexToBytes(blob);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
212
|
+
const value = schema?.paramType === 'String'
|
|
213
|
+
? new TextDecoder().decode(bytes)
|
|
214
|
+
: bytesToBase64(bytes); // Bytes + schema-less: base64 at read
|
|
215
|
+
return { value, contentBytes: bytes.length };
|
|
155
216
|
}
|
|
156
217
|
catch {
|
|
157
|
-
return p.value;
|
|
218
|
+
return literal(p.value);
|
|
158
219
|
}
|
|
159
220
|
}
|
|
221
|
+
// ── internals ──────────────────────────────────────────────────────────────────
|
|
160
222
|
/** A readable-ASCII `bytes32` literal as its string (e.g. a `display.animation` value). */
|
|
161
223
|
function decodeTagLoose(value) {
|
|
162
224
|
const bytes = hexToBytes(value);
|
|
@@ -173,6 +235,6 @@ function decodeBytes32Key(key) {
|
|
|
173
235
|
function keyToBytes32(key) {
|
|
174
236
|
const bytes = new Uint8Array(32);
|
|
175
237
|
bytes.set(stringToBytes(key).slice(0, 32));
|
|
176
|
-
return
|
|
238
|
+
return bytesToHex(bytes);
|
|
177
239
|
}
|
|
178
240
|
//# sourceMappingURL=tokendata.js.map
|
package/dist/tokendata.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokendata.js","sourceRoot":"","sources":["../src/tokendata.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,aAAa,GAId,MAAM,MAAM,CAAC;AACd,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAqB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tokendata.js","sourceRoot":"","sources":["../src/tokendata.ts"],"names":[],"mappings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AK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAClF,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAQ;IAChC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3C,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
export interface TokenRow {
|
|
3
|
+
tokenId: string;
|
|
4
|
+
/** `null` when `ownerOf` reverts — see {@link lifecycle}, which says WHY it reverted whenever the
|
|
5
|
+
* chain gives enough evidence to tell. Always `null` on an ERC-1155 edition: an id can have many
|
|
6
|
+
* concurrent holders, and *which* holders is not chain-enumerable outside the event log (that's
|
|
7
|
+
* the indexer's job, not a head read). */
|
|
8
|
+
owner: Address | null;
|
|
9
|
+
/**
|
|
10
|
+
* Does a token exist at this id right now — from head reads alone, no event log. The same words the
|
|
11
|
+
* fold uses ({@link TokenState.lifecycle}), plus `'unknown'` for the one case where a head read
|
|
12
|
+
* genuinely cannot say and the log can:
|
|
13
|
+
*
|
|
14
|
+
* - `'live'` — `ownerOf` answered (721), or `totalSupply(id) > 0` (edition).
|
|
15
|
+
* - `'burned'` — 721 only, terminal, and *decidable at head*: `nextTokenId` is a mint frontier that
|
|
16
|
+
* only ever rises, so an id BELOW it whose `ownerOf` reverts was minted and destroyed. A listing
|
|
17
|
+
* enumerates `0 … nextTokenId - 1`, so inside that range a revert IS a burn.
|
|
18
|
+
* - `'unminted'` — 721: at or past the frontier, never issued.
|
|
19
|
+
* - `'no-live-copies'` — editions: `totalSupply(id) == 0`. **The same word the fold uses for the
|
|
20
|
+
* same id**, deliberately: the fold could distinguish never-minted from fully-burned and does not,
|
|
21
|
+
* because the distinction has no consumer (the id can mint again either way). One field name, one
|
|
22
|
+
* value per id, whichever lane produced it.
|
|
23
|
+
* - `'unknown'` — a 1/1 exposes no `nextTokenId`, so a reverting `ownerOf` there is evidence of
|
|
24
|
+
* nothing: it is equally consistent with never-minted and with burned. The log settles it; a head
|
|
25
|
+
* read must not guess. This is the *only* remaining case, and it is why the word exists.
|
|
26
|
+
*
|
|
27
|
+
* The first draft had this lane answer `'unknown'` for an edition at zero while the fold answered
|
|
28
|
+
* `'burned'` for the same id — two values under one field name, which is the sibling-drift class
|
|
29
|
+
* this repo treats as a bug (see {@link TokenState.maxSupply}'s note). Splitting `'burned'` from
|
|
30
|
+
* `'no-live-copies'` is what makes the claim true instead of aspirational.
|
|
31
|
+
*/
|
|
32
|
+
lifecycle: 'live' | 'burned' | 'unminted' | 'no-live-copies' | 'unknown';
|
|
33
|
+
/**
|
|
34
|
+
* The mint-time seed as the raw `bytes32` — exactly what `tokenData` carries. A schema is what
|
|
35
|
+
* buys a human decode and `seed` deliberately has none, so raw hex IS its canonical form.
|
|
36
|
+
* `null` ⇒ no seed set for this token (no seed source, or not minted).
|
|
37
|
+
*/
|
|
38
|
+
seed: Hex | null;
|
|
39
|
+
/**
|
|
40
|
+
* Token-scope params, decoded to their canonical strings. Contract-scope params are listed once
|
|
41
|
+
* on {@link TokenListing.contractParams} rather than repeated per row; the work sees
|
|
42
|
+
* contract ∪ token with **token winning** (see `buildTokenData`, the canonical assembly).
|
|
43
|
+
*/
|
|
44
|
+
params: Record<string, string>;
|
|
45
|
+
/** ERC-1155 editions only — this id's live supply (`totalSupply(id)`), as a decimal string.
|
|
46
|
+
* Absent on a 721 token. */
|
|
47
|
+
supply?: string;
|
|
48
|
+
/** ERC-1155 editions only — this id's current supply cap (`maxSupply(id)`; `"0"` reads as
|
|
49
|
+
* open/uncapped exactly like the contract's own convention). Absent on a 721 token. */
|
|
50
|
+
maxSupply?: string;
|
|
51
|
+
}
|
|
52
|
+
/** What an edition id's cap actually means. `closed` is the state the on-chain getter cannot express
|
|
53
|
+
* (`maxSupply(id)` returns `0` for both "never capped" and "deliberately closed") — see
|
|
54
|
+
* {@link editionCapOf}. */
|
|
55
|
+
export type EditionCap = {
|
|
56
|
+
kind: 'open';
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'capped';
|
|
59
|
+
cap: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'closed';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Read an edition id's cap without re-deriving the rule at each call site — the derivation this
|
|
65
|
+
* protocol got wrong twice, in opposite directions: the on-chain getter overloads `0`, and the
|
|
66
|
+
* event fold used to miss the collection default entirely.
|
|
67
|
+
*
|
|
68
|
+
* Pass a folded {@link TokenState} (from `reconstructProject`) to get all three states. Pass a
|
|
69
|
+
* head-read {@link TokenRow}, which has no `maxSupplyOverridden` because a state read cannot know
|
|
70
|
+
* it, and a `'0'` cap reads `open` — the documented on-chain convention, and the reason
|
|
71
|
+
* `IAbxEditionSupply` tells an integrator rendering a buy button to consult the log.
|
|
72
|
+
*
|
|
73
|
+
* `null` ⇒ no cap information at all (a 721 token, or a row from a projection written before
|
|
74
|
+
* `DefaultMaxSupplySet` was folded).
|
|
75
|
+
*/
|
|
76
|
+
export declare function editionCapOf(token: {
|
|
77
|
+
maxSupply?: string;
|
|
78
|
+
maxSupplyOverridden?: boolean;
|
|
79
|
+
}): EditionCap | null;
|
|
80
|
+
export interface TokenListing {
|
|
81
|
+
chainId: number;
|
|
82
|
+
address: Address;
|
|
83
|
+
/** Ids `0 … nextTokenId - 1` have been minted at some point. `null` on a token type with no
|
|
84
|
+
* sequential mint frontier — a 1/1 (always just token 0), or an ERC-1155 edition (ids are
|
|
85
|
+
* caller-named, not a cursor; see each row's own `supply`/`maxSupply` instead). */
|
|
86
|
+
nextTokenId: number | null;
|
|
87
|
+
/** Live supply (mints − burns) — differs from `nextTokenId` only if tokens were burned. `null`
|
|
88
|
+
* on an edition: there's no unconditional whole-contract total, only a per-id one (each row's
|
|
89
|
+
* `supply`). */
|
|
90
|
+
totalSupply: number | null;
|
|
91
|
+
/** How many tokens have been destroyed: `nextTokenId − totalSupply`, both of which the contract
|
|
92
|
+
* keeps (the frontier counts mints and never falls; the total counts live tokens). `null` when
|
|
93
|
+
* either is absent — a 1/1, or an edition, where burns are per id (each row's `supply`). */
|
|
94
|
+
burnedCount: number | null;
|
|
95
|
+
maxInvocations: number | null;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the contract exposes the params surface at all. `false` for the image token types
|
|
98
|
+
* (they have no Params extension), in which case every row's `seed` is `null` and `params` is
|
|
99
|
+
* empty — correct, not a failed read.
|
|
100
|
+
*/
|
|
101
|
+
hasParams: boolean;
|
|
102
|
+
/** Whether the contract exposes on-chain param *enumeration*. `false` on a project deployed
|
|
103
|
+
* before enumeration shipped: seeds still read (by name), but params can't be listed. */
|
|
104
|
+
hasParamEnumeration: boolean;
|
|
105
|
+
contractParams: Record<string, string>;
|
|
106
|
+
tokens: TokenRow[];
|
|
107
|
+
}
|
|
108
|
+
export interface ListTokensOptions {
|
|
109
|
+
/** Read only this many ids from `from` (default: all). */
|
|
110
|
+
limit?: number;
|
|
111
|
+
/** First token id to read (default 0). */
|
|
112
|
+
from?: number;
|
|
113
|
+
concurrency?: number;
|
|
114
|
+
/** Called after each token resolves — for a progress line on a large collection. */
|
|
115
|
+
onProgress?: (done: number, total: number) => void;
|
|
116
|
+
}
|
|
117
|
+
/** Every token's owner, seed, and params, straight from the contract. */
|
|
118
|
+
export declare function listTokens(client: PublicClient, address: Address, opts?: ListTokensOptions): Promise<TokenListing>;
|
|
119
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAC,MAAM,MAAM,CAAC;AA+B5E,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB;;;+CAG2C;IAC3C,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB;;;;;;;;;;;;;;;;;;;;;;MAsBE;IACH,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACzE;;;;OAIG;IACH,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B;iCAC6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;4FACwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;4BAE4B;AAC5B,MAAM,MAAM,UAAU,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAC,CAAC;AAE3F;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAC,GAAG,UAAU,GAAG,IAAI,CAI1G;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