@artblocks/abx-sdk 0.1.0-alpha.2 → 0.1.0-alpha.20
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/README.md +131 -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 +266 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +653 -0
- package/dist/anchors.js.map +1 -0
- package/dist/chains.d.ts +15 -9
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +19 -15
- package/dist/chains.js.map +1 -1
- package/dist/chunks.d.ts +53 -23
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +68 -6
- 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 +85 -1
- package/dist/create2.d.ts.map +1 -1
- package/dist/create2.js +159 -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 +12 -0
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +155 -28
- package/dist/deployments.js.map +1 -1
- package/dist/deps.d.ts +122 -5
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +248 -6
- package/dist/deps.js.map +1 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +8 -0
- package/dist/env.js.map +1 -1
- package/dist/errors.d.ts +94 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +126 -0
- package/dist/errors.js.map +1 -0
- package/dist/execute.d.ts +115 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +142 -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 +58 -0
- package/dist/generator-document.d.ts.map +1 -0
- package/dist/generator-document.js +124 -0
- package/dist/generator-document.js.map +1 -0
- package/dist/generator.d.ts +43 -1
- 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 +17 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -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 +140 -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 +10 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +24 -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 +273 -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 +848 -32
- package/dist/ops.js.map +1 -1
- package/dist/probe.d.ts +29 -0
- package/dist/probe.d.ts.map +1 -1
- package/dist/probe.js +104 -9
- package/dist/probe.js.map +1 -1
- package/dist/reconstruct.d.ts +92 -2
- package/dist/reconstruct.d.ts.map +1 -1
- package/dist/reconstruct.js +378 -93
- package/dist/reconstruct.js.map +1 -1
- package/dist/resume.d.ts +96 -0
- package/dist/resume.d.ts.map +1 -0
- package/dist/resume.js +95 -0
- package/dist/resume.js.map +1 -0
- package/dist/script-chunks.d.ts +24 -0
- package/dist/script-chunks.d.ts.map +1 -0
- package/dist/script-chunks.js +63 -0
- package/dist/script-chunks.js.map +1 -0
- package/dist/service.d.ts +188 -9
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +228 -18
- package/dist/service.js.map +1 -1
- package/dist/spine.d.ts +31 -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 +124 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +134 -0
- package/dist/staging.js.map +1 -0
- package/dist/tokendata.d.ts +62 -2
- package/dist/tokendata.d.ts.map +1 -1
- package/dist/tokendata.js +79 -17
- package/dist/tokendata.js.map +1 -1
- package/dist/tokens.d.ts +94 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +296 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +60 -3
- 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 +10 -2
package/dist/tokendata.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
7
|
* authoritative (`specs/protocol/code-projects.md`). One flat object: the reserved
|
|
@@ -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
|
}
|
|
@@ -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 — `specs/protocol/effects.md → 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":"AAAA,OAAO,EACL,UAAU,EACV,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;AAEjE,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AAExC;;;;;;;;;;;;;GAaG;AAEH;;;sDAGsD;AACtD,MAAM,CAAC,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC;IACnE,SAAS;IACT,iBAAiB;IACjB,SAAS;IACT,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,QAAQ,CAAC;IAC9B,0GAA0G;CAC3G,CAAC,CAAC;AASH,6FAA6F;AAC7F,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,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AC,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,94 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
export interface TokenRow {
|
|
3
|
+
tokenId: string;
|
|
4
|
+
/**
|
|
5
|
+
* `null` when `ownerOf` reverts. That is deliberately NOT reported as "not minted": an id past
|
|
6
|
+
* the mint frontier and a **burned** id both revert identically, and a chain-only read cannot
|
|
7
|
+
* tell them apart without the Transfer log it is the point of this path not to need. Always
|
|
8
|
+
* `null` on an ERC-1155 edition — an id can have many concurrent holders, and *which* holders
|
|
9
|
+
* is not chain-enumerable outside the event log (that's the indexer's job, not a head read).
|
|
10
|
+
*/
|
|
11
|
+
owner: Address | null;
|
|
12
|
+
/**
|
|
13
|
+
* The mint-time seed as the raw `bytes32` — exactly what `tokenData` carries. A schema is what
|
|
14
|
+
* buys a human decode and `seed` deliberately has none, so raw hex IS its canonical form.
|
|
15
|
+
* `null` ⇒ no seed set for this token (no seed source, or not minted).
|
|
16
|
+
*/
|
|
17
|
+
seed: Hex | null;
|
|
18
|
+
/**
|
|
19
|
+
* Token-scope params, decoded to their canonical strings. Contract-scope params are listed once
|
|
20
|
+
* on {@link TokenListing.contractParams} rather than repeated per row; the work sees
|
|
21
|
+
* contract ∪ token with **token winning** (see `buildTokenData`, the canonical assembly).
|
|
22
|
+
*/
|
|
23
|
+
params: Record<string, string>;
|
|
24
|
+
/** ERC-1155 editions only — this id's live supply (`totalSupply(id)`), as a decimal string.
|
|
25
|
+
* Absent on a 721 token. */
|
|
26
|
+
supply?: string;
|
|
27
|
+
/** ERC-1155 editions only — this id's current supply cap (`maxSupply(id)`; `"0"` reads as
|
|
28
|
+
* open/uncapped exactly like the contract's own convention). Absent on a 721 token. */
|
|
29
|
+
maxSupply?: string;
|
|
30
|
+
}
|
|
31
|
+
/** What an edition id's cap actually means. `closed` is the state the on-chain getter cannot express
|
|
32
|
+
* (`maxSupply(id)` returns `0` for both "never capped" and "deliberately closed") — see
|
|
33
|
+
* {@link editionCapOf}. */
|
|
34
|
+
export type EditionCap = {
|
|
35
|
+
kind: 'open';
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'capped';
|
|
38
|
+
cap: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'closed';
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Read an edition id's cap without re-deriving the rule at each call site — the derivation this
|
|
44
|
+
* protocol got wrong twice, in opposite directions: the on-chain getter overloads `0`, and the
|
|
45
|
+
* event fold used to miss the collection default entirely.
|
|
46
|
+
*
|
|
47
|
+
* Pass a folded {@link TokenState} (from `reconstructProject`) to get all three states. Pass a
|
|
48
|
+
* head-read {@link TokenRow}, which has no `maxSupplyOverridden` because a state read cannot know
|
|
49
|
+
* it, and a `'0'` cap reads `open` — the documented on-chain convention, and the reason
|
|
50
|
+
* `IAbxEditionSupply` tells an integrator rendering a buy button to consult the log.
|
|
51
|
+
*
|
|
52
|
+
* `null` ⇒ no cap information at all (a 721 token, or a row from a projection written before
|
|
53
|
+
* `DefaultMaxSupplySet` was folded).
|
|
54
|
+
*/
|
|
55
|
+
export declare function editionCapOf(token: {
|
|
56
|
+
maxSupply?: string;
|
|
57
|
+
maxSupplyOverridden?: boolean;
|
|
58
|
+
}): EditionCap | null;
|
|
59
|
+
export interface TokenListing {
|
|
60
|
+
chainId: number;
|
|
61
|
+
address: Address;
|
|
62
|
+
/** Ids `0 … nextTokenId - 1` have been minted at some point. `null` on a token type with no
|
|
63
|
+
* sequential mint frontier — a 1/1 (always just token 0), or an ERC-1155 edition (ids are
|
|
64
|
+
* caller-named, not a cursor; see each row's own `supply`/`maxSupply` instead). */
|
|
65
|
+
nextTokenId: number | null;
|
|
66
|
+
/** Live supply (mints − burns) — differs from `nextTokenId` only if tokens were burned. `null`
|
|
67
|
+
* on an edition: there's no unconditional whole-contract total, only a per-id one (each row's
|
|
68
|
+
* `supply`). */
|
|
69
|
+
totalSupply: number | null;
|
|
70
|
+
maxInvocations: number | null;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the contract exposes the params surface at all. `false` for the image token types
|
|
73
|
+
* (they have no Params extension), in which case every row's `seed` is `null` and `params` is
|
|
74
|
+
* empty — correct, not a failed read.
|
|
75
|
+
*/
|
|
76
|
+
hasParams: boolean;
|
|
77
|
+
/** Whether the contract exposes on-chain param *enumeration*. `false` on a project deployed
|
|
78
|
+
* before enumeration shipped: seeds still read (by name), but params can't be listed. */
|
|
79
|
+
hasParamEnumeration: boolean;
|
|
80
|
+
contractParams: Record<string, string>;
|
|
81
|
+
tokens: TokenRow[];
|
|
82
|
+
}
|
|
83
|
+
export interface ListTokensOptions {
|
|
84
|
+
/** Read only this many ids from `from` (default: all). */
|
|
85
|
+
limit?: number;
|
|
86
|
+
/** First token id to read (default 0). */
|
|
87
|
+
from?: number;
|
|
88
|
+
concurrency?: number;
|
|
89
|
+
/** Called after each token resolves — for a progress line on a large collection. */
|
|
90
|
+
onProgress?: (done: number, total: number) => void;
|
|
91
|
+
}
|
|
92
|
+
/** Every token's owner, seed, and params, straight from the contract. */
|
|
93
|
+
export declare function listTokens(client: PublicClient, address: Address, opts?: ListTokensOptions): Promise<TokenListing>;
|
|
94
|
+
//# 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;;;;;;OAMG;IACH,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB;;;;OAIG;IACH,IAAI,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AAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAiCD,yEAAyE;AACzE,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAwFvB"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { zeroAddress } from 'viem';
|
|
2
|
+
import { editionCodeAbi, seriesCodeAbi } from './abi/index.js';
|
|
3
|
+
import { readParamSchema } from './ops.js';
|
|
4
|
+
import { AUTH_OPTIONS, decodeTag, encodeTag, PARAM_TYPES } from './spine.js';
|
|
5
|
+
import { decodeParam } from './tokendata.js';
|
|
6
|
+
/**
|
|
7
|
+
* The whole collection's tokens — seeds, owners, and params — read **from chain alone**.
|
|
8
|
+
*
|
|
9
|
+
* No indexer projection, no event scan, no running resolver: every input is a plain `eth_call`
|
|
10
|
+
* against the token contract, because the params store maintains its own key lists inside its
|
|
11
|
+
* write paths (`tokenParamKeys` / `contractParamKeys`) and the seed is just a reserved param.
|
|
12
|
+
* That matters for the question this answers — *for a generative collection the seed list IS the
|
|
13
|
+
* collection* — since it means the answer is available to anyone with an RPC URL, including
|
|
14
|
+
* before any indexing has happened, and it can never disagree with the chain.
|
|
15
|
+
*
|
|
16
|
+
* Deliberately not built on {@link reconstructProject}: that folds the event spine (a `getLogs`
|
|
17
|
+
* range scan, which a range-capped RPC can refuse) to recover *structure*. Here every value
|
|
18
|
+
* wanted is a head read, so a scan would be strictly more fragile for strictly less.
|
|
19
|
+
*/
|
|
20
|
+
/** The reserved param the seed source writes at mint. Never in the enumerable key lists (every
|
|
21
|
+
* consumer reads it as a tokenData coordinate), so it is read by name. */
|
|
22
|
+
const SEED_KEY = 'seed';
|
|
23
|
+
/** How many tokens to read concurrently. Each token costs ~2 + (params) `eth_call`s, so a
|
|
24
|
+
* 1000-token collection is a few thousand reads — wide enough to be quick, narrow enough that a
|
|
25
|
+
* free-tier RPC doesn't rate-limit. */
|
|
26
|
+
const DEFAULT_CONCURRENCY = 8;
|
|
27
|
+
/**
|
|
28
|
+
* Read an edition id's cap without re-deriving the rule at each call site — the derivation this
|
|
29
|
+
* protocol got wrong twice, in opposite directions: the on-chain getter overloads `0`, and the
|
|
30
|
+
* event fold used to miss the collection default entirely.
|
|
31
|
+
*
|
|
32
|
+
* Pass a folded {@link TokenState} (from `reconstructProject`) to get all three states. Pass a
|
|
33
|
+
* head-read {@link TokenRow}, which has no `maxSupplyOverridden` because a state read cannot know
|
|
34
|
+
* it, and a `'0'` cap reads `open` — the documented on-chain convention, and the reason
|
|
35
|
+
* `IAbxEditionSupply` tells an integrator rendering a buy button to consult the log.
|
|
36
|
+
*
|
|
37
|
+
* `null` ⇒ no cap information at all (a 721 token, or a row from a projection written before
|
|
38
|
+
* `DefaultMaxSupplySet` was folded).
|
|
39
|
+
*/
|
|
40
|
+
export function editionCapOf(token) {
|
|
41
|
+
if (token.maxSupply === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
if (token.maxSupply !== '0')
|
|
44
|
+
return { kind: 'capped', cap: token.maxSupply };
|
|
45
|
+
return token.maxSupplyOverridden ? { kind: 'closed' } : { kind: 'open' };
|
|
46
|
+
}
|
|
47
|
+
/** Minimal ERC-165 fragment — shared by any capability check that only needs `supportsInterface`
|
|
48
|
+
* (no need to pull in a whole token ABI just for this one function). */
|
|
49
|
+
const ERC165_PROBE_ABI = [
|
|
50
|
+
{
|
|
51
|
+
type: 'function',
|
|
52
|
+
name: 'supportsInterface',
|
|
53
|
+
stateMutability: 'view',
|
|
54
|
+
inputs: [{ name: 'interfaceId', type: 'bytes4' }],
|
|
55
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
/** The standard's own ERC-165 id — the cheapest capability check that can never collide with a
|
|
59
|
+
* 721 token (which doesn't implement ERC-1155 at all, so this reverts/returns false there). */
|
|
60
|
+
const ERC1155_INTERFACE_ID = '0xd9b67a26';
|
|
61
|
+
/** Whether `address` is an ERC-1155 edition (vs. the 721 family) — the probe {@link listTokens}
|
|
62
|
+
* branches on before choosing its read path. */
|
|
63
|
+
async function probeIsEdition(client, address) {
|
|
64
|
+
try {
|
|
65
|
+
return (await client.readContract({
|
|
66
|
+
address,
|
|
67
|
+
abi: ERC165_PROBE_ABI,
|
|
68
|
+
functionName: 'supportsInterface',
|
|
69
|
+
args: [ERC1155_INTERFACE_ID],
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Every token's owner, seed, and params, straight from the contract. */
|
|
77
|
+
export async function listTokens(client, address, opts = {}) {
|
|
78
|
+
if (await probeIsEdition(client, address))
|
|
79
|
+
return listEditionTokens(client, address, opts);
|
|
80
|
+
const read = async (functionName, args = []) => {
|
|
81
|
+
try {
|
|
82
|
+
// dynamic dispatch over the superset ABI — cast past viem's literal-name inference. Every
|
|
83
|
+
// getter here is absent on at least one token type, so the try/catch IS the capability probe.
|
|
84
|
+
return (await client.readContract({ address, abi: seriesCodeAbi, functionName, args }));
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null; // absent on this token type, or an unminted id — the caller decides what that means
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const [chainId, nextTokenId, totalSupply, maxInvocations, contractKeys] = await Promise.all([
|
|
91
|
+
client.getChainId(),
|
|
92
|
+
read('nextTokenId'),
|
|
93
|
+
read('totalSupply'),
|
|
94
|
+
read('maxInvocations'),
|
|
95
|
+
read('contractParamKeys'),
|
|
96
|
+
]);
|
|
97
|
+
// The params surface is probed by a read that only a params-bearing token answers. `seed` is the
|
|
98
|
+
// cheapest such probe that works on a LEGACY project too (deployed before enumeration shipped),
|
|
99
|
+
// so the two capabilities are detected separately rather than collapsed.
|
|
100
|
+
const seedProbe = await read('tokenParam', [0n, encodeTag(SEED_KEY)]);
|
|
101
|
+
const hasParams = seedProbe !== null || contractKeys !== null;
|
|
102
|
+
const hasParamEnumeration = contractKeys !== null;
|
|
103
|
+
// Schemas are read once per key and shared across every token — on a 1000-token collection this
|
|
104
|
+
// is the difference between one read per key and one per key PER TOKEN.
|
|
105
|
+
const schemaCache = new Map();
|
|
106
|
+
const schemaOf = (key) => {
|
|
107
|
+
let hit = schemaCache.get(key);
|
|
108
|
+
if (!hit) {
|
|
109
|
+
hit = schemaFor(client, address, key);
|
|
110
|
+
schemaCache.set(key, hit);
|
|
111
|
+
}
|
|
112
|
+
return hit;
|
|
113
|
+
};
|
|
114
|
+
const contractParams = {};
|
|
115
|
+
for (const raw of contractKeys ?? []) {
|
|
116
|
+
const key = decodeTag(raw);
|
|
117
|
+
const slot = await read('contractParam', [raw]);
|
|
118
|
+
if (!slot?.[2])
|
|
119
|
+
continue; // not set
|
|
120
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
121
|
+
contractParams[key] = (await decodeParam(client, address, '0', p, false, await schemaOf(key))).value;
|
|
122
|
+
}
|
|
123
|
+
// The id range. `nextTokenId` is the mint frontier; a 1/1 has none and is always token 0 alone.
|
|
124
|
+
const count = nextTokenId !== null ? Number(nextTokenId) : totalSupply !== null ? Number(totalSupply) : 1;
|
|
125
|
+
const from = Math.max(0, opts.from ?? 0);
|
|
126
|
+
const end = opts.limit === undefined ? count : Math.min(count, from + Math.max(0, opts.limit));
|
|
127
|
+
const ids = Array.from({ length: Math.max(0, end - from) }, (_, i) => from + i);
|
|
128
|
+
let done = 0;
|
|
129
|
+
const tokens = await pool(ids, opts.concurrency ?? DEFAULT_CONCURRENCY, async (id) => {
|
|
130
|
+
const tokenId = String(id);
|
|
131
|
+
const [owner, seedSlot, keys] = await Promise.all([
|
|
132
|
+
read('ownerOf', [BigInt(id)]),
|
|
133
|
+
hasParams ? read('tokenParam', [BigInt(id), encodeTag(SEED_KEY)]) : null,
|
|
134
|
+
hasParamEnumeration ? read('tokenParamKeys', [BigInt(id)]) : null,
|
|
135
|
+
]);
|
|
136
|
+
const params = {};
|
|
137
|
+
for (const raw of keys ?? []) {
|
|
138
|
+
const key = decodeTag(raw);
|
|
139
|
+
const slot = await read('tokenParam', [BigInt(id), raw]);
|
|
140
|
+
if (!slot?.[2])
|
|
141
|
+
continue;
|
|
142
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
143
|
+
params[key] = (await decodeParam(client, address, tokenId, p, true, await schemaOf(key))).value;
|
|
144
|
+
}
|
|
145
|
+
opts.onProgress?.(++done, ids.length);
|
|
146
|
+
return { tokenId, owner, seed: seedSlot?.[2] ? seedSlot[0] : null, params };
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
chainId,
|
|
150
|
+
address,
|
|
151
|
+
nextTokenId: nextTokenId === null ? null : Number(nextTokenId),
|
|
152
|
+
totalSupply: totalSupply === null ? null : Number(totalSupply),
|
|
153
|
+
maxInvocations: maxInvocations === null ? null : Number(maxInvocations),
|
|
154
|
+
hasParams,
|
|
155
|
+
hasParamEnumeration,
|
|
156
|
+
contractParams,
|
|
157
|
+
tokens,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The edition (ERC-1155) path {@link listTokens} delegates to once {@link probeIsEdition} says
|
|
162
|
+
* yes — a parallel implementation, not a set of `if (isEdition)` branches threaded through the
|
|
163
|
+
* 721 path above, so that path stays byte-identical. Reads against `editionCodeAbi` (the
|
|
164
|
+
* narrowest-common-superset ABI for the family, same role `seriesCodeAbi` plays on the 721
|
|
165
|
+
* side): per id, `totalSupply(id)`/`maxSupply(id)` instead of `ownerOf` — `owner` is always
|
|
166
|
+
* `null` here (a multi-holder id has no single owner, and *which* holders isn't chain-enumerable
|
|
167
|
+
* outside the event log). `params`/`seed` still apply — EditionCode composes the same Params/
|
|
168
|
+
* ConfigurableParams extensions as SeriesCode, unchanged — but are absent (every read reverts,
|
|
169
|
+
* same honest "absent" answer as a 1/1 image) on `OneOfOneEdition`/`EditionImage`.
|
|
170
|
+
*/
|
|
171
|
+
async function listEditionTokens(client, address, opts) {
|
|
172
|
+
const read = async (functionName, args = []) => {
|
|
173
|
+
try {
|
|
174
|
+
return (await client.readContract({ address, abi: editionCodeAbi, functionName, args }));
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const [chainId, maxInvocations, contractKeys] = await Promise.all([
|
|
181
|
+
client.getChainId(),
|
|
182
|
+
read('maxInvocations'), // absent on OneOfOneEdition — its id space is fixed to {0}
|
|
183
|
+
read('contractParamKeys'),
|
|
184
|
+
]);
|
|
185
|
+
const seedProbe = await read('tokenParam', [0n, encodeTag(SEED_KEY)]);
|
|
186
|
+
const hasParams = seedProbe !== null || contractKeys !== null;
|
|
187
|
+
const hasParamEnumeration = contractKeys !== null;
|
|
188
|
+
const schemaCache = new Map();
|
|
189
|
+
const schemaOf = (key) => {
|
|
190
|
+
let hit = schemaCache.get(key);
|
|
191
|
+
if (!hit) {
|
|
192
|
+
hit = schemaFor(client, address, key);
|
|
193
|
+
schemaCache.set(key, hit);
|
|
194
|
+
}
|
|
195
|
+
return hit;
|
|
196
|
+
};
|
|
197
|
+
const contractParams = {};
|
|
198
|
+
for (const raw of contractKeys ?? []) {
|
|
199
|
+
const key = decodeTag(raw);
|
|
200
|
+
const slot = await read('contractParam', [raw]);
|
|
201
|
+
if (!slot?.[2])
|
|
202
|
+
continue;
|
|
203
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
204
|
+
contractParams[key] = (await decodeParam(client, address, '0', p, false, await schemaOf(key))).value;
|
|
205
|
+
}
|
|
206
|
+
// The id space: the id-space cap (`maxInvocations`) when the token has one (EditionImage/
|
|
207
|
+
// EditionCode); `OneOfOneEdition` has no id-space extension at all — its id space is the
|
|
208
|
+
// single work, id 0 alone (mirrors the 1/1 count fallback on the 721 path above).
|
|
209
|
+
const count = maxInvocations !== null ? Number(maxInvocations) : 1;
|
|
210
|
+
const from = Math.max(0, opts.from ?? 0);
|
|
211
|
+
const end = opts.limit === undefined ? count : Math.min(count, from + Math.max(0, opts.limit));
|
|
212
|
+
const ids = Array.from({ length: Math.max(0, end - from) }, (_, i) => from + i);
|
|
213
|
+
let done = 0;
|
|
214
|
+
const tokens = await pool(ids, opts.concurrency ?? DEFAULT_CONCURRENCY, async (id) => {
|
|
215
|
+
const tokenId = String(id);
|
|
216
|
+
const [supply, maxSupply, seedSlot, keys] = await Promise.all([
|
|
217
|
+
read('totalSupply', [BigInt(id)]),
|
|
218
|
+
read('maxSupply', [BigInt(id)]),
|
|
219
|
+
hasParams ? read('tokenParam', [BigInt(id), encodeTag(SEED_KEY)]) : null,
|
|
220
|
+
hasParamEnumeration ? read('tokenParamKeys', [BigInt(id)]) : null,
|
|
221
|
+
]);
|
|
222
|
+
const params = {};
|
|
223
|
+
for (const raw of keys ?? []) {
|
|
224
|
+
const key = decodeTag(raw);
|
|
225
|
+
const slot = await read('tokenParam', [BigInt(id), raw]);
|
|
226
|
+
if (!slot?.[2])
|
|
227
|
+
continue;
|
|
228
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
229
|
+
params[key] = (await decodeParam(client, address, tokenId, p, true, await schemaOf(key))).value;
|
|
230
|
+
}
|
|
231
|
+
opts.onProgress?.(++done, ids.length);
|
|
232
|
+
return {
|
|
233
|
+
tokenId,
|
|
234
|
+
owner: null, // not chain-enumerable for a multi-holder id — indexer territory
|
|
235
|
+
seed: seedSlot?.[2] ? seedSlot[0] : null,
|
|
236
|
+
params,
|
|
237
|
+
supply: supply === null ? undefined : supply.toString(),
|
|
238
|
+
maxSupply: maxSupply === null ? undefined : maxSupply.toString(),
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
return {
|
|
242
|
+
chainId,
|
|
243
|
+
address,
|
|
244
|
+
nextTokenId: null, // editions have no sequential mint cursor — ids are caller-named
|
|
245
|
+
totalSupply: null, // no unconditional whole-contract total; supply is per id (see each row)
|
|
246
|
+
maxInvocations: maxInvocations === null ? null : Number(maxInvocations),
|
|
247
|
+
hasParams,
|
|
248
|
+
hasParamEnumeration,
|
|
249
|
+
contractParams,
|
|
250
|
+
tokens,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* One key's declared schema in the shape {@link decodeParam} wants, or `undefined` when the key is
|
|
255
|
+
* un-governed or the contract has no schema surface. A schema-less param is a normal, supported
|
|
256
|
+
* state — its value simply stays raw, which is exactly what `seed` relies on.
|
|
257
|
+
*
|
|
258
|
+
* Delegates the read to {@link readParamSchema} (the one implementation, which also backs the
|
|
259
|
+
* read-modify-write in `set-schema`) and only maps its numeric enums onto their canonical names.
|
|
260
|
+
*/
|
|
261
|
+
async function schemaFor(client, address, key) {
|
|
262
|
+
try {
|
|
263
|
+
const s = await readParamSchema(client, address, key);
|
|
264
|
+
if (!s.exists)
|
|
265
|
+
return undefined;
|
|
266
|
+
return {
|
|
267
|
+
key,
|
|
268
|
+
paramType: PARAM_TYPES[s.paramType] ?? String(s.paramType),
|
|
269
|
+
auth: AUTH_OPTIONS[s.auth] ?? String(s.auth),
|
|
270
|
+
authAddress: s.authAddress === zeroAddress ? null : s.authAddress,
|
|
271
|
+
lockAfter: String(s.lockAfter),
|
|
272
|
+
min: s.min,
|
|
273
|
+
max: s.max,
|
|
274
|
+
selectOptions: s.selectOptions,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return undefined; // no schema surface on this token type
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/** Bounded-concurrency map, order-preserving. */
|
|
282
|
+
async function pool(items, width, fn) {
|
|
283
|
+
const out = new Array(items.length);
|
|
284
|
+
let next = 0;
|
|
285
|
+
const workers = Array.from({ length: Math.max(1, Math.min(width, items.length)) }, async () => {
|
|
286
|
+
for (;;) {
|
|
287
|
+
const i = next++;
|
|
288
|
+
if (i >= items.length)
|
|
289
|
+
return;
|
|
290
|
+
out[i] = await fn(items[i]);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
await Promise.all(workers);
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAA4C,MAAM,MAAM,CAAC;AAC5E,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;;;;;;GAaG;AAEH;2EAC2E;AAC3E,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;wCAEwC;AACxC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAqC9B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,KAA0D;IACrF,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC/C,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG;QAAE,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAC,CAAC;IAC3E,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;AACvE,CAAC;AAqCD;yEACyE;AACzE,MAAM,gBAAgB,GAAG;IACvB;QACE,IAAI,EAAE,UAAU;QAChB,I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