@artblocks/abx-sdk 0.1.0-alpha.0 → 0.1.0-alpha.10
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 +585 -12
- package/dist/abi/generated.d.ts.map +1 -1
- package/dist/abi/generated.js +16 -16
- package/dist/abi/generated.js.map +1 -1
- package/dist/abi/index.d.ts +209 -12
- package/dist/abi/index.d.ts.map +1 -1
- package/dist/anchors.d.ts +150 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +290 -0
- package/dist/anchors.js.map +1 -0
- package/dist/chains.d.ts +34 -9
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +45 -18
- 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/creator-token.d.ts +65 -0
- package/dist/creator-token.d.ts.map +1 -0
- package/dist/creator-token.js +93 -0
- package/dist/creator-token.js.map +1 -0
- package/dist/deploy.d.ts +24 -10
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +62 -87
- package/dist/deploy.js.map +1 -1
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +38 -22
- package/dist/deployments.js.map +1 -1
- package/dist/deps.d.ts +38 -0
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +70 -1
- package/dist/deps.js.map +1 -1
- package/dist/env.d.ts +11 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +42 -2
- package/dist/env.js.map +1 -1
- package/dist/errors.d.ts +63 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -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/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- 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 +290 -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/node.d.ts +13 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +13 -0
- package/dist/node.js.map +1 -0
- package/dist/onchain-uri.d.ts +96 -0
- package/dist/onchain-uri.d.ts.map +1 -0
- package/dist/onchain-uri.js +231 -0
- package/dist/onchain-uri.js.map +1 -0
- package/dist/ops.d.ts +113 -5
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +172 -13
- package/dist/ops.js.map +1 -1
- package/dist/reconstruct.d.ts +20 -1
- package/dist/reconstruct.d.ts.map +1 -1
- package/dist/reconstruct.js +124 -50
- 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/service.d.ts +369 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +376 -0
- package/dist/service.js.map +1 -0
- package/dist/staging.d.ts +95 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +57 -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 +60 -16
- package/dist/tokendata.js.map +1 -1
- package/dist/tokens.d.ts +55 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +152 -0
- package/dist/tokens.js.map +1 -0
- package/dist/util.d.ts +59 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +89 -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,9 @@ 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
|
-
if (
|
|
73
|
+
if (RESERVED_TOKEN_DATA_KEYS.has(key) && key !== 'seed')
|
|
64
74
|
continue; // coordinates win
|
|
65
|
-
data[key] = await decodeParam(client, state.address, token.tokenId, p, tokenScope, schemas.get(key));
|
|
75
|
+
data[key] = (await decodeParam(client, state.address, token.tokenId, p, tokenScope, schemas.get(key))).value;
|
|
66
76
|
}
|
|
67
77
|
// augment hook — last, wins per key (except the reserved coordinates). Skipped for the
|
|
68
78
|
// SETTLED form (opts.augment false): live data belongs in the live view, never in the
|
|
@@ -78,7 +88,7 @@ export async function buildTokenData(client, state, token, opts = {}) {
|
|
|
78
88
|
}));
|
|
79
89
|
for (const e of entries) {
|
|
80
90
|
const key = decodeBytes32Key(e.key);
|
|
81
|
-
if (
|
|
91
|
+
if (RESERVED_TOKEN_DATA_KEYS.has(key))
|
|
82
92
|
continue;
|
|
83
93
|
data[key] = e.value;
|
|
84
94
|
}
|
|
@@ -127,20 +137,52 @@ export function contentDigestOf(state) {
|
|
|
127
137
|
export function renderArtifactKey(chainId, address, tokenId, hash, outputKey = 'image', effectKey = 'render') {
|
|
128
138
|
return keccak256(stringToBytes(`${chainId}/${address.toLowerCase()}/${tokenId}/${effectKey}/${hash}/${outputKey}`));
|
|
129
139
|
}
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
/**
|
|
141
|
+
* The **bound** effect outputs — `specs/protocol/effects.md → Bound vs referenced`. An output is
|
|
142
|
+
* bound iff a binding stitches its *content* into the metadata JSON, which is what decides who holds
|
|
143
|
+
* its bytes:
|
|
144
|
+
*
|
|
145
|
+
* - **bound** (`render/traits` → `attributes`): the serving node holds the content, capped at
|
|
146
|
+
* {@link BOUND_ARTIFACT_MAX_BYTES} and servable only at the current settled `inputsHash`. A
|
|
147
|
+
* locator here cannot work — the content is assembled into `tokenURI`, so a locator would put a
|
|
148
|
+
* third-party fetch on the hottest read the resolver serves.
|
|
149
|
+
* - **referenced** (everything else — `render/image` projects a *URL*, a `video`/`model` only
|
|
150
|
+
* appears in the manifest): the PRODUCER holds the bytes and the node stores a locator. Holding
|
|
151
|
+
* these bytes buys a node no capability (it redirects either way) and costs it an object store.
|
|
152
|
+
*
|
|
153
|
+
* This is the wire rule for `POST /v1/effect-artifacts` in both directions: bytes for a referenced
|
|
154
|
+
* output and a locator for a bound one are each a `400`. Growing this set is an interface change —
|
|
155
|
+
* every serving node must be able to stitch a bound output's content.
|
|
156
|
+
*/
|
|
157
|
+
export const BOUND_EFFECT_OUTPUTS = new Set(['render/traits']);
|
|
158
|
+
/** The cap a serving node MUST accept per bound output and MUST refuse above (~100× a real traits
|
|
159
|
+
* payload — generous for JSON, far too small to become blob storage). */
|
|
160
|
+
export const BOUND_ARTIFACT_MAX_BYTES = 64 * 1024;
|
|
161
|
+
/** Is `{effectKey}/{outputKey}` a bound output — content the serving node must hold and stitch?
|
|
162
|
+
* Unknown effects answer `false`: an output a node can't stitch is referenced by definition, since
|
|
163
|
+
* bytes it can't stitch are bytes it could only redirect to. */
|
|
164
|
+
export function isBoundOutput(effectKey, outputKey) {
|
|
165
|
+
return BOUND_EFFECT_OUTPUTS.has(`${effectKey}/${outputKey}`);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The canonical per-param decode — the one implementation every off-chain surface shares
|
|
169
|
+
* (tokenData assembly here, `abx_params` in the resolver), so a value reads the same
|
|
170
|
+
* everywhere and stays byte-parallel with the on-chain generator and renderer.
|
|
171
|
+
*/
|
|
172
|
+
export async function decodeParam(client, token, tokenId, p, tokenScope, schema) {
|
|
173
|
+
const literal = (value) => ({ value, contentBytes: null });
|
|
132
174
|
if (!p.valueIsHash) {
|
|
133
175
|
if (!schema)
|
|
134
|
-
return p.key === 'seed' ? p.value : decodeTagLoose(p.value);
|
|
176
|
+
return literal(p.key === 'seed' ? p.value : decodeTagLoose(p.value));
|
|
135
177
|
if (schema.paramType === 'Select') {
|
|
136
178
|
const idx = Number(BigInt(p.value));
|
|
137
|
-
return schema.selectOptions[idx] ?? String(idx);
|
|
179
|
+
return literal(schema.selectOptions[idx] ?? String(idx));
|
|
138
180
|
}
|
|
139
|
-
return decodeScalarParam(schema.paramType, p.value);
|
|
181
|
+
return literal(decodeScalarParam(schema.paramType, p.value));
|
|
140
182
|
}
|
|
141
183
|
// data-backed: read the blob (token scope falls back to contract scope by construction)
|
|
142
184
|
if (!client)
|
|
143
|
-
return p.value; // best-effort floor: the hash itself
|
|
185
|
+
return literal(p.value); // best-effort floor: the hash itself
|
|
144
186
|
try {
|
|
145
187
|
const blob = (await client.readContract({
|
|
146
188
|
address: token,
|
|
@@ -149,14 +191,16 @@ async function decodeParam(client, token, tokenId, p, tokenScope, schema) {
|
|
|
149
191
|
args: tokenScope ? [BigInt(tokenId), keyToBytes32(p.key)] : [keyToBytes32(p.key)],
|
|
150
192
|
}));
|
|
151
193
|
const bytes = hexToBytes(blob);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
194
|
+
const value = schema?.paramType === 'String'
|
|
195
|
+
? new TextDecoder().decode(bytes)
|
|
196
|
+
: bytesToBase64(bytes); // Bytes + schema-less: base64 at read
|
|
197
|
+
return { value, contentBytes: bytes.length };
|
|
155
198
|
}
|
|
156
199
|
catch {
|
|
157
|
-
return p.value;
|
|
200
|
+
return literal(p.value);
|
|
158
201
|
}
|
|
159
202
|
}
|
|
203
|
+
// ── internals ──────────────────────────────────────────────────────────────────
|
|
160
204
|
/** A readable-ASCII `bytes32` literal as its string (e.g. a `display.animation` value). */
|
|
161
205
|
function decodeTagLoose(value) {
|
|
162
206
|
const bytes = hexToBytes(value);
|
|
@@ -173,6 +217,6 @@ function decodeBytes32Key(key) {
|
|
|
173
217
|
function keyToBytes32(key) {
|
|
174
218
|
const bytes = new Uint8Array(32);
|
|
175
219
|
bytes.set(stringToBytes(key).slice(0, 32));
|
|
176
|
-
return
|
|
220
|
+
return bytesToHex(bytes);
|
|
177
221
|
}
|
|
178
222
|
//# 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,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC;AACxE,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,KAAmB;IAC/C,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,0FAA0F;A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AE,CAAC;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,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,55 @@
|
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
owner: Address | null;
|
|
10
|
+
/**
|
|
11
|
+
* The mint-time seed as the raw `bytes32` — exactly what `tokenData` carries. A schema is what
|
|
12
|
+
* buys a human decode and `seed` deliberately has none, so raw hex IS its canonical form.
|
|
13
|
+
* `null` ⇒ no seed set for this token (no seed source, or not minted).
|
|
14
|
+
*/
|
|
15
|
+
seed: Hex | null;
|
|
16
|
+
/**
|
|
17
|
+
* Token-scope params, decoded to their canonical strings. Contract-scope params are listed once
|
|
18
|
+
* on {@link TokenListing.contractParams} rather than repeated per row; the artwork sees
|
|
19
|
+
* contract ∪ token with **token winning** (see `buildTokenData`, the canonical assembly).
|
|
20
|
+
*/
|
|
21
|
+
params: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface TokenListing {
|
|
24
|
+
chainId: number;
|
|
25
|
+
address: Address;
|
|
26
|
+
/** Ids `0 … nextTokenId - 1` have been minted at some point. `null` on a token type with no
|
|
27
|
+
* sequential mint frontier (a 1/1, which is always just token 0). */
|
|
28
|
+
nextTokenId: number | null;
|
|
29
|
+
/** Live supply (mints − burns) — differs from `nextTokenId` only if tokens were burned. */
|
|
30
|
+
totalSupply: number | null;
|
|
31
|
+
maxInvocations: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the contract exposes the params surface at all. `false` for the image token types
|
|
34
|
+
* (they have no Params extension), in which case every row's `seed` is `null` and `params` is
|
|
35
|
+
* empty — correct, not a failed read.
|
|
36
|
+
*/
|
|
37
|
+
hasParams: boolean;
|
|
38
|
+
/** Whether the contract exposes on-chain param *enumeration*. `false` on a project deployed
|
|
39
|
+
* before enumeration shipped: seeds still read (by name), but params can't be listed. */
|
|
40
|
+
hasParamEnumeration: boolean;
|
|
41
|
+
contractParams: Record<string, string>;
|
|
42
|
+
tokens: TokenRow[];
|
|
43
|
+
}
|
|
44
|
+
export interface ListTokensOptions {
|
|
45
|
+
/** Read only this many ids from `from` (default: all). */
|
|
46
|
+
limit?: number;
|
|
47
|
+
/** First token id to read (default 0). */
|
|
48
|
+
from?: number;
|
|
49
|
+
concurrency?: number;
|
|
50
|
+
/** Called after each token resolves — for a progress line on a large collection. */
|
|
51
|
+
onProgress?: (done: number, total: number) => void;
|
|
52
|
+
}
|
|
53
|
+
/** Every token's owner, seed, and params, straight from the contract. */
|
|
54
|
+
export declare function listTokens(client: PublicClient, address: Address, opts?: ListTokensOptions): Promise<TokenListing>;
|
|
55
|
+
//# 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;;;;OAIG;IACH,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB;;;;OAIG;IACH,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB;0EACsE;IACtE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,2FAA2F;IAC3F,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;8FAC0F;IAC1F,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,yEAAyE;AACzE,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAsFvB"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { zeroAddress } from 'viem';
|
|
2
|
+
import { 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
|
+
/** Every token's owner, seed, and params, straight from the contract. */
|
|
28
|
+
export async function listTokens(client, address, opts = {}) {
|
|
29
|
+
const read = async (functionName, args = []) => {
|
|
30
|
+
try {
|
|
31
|
+
// dynamic dispatch over the superset ABI — cast past viem's literal-name inference. Every
|
|
32
|
+
// getter here is absent on at least one token type, so the try/catch IS the capability probe.
|
|
33
|
+
return (await client.readContract({ address, abi: seriesCodeAbi, functionName, args }));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null; // absent on this token type, or an unminted id — the caller decides what that means
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const [chainId, nextTokenId, totalSupply, maxInvocations, contractKeys] = await Promise.all([
|
|
40
|
+
client.getChainId(),
|
|
41
|
+
read('nextTokenId'),
|
|
42
|
+
read('totalSupply'),
|
|
43
|
+
read('maxInvocations'),
|
|
44
|
+
read('contractParamKeys'),
|
|
45
|
+
]);
|
|
46
|
+
// The params surface is probed by a read that only a params-bearing token answers. `seed` is the
|
|
47
|
+
// cheapest such probe that works on a LEGACY project too (deployed before enumeration shipped),
|
|
48
|
+
// so the two capabilities are detected separately rather than collapsed.
|
|
49
|
+
const seedProbe = await read('tokenParam', [0n, encodeTag(SEED_KEY)]);
|
|
50
|
+
const hasParams = seedProbe !== null || contractKeys !== null;
|
|
51
|
+
const hasParamEnumeration = contractKeys !== null;
|
|
52
|
+
// Schemas are read once per key and shared across every token — on a 1000-token collection this
|
|
53
|
+
// is the difference between one read per key and one per key PER TOKEN.
|
|
54
|
+
const schemaCache = new Map();
|
|
55
|
+
const schemaOf = (key) => {
|
|
56
|
+
let hit = schemaCache.get(key);
|
|
57
|
+
if (!hit) {
|
|
58
|
+
hit = schemaFor(client, address, key);
|
|
59
|
+
schemaCache.set(key, hit);
|
|
60
|
+
}
|
|
61
|
+
return hit;
|
|
62
|
+
};
|
|
63
|
+
const contractParams = {};
|
|
64
|
+
for (const raw of contractKeys ?? []) {
|
|
65
|
+
const key = decodeTag(raw);
|
|
66
|
+
const slot = await read('contractParam', [raw]);
|
|
67
|
+
if (!slot?.[2])
|
|
68
|
+
continue; // not set
|
|
69
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
70
|
+
contractParams[key] = (await decodeParam(client, address, '0', p, false, await schemaOf(key))).value;
|
|
71
|
+
}
|
|
72
|
+
// The id range. `nextTokenId` is the mint frontier; a 1/1 has none and is always token 0 alone.
|
|
73
|
+
const count = nextTokenId !== null ? Number(nextTokenId) : totalSupply !== null ? Number(totalSupply) : 1;
|
|
74
|
+
const from = Math.max(0, opts.from ?? 0);
|
|
75
|
+
const end = opts.limit === undefined ? count : Math.min(count, from + Math.max(0, opts.limit));
|
|
76
|
+
const ids = Array.from({ length: Math.max(0, end - from) }, (_, i) => from + i);
|
|
77
|
+
let done = 0;
|
|
78
|
+
const tokens = await pool(ids, opts.concurrency ?? DEFAULT_CONCURRENCY, async (id) => {
|
|
79
|
+
const tokenId = String(id);
|
|
80
|
+
const [owner, seedSlot, keys] = await Promise.all([
|
|
81
|
+
read('ownerOf', [BigInt(id)]),
|
|
82
|
+
hasParams ? read('tokenParam', [BigInt(id), encodeTag(SEED_KEY)]) : null,
|
|
83
|
+
hasParamEnumeration ? read('tokenParamKeys', [BigInt(id)]) : null,
|
|
84
|
+
]);
|
|
85
|
+
const params = {};
|
|
86
|
+
for (const raw of keys ?? []) {
|
|
87
|
+
const key = decodeTag(raw);
|
|
88
|
+
const slot = await read('tokenParam', [BigInt(id), raw]);
|
|
89
|
+
if (!slot?.[2])
|
|
90
|
+
continue;
|
|
91
|
+
const p = { key, value: slot[0], valueIsHash: slot[1], updatedBy: address };
|
|
92
|
+
params[key] = (await decodeParam(client, address, tokenId, p, true, await schemaOf(key))).value;
|
|
93
|
+
}
|
|
94
|
+
opts.onProgress?.(++done, ids.length);
|
|
95
|
+
return { tokenId, owner, seed: seedSlot?.[2] ? seedSlot[0] : null, params };
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
chainId,
|
|
99
|
+
address,
|
|
100
|
+
nextTokenId: nextTokenId === null ? null : Number(nextTokenId),
|
|
101
|
+
totalSupply: totalSupply === null ? null : Number(totalSupply),
|
|
102
|
+
maxInvocations: maxInvocations === null ? null : Number(maxInvocations),
|
|
103
|
+
hasParams,
|
|
104
|
+
hasParamEnumeration,
|
|
105
|
+
contractParams,
|
|
106
|
+
tokens,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* One key's declared schema in the shape {@link decodeParam} wants, or `undefined` when the key is
|
|
111
|
+
* un-governed or the contract has no schema surface. A schema-less param is a normal, supported
|
|
112
|
+
* state — its value simply stays raw, which is exactly what `seed` relies on.
|
|
113
|
+
*
|
|
114
|
+
* Delegates the read to {@link readParamSchema} (the one implementation, which also backs the
|
|
115
|
+
* read-modify-write in `set-schema`) and only maps its numeric enums onto their canonical names.
|
|
116
|
+
*/
|
|
117
|
+
async function schemaFor(client, address, key) {
|
|
118
|
+
try {
|
|
119
|
+
const s = await readParamSchema(client, address, key);
|
|
120
|
+
if (!s.exists)
|
|
121
|
+
return undefined;
|
|
122
|
+
return {
|
|
123
|
+
key,
|
|
124
|
+
paramType: PARAM_TYPES[s.paramType] ?? String(s.paramType),
|
|
125
|
+
auth: AUTH_OPTIONS[s.auth] ?? String(s.auth),
|
|
126
|
+
authAddress: s.authAddress === zeroAddress ? null : s.authAddress,
|
|
127
|
+
lockAfter: String(s.lockAfter),
|
|
128
|
+
min: s.min,
|
|
129
|
+
max: s.max,
|
|
130
|
+
selectOptions: s.selectOptions,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return undefined; // no schema surface on this token type
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Bounded-concurrency map, order-preserving. */
|
|
138
|
+
async function pool(items, width, fn) {
|
|
139
|
+
const out = new Array(items.length);
|
|
140
|
+
let next = 0;
|
|
141
|
+
const workers = Array.from({ length: Math.max(1, Math.min(width, items.length)) }, async () => {
|
|
142
|
+
for (;;) {
|
|
143
|
+
const i = next++;
|
|
144
|
+
if (i >= items.length)
|
|
145
|
+
return;
|
|
146
|
+
out[i] = await fn(items[i]);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
await Promise.all(workers);
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
//# 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,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,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;AAwD9B,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAoB,EACpB,OAAgB,EAChB,OAA0B,EAAE;IAE5B,MAAM,IAAI,GAAG,KAAK,EAAK,YAAoB,EAAE,OAA2B,EAAE,EAAqB,EAAE;QAC/F,IAAI,CAAC;YACH,0FAA0F;YAC1F,8FAA8F;YAC9F,OAAO,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,EAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAU,CAAC,CAAM,CAAC;QACtG,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,CAA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+
* `node:*` or references a Node-only global (`Buffer`, `process` unguarded) — this module
|
|
4
|
+
* is reachable from the browser bundle (see `test/browser-bundle.test.ts`), so it has to
|
|
5
|
+
* run identically wherever a caller (Node, a bundler, a browser tab) loads it.
|
|
6
|
+
*/
|
|
7
|
+
import type { Address, PublicClient } from 'viem';
|
|
8
|
+
/** `process.env[name]`, or `undefined` — safe to call even where `process` doesn't exist
|
|
9
|
+
* (a browser bundle). The SDK core never assumes Node; a host (the CLI, the effects
|
|
10
|
+
* runner) is where `process.env` is actually meaningful. */
|
|
11
|
+
export declare function readEnv(name: string): string | undefined;
|
|
12
|
+
/** Wait `ms` milliseconds. The one place the SDK debounces/retries, so every caller shares
|
|
13
|
+
* the same primitive instead of re-declaring `new Promise((r) => setTimeout(r, ms))`. */
|
|
14
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
15
|
+
/** The delay before retry `attempt` (1-indexed) under a LINEAR backoff: `attempt * baseMs`.
|
|
16
|
+
* Matches the shape `service.ts`'s request ladder already used (`retryDelayMs * attempt`) —
|
|
17
|
+
* pulled out here so every linear-backoff retry loop (the service client, the effects
|
|
18
|
+
* runner's resolver poll) computes the same delay the same way. */
|
|
19
|
+
export declare function linearBackoffDelay(attempt: number, baseMs: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* A parsed `data:` URI (RFC 2397) — the most permissive of the three ad hoc parses this
|
|
22
|
+
* replaces (a bare `data:,...`, a `;base64` flag anywhere in the parameter list, and an
|
|
23
|
+
* arbitrary `;charset=...` alongside it). `mime` is empty-string-normalized to `text/plain`
|
|
24
|
+
* (RFC 2397's own default); `body` is returned VERBATIM — still percent-encoded for a
|
|
25
|
+
* non-base64 URI, still base64 text for one that is — so the caller decodes it exactly the
|
|
26
|
+
* way it always did (`decodeURIComponent` vs a base64 decode).
|
|
27
|
+
*/
|
|
28
|
+
export interface ParsedDataUri {
|
|
29
|
+
mime: string;
|
|
30
|
+
base64: boolean;
|
|
31
|
+
body: string;
|
|
32
|
+
}
|
|
33
|
+
/** Parse a `data:` URI, or `null` if `uri` isn't one. */
|
|
34
|
+
export declare function parseDataUri(uri: string): ParsedDataUri | null;
|
|
35
|
+
/**
|
|
36
|
+
* Read a contract, swallowing any failure ("no data" from a codeless address, a revert on
|
|
37
|
+
* an extension the target doesn't compose) into `undefined` rather than a throw — the shape
|
|
38
|
+
* every "does this getter exist / is there even a contract here" caller wants. Replaces the
|
|
39
|
+
* three near-identical try/catch wrappers this SDK's callers each hand-rolled (a resume
|
|
40
|
+
* planner's field-by-field read, a state dump's per-getter read, an owner-op's diagnostic
|
|
41
|
+
* read) with one implementation.
|
|
42
|
+
*
|
|
43
|
+
* A caller that wants to DISTINGUISH "no contract at all" from "contract exists but this
|
|
44
|
+
* call reverted" (the CLI's `assertContractExists` diagnostic) still does that itself — this
|
|
45
|
+
* helper only knows "did the read come back", not why it didn't.
|
|
46
|
+
*/
|
|
47
|
+
export declare function tryReadContract<T>(client: PublicClient, args: {
|
|
48
|
+
address: Address;
|
|
49
|
+
abi: readonly unknown[];
|
|
50
|
+
functionName: string;
|
|
51
|
+
args?: readonly unknown[];
|
|
52
|
+
}): Promise<T | undefined>;
|
|
53
|
+
/** Bytes → base64 (RFC 4648). No `Buffer`, no `btoa` — both are runtime-conditional (Node
|
|
54
|
+
* lacks the latter, and a stricter embedder than a browser can lack the former too), and the
|
|
55
|
+
* SDK core needs exactly one behavior everywhere it runs. */
|
|
56
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
57
|
+
/** base64 → bytes — the inverse of {@link bytesToBase64}. */
|
|
58
|
+
export declare function base64ToBytes(b64: string): Uint8Array;
|
|
59
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,MAAM,CAAC;AAEhD;;6DAE6D;AAC7D,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxD;AAED;0FAC0F;AAC1F,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;oEAGoE;AACpE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAID,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAS9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,SAAS,OAAO,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;CAAC,GACjG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAMxB;AAID;;8DAE8D;AAC9D,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAYvD;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAcrD"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** `process.env[name]`, or `undefined` — safe to call even where `process` doesn't exist
|
|
2
|
+
* (a browser bundle). The SDK core never assumes Node; a host (the CLI, the effects
|
|
3
|
+
* runner) is where `process.env` is actually meaningful. */
|
|
4
|
+
export function readEnv(name) {
|
|
5
|
+
if (typeof process === 'undefined' || !process.env)
|
|
6
|
+
return undefined;
|
|
7
|
+
return process.env[name];
|
|
8
|
+
}
|
|
9
|
+
/** Wait `ms` milliseconds. The one place the SDK debounces/retries, so every caller shares
|
|
10
|
+
* the same primitive instead of re-declaring `new Promise((r) => setTimeout(r, ms))`. */
|
|
11
|
+
export function sleep(ms) {
|
|
12
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
|
+
}
|
|
14
|
+
/** The delay before retry `attempt` (1-indexed) under a LINEAR backoff: `attempt * baseMs`.
|
|
15
|
+
* Matches the shape `service.ts`'s request ladder already used (`retryDelayMs * attempt`) —
|
|
16
|
+
* pulled out here so every linear-backoff retry loop (the service client, the effects
|
|
17
|
+
* runner's resolver poll) computes the same delay the same way. */
|
|
18
|
+
export function linearBackoffDelay(attempt, baseMs) {
|
|
19
|
+
return attempt * baseMs;
|
|
20
|
+
}
|
|
21
|
+
const DATA_URI_RE = /^data:([^;,]*)((?:;[^,]*)?),([\s\S]*)$/;
|
|
22
|
+
/** Parse a `data:` URI, or `null` if `uri` isn't one. */
|
|
23
|
+
export function parseDataUri(uri) {
|
|
24
|
+
const m = DATA_URI_RE.exec(uri);
|
|
25
|
+
if (!m)
|
|
26
|
+
return null;
|
|
27
|
+
const params = m[2] ?? '';
|
|
28
|
+
return {
|
|
29
|
+
mime: m[1] || 'text/plain',
|
|
30
|
+
base64: /(^|;)base64(;|$)/.test(params),
|
|
31
|
+
body: m[3],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Read a contract, swallowing any failure ("no data" from a codeless address, a revert on
|
|
36
|
+
* an extension the target doesn't compose) into `undefined` rather than a throw — the shape
|
|
37
|
+
* every "does this getter exist / is there even a contract here" caller wants. Replaces the
|
|
38
|
+
* three near-identical try/catch wrappers this SDK's callers each hand-rolled (a resume
|
|
39
|
+
* planner's field-by-field read, a state dump's per-getter read, an owner-op's diagnostic
|
|
40
|
+
* read) with one implementation.
|
|
41
|
+
*
|
|
42
|
+
* A caller that wants to DISTINGUISH "no contract at all" from "contract exists but this
|
|
43
|
+
* call reverted" (the CLI's `assertContractExists` diagnostic) still does that itself — this
|
|
44
|
+
* helper only knows "did the read come back", not why it didn't.
|
|
45
|
+
*/
|
|
46
|
+
export async function tryReadContract(client, args) {
|
|
47
|
+
try {
|
|
48
|
+
return (await client.readContract(args));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
55
|
+
/** Bytes → base64 (RFC 4648). No `Buffer`, no `btoa` — both are runtime-conditional (Node
|
|
56
|
+
* lacks the latter, and a stricter embedder than a browser can lack the former too), and the
|
|
57
|
+
* SDK core needs exactly one behavior everywhere it runs. */
|
|
58
|
+
export function bytesToBase64(bytes) {
|
|
59
|
+
let out = '';
|
|
60
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
61
|
+
const b0 = bytes[i];
|
|
62
|
+
const b1 = bytes[i + 1];
|
|
63
|
+
const b2 = bytes[i + 2];
|
|
64
|
+
out += BASE64_CHARS[b0 >> 2];
|
|
65
|
+
out += BASE64_CHARS[((b0 & 0x03) << 4) | (b1 === undefined ? 0 : b1 >> 4)];
|
|
66
|
+
out += b1 === undefined ? '=' : BASE64_CHARS[((b1 & 0x0f) << 2) | (b2 === undefined ? 0 : b2 >> 6)];
|
|
67
|
+
out += b2 === undefined ? '=' : BASE64_CHARS[b2 & 0x3f];
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/** base64 → bytes — the inverse of {@link bytesToBase64}. */
|
|
72
|
+
export function base64ToBytes(b64) {
|
|
73
|
+
const clean = b64.replace(/=+$/, '');
|
|
74
|
+
const out = new Uint8Array(Math.floor((clean.length * 3) / 4));
|
|
75
|
+
let p = 0;
|
|
76
|
+
for (let i = 0; i < clean.length; i += 4) {
|
|
77
|
+
const c0 = BASE64_CHARS.indexOf(clean[i]);
|
|
78
|
+
const c1 = BASE64_CHARS.indexOf(clean[i + 1]);
|
|
79
|
+
const c2 = clean[i + 2] === undefined ? -1 : BASE64_CHARS.indexOf(clean[i + 2]);
|
|
80
|
+
const c3 = clean[i + 3] === undefined ? -1 : BASE64_CHARS.indexOf(clean[i + 3]);
|
|
81
|
+
out[p++] = (c0 << 2) | (c1 >> 4);
|
|
82
|
+
if (c2 >= 0)
|
|
83
|
+
out[p++] = ((c1 & 0x0f) << 4) | (c2 >> 2);
|
|
84
|
+
if (c3 >= 0)
|
|
85
|
+
out[p++] = ((c2 & 0x03) << 6) | c3;
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAQA;;6DAE6D;AAC7D,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IACrE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;0FAC0F;AAC1F,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;oEAGoE;AACpE,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,MAAc;IAChE,OAAO,OAAO,GAAG,MAAM,CAAC;AAC1B,CAAC;AAgBD,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAE7D,yDAAyD;AACzD,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI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ChF,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChF,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACjC,IAAI,EAAE,IAAI,CAAC;YAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACvD,IAAI,EAAE,IAAI,CAAC;YAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAClD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artblocks/abx-sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ABX SDK (Layer 2) — the neutral, low-level library that turns protocol operations into typed function calls. No provider, no chain, no UX baked in.",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
"./abi": {
|
|
14
14
|
"types": "./dist/abi/index.d.ts",
|
|
15
15
|
"import": "./dist/abi/index.js"
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
"./node": {
|
|
18
|
+
"types": "./dist/node.d.ts",
|
|
19
|
+
"import": "./dist/node.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
17
22
|
},
|
|
18
23
|
"files": [
|
|
19
24
|
"dist",
|
|
@@ -45,6 +50,9 @@
|
|
|
45
50
|
"dependencies": {
|
|
46
51
|
"viem": "^2.21.0"
|
|
47
52
|
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"esbuild": "^0.28.1"
|
|
55
|
+
},
|
|
48
56
|
"scripts": {
|
|
49
57
|
"build": "tsc -b tsconfig.build.json",
|
|
50
58
|
"sync-abis": "tsx scripts/sync-abis.ts"
|