@artblocks/abx-cli 0.1.0-alpha.41 → 0.1.0-alpha.43
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 +8 -156
- package/dist/commands/deploy.d.ts +51 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +300 -130
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/maintenance.js +3 -3
- package/dist/commands/project.d.ts +1 -1
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +36 -12
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/reads.d.ts +1 -1
- package/dist/commands/reads.js +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +6 -6
- package/dist/config.js.map +1 -1
- package/dist/deploy-plan.d.ts +86 -18
- package/dist/deploy-plan.d.ts.map +1 -1
- package/dist/deploy-plan.js +7 -18
- package/dist/deploy-plan.js.map +1 -1
- package/dist/main.js +17 -7
- package/dist/main.js.map +1 -1
- package/dist/ownerops.d.ts +74 -5
- package/dist/ownerops.d.ts.map +1 -1
- package/dist/ownerops.js +173 -14
- package/dist/ownerops.js.map +1 -1
- package/dist/riskgate.d.ts +36 -0
- package/dist/riskgate.d.ts.map +1 -1
- package/dist/riskgate.js +91 -17
- package/dist/riskgate.js.map +1 -1
- package/package.json +8 -8
- package/skill/SKILL.md +1 -1
- package/skill/reference/code.md +14 -0
- package/skill/reference/operate.md +12 -0
package/dist/ownerops.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* served state reflects the change. The agent picks the lane; the human only
|
|
7
7
|
* approves (wallet lane) or it's the env key (hot lane).
|
|
8
8
|
*/
|
|
9
|
-
import { type OnChainParamSchema, type SeedSourceProbe, type SendTx, type Address, type Hex, type OnChainFieldInput, tokenUriGasEstimate, ONCHAIN_PROJECT_SOFT_LIMIT, ONCHAIN_READ_WARN_BYTES, ETH_CALL_GAS_FLOOR, readableBytesAtGas, type Compress, type ContentPlan } from '@artblocks/abx-sdk';
|
|
9
|
+
import { type OnChainParamSchema, type SeedSourceProbe, type SendTx, type Address, type Hex, type PublicClient, type OnChainFieldInput, tokenUriGasEstimate, ONCHAIN_PROJECT_SOFT_LIMIT, ONCHAIN_READ_WARN_BYTES, ETH_CALL_GAS_FLOOR, readableBytesAtGas, type Compress, type ContentPlan } from '@artblocks/abx-sdk';
|
|
10
10
|
import { type WalletSession } from './signer.js';
|
|
11
11
|
import { type ParsedSchema } from './schema.js';
|
|
12
12
|
export { ONCHAIN_PROJECT_SOFT_LIMIT, ONCHAIN_READ_WARN_BYTES, ETH_CALL_GAS_FLOOR, tokenUriGasEstimate, readableBytesAtGas, type Compress };
|
|
@@ -85,7 +85,7 @@ export declare function cmdLockDependencies(address: string | undefined, flags:
|
|
|
85
85
|
export declare function cmdLockScript(address: string | undefined, flags: Flags): Promise<void>;
|
|
86
86
|
/**
|
|
87
87
|
* `abx replace-script <address> --script <path>` — the safe, first-class way to replace an
|
|
88
|
-
* UNLOCKED code project's on-chain program
|
|
88
|
+
* UNLOCKED code project's on-chain program. `OnChainScript.sol` permits `setScriptChunk`/
|
|
89
89
|
* `removeLastScriptChunk` right up until `lock-script` — but before this command the only writer
|
|
90
90
|
* was `deploy-code` (its initial setup, or its `--resume` leg for a setup that never landed).
|
|
91
91
|
* Neither is "replace a program that's already live and correct on-chain", which is the gap this
|
|
@@ -414,8 +414,8 @@ export declare function cmdSetField(address: string | undefined, flags: Flags):
|
|
|
414
414
|
* /data/{key}`, the token-api route grammar (`packages/token-api/src/server.ts`'s `/t` and `/c`
|
|
415
415
|
* routes). `base` already carries its OWN `/t` or `/c` prefix (see `TokenURI.sol`/`ContractURI.sol`
|
|
416
416
|
* — `deploy-code`/`deploy`/etc. bake `tokenURIBase = "${host}/t"`), so this never re-adds one.
|
|
417
|
-
* Exported so a creator or an agent never hand-
|
|
418
|
-
*
|
|
417
|
+
* Exported so a creator or an agent never has to hand-assemble this from the docs. The old `attach`
|
|
418
|
+
* output was a bare path, not a URL anyone could actually GET.
|
|
419
419
|
*/
|
|
420
420
|
export declare function canonicalAttachmentUrl(opts: {
|
|
421
421
|
uriBase: string;
|
|
@@ -426,7 +426,7 @@ export declare function canonicalAttachmentUrl(opts: {
|
|
|
426
426
|
}): string;
|
|
427
427
|
/**
|
|
428
428
|
* Is ANY resolver actually answering for this project right now — the precondition for an
|
|
429
|
-
* attachment to ever become fetchable, and the check `attach`
|
|
429
|
+
* attachment to ever become fetchable, and the check `attach` did not originally run (it warned on
|
|
430
430
|
* an EMPTY resolver base, but a non-empty one that answered nothing got a silent, confident "listed
|
|
431
431
|
* in this project's resolver artifacts"). Reuses `cmdVerifyRemote`'s own GET-and-classify shape
|
|
432
432
|
* (`served.ts`'s `fetchServedTokenUri`) rather than a second HTTP client.
|
|
@@ -476,6 +476,75 @@ export declare function probeResolverReachable(opts: {
|
|
|
476
476
|
* transaction it always did.
|
|
477
477
|
*/
|
|
478
478
|
export declare function cmdAttach(rest: string[], flags: Flags): Promise<void>;
|
|
479
|
+
/**
|
|
480
|
+
* Which scope actually SERVES `field` right now — the same question `abx tokenuri`'s
|
|
481
|
+
* `abx_provenance` line answers, and the one `lock-field` did not originally ask:
|
|
482
|
+
* `lock-field --field description --token 0` reported "would succeed" — and DID succeed — on a
|
|
483
|
+
* project where `description` is COLLECTION-scoped, freezing an empty token-scope slot while the
|
|
484
|
+
* value every viewer actually sees (the collection one) stayed completely mutable. Every statement
|
|
485
|
+
* the CLI made was true; together they promised a permanent freeze that never happened.
|
|
486
|
+
*
|
|
487
|
+
* Mirrors the renderer's own fallback (`AbxMetadataRenderer._field` / `fieldWithFallback` in
|
|
488
|
+
* token-api/metadata.ts): a token-scope value wins when set; only when the token slot is empty does
|
|
489
|
+
* the collection-scope value show through. Best-effort by design — a read that could not be
|
|
490
|
+
* answered (RPC unreachable, or a contract predating the on-chain-metadata extension) returns
|
|
491
|
+
* `null` rather than asserting a scope this call does not actually know, matching
|
|
492
|
+
* `refuseIfParamKey`'s posture just above.
|
|
493
|
+
*
|
|
494
|
+
* Exported with an injected `client` (mirrors `readCollectionLocks` in project.ts) so a test can
|
|
495
|
+
* exercise the real chain-read shape against a mocked `PublicClient` — no network, no live fixture.
|
|
496
|
+
*/
|
|
497
|
+
export declare function fieldScopePresence(client: PublicClient, contract: Address, tokenId: bigint, field: string): Promise<FieldScopePresence | null>;
|
|
498
|
+
/** Does the token scope, or the collection scope, hold a (non-empty) value for the field —
|
|
499
|
+
* independently; a project can have either, both, or neither. See {@link fieldScopePresence}. */
|
|
500
|
+
export interface FieldScopePresence {
|
|
501
|
+
token: boolean;
|
|
502
|
+
collection: boolean;
|
|
503
|
+
}
|
|
504
|
+
export type LockFieldScope = 'token' | 'collection';
|
|
505
|
+
/**
|
|
506
|
+
* Pure decision core for the wrong-scope lock check — exported so it is unit-testable with no chain
|
|
507
|
+
* at all, matching `computeAvailability`'s split (project.ts): the
|
|
508
|
+
* chain read is a thin, low-risk passthrough; the judgment call belongs in a function a test can
|
|
509
|
+
* call directly.
|
|
510
|
+
*
|
|
511
|
+
* Mirrors the renderer's own fallback (`AbxMetadataRenderer._field` / `fieldWithFallback` in
|
|
512
|
+
* token-api/metadata.ts): a token-scope value wins over collection when both are set, so the scope
|
|
513
|
+
* that's actually SERVED can differ from the scope the caller names. Returns `null` — nothing to
|
|
514
|
+
* flag — when the chosen scope already IS what's served, or when genuinely neither scope carries a
|
|
515
|
+
* value yet (locking a truly empty field is unambiguous: there's no "other" visible value this
|
|
516
|
+
* command could fail to protect).
|
|
517
|
+
*/
|
|
518
|
+
export declare function detectLockFieldScopeMismatch(presence: FieldScopePresence, chosen: LockFieldScope): {
|
|
519
|
+
effective: LockFieldScope;
|
|
520
|
+
chosen: LockFieldScope;
|
|
521
|
+
} | null;
|
|
522
|
+
/**
|
|
523
|
+
* Refuse, or (under `--force-field`) loudly warn but proceed — the two allowed outcomes of a
|
|
524
|
+
* detected mismatch, decided PURELY from the mismatch + whether the override flag was passed, so
|
|
525
|
+
* this is unit-testable without a chain or a console.
|
|
526
|
+
*
|
|
527
|
+
* Deliberately does NOT refuse unconditionally with no escape hatch: pre-locking an empty slot so
|
|
528
|
+
* it can never be filled — e.g. permanently guaranteeing one token can never diverge from the
|
|
529
|
+
* collection default — is a legitimate, deliberate use of this same command, and an unconditional
|
|
530
|
+
* refusal would just trade one bug (a silent no-op freeze) for another (a real, protocol-supported
|
|
531
|
+
* shape the CLI now falsely claims is impossible — see "false refusal is a membrane defect").
|
|
532
|
+
* `--force-field` is lock-field's existing general override for its own protective checks (see
|
|
533
|
+
* `refuseIfParamKey` above); this reuses it rather than adding a second, narrower flag for the same
|
|
534
|
+
* "yes, I really mean this" answer.
|
|
535
|
+
*/
|
|
536
|
+
export declare function lockFieldScopeVerdict(mismatch: {
|
|
537
|
+
effective: LockFieldScope;
|
|
538
|
+
chosen: LockFieldScope;
|
|
539
|
+
}, opts: {
|
|
540
|
+
contract: string;
|
|
541
|
+
tokenId: bigint;
|
|
542
|
+
field: string;
|
|
543
|
+
forced: boolean;
|
|
544
|
+
}): {
|
|
545
|
+
action: 'refuse' | 'warn';
|
|
546
|
+
message: string;
|
|
547
|
+
};
|
|
479
548
|
export declare function cmdLockField(address: string | undefined, flags: Flags): Promise<void>;
|
|
480
549
|
/** Point a token's URI resolution at an on-chain renderer (or clear it with `--off`).
|
|
481
550
|
* `flags.renderer` is the resolved address (main.ts defaults it to the canonical
|
package/dist/ownerops.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownerops.d.ts","sourceRoot":"","sources":["../src/ownerops.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EA4CL,KAAK,kBAAkB,EAavB,KAAK,eAAe,EAapB,KAAK,MAAM,EAIX,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,iBAAiB,EAMtB,mBAAmB,EAEnB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,kBA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M,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB7G"}
|
package/dist/ownerops.js
CHANGED
|
@@ -16,7 +16,7 @@ import { toHex as toHexSdk } from 'viem';
|
|
|
16
16
|
import { existsSync, readFileSync } from 'node:fs';
|
|
17
17
|
import { basename, resolve as resolvePath } from 'node:path';
|
|
18
18
|
import { gzipSync } from 'node:zlib';
|
|
19
|
-
import { formatEther, getAddress, isAddress, parseEther, toHex, zeroAddress } from 'viem';
|
|
19
|
+
import { formatEther, getAddress, hexToBytes, isAddress, parseEther, toHex, zeroAddress } from 'viem';
|
|
20
20
|
import { backendResolution, CHAIN, chainId, fixedPriceMinterAddress, fixedPriceMinter1155Address, localIndexer } from './config.js';
|
|
21
21
|
import { CliError } from './errors.js';
|
|
22
22
|
import { detectTokenKind, isEditionContract, assertHasParamsSurface, hasParamsSurface } from './kind.js';
|
|
@@ -557,9 +557,56 @@ function chainScriptReader(contract) {
|
|
|
557
557
|
},
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* The `gasFloor` `replace-script` restates for its batched multicall (see the call site's own
|
|
562
|
+
* comment for WHY it restates rather than sums the per-op values `prepareSetScriptChunk` already
|
|
563
|
+
* computes). This used to be `writeByteCounts.reduce((sum, n) => sum + n * 200, 0)` — code-deposit
|
|
564
|
+
* cost alone, mirroring `prepareSetScriptChunk`'s own per-chunk floor exactly.
|
|
565
|
+
*
|
|
566
|
+
* A funded on-chain sweep found that number 49% below what a real replace-script send actually
|
|
567
|
+
* needed, and the send failed after passing a `--dry-run` that called it "would succeed" (see
|
|
568
|
+
* riskgate.ts's `simulateDryRun`, fixed alongside this for the OTHER half of that finding: the dry
|
|
569
|
+
* run never checked gas/cost at all, floor included). Investigating this specific number: the
|
|
570
|
+
* deposit-only floor was never WRONG about what it claims — it is still a true lower bound — but it
|
|
571
|
+
* was radically INCOMPLETE for a multi-chunk replacement, because it omits two costs that are just as
|
|
572
|
+
* unconditionally "physics" as the 200 gas/byte deposit, and are not "an invented estimate" the
|
|
573
|
+
* codebase's own philosophy (see execute.ts's `pinGas` doc) warns against including:
|
|
574
|
+
*
|
|
575
|
+
* - `Gcreate` = 32,000 gas per `setScriptChunk` WRITE. `OnChainScript.setScriptChunk` stores its
|
|
576
|
+
* bytes via `SSTORE2.write`, which is one `CREATE` per call — a fixed opcode cost incurred
|
|
577
|
+
* regardless of chain state, chunk size, or whether the index already held something. A replace
|
|
578
|
+
* that (say) uses a small `--chunk-size` to spread one program over many chunks pays this 32,000
|
|
579
|
+
* once per chunk; the old floor counted 0 of it, so the gap grows with chunk COUNT, not just
|
|
580
|
+
* total bytes — exactly the shape a small-`--chunk-size` multi-chunk replacement produces.
|
|
581
|
+
* - The intrinsic cost of the multicall's own calldata — 16 gas per non-zero byte, 4 gas per zero
|
|
582
|
+
* byte (EIP-2028), plus the flat 21,000 base every transaction pays (EIP-2) — computed from the
|
|
583
|
+
* REAL encoded `data`, not approximated from chunk byte counts. `eth_estimateGas` (what `pinGas`
|
|
584
|
+
* compares the floor against) always includes both; the old floor included neither, so it could
|
|
585
|
+
* never clear this amount even for a single-chunk replacement with no removes at all.
|
|
586
|
+
*
|
|
587
|
+
* Deliberately still NOT included, because — unlike the two above — they genuinely depend on
|
|
588
|
+
* on-chain state this function doesn't read, and a floor that could overstate the true minimum stops
|
|
589
|
+
* being a floor: the SSTORE cost of the chunk-pointer mapping and the chunk-count counter (cold vs.
|
|
590
|
+
* warm, zero-vs-nonzero all vary by what's on chain now), `removeLastScriptChunk`'s own cost, and any
|
|
591
|
+
* gas refund (refunds apply AFTER execution and never reduce what a transaction must be GIVEN to
|
|
592
|
+
* avoid running out mid-execution, so they could only ever justify a LOWER floor, working against the
|
|
593
|
+
* "never send an under-funded tx" goal this exists for). So this remains a floor, not an estimate —
|
|
594
|
+
* `simulateDryRun`'s new `estimatedGas`/`estimatedCostWei` (from `pinGas`'s real `eth_estimateGas`,
|
|
595
|
+
* the same call the send itself makes) is the number to trust for cost guidance; this is only ever
|
|
596
|
+
* the threshold that flags an implausible one.
|
|
597
|
+
*/
|
|
598
|
+
function replaceScriptGasFloor(finalCalldata, writeByteCounts) {
|
|
599
|
+
const bytes = hexToBytes(finalCalldata);
|
|
600
|
+
let calldataGas = 0n;
|
|
601
|
+
for (const b of bytes)
|
|
602
|
+
calldataGas += b === 0 ? 4n : 16n;
|
|
603
|
+
const createBase = BigInt(writeByteCounts.length) * 32000n;
|
|
604
|
+
const depositGas = writeByteCounts.reduce((sum, n) => sum + BigInt(n) * 200n, 0n);
|
|
605
|
+
return 21000n + calldataGas + createBase + depositGas;
|
|
606
|
+
}
|
|
560
607
|
/**
|
|
561
608
|
* `abx replace-script <address> --script <path>` — the safe, first-class way to replace an
|
|
562
|
-
* UNLOCKED code project's on-chain program
|
|
609
|
+
* UNLOCKED code project's on-chain program. `OnChainScript.sol` permits `setScriptChunk`/
|
|
563
610
|
* `removeLastScriptChunk` right up until `lock-script` — but before this command the only writer
|
|
564
611
|
* was `deploy-code` (its initial setup, or its `--resume` leg for a setup that never landed).
|
|
565
612
|
* Neither is "replace a program that's already live and correct on-chain", which is the gap this
|
|
@@ -646,11 +693,14 @@ export async function cmdReplaceScript(address, flags) {
|
|
|
646
693
|
throw new Error(`replace-script expected to batch ${ops.length} op(s) into one transaction, got ${batched.length}`);
|
|
647
694
|
}
|
|
648
695
|
// `batchOps`/`prepareMulticall` don't sum a folded gasFloor from their sub-ops (each PER-CHUNK
|
|
649
|
-
// gasFloor is real physics — see prepareSetScriptChunk's own doc — but is dropped once several
|
|
650
|
-
//
|
|
651
|
-
//
|
|
652
|
-
|
|
653
|
-
|
|
696
|
+
// gasFloor is real physics — see prepareSetScriptChunk's own doc — but is dropped once several ops
|
|
697
|
+
// merge into one multicall PreparedTx). Restate it here — using the REAL final calldata, not an
|
|
698
|
+
// approximation — so the eth_estimateGas sanity check fires for any replacement that changes
|
|
699
|
+
// anything on-chain, writes or pure removes alike. See replaceScriptGasFloor's own doc for what
|
|
700
|
+
// changed here and why (a real sweep found the deposit-only version 49% under the true minimum).
|
|
701
|
+
const writeByteCounts = plan.toWrite.map((w) => (w.hex.length - 2) / 2);
|
|
702
|
+
const floor = replaceScriptGasFloor(batched[0].data, writeByteCounts);
|
|
703
|
+
const tx = { ...batched[0], gasFloor: `0x${floor.toString(16)}` };
|
|
654
704
|
const sent = await runWrite(contract, tx, flags, owner);
|
|
655
705
|
if (!sent)
|
|
656
706
|
return; // dry run, or the cold lane — nothing landed to verify yet
|
|
@@ -2114,14 +2164,14 @@ async function reportUriAfterFieldWrite(contract, collection, flags) {
|
|
|
2114
2164
|
` a field renderer must NEVER revert.`);
|
|
2115
2165
|
}
|
|
2116
2166
|
}
|
|
2117
|
-
// ── attach: the canonical fetch URL + a real reachability probe
|
|
2167
|
+
// ── attach: the canonical fetch URL + a real reachability probe ───────────────
|
|
2118
2168
|
/**
|
|
2119
2169
|
* The exact, directly-fetchable URL for one attached key — `{base}/{chainId}/{address}[/{tokenId}]
|
|
2120
2170
|
* /data/{key}`, the token-api route grammar (`packages/token-api/src/server.ts`'s `/t` and `/c`
|
|
2121
2171
|
* routes). `base` already carries its OWN `/t` or `/c` prefix (see `TokenURI.sol`/`ContractURI.sol`
|
|
2122
2172
|
* — `deploy-code`/`deploy`/etc. bake `tokenURIBase = "${host}/t"`), so this never re-adds one.
|
|
2123
|
-
* Exported so a creator or an agent never hand-
|
|
2124
|
-
*
|
|
2173
|
+
* Exported so a creator or an agent never has to hand-assemble this from the docs. The old `attach`
|
|
2174
|
+
* output was a bare path, not a URL anyone could actually GET.
|
|
2125
2175
|
*/
|
|
2126
2176
|
export function canonicalAttachmentUrl(opts) {
|
|
2127
2177
|
const base = opts.uriBase.replace(/\/+$/, '');
|
|
@@ -2130,7 +2180,7 @@ export function canonicalAttachmentUrl(opts) {
|
|
|
2130
2180
|
}
|
|
2131
2181
|
/**
|
|
2132
2182
|
* Is ANY resolver actually answering for this project right now — the precondition for an
|
|
2133
|
-
* attachment to ever become fetchable, and the check `attach`
|
|
2183
|
+
* attachment to ever become fetchable, and the check `attach` did not originally run (it warned on
|
|
2134
2184
|
* an EMPTY resolver base, but a non-empty one that answered nothing got a silent, confident "listed
|
|
2135
2185
|
* in this project's resolver artifacts"). Reuses `cmdVerifyRemote`'s own GET-and-classify shape
|
|
2136
2186
|
* (`served.ts`'s `fetchServedTokenUri`) rather than a second HTTP client.
|
|
@@ -2258,7 +2308,7 @@ export async function cmdAttach(rest, flags) {
|
|
|
2258
2308
|
for (const p of pairs) {
|
|
2259
2309
|
console.log(` attaching ${bold(p.key)} ${dim(`(${p.mimeType}, ${p.representation})`)} to ${scope}: ${dim(p.uri)}`);
|
|
2260
2310
|
}
|
|
2261
|
-
// Where it surfaces — and whether anything can actually SERVE it
|
|
2311
|
+
// Where it surfaces — and whether anything can actually SERVE it. This used to be one dim
|
|
2262
2312
|
// line assuming a non-empty resolver base meant the artifact would be listed; it never checked.
|
|
2263
2313
|
// An integrator attached five audio stems to a fully-on-chain token, paid to store them, and found
|
|
2264
2314
|
// `tokenURI` listed none of them — "paid for, stored on-chain, and invisible". The on-chain
|
|
@@ -2317,7 +2367,7 @@ export async function cmdAttach(rest, flags) {
|
|
|
2317
2367
|
if (sent) {
|
|
2318
2368
|
const id = flags.token ?? '0';
|
|
2319
2369
|
const names = pairs.map((p) => bold(p.key)).join(', ');
|
|
2320
|
-
//
|
|
2370
|
+
// Preserve the distinction between the on-chain FIELD WRITE succeeding (this line, always true
|
|
2321
2371
|
// when we get here) is not the same fact as the artifact being SERVABLE — say both, separately,
|
|
2322
2372
|
// rather than one "✓ attached" that a reader takes to mean "and it's live".
|
|
2323
2373
|
const servingLine = !uriBase || uriBase.trim() === ''
|
|
@@ -2370,19 +2420,128 @@ async function refuseIfParamKey(contract, field) {
|
|
|
2370
2420
|
`\`abx inspect ${contract}\`.)\n` +
|
|
2371
2421
|
` If you really did mean the metadata field "${field}" and not the param, re-run with --force-field.`);
|
|
2372
2422
|
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Which scope actually SERVES `field` right now — the same question `abx tokenuri`'s
|
|
2425
|
+
* `abx_provenance` line answers, and the one `lock-field` did not originally ask:
|
|
2426
|
+
* `lock-field --field description --token 0` reported "would succeed" — and DID succeed — on a
|
|
2427
|
+
* project where `description` is COLLECTION-scoped, freezing an empty token-scope slot while the
|
|
2428
|
+
* value every viewer actually sees (the collection one) stayed completely mutable. Every statement
|
|
2429
|
+
* the CLI made was true; together they promised a permanent freeze that never happened.
|
|
2430
|
+
*
|
|
2431
|
+
* Mirrors the renderer's own fallback (`AbxMetadataRenderer._field` / `fieldWithFallback` in
|
|
2432
|
+
* token-api/metadata.ts): a token-scope value wins when set; only when the token slot is empty does
|
|
2433
|
+
* the collection-scope value show through. Best-effort by design — a read that could not be
|
|
2434
|
+
* answered (RPC unreachable, or a contract predating the on-chain-metadata extension) returns
|
|
2435
|
+
* `null` rather than asserting a scope this call does not actually know, matching
|
|
2436
|
+
* `refuseIfParamKey`'s posture just above.
|
|
2437
|
+
*
|
|
2438
|
+
* Exported with an injected `client` (mirrors `readCollectionLocks` in project.ts) so a test can
|
|
2439
|
+
* exercise the real chain-read shape against a mocked `PublicClient` — no network, no live fixture.
|
|
2440
|
+
*/
|
|
2441
|
+
export async function fieldScopePresence(client, contract, tokenId, field) {
|
|
2442
|
+
const tag = encodeTag(field);
|
|
2443
|
+
const [tokenEntry, collectionEntry] = await Promise.all([
|
|
2444
|
+
tryReadContract(client, { address: contract, abi: oneOfOneImageAbi, functionName: 'tokenField', args: [tokenId, tag] }),
|
|
2445
|
+
tryReadContract(client, { address: contract, abi: oneOfOneImageAbi, functionName: 'contractField', args: [tag] }),
|
|
2446
|
+
]);
|
|
2447
|
+
if (!tokenEntry || !collectionEntry)
|
|
2448
|
+
return null;
|
|
2449
|
+
return { token: tokenEntry[1] !== '0x', collection: collectionEntry[1] !== '0x' };
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Pure decision core for the wrong-scope lock check — exported so it is unit-testable with no chain
|
|
2453
|
+
* at all, matching `computeAvailability`'s split (project.ts): the
|
|
2454
|
+
* chain read is a thin, low-risk passthrough; the judgment call belongs in a function a test can
|
|
2455
|
+
* call directly.
|
|
2456
|
+
*
|
|
2457
|
+
* Mirrors the renderer's own fallback (`AbxMetadataRenderer._field` / `fieldWithFallback` in
|
|
2458
|
+
* token-api/metadata.ts): a token-scope value wins over collection when both are set, so the scope
|
|
2459
|
+
* that's actually SERVED can differ from the scope the caller names. Returns `null` — nothing to
|
|
2460
|
+
* flag — when the chosen scope already IS what's served, or when genuinely neither scope carries a
|
|
2461
|
+
* value yet (locking a truly empty field is unambiguous: there's no "other" visible value this
|
|
2462
|
+
* command could fail to protect).
|
|
2463
|
+
*/
|
|
2464
|
+
export function detectLockFieldScopeMismatch(presence, chosen) {
|
|
2465
|
+
const effective = presence.token ? 'token' : presence.collection ? 'collection' : 'none';
|
|
2466
|
+
if (effective === 'none' || effective === chosen)
|
|
2467
|
+
return null;
|
|
2468
|
+
return { effective, chosen };
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* Refuse, or (under `--force-field`) loudly warn but proceed — the two allowed outcomes of a
|
|
2472
|
+
* detected mismatch, decided PURELY from the mismatch + whether the override flag was passed, so
|
|
2473
|
+
* this is unit-testable without a chain or a console.
|
|
2474
|
+
*
|
|
2475
|
+
* Deliberately does NOT refuse unconditionally with no escape hatch: pre-locking an empty slot so
|
|
2476
|
+
* it can never be filled — e.g. permanently guaranteeing one token can never diverge from the
|
|
2477
|
+
* collection default — is a legitimate, deliberate use of this same command, and an unconditional
|
|
2478
|
+
* refusal would just trade one bug (a silent no-op freeze) for another (a real, protocol-supported
|
|
2479
|
+
* shape the CLI now falsely claims is impossible — see "false refusal is a membrane defect").
|
|
2480
|
+
* `--force-field` is lock-field's existing general override for its own protective checks (see
|
|
2481
|
+
* `refuseIfParamKey` above); this reuses it rather than adding a second, narrower flag for the same
|
|
2482
|
+
* "yes, I really mean this" answer.
|
|
2483
|
+
*/
|
|
2484
|
+
export function lockFieldScopeVerdict(mismatch, opts) {
|
|
2485
|
+
const { effective, chosen } = mismatch;
|
|
2486
|
+
const correctCmd = effective === 'collection'
|
|
2487
|
+
? `abx lock-field ${opts.contract} --field ${opts.field} --collection`
|
|
2488
|
+
: `abx lock-field ${opts.contract} --field ${opts.field} --token ${opts.tokenId}`;
|
|
2489
|
+
const servedFrom = effective === 'collection' ? 'COLLECTION scope (shared across every token)' : `TOKEN #${opts.tokenId}'s own scope (a per-token override)`;
|
|
2490
|
+
const chosenDesc = chosen === 'collection' ? 'the COLLECTION scope' : `token #${opts.tokenId}'s scope`;
|
|
2491
|
+
if (!opts.forced) {
|
|
2492
|
+
return {
|
|
2493
|
+
action: 'refuse',
|
|
2494
|
+
message: `locking ${chosenDesc} would report "permanent" and DO NOTHING to freeze what's actually shown: '${opts.field}' for token #${opts.tokenId} ` +
|
|
2495
|
+
`is currently served from ${servedFrom}, not the scope you're about to lock. Lock the scope that's actually visible instead:\n` +
|
|
2496
|
+
` ${correctCmd}\n` +
|
|
2497
|
+
` If you deliberately want to freeze ${chosenDesc}'s slot forever anyway (e.g. guaranteeing this token can never diverge from the ` +
|
|
2498
|
+
`collection default), re-run with --force-field — it will proceed, with a loud warning that ${servedFrom} stays unfrozen.`,
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
return {
|
|
2502
|
+
action: 'warn',
|
|
2503
|
+
message: `⚠⚠ LOCKING A SLOT THAT IS NOT WHAT'S DISPLAYED ⚠⚠\n` +
|
|
2504
|
+
` '${opts.field}' for token #${opts.tokenId} is currently served from ${servedFrom} — THIS LOCK DOES NOT FREEZE THAT VALUE.\n` +
|
|
2505
|
+
` You are about to PERMANENTLY lock ${chosenDesc}'s slot instead (proceeding because of --force-field). That value can never change again, ` +
|
|
2506
|
+
`but the value viewers actually see today is untouched by this operation and remains fully mutable.`,
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Refuse (or, under `--force-field`, loudly warn but proceed) a `lock-field` whose CHOSEN scope is
|
|
2511
|
+
* not the scope actually serving `field` right now. Best-effort by design: a read that could not be
|
|
2512
|
+
* answered (RPC unreachable, or a contract predating the on-chain-metadata extension) skips the
|
|
2513
|
+
* check rather than asserting a scope this call does not actually know, matching
|
|
2514
|
+
* `refuseIfParamKey`'s posture above. Runs BEFORE `runWrite`, so `--dry-run` and a real send see
|
|
2515
|
+
* this identically.
|
|
2516
|
+
*/
|
|
2517
|
+
async function warnOrRefuseWrongScope(contract, tokenId, field, collection, flags) {
|
|
2518
|
+
const presence = await fieldScopePresence(makePublicClient({ chainKey: CHAIN }), contract, tokenId, field);
|
|
2519
|
+
if (!presence)
|
|
2520
|
+
return; // couldn't determine either scope — don't block on a fact we don't have
|
|
2521
|
+
const chosen = collection ? 'collection' : 'token';
|
|
2522
|
+
const mismatch = detectLockFieldScopeMismatch(presence, chosen);
|
|
2523
|
+
if (!mismatch)
|
|
2524
|
+
return; // nothing to freeze, or the right scope
|
|
2525
|
+
const verdict = lockFieldScopeVerdict(mismatch, { contract, tokenId, field, forced: flags['force-field'] !== undefined });
|
|
2526
|
+
if (verdict.action === 'refuse')
|
|
2527
|
+
throw new Error(verdict.message);
|
|
2528
|
+
console.log(` ${red(verdict.message)}`);
|
|
2529
|
+
}
|
|
2373
2530
|
export async function cmdLockField(address, flags) {
|
|
2374
2531
|
const contract = requireAddress(address, 'abx lock-field <address> --field <name> [--collection | --token 0] [--sign|--unsigned]');
|
|
2375
2532
|
const field = requireFlag(flags, 'field', 'abx lock-field <address> --field <name>');
|
|
2376
2533
|
const collection = !!flags.collection;
|
|
2534
|
+
const tokenId = BigInt(flags.token ?? '0');
|
|
2377
2535
|
// The metadata field and a same-named param are different things; only an explicit --force-field
|
|
2378
2536
|
// says "yes, I mean the field". See refuseIfParamKey.
|
|
2379
2537
|
if (flags['force-field'] === undefined)
|
|
2380
2538
|
await refuseIfParamKey(contract, field);
|
|
2539
|
+
await warnOrRefuseWrongScope(contract, tokenId, field, collection, flags);
|
|
2381
2540
|
const owner = await read(contract, 'owner');
|
|
2382
2541
|
console.log(dim(` note: locking the '${field}' field is permanent and irreversible (freezes all its representations).`));
|
|
2383
2542
|
const tx = collection
|
|
2384
2543
|
? prepareLockContractField({ contract, field, chainId: chainId() })
|
|
2385
|
-
: prepareLockTokenField({ contract, tokenId
|
|
2544
|
+
: prepareLockTokenField({ contract, tokenId, field, chainId: chainId() });
|
|
2386
2545
|
await runWrite(contract, tx, flags, owner);
|
|
2387
2546
|
}
|
|
2388
2547
|
// ── set-renderer (toggle on-chain URI resolution) ─────────────────────────────
|