@artblocks/abx-sdk 0.1.0-alpha.4 → 0.1.0-alpha.40
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 +64 -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 +325 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +740 -0
- package/dist/anchors.js.map +1 -0
- package/dist/chain-support.d.ts +28 -0
- package/dist/chain-support.d.ts.map +1 -0
- package/dist/chain-support.js +65 -0
- package/dist/chain-support.js.map +1 -0
- package/dist/chain-support.json +60 -0
- package/dist/chains.d.ts +24 -10
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +51 -17
- package/dist/chains.js.map +1 -1
- package/dist/chunks.d.ts +162 -31
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +179 -14
- 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/contract-generations.d.ts +58 -0
- package/dist/contract-generations.d.ts.map +1 -0
- package/dist/contract-generations.js +109 -0
- package/dist/contract-generations.js.map +1 -0
- package/dist/contract-generations.json +48 -0
- 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 +38 -5
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +156 -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 +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -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 +147 -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 +155 -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/deps.js
CHANGED
|
@@ -11,11 +11,20 @@
|
|
|
11
11
|
* in bytes32 — read directly, never through a registry.
|
|
12
12
|
*
|
|
13
13
|
* Also speaks the AB-compatible registry READ interface (`IDependencyRegistryV0`,
|
|
14
|
-
*
|
|
15
|
-
* load-bearing read behind the CLI's best-effort selection-time check
|
|
14
|
+
* site/content/docs/protocol/code-projects.mdx): `getDependencyDetails(bytes32)` is the
|
|
15
|
+
* load-bearing read behind the CLI's best-effort selection-time check, and
|
|
16
|
+
* `getDependencyScript(bytes32, index)` is the resolver's own read for on-chain bytes (see the
|
|
17
|
+
* "resolver's registry-aware serving lane" section below — shared with
|
|
18
|
+
* `@artblocks/abx-token-api`, because it uses this exact
|
|
19
|
+
* vocabulary end to end).
|
|
16
20
|
*/
|
|
17
|
-
import { padHex, toHex } from 'viem';
|
|
21
|
+
import { encodeFunctionData, hexToString, padHex, toHex } from 'viem';
|
|
18
22
|
import { decodeTag } from './spine.js';
|
|
23
|
+
import { seriesCodeAbi } from './abi/index.js';
|
|
24
|
+
import { resolveDependencyRegistry } from './deployments.js';
|
|
25
|
+
import { escapeInlineScript } from './generator-document.js';
|
|
26
|
+
import { base64ToBytes } from './util.js';
|
|
27
|
+
import { InflateRequiredError } from './errors.js';
|
|
19
28
|
/** `IAbxDependencies.Resolution` — index-aligned with the Solidity enum. */
|
|
20
29
|
export const DEP_RESOLUTION = { registry: 0, onchain: 1 };
|
|
21
30
|
// Printable non-space ASCII — what a readable bytes32 tag can carry unambiguously
|
|
@@ -57,9 +66,16 @@ export function decodeDependencyRef(resolution, ref) {
|
|
|
57
66
|
return resolution === DEP_RESOLUTION.onchain ? '0x' + ref.slice(2, 42) : decodeTag(ref);
|
|
58
67
|
}
|
|
59
68
|
// ── the AB-compatible registry read (IDependencyRegistryV0) ───────────────────
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The load-bearing reads of AB's `IDependencyRegistryV0` — the exact upstream signatures (any
|
|
71
|
+
* registry ABX consumers read from speaks this shape; see the dependency-registry spec).
|
|
72
|
+
* `getDependencyDetails` backs both the CLI's best-effort selection-time check and the
|
|
73
|
+
* resolver's own resolution; `getDependencyScript` is the resolver-only per-chunk read for a
|
|
74
|
+
* dep whose bytes live on chain. (Merging this hoist: token-api's `DEPENDENCY_REGISTRY_ABI` and
|
|
75
|
+
* this module's prior `dependencyRegistryReadAbi` declared the identical `getDependencyDetails`
|
|
76
|
+
* entry twice — one array now backs both callers.)
|
|
77
|
+
*/
|
|
78
|
+
export const DEPENDENCY_REGISTRY_ABI = [
|
|
63
79
|
{
|
|
64
80
|
type: 'function',
|
|
65
81
|
name: 'getDependencyDetails',
|
|
@@ -77,6 +93,16 @@ export const dependencyRegistryReadAbi = [
|
|
|
77
93
|
{ name: 'scriptCount', type: 'uint24' },
|
|
78
94
|
],
|
|
79
95
|
},
|
|
96
|
+
{
|
|
97
|
+
type: 'function',
|
|
98
|
+
name: 'getDependencyScript',
|
|
99
|
+
stateMutability: 'view',
|
|
100
|
+
inputs: [
|
|
101
|
+
{ name: 'dependencyNameAndVersion', type: 'bytes32' },
|
|
102
|
+
{ name: 'index', type: 'uint256' },
|
|
103
|
+
],
|
|
104
|
+
outputs: [{ type: 'string' }],
|
|
105
|
+
},
|
|
80
106
|
];
|
|
81
107
|
/**
|
|
82
108
|
* Read one dependency's registry record. Returns `null` when the registry doesn't know the
|
|
@@ -90,7 +116,7 @@ export const dependencyRegistryReadAbi = [
|
|
|
90
116
|
export async function readRegistryDependency(client, registry, ref) {
|
|
91
117
|
const out = (await client.readContract({
|
|
92
118
|
address: registry,
|
|
93
|
-
abi:
|
|
119
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
94
120
|
functionName: 'getDependencyDetails',
|
|
95
121
|
args: [ref],
|
|
96
122
|
}));
|
|
@@ -100,4 +126,220 @@ export async function readRegistryDependency(client, registry, ref) {
|
|
|
100
126
|
return null;
|
|
101
127
|
return { nameAndVersion, licenseType, preferredCDN, availableOnChain, scriptCount: Number(scriptCount) };
|
|
102
128
|
}
|
|
129
|
+
// ── the deploy-time dependency lane (registry pointer, setup legs, selection-time check) ──────
|
|
130
|
+
// The rest of a code project's dependency handling: resolving which registry a deploy should point
|
|
131
|
+
// at, composing the setup-multicall legs, and the best-effort existence check against that registry.
|
|
132
|
+
// `parseDepFlag` (the `--dep` CLI flag grammar) is CLI-local and stays there — everything downstream
|
|
133
|
+
// of a parsed `ParsedDependencyRef[]` lives here.
|
|
134
|
+
/**
|
|
135
|
+
* The registry pointer a deploy with ≥1 Registry-resolution dep should set: an explicit
|
|
136
|
+
* `--dep-registry` wins (validated), else the chain's known AB registry (env-overridable),
|
|
137
|
+
* else none — the caller WARNS and skips the leg (soft pointer; the resolver falls back to
|
|
138
|
+
* its built-in CDN map). Never a blocker.
|
|
139
|
+
*/
|
|
140
|
+
export function resolveDepRegistryPointer(flagValue, chainId) {
|
|
141
|
+
if (flagValue !== undefined) {
|
|
142
|
+
if (flagValue === 'true' || !/^0x[0-9a-fA-F]{40}$/.test(flagValue)) {
|
|
143
|
+
throw new Error(`--dep-registry must be an address (0x + 40 hex); got '${flagValue}'`);
|
|
144
|
+
}
|
|
145
|
+
return { registry: flagValue, source: 'flag' };
|
|
146
|
+
}
|
|
147
|
+
const known = resolveDependencyRegistry(chainId);
|
|
148
|
+
return known ? { registry: known, source: 'default' } : { registry: null, source: 'none' };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The dependency legs of the setup multicall: one `setDependency(i, resolution, ref)` per
|
|
152
|
+
* dep in index order, plus the `setDependencyRegistry` leg when a pointer resolved. These
|
|
153
|
+
* ride the SAME atomic setup multicall as script chunks/schemas/mints, in every signing lane.
|
|
154
|
+
*/
|
|
155
|
+
export function dependencySetupCalls(deps, registry) {
|
|
156
|
+
const calls = deps.map((d, i) => encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setDependency', args: [BigInt(i), d.resolution, d.ref] }));
|
|
157
|
+
if (deps.length && registry) {
|
|
158
|
+
calls.push(encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setDependencyRegistry', args: [registry] }));
|
|
159
|
+
}
|
|
160
|
+
return calls;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Best-effort existence/on-chain-ness check of every Registry-resolution dep against the
|
|
164
|
+
* pointer registry. A revert or an empty record ⇒ `not-found` (a warning — the owner may
|
|
165
|
+
* intend a custom registry). A transport failure ⇒ the remaining checks are `skipped` and
|
|
166
|
+
* `rpcOk: false` — one info line, never an error: the deploy proceeds regardless.
|
|
167
|
+
*/
|
|
168
|
+
export async function checkRegistryDeps(client, registry, deps) {
|
|
169
|
+
const registryDeps = deps.filter((d) => d.resolution === DEP_RESOLUTION.registry);
|
|
170
|
+
const checks = [];
|
|
171
|
+
let rpcOk = true;
|
|
172
|
+
for (const d of registryDeps) {
|
|
173
|
+
if (!rpcOk) {
|
|
174
|
+
checks.push({ dep: d.display, status: 'skipped' });
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const details = await readRegistryDependency(client, registry, d.ref);
|
|
179
|
+
checks.push(details ? { dep: d.display, status: 'found', details } : { dep: d.display, status: 'not-found' });
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
// A contract revert means the registry answered "no such dependency"; anything else
|
|
183
|
+
// (DNS, timeout, HTTP) means we couldn't ask — degrade to skipped, not failed.
|
|
184
|
+
const msg = `${e.name ?? ''} ${e.message ?? ''}`;
|
|
185
|
+
if (/ContractFunction|revert|returned no data/i.test(msg)) {
|
|
186
|
+
checks.push({ dep: d.display, status: 'not-found' });
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
rpcOk = false;
|
|
190
|
+
checks.push({ dep: d.display, status: 'skipped' });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return { checks, rpcOk };
|
|
195
|
+
}
|
|
196
|
+
// Resolved registry entries are effectively immutable (admin-gated writes), so an in-process
|
|
197
|
+
// cache is safe; the TTL only guards admin updates. Failures negative-cache briefly so a dead
|
|
198
|
+
// registry doesn't cost an eth_call (and a warn) per request.
|
|
199
|
+
const REGISTRY_CACHE_TTL_MS = 60 * 60 * 1000; // 1h
|
|
200
|
+
const REGISTRY_NEGATIVE_TTL_MS = 60 * 1000; // 1min
|
|
201
|
+
const registryCache = new Map();
|
|
202
|
+
/** Reset the in-process registry-resolution cache — for tests. */
|
|
203
|
+
export function resetRegistryDependencyCache() {
|
|
204
|
+
registryCache.clear();
|
|
205
|
+
}
|
|
206
|
+
/** The collection's registry pointer, if set to a real address (zero/undefined ⇒ none). */
|
|
207
|
+
export function activeRegistry(state) {
|
|
208
|
+
const registry = state.dependencies?.registry ?? null;
|
|
209
|
+
if (!registry || /^0x0{40}$/i.test(registry))
|
|
210
|
+
return null;
|
|
211
|
+
return registry;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolve one `name@version` ref through the collection's registry. Returns the resolution
|
|
215
|
+
* (or null when the registry couldn't answer — caller falls back to the built-in map) plus
|
|
216
|
+
* whether it was served from cache. Never throws for a resolution failure; a fresh one logs ONE
|
|
217
|
+
* warn (the negative cache rate-limits it) naming the dep and why. DOES throw
|
|
218
|
+
* {@link InflateRequiredError} when the resolution needs decompression and `opts.inflate` is
|
|
219
|
+
* absent — that is a caller-configuration bug, not a resolution outcome.
|
|
220
|
+
*/
|
|
221
|
+
export async function resolveRegistryDep(client, registry, dep, opts = {}) {
|
|
222
|
+
const key = `${registry.toLowerCase()}|${dep.refDecoded}`;
|
|
223
|
+
const hit = registryCache.get(key);
|
|
224
|
+
if (hit && hit.expiresAt > Date.now()) {
|
|
225
|
+
return { resolution: hit.value, cached: true, error: hit.error };
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
// nameAndVersion rides as readable-ASCII bytes32 — the raw evented ref, right-padded.
|
|
229
|
+
const ref = padHex(dep.ref, { size: 32, dir: 'right' });
|
|
230
|
+
const details = (await client.readContract({
|
|
231
|
+
address: registry,
|
|
232
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
233
|
+
functionName: 'getDependencyDetails',
|
|
234
|
+
args: [ref],
|
|
235
|
+
}));
|
|
236
|
+
const [nameAndVersion, , preferredCDN, , , , , availableOnChain, scriptCount] = details;
|
|
237
|
+
if (availableOnChain && scriptCount > 0) {
|
|
238
|
+
// Per-chunk reads; the concatenated chunk strings form one base64(gzip(script)) stream.
|
|
239
|
+
const chunks = (await Promise.all(Array.from({ length: Number(scriptCount) }, (_, i) => client.readContract({
|
|
240
|
+
address: registry,
|
|
241
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
242
|
+
functionName: 'getDependencyScript',
|
|
243
|
+
args: [ref, BigInt(i)],
|
|
244
|
+
}))));
|
|
245
|
+
if (!opts.inflate)
|
|
246
|
+
throw new InflateRequiredError();
|
|
247
|
+
const gz = base64ToBytes(chunks.join(''));
|
|
248
|
+
const script = new TextDecoder().decode(opts.inflate(gz));
|
|
249
|
+
const value = { kind: 'onchain', script };
|
|
250
|
+
registryCache.set(key, { value, expiresAt: Date.now() + REGISTRY_CACHE_TTL_MS });
|
|
251
|
+
return { resolution: value, cached: false };
|
|
252
|
+
}
|
|
253
|
+
if (preferredCDN) {
|
|
254
|
+
const value = { kind: 'cdn', url: preferredCDN };
|
|
255
|
+
registryCache.set(key, { value, expiresAt: Date.now() + REGISTRY_CACHE_TTL_MS });
|
|
256
|
+
return { resolution: value, cached: false };
|
|
257
|
+
}
|
|
258
|
+
// An empty struct back means the entry simply isn't registered.
|
|
259
|
+
const why = nameAndVersion
|
|
260
|
+
? 'registered but has neither on-chain bytes nor a preferredCDN'
|
|
261
|
+
: 'not registered in the registry';
|
|
262
|
+
return failRegistryResolution(key, dep, registry, why);
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
// A missing inflate is a host-configuration bug, not a resolution outcome — surface it
|
|
266
|
+
// rather than mis-reporting it as "registry read failed" and quietly falling back.
|
|
267
|
+
if (err instanceof InflateRequiredError)
|
|
268
|
+
throw err;
|
|
269
|
+
return failRegistryResolution(key, dep, registry, `registry read failed: ${err.message}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** Negative-cache a failed resolution + one warn (per negative-TTL window). Never throws. */
|
|
273
|
+
function failRegistryResolution(key, dep, registry, why) {
|
|
274
|
+
registryCache.set(key, { value: null, error: why, expiresAt: Date.now() + REGISTRY_NEGATIVE_TTL_MS });
|
|
275
|
+
console.warn(`[deps] registry resolution failed for ${dep.refDecoded} via ${registry}: ${why} — falling back to the built-in CDN map`);
|
|
276
|
+
return { resolution: null, cached: false, error: why };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Resolve a `name@version` registry ref to a CDN URL — the built-in reference convention,
|
|
280
|
+
* the LAST-resort rung of the resolution order (the soft registry pointer stays
|
|
281
|
+
* non-validating). Known runtimes get their real dist paths; anything else is best-effort npm.
|
|
282
|
+
*/
|
|
283
|
+
export function registryDepUrl(ref) {
|
|
284
|
+
const at = ref.lastIndexOf('@');
|
|
285
|
+
if (at <= 0)
|
|
286
|
+
return null;
|
|
287
|
+
const name = ref.slice(0, at);
|
|
288
|
+
const version = ref.slice(at + 1);
|
|
289
|
+
const known = {
|
|
290
|
+
p5js: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
|
|
291
|
+
p5: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
|
|
292
|
+
threejs: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
|
|
293
|
+
three: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
|
|
294
|
+
tonejs: `https://cdn.jsdelivr.net/npm/tone@${version}/build/Tone.js`,
|
|
295
|
+
};
|
|
296
|
+
return known[name] ?? `https://cdn.jsdelivr.net/npm/${name}@${version}`;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The ordered dependency `<script>` tags for the generator document, each dep resolved per
|
|
300
|
+
* the Consumers table: registry on-chain bytes → registry preferredCDN → built-in map;
|
|
301
|
+
* `onchain`-resolution refs read their SSTORE2 data contract directly (never a registry).
|
|
302
|
+
* Never throws for a resolution failure — an unresolvable dep is skipped (after the warn) and
|
|
303
|
+
* the document assembles. DOES propagate {@link InflateRequiredError} (see
|
|
304
|
+
* {@link resolveRegistryDep}) — a missing `inflate` is a host wiring bug, not a bad dep.
|
|
305
|
+
*/
|
|
306
|
+
export async function dependencyScriptTags(client, state, opts = {}) {
|
|
307
|
+
const registry = activeRegistry(state);
|
|
308
|
+
const tags = [];
|
|
309
|
+
for (const dep of state.dependencies?.list ?? []) {
|
|
310
|
+
if (dep.resolution === 'registry') {
|
|
311
|
+
if (registry) {
|
|
312
|
+
const { resolution } = await resolveRegistryDep(client, registry, dep, opts);
|
|
313
|
+
if (resolution?.kind === 'onchain') {
|
|
314
|
+
tags.push(`<script>${escapeInlineScript(resolution.script)}</script>`);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (resolution?.kind === 'cdn') {
|
|
318
|
+
tags.push(`<script src="${resolution.url}"></script>`);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
// fell through — resolveRegistryDep already warned; last resort below
|
|
322
|
+
}
|
|
323
|
+
const url = registryDepUrl(dep.refDecoded);
|
|
324
|
+
if (url)
|
|
325
|
+
tags.push(`<script src="${url}"></script>`);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
// on-chain dep: an SSTORE2 data contract holding the JS (code = 0x00 ‖ content). No
|
|
329
|
+
// inflate needed here — raw bytecode, never gzip'd — so this branch never touches `opts`.
|
|
330
|
+
const bytecode = await client.getCode({ address: dep.refDecoded });
|
|
331
|
+
if (bytecode && bytecode.length > 4) {
|
|
332
|
+
tags.push(`<script>${escapeInlineScript(hexToString(('0x' + bytecode.slice(4))))}</script>`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return tags;
|
|
337
|
+
}
|
|
338
|
+
/** The spec's URL-carried tokenData size budget: gateway front-ends commonly cap request lines
|
|
339
|
+
* near 8KB. Applies to URL-carried `?abx=` payloads (a resolver's directory-mode 302 fallback);
|
|
340
|
+
* inline document serving is unaffected. Hoisted alongside the rest of this lane — the
|
|
341
|
+
* budget-tracking/observability surface built on it (`checkUrlBudget`, `urlBudgetStatus`) stays
|
|
342
|
+
* resolver-local (token-api/src/deps.ts), since it's a serving-observability concern rather than
|
|
343
|
+
* a resolution rule. */
|
|
344
|
+
export const URL_BUDGET_BYTES = 8192;
|
|
103
345
|
//# sourceMappingURL=deps.js.map
|
package/dist/deps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAC,MAAM,EAAE,KAAK,EAAyB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAErC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAU,CAAC;AAUjE,kFAAkF;AAClF,oFAAoF;AACpF,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC;;sFAEsF;AACtF,MAAM,UAAU,oBAAoB,CAAC,cAAsB;IACzD,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,cAAc,4EAA4E,CAAC,CAAC;IACjI,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE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/**
|
|
3
3
|
* Parse `.env` text into ordered entries plus any keys the file sets MORE THAN ONCE (pure — the
|
|
4
|
-
* testable half of {@link loadDotEnv}).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* testable half of {@link loadDotEnv}). LAST occurrence wins, matching conventional dotenv tooling
|
|
5
|
+
* (and the expectation that an appended override actually takes effect). Duplicates are still returned rather
|
|
6
|
+
* than swallowed, because a stale duplicate (two `ABX_RPC_URLS_SEPOLIA` lines, one pointing at a
|
|
7
|
+
* different network) leaves every downstream check passing while the tool talks to somewhere
|
|
8
|
+
* unintended — and the symptom surfaces far away as "no contract at that address".
|
|
8
9
|
*/
|
|
9
10
|
export declare function parseEnvContent(content: string): {
|
|
10
11
|
entries: Array<[string, string]>;
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAC,QAAQ,GAAE,MAAsB,GAAG,IAAI,CAcjE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAC,CAmCzG"}
|
package/dist/env.js
CHANGED
|
@@ -5,6 +5,14 @@ import { dirname, resolve } from 'node:path';
|
|
|
5
5
|
* root looking for a `.env`, and sets any keys not already present in the
|
|
6
6
|
* environment. Deliberately tiny — the toolkit must run with `pnpm install`
|
|
7
7
|
* and nothing else.
|
|
8
|
+
*
|
|
9
|
+
* Node-only (needs `node:fs` + `node:path`) — reached exclusively through the
|
|
10
|
+
* `@artblocks/abx-sdk/node` subpath, never the package's main entry (which a browser
|
|
11
|
+
* bundle must be able to import — see `test/browser-bundle.test.ts`). A host calls
|
|
12
|
+
* {@link loadDotEnv} once at startup; the SDK core never calls it itself (it reads
|
|
13
|
+
* whatever's already in `process.env` via `util.ts`'s `readEnv`). Because this module is
|
|
14
|
+
* Node-subpath-only, `parseInto`'s `console.error` on a conflicting duplicate key is fine
|
|
15
|
+
* to leave as a direct console write — there is no browser caller to surprise.
|
|
8
16
|
*/
|
|
9
17
|
let loaded = false;
|
|
10
18
|
export function loadDotEnv(startDir = process.cwd()) {
|
|
@@ -26,14 +34,16 @@ export function loadDotEnv(startDir = process.cwd()) {
|
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Parse `.env` text into ordered entries plus any keys the file sets MORE THAN ONCE (pure — the
|
|
29
|
-
* testable half of {@link loadDotEnv}).
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
37
|
+
* testable half of {@link loadDotEnv}). LAST occurrence wins, matching conventional dotenv tooling
|
|
38
|
+
* (and the expectation that an appended override actually takes effect). Duplicates are still returned rather
|
|
39
|
+
* than swallowed, because a stale duplicate (two `ABX_RPC_URLS_SEPOLIA` lines, one pointing at a
|
|
40
|
+
* different network) leaves every downstream check passing while the tool talks to somewhere
|
|
41
|
+
* unintended — and the symptom surfaces far away as "no contract at that address".
|
|
33
42
|
*/
|
|
34
43
|
export function parseEnvContent(content) {
|
|
35
44
|
const entries = [];
|
|
36
45
|
const seen = new Map();
|
|
46
|
+
const indexOf = new Map();
|
|
37
47
|
const duplicates = [];
|
|
38
48
|
for (const rawLine of content.split('\n')) {
|
|
39
49
|
const line = rawLine.trim();
|
|
@@ -56,9 +66,14 @@ export function parseEnvContent(content) {
|
|
|
56
66
|
// command is its own process, so there is nowhere to throttle a genuine warning to "once").
|
|
57
67
|
if (seen.get(key) !== value && !duplicates.includes(key))
|
|
58
68
|
duplicates.push(key);
|
|
69
|
+
// LAST wins: overwrite the value in place (keeping the key's original position in `entries`,
|
|
70
|
+
// since order otherwise doesn't matter for env application).
|
|
71
|
+
seen.set(key, value);
|
|
72
|
+
entries[indexOf.get(key)] = [key, value];
|
|
59
73
|
continue;
|
|
60
74
|
}
|
|
61
75
|
seen.set(key, value);
|
|
76
|
+
indexOf.set(key, entries.length);
|
|
62
77
|
entries.push([key, value]);
|
|
63
78
|
}
|
|
64
79
|
return { entries, duplicates };
|
|
@@ -71,7 +86,7 @@ function parseInto(content) {
|
|
|
71
86
|
}
|
|
72
87
|
if (duplicates.length) {
|
|
73
88
|
console.error(`⚠ .env sets ${duplicates.length === 1 ? 'this key' : 'these keys'} to CONFLICTING values: ${duplicates.join(', ')}. ` +
|
|
74
|
-
`The
|
|
89
|
+
`The LAST value wins and the earlier one is ignored — delete the stale line, or you may be pointed somewhere you didn't intend.`);
|
|
75
90
|
}
|
|
76
91
|
}
|
|
77
92
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,UAAU,CAAC,WAAmB,OAAO,CAAC,GAAG,EAAE;IACzD,IAAI,MAAM;QAAE,OAAO;IACnB,MAAM,GAAG,IAAI,CAAC;IACd,IAAI,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,KAAK,IAAI,C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AAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/D,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CACX,eAAe,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,2BAA2B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACpH,gIAAgI,CACnI,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import type { SeedSourceProbe, SeedSourceVerdict } from './ops.js';
|
|
3
|
+
/**
|
|
4
|
+
* The SDK's error taxonomy — deliberately minimal. A caller that wants to react to a SPECIFIC
|
|
5
|
+
* failure (retry a stale estimate, surface a revert's tx hash) should catch by TYPE, not by
|
|
6
|
+
* parsing `.message`; every SDK-thrown error a caller is expected to distinguish extends this,
|
|
7
|
+
* following the same `name` + typed-fields convention `AbxServiceError` already uses (service.ts).
|
|
8
|
+
* This module stays small on purpose — it grows only when a real caller needs a new type to catch,
|
|
9
|
+
* not as a speculative taxonomy of everything that could go wrong.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AbxSdkError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A sent transaction MINED with `status: 'reverted'`. Thrown by {@link makeHotSender} (and anything
|
|
16
|
+
* else driving `SendTx`) instead of letting a revert masquerade as a "confirmed" send — carries the
|
|
17
|
+
* tx hash so a caller can look it up on an explorer without re-parsing a message string.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TxRevertedError extends AbxSdkError {
|
|
20
|
+
readonly op: string;
|
|
21
|
+
readonly txHash: Hex;
|
|
22
|
+
constructor(op: string, txHash: Hex);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `pinGas`'s refusal: every estimate attempt came back below the transaction's PROVABLE gas floor
|
|
26
|
+
* (`PreparedTx.gasFloor` — EVM code deposit at exactly 200 gas/byte, and nothing else is physics).
|
|
27
|
+
* That is proof the node answering the estimate hasn't seen the target's deploy block yet, not that
|
|
28
|
+
* the floor is wrong — see `pinGas` in `execute.ts` for the full reasoning. Carries both numbers so a
|
|
29
|
+
* caller can decide to retry against a different RPC rather than re-parse the message.
|
|
30
|
+
*/
|
|
31
|
+
export declare class GasEstimateBelowFloorError extends AbxSdkError {
|
|
32
|
+
readonly estimate: bigint;
|
|
33
|
+
readonly floor: bigint;
|
|
34
|
+
constructor(estimate: bigint, floor: bigint);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* No signing key resolved. SINGLE env name: `ABX_DEPLOYER_PK` — thrown by {@link makeWalletClient}
|
|
38
|
+
* and {@link envSigningKey} (clients.ts). Names the two retired names explicitly (`SEPOLIA_FUNDED_PK`
|
|
39
|
+
* / `SEPOLIA_WALLET_PK`) rather than just omitting them, because a caller upgrading from an older
|
|
40
|
+
* alpha has one of those set in their `.env` and would otherwise see a plain "no key found" with no
|
|
41
|
+
* clue that the key IS there, just under a name the SDK no longer reads.
|
|
42
|
+
*/
|
|
43
|
+
export declare class MissingSigningKeyError extends AbxSdkError {
|
|
44
|
+
constructor();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A registry-resolved dependency's on-chain bytes are gzip'd, and no `inflate` was supplied to
|
|
48
|
+
* decompress them (`resolveRegistryDep`/`dependencyScriptTags`, deps.ts). SDK core carries no
|
|
49
|
+
* `node:zlib` — it has to stay reachable from a browser bundle (see `test/browser-bundle.test.ts`)
|
|
50
|
+
* — so decompression is an injected function rather than a direct call. Thrown instead of letting
|
|
51
|
+
* the caller either crash on `opts.inflate(...)` being undefined or silently serve a broken
|
|
52
|
+
* document; names the exact fix instead of a generic "cannot read properties of undefined".
|
|
53
|
+
*/
|
|
54
|
+
export declare class InflateRequiredError extends AbxSdkError {
|
|
55
|
+
constructor();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A caller asked reconstruction to stop at the `"safe"` or `"finalized"` block tag
|
|
59
|
+
* ({@link resolveBlockTag}, reconstruct.ts) and the RPC either rejected `eth_getBlockByNumber` for
|
|
60
|
+
* that tag or answered with no block number. Thrown rather than silently falling back to `latest`:
|
|
61
|
+
* the whole point of naming `safe`/`finalized` is the reorg-safety guarantee that tag carries, and a
|
|
62
|
+
* quiet substitution would hand back a normal-looking reconstruction that scanned further than the
|
|
63
|
+
* caller asked for — indistinguishable from success until a reorg proves it wrong. Some
|
|
64
|
+
* chains/providers genuinely don't serve these tags: pre-merge chains have no post-merge finality,
|
|
65
|
+
* and some non-archive or indexer-backed RPCs answer neither tag at all. Expected and actionable,
|
|
66
|
+
* not a bug — names the fallback so a caller isn't stuck.
|
|
67
|
+
*/
|
|
68
|
+
export declare class BlockTagUnavailableError extends AbxSdkError {
|
|
69
|
+
readonly tag: 'safe' | 'finalized';
|
|
70
|
+
constructor(tag: 'safe' | 'finalized', cause?: unknown);
|
|
71
|
+
}
|
|
72
|
+
/** The bootstrap-or-refuse trust anchors / singletons `ensureFactory` & co. (anchors.ts) resolve —
|
|
73
|
+
* the 721 set (five) plus the ERC-1155 editions twins (`ensureOneOfOneEditionFactory`/
|
|
74
|
+
* `ensureEditionFactory`/`ensureEditionCodeFactory`). */
|
|
75
|
+
export type AnchorKind = 'factory' | 'series-factory' | 'series-code-factory' | 'renderer' | 'seed-source' | 'one-of-one-edition-factory' | 'edition-factory' | 'edition-code-factory';
|
|
76
|
+
/**
|
|
77
|
+
* A trust anchor {@link AnchorKind} that `ensureFactory`/`ensureSeriesFactory`/
|
|
78
|
+
* `ensureSeriesCodeFactory` (anchors.ts) could not resolve to a usable address, with
|
|
79
|
+
* `allowBootstrap` false — the caller must either point at a working one (override / env /
|
|
80
|
+
* manifest) or opt in to deploying a private one. Carries structured `detail` + `address` instead
|
|
81
|
+
* of a formatted sentence: the SDK doesn't know a UX's flag names or chain-key strings, so it never
|
|
82
|
+
* composes the actual guidance text itself — that's the CLI's `refuseMissingFactory`, which catches
|
|
83
|
+
* this and names the env var / `--bootstrap-factory` / the chain.
|
|
84
|
+
*/
|
|
85
|
+
export declare class AnchorUnavailableError extends AbxSdkError {
|
|
86
|
+
readonly anchor: AnchorKind;
|
|
87
|
+
readonly detail: 'no-code' | 'stale-version' | 'not-configured';
|
|
88
|
+
readonly address?: Address;
|
|
89
|
+
constructor(anchor: AnchorKind, detail: 'no-code' | 'stale-version' | 'not-configured', address?: Address);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A candidate seed source that {@link probeSeedSource} found unusable — thrown by
|
|
93
|
+
* `assertSeedSourceUsable` (ops.ts). Carries the whole probe (verdict + what was observed) rather
|
|
94
|
+
* than a formatted sentence, same reason as {@link AnchorUnavailableError}: the SDK doesn't know
|
|
95
|
+
* whether the caller got this address from a `--seed-source` flag, an env var, or a form field, so
|
|
96
|
+
* it never composes the guidance itself.
|
|
97
|
+
*
|
|
98
|
+
* Worth catching by type: this is the ONE misconfiguration whose consequence is "every mint of the
|
|
99
|
+
* collection reverts", and it is invisible on every read surface (`seedSource()` returns exactly
|
|
100
|
+
* what was set; the `SeedSourceSet` event fires) — so a UX should treat it as a hard stop, not a
|
|
101
|
+
* warning it can proceed past.
|
|
102
|
+
*/
|
|
103
|
+
export declare class SeedSourceUnusableError extends AbxSdkError {
|
|
104
|
+
readonly verdict: SeedSourceVerdict;
|
|
105
|
+
readonly address: Address;
|
|
106
|
+
readonly probe: SeedSourceProbe;
|
|
107
|
+
constructor(probe: SeedSourceProbe);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,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