@artblocks/abx-cli 0.1.0-alpha.2 → 0.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1762 -0
- package/assets/renderer-scaffold/src/interfaces/IAbxParams.sol +17 -0
- package/assets/renderer-scaffold/test/MyRenderer.t.sol +51 -2
- package/dist/commands/deploy.d.ts +206 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +4004 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/project.d.ts +241 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +1044 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/reads.d.ts +64 -0
- package/dist/commands/reads.d.ts.map +1 -0
- package/dist/commands/reads.js +667 -0
- package/dist/commands/reads.js.map +1 -0
- package/dist/commands/scaffold.d.ts +71 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/scaffold.js +544 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/commands/service.d.ts +41 -0
- package/dist/commands/service.d.ts.map +1 -0
- package/dist/commands/service.js +618 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/storage.d.ts +37 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +335 -0
- package/dist/commands/storage.js.map +1 -0
- package/dist/config.d.ts +91 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +244 -11
- package/dist/config.js.map +1 -1
- package/dist/conformance.d.ts +31 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +371 -0
- package/dist/conformance.js.map +1 -0
- package/dist/deps.d.ts +6 -39
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +4 -68
- package/dist/deps.js.map +1 -1
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/flags.d.ts +41 -0
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +94 -1
- package/dist/flags.js.map +1 -1
- package/dist/jsonout.d.ts +37 -0
- package/dist/jsonout.d.ts.map +1 -0
- package/dist/jsonout.js +68 -0
- package/dist/jsonout.js.map +1 -0
- package/dist/kind.d.ts +48 -0
- package/dist/kind.d.ts.map +1 -0
- package/dist/kind.js +69 -0
- package/dist/kind.js.map +1 -0
- package/dist/main.js +509 -4708
- package/dist/main.js.map +1 -1
- package/dist/mintpage.d.ts +17 -2
- package/dist/mintpage.d.ts.map +1 -1
- package/dist/mintpage.js +214 -52
- package/dist/mintpage.js.map +1 -1
- package/dist/output.d.ts +148 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +634 -0
- package/dist/output.js.map +1 -0
- package/dist/ownerops.d.ts +132 -44
- package/dist/ownerops.d.ts.map +1 -1
- package/dist/ownerops.js +1067 -327
- package/dist/ownerops.js.map +1 -1
- package/dist/preview.d.ts +81 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +535 -0
- package/dist/preview.js.map +1 -0
- package/dist/prompt.d.ts +17 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +19 -0
- package/dist/prompt.js.map +1 -0
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +10 -7
- package/dist/provision.js.map +1 -1
- package/dist/remote.d.ts +134 -53
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +352 -46
- package/dist/remote.js.map +1 -1
- package/dist/riskgate.d.ts +29 -0
- package/dist/riskgate.d.ts.map +1 -0
- package/dist/riskgate.js +91 -0
- package/dist/riskgate.js.map +1 -0
- package/dist/scaffold.d.ts +10 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +52 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/schema.d.ts +18 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +74 -23
- package/dist/schema.js.map +1 -1
- package/dist/served.d.ts +30 -0
- package/dist/served.d.ts.map +1 -0
- package/dist/served.js +112 -0
- package/dist/served.js.map +1 -0
- package/dist/signer.d.ts +13 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +80 -14
- package/dist/signer.js.map +1 -1
- package/dist/update-check.d.ts +58 -4
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +92 -11
- package/dist/update-check.js.map +1 -1
- package/package.json +10 -6
- package/skill/SKILL.md +104 -60
- package/skill/reference/code-projects.md +87 -13
- package/skill/reference/creator-token.md +86 -0
- package/skill/reference/decisions.md +61 -0
- package/skill/reference/hosting.md +48 -15
- package/skill/reference/operating.md +29 -8
- package/skill/reference/setup.md +10 -3
- package/skill/reference/troubleshooting.md +31 -4
- package/dist/inspect.d.ts +0 -48
- package/dist/inspect.d.ts.map +0 -1
- package/dist/inspect.js +0 -184
- package/dist/inspect.js.map +0 -1
- package/dist/migrate.d.ts +0 -65
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -180
- package/dist/migrate.js.map +0 -1
- package/dist/onchain-uri.d.ts +0 -97
- package/dist/onchain-uri.d.ts.map +0 -1
- package/dist/onchain-uri.js +0 -243
- package/dist/onchain-uri.js.map +0 -1
- package/dist/upload.d.ts +0 -28
- package/dist/upload.d.ts.map +0 -1
- package/dist/upload.js +0 -41
- package/dist/upload.js.map +0 -1
package/dist/flags.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* the first (a real footgun on a multi-param drop; a Select's options use `|` not `,`, so the
|
|
10
10
|
* comma-join never collides with an option list).
|
|
11
11
|
*/
|
|
12
|
+
import { type Hex } from 'viem';
|
|
12
13
|
export type Flags = Record<string, string | undefined>;
|
|
13
14
|
/** Flags where every occurrence counts (values comma-join, in argv order). */
|
|
14
15
|
export declare const REPEATABLE_FLAGS: ReadonlySet<string>;
|
|
@@ -18,7 +19,18 @@ export declare const REPEATABLE_FLAGS: ReadonlySet<string>;
|
|
|
18
19
|
* `no-update-check` opts out of the startup update nudge (see update-check.ts).
|
|
19
20
|
*/
|
|
20
21
|
export declare const GLOBAL_FLAGS: ReadonlySet<string>;
|
|
22
|
+
/** Whether `--dry-run` was passed. The one place that truthiness is decided — every write command
|
|
23
|
+
* (owner-op or deploy) reads it through here rather than hand-rolling `!!flags['dry-run']`, so a
|
|
24
|
+
* fresh command can't ship with a *slightly* different spelling of the same check (or skip it). */
|
|
25
|
+
export declare function isDryRun(flags: Flags): boolean;
|
|
21
26
|
export declare function parseFlags(args: string[]): Flags;
|
|
27
|
+
/**
|
|
28
|
+
* The bare (non-flag) arguments, with flag VALUES removed — the mirror of {@link parseFlags}, and
|
|
29
|
+
* deliberately next to it: the two must consume argv by the same rule or a flag's value looks like a
|
|
30
|
+
* positional. (Hand-rolling `args.filter(a => !a.startsWith('-'))` reads `--token 0` as a stray
|
|
31
|
+
* positional `0`, which is exactly the bug a stray-positional check is meant to catch.)
|
|
32
|
+
*/
|
|
33
|
+
export declare function positionalArgs(args: string[]): string[];
|
|
22
34
|
/**
|
|
23
35
|
* The flag keys in `flags` that are NOT in `allowed` — for a non-fatal "unrecognized flag"
|
|
24
36
|
* notice at a command's entry. {@link parseFlags} keeps any `--k` it sees, so a typo'd or
|
|
@@ -28,4 +40,33 @@ export declare function parseFlags(args: string[]): Flags;
|
|
|
28
40
|
* scripted deploy (owner's stateless/scriptable line — see cli-ux-decisions).
|
|
29
41
|
*/
|
|
30
42
|
export declare function unknownFlags(flags: Flags, allowed: Iterable<string>): string[];
|
|
43
|
+
/** Warn (never throw) on a flag the command doesn't recognize — a typo'd or unsupported flag
|
|
44
|
+
* otherwise no-ops INVISIBLY (the worst failure mode for a write-adjacent value like a mistyped
|
|
45
|
+
* --royalty-bps). Non-fatal, per the owner's scriptability line ([[cli-ux-decisions]]). */
|
|
46
|
+
export declare const FLAG_HINTS: Record<string, (cmd: string) => string | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Unknown flags on a command that can SEND: refuse, don't warn.
|
|
49
|
+
*
|
|
50
|
+
* This used to warn and carry on, and `--chain sepolia` proved why that isn't enough — the warning was
|
|
51
|
+
* accurate, it scrolled past, and the deploy ran on the DEFAULT chain. On a dry run that costs a
|
|
52
|
+
* confused minute; on a funded send it is a wrong-chain deploy. "Prose that was ignored once will be
|
|
53
|
+
* ignored again" is the standing rule here, so the tx-sending commands stop instead.
|
|
54
|
+
*
|
|
55
|
+
* Safe to refuse rather than warn because a flag absent from the allowlist is, by construction, one
|
|
56
|
+
* the command never reads — verified per command by comparing every `flags.x` read in its body against
|
|
57
|
+
* its allowlist. So refusal cannot break a working flag; it only makes an already-ignored one loud.
|
|
58
|
+
*
|
|
59
|
+
* `--dry-run` refuses identically. A preview that accepts what the real send rejects is its own trap:
|
|
60
|
+
* you'd validate a command in preview and have it fail at the moment it matters.
|
|
61
|
+
*/
|
|
62
|
+
export declare function refuseStrayFlags(flags: Flags, allowed: Set<string>, cmd: string): void;
|
|
63
|
+
/** Unknown flags on a READ-ONLY command: warn, don't refuse. Nothing can be mis-sent, and a stray
|
|
64
|
+
* flag on `preview`/`inspect` shouldn't stop a creator mid-iteration. */
|
|
65
|
+
export declare function warnStrayFlags(flags: Flags, allowed: Set<string>, cmd: string): void;
|
|
66
|
+
/** The wallet-lane owner-pinning guard: on `--sign` with no `--for`, whichever wallet connects
|
|
67
|
+
* becomes owner + royalty receiver + mint recipient (the launch-readiness "random wallet owns the
|
|
68
|
+
* collection" trap). Fires uniformly on deploy / deploy-series / deploy-code. */
|
|
69
|
+
export declare function warnSignWithoutFor(flags: Flags): void;
|
|
70
|
+
/** Validate an explicit --salt (a 32-byte hex). Undefined when absent. */
|
|
71
|
+
export declare function parseSaltFlag(raw: string | undefined): Hex | undefined;
|
|
31
72
|
//# sourceMappingURL=flags.d.ts.map
|
package/dist/flags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CASpF;AAED;;kFAEkF;AAClF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAIrD;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,SAAS,CAMtE"}
|
package/dist/flags.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { bold, info, warn } from './output.js';
|
|
1
2
|
/** Flags where every occurrence counts (values comma-join, in argv order). */
|
|
2
|
-
export const REPEATABLE_FLAGS = new Set(['dep', 'schema']);
|
|
3
|
+
export const REPEATABLE_FLAGS = new Set(['dep', 'schema', 'param']);
|
|
3
4
|
/**
|
|
4
5
|
* Flags valid on ANY command (handled centrally in main, not by a command handler), so
|
|
5
6
|
* {@link unknownFlags} never flags them as unrecognized regardless of the per-command allowlist.
|
|
6
7
|
* `no-update-check` opts out of the startup update nudge (see update-check.ts).
|
|
7
8
|
*/
|
|
8
9
|
export const GLOBAL_FLAGS = new Set(['no-update-check']);
|
|
10
|
+
/** Whether `--dry-run` was passed. The one place that truthiness is decided — every write command
|
|
11
|
+
* (owner-op or deploy) reads it through here rather than hand-rolling `!!flags['dry-run']`, so a
|
|
12
|
+
* fresh command can't ship with a *slightly* different spelling of the same check (or skip it). */
|
|
13
|
+
export function isDryRun(flags) {
|
|
14
|
+
return !!flags['dry-run'];
|
|
15
|
+
}
|
|
9
16
|
export function parseFlags(args) {
|
|
10
17
|
const out = {};
|
|
11
18
|
const set = (k, v) => {
|
|
@@ -25,6 +32,25 @@ export function parseFlags(args) {
|
|
|
25
32
|
}
|
|
26
33
|
return out;
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The bare (non-flag) arguments, with flag VALUES removed — the mirror of {@link parseFlags}, and
|
|
37
|
+
* deliberately next to it: the two must consume argv by the same rule or a flag's value looks like a
|
|
38
|
+
* positional. (Hand-rolling `args.filter(a => !a.startsWith('-'))` reads `--token 0` as a stray
|
|
39
|
+
* positional `0`, which is exactly the bug a stray-positional check is meant to catch.)
|
|
40
|
+
*/
|
|
41
|
+
export function positionalArgs(args) {
|
|
42
|
+
const out = [];
|
|
43
|
+
for (let i = 0; i < args.length; i++) {
|
|
44
|
+
const a = args[i];
|
|
45
|
+
if (a.startsWith('--')) {
|
|
46
|
+
if (a.indexOf('=') === -1 && args[i + 1] && !args[i + 1].startsWith('--'))
|
|
47
|
+
i++; // this flag consumes the next token
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
out.push(a);
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
28
54
|
/**
|
|
29
55
|
* The flag keys in `flags` that are NOT in `allowed` — for a non-fatal "unrecognized flag"
|
|
30
56
|
* notice at a command's entry. {@link parseFlags} keeps any `--k` it sees, so a typo'd or
|
|
@@ -37,4 +63,71 @@ export function unknownFlags(flags, allowed) {
|
|
|
37
63
|
const ok = new Set(allowed);
|
|
38
64
|
return Object.keys(flags).filter((k) => !ok.has(k) && !GLOBAL_FLAGS.has(k));
|
|
39
65
|
}
|
|
66
|
+
/** Warn (never throw) on a flag the command doesn't recognize — a typo'd or unsupported flag
|
|
67
|
+
* otherwise no-ops INVISIBLY (the worst failure mode for a write-adjacent value like a mistyped
|
|
68
|
+
* --royalty-bps). Non-fatal, per the owner's scriptability line ([[cli-ux-decisions]]). */
|
|
69
|
+
// Targeted "did you mean" hints for the flags creators most often invent (seen across agent sessions).
|
|
70
|
+
// A stray flag is otherwise silently ignored, so a wrong-but-plausible one (a price/supply flag that
|
|
71
|
+
// doesn't exist) reads as "it worked." Command-aware so a flag valid elsewhere isn't mis-hinted.
|
|
72
|
+
export const FLAG_HINTS = {
|
|
73
|
+
count: (cmd) => (cmd === 'deploy-code' ? 'did you mean --max <N> (the supply cap)?' : undefined),
|
|
74
|
+
price: () => 'a sale price is NOT set at deploy — configure it after with `abx minter configure <addr> --price <eth>`.',
|
|
75
|
+
supply: () => 'did you mean --max <N> (the supply cap)?',
|
|
76
|
+
amount: () => 'a sale price/amount is set post-deploy via `abx minter configure`.',
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Unknown flags on a command that can SEND: refuse, don't warn.
|
|
80
|
+
*
|
|
81
|
+
* This used to warn and carry on, and `--chain sepolia` proved why that isn't enough — the warning was
|
|
82
|
+
* accurate, it scrolled past, and the deploy ran on the DEFAULT chain. On a dry run that costs a
|
|
83
|
+
* confused minute; on a funded send it is a wrong-chain deploy. "Prose that was ignored once will be
|
|
84
|
+
* ignored again" is the standing rule here, so the tx-sending commands stop instead.
|
|
85
|
+
*
|
|
86
|
+
* Safe to refuse rather than warn because a flag absent from the allowlist is, by construction, one
|
|
87
|
+
* the command never reads — verified per command by comparing every `flags.x` read in its body against
|
|
88
|
+
* its allowlist. So refusal cannot break a working flag; it only makes an already-ignored one loud.
|
|
89
|
+
*
|
|
90
|
+
* `--dry-run` refuses identically. A preview that accepts what the real send rejects is its own trap:
|
|
91
|
+
* you'd validate a command in preview and have it fail at the moment it matters.
|
|
92
|
+
*/
|
|
93
|
+
export function refuseStrayFlags(flags, allowed, cmd) {
|
|
94
|
+
const stray = unknownFlags(flags, allowed);
|
|
95
|
+
if (!stray.length)
|
|
96
|
+
return;
|
|
97
|
+
const hints = stray.map((f) => FLAG_HINTS[f]?.(cmd)).filter(Boolean);
|
|
98
|
+
throw new Error(`unrecognized flag(s): ${stray.map((f) => '--' + f).join(', ')} — this command would have ignored them silently, so it is refusing instead.\n` +
|
|
99
|
+
hints.map((h, i) => ` ↳ --${stray[i]}: ${h}`).join('\n') +
|
|
100
|
+
(hints.length ? '\n' : '') +
|
|
101
|
+
` see \`abx help ${cmd}\` for the flags it accepts.`);
|
|
102
|
+
}
|
|
103
|
+
/** Unknown flags on a READ-ONLY command: warn, don't refuse. Nothing can be mis-sent, and a stray
|
|
104
|
+
* flag on `preview`/`inspect` shouldn't stop a creator mid-iteration. */
|
|
105
|
+
export function warnStrayFlags(flags, allowed, cmd) {
|
|
106
|
+
const stray = unknownFlags(flags, allowed);
|
|
107
|
+
if (stray.length) {
|
|
108
|
+
warn(`unrecognized flag(s), ignored: ${stray.map((f) => bold('--' + f)).join(', ')} — see \`abx help ${cmd}\`. (A misspelled or unsupported flag silently does nothing.)`);
|
|
109
|
+
for (const f of stray) {
|
|
110
|
+
const hint = FLAG_HINTS[f]?.(cmd);
|
|
111
|
+
if (hint)
|
|
112
|
+
info(` ↳ --${f}: ${hint}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** The wallet-lane owner-pinning guard: on `--sign` with no `--for`, whichever wallet connects
|
|
117
|
+
* becomes owner + royalty receiver + mint recipient (the launch-readiness "random wallet owns the
|
|
118
|
+
* collection" trap). Fires uniformly on deploy / deploy-series / deploy-code. */
|
|
119
|
+
export function warnSignWithoutFor(flags) {
|
|
120
|
+
if (flags.sign !== undefined && !flags.for) {
|
|
121
|
+
warn(`--sign without --for: whichever wallet connects becomes ${bold('owner + royalty receiver + mint recipient')}. Pass ${bold('--for <your address>')} to PIN it — the sign page then refuses a mismatched wallet (the intended safety on the wallet lane).`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Validate an explicit --salt (a 32-byte hex). Undefined when absent. */
|
|
125
|
+
export function parseSaltFlag(raw) {
|
|
126
|
+
if (!raw || raw === 'true')
|
|
127
|
+
return undefined;
|
|
128
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(raw)) {
|
|
129
|
+
throw new Error(`--salt must be a 32-byte hex (0x + 64 hex chars); got '${raw}'`);
|
|
130
|
+
}
|
|
131
|
+
return raw;
|
|
132
|
+
}
|
|
40
133
|
//# sourceMappingURL=flags.js.map
|
package/dist/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,aAAa,CAAC;AAI7C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAE9E;;oGAEoG;AACpG,MAAM,UAAU,QAAQ,CAAC,KAAY;IACnC,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACnC,GAAG,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC;IACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAClC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,EAAE,KAAK,CAAC,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IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,0DAA0D,GAAG,GAAG,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Flags } from './flags.js';
|
|
2
|
+
/**
|
|
3
|
+
* `--json`: make **stdout a machine channel**.
|
|
4
|
+
*
|
|
5
|
+
* The rule this enforces, from an integrator who drove the CLI from a server: *a value a program
|
|
6
|
+
* needs must be obtainable without parsing prose.* They had to regex-scrape ANSI-coloured stdout for
|
|
7
|
+
* every value — and an escape code ended up inside a locator, was written into a stored player URL,
|
|
8
|
+
* and 404'd in production. The cause was found only by inspecting stored bytes.
|
|
9
|
+
*
|
|
10
|
+
* So under `--json`, stdout carries exactly one JSON document and nothing else. Every narration line
|
|
11
|
+
* the command would print for a human goes to **stderr** instead — not suppressed, because a human
|
|
12
|
+
* watching a deploy still wants to see it, and a program redirecting stdout still gets a clean parse.
|
|
13
|
+
* The update-check already wrote to stderr for precisely this reason; this carries that instinct
|
|
14
|
+
* through to the values themselves.
|
|
15
|
+
*
|
|
16
|
+
* It works by swapping `console.log` for the duration rather than threading a `quiet` flag through
|
|
17
|
+
* every command body. That is deliberate: the alternative is touching dozens of call sites, where the
|
|
18
|
+
* one that gets missed is a stray line that corrupts a parse — the exact failure mode being fixed.
|
|
19
|
+
* `console.error`/`console.warn` are untouched (already stderr), and the payload is written through a
|
|
20
|
+
* captured reference to the real `console.log`, so nothing can intercept it back.
|
|
21
|
+
*/
|
|
22
|
+
export declare function jsonMode(flags: Flags): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Run `body` and, under `--json`, print whatever it returns as the sole contents of stdout.
|
|
25
|
+
*
|
|
26
|
+
* `body` receives an `emit` it may call to contribute the payload incrementally — for a command that
|
|
27
|
+
* discovers its value midway (a deploy learning its address) and would otherwise have to restructure
|
|
28
|
+
* to return it at the end. The last `emit` wins; a returned value overrides both.
|
|
29
|
+
*
|
|
30
|
+
* Without `--json` this is a plain pass-through: zero behaviour change on the human path.
|
|
31
|
+
*/
|
|
32
|
+
export declare function withJson<T extends Record<string, unknown>>(flags: Flags, body: (emit: (payload: T) => void) => Promise<T | void>): Promise<void>;
|
|
33
|
+
/** BigInt-safe JSON: bigints become decimal strings rather than throwing. Every on-chain number a
|
|
34
|
+
* payload carries (supply, a token id, a block) arrives as a bigint, and `JSON.stringify` refuses
|
|
35
|
+
* them outright — so a payload builder that forgets one would fail at the last line of a deploy. */
|
|
36
|
+
export declare function jsonSafe<T>(value: T): T;
|
|
37
|
+
//# sourceMappingURL=jsonout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonout.d.ts","sourceRoot":"","sources":["../src/jsonout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;qGAEqG;AACrG,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC"}
|
package/dist/jsonout.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--json`: make **stdout a machine channel**.
|
|
3
|
+
*
|
|
4
|
+
* The rule this enforces, from an integrator who drove the CLI from a server: *a value a program
|
|
5
|
+
* needs must be obtainable without parsing prose.* They had to regex-scrape ANSI-coloured stdout for
|
|
6
|
+
* every value — and an escape code ended up inside a locator, was written into a stored player URL,
|
|
7
|
+
* and 404'd in production. The cause was found only by inspecting stored bytes.
|
|
8
|
+
*
|
|
9
|
+
* So under `--json`, stdout carries exactly one JSON document and nothing else. Every narration line
|
|
10
|
+
* the command would print for a human goes to **stderr** instead — not suppressed, because a human
|
|
11
|
+
* watching a deploy still wants to see it, and a program redirecting stdout still gets a clean parse.
|
|
12
|
+
* The update-check already wrote to stderr for precisely this reason; this carries that instinct
|
|
13
|
+
* through to the values themselves.
|
|
14
|
+
*
|
|
15
|
+
* It works by swapping `console.log` for the duration rather than threading a `quiet` flag through
|
|
16
|
+
* every command body. That is deliberate: the alternative is touching dozens of call sites, where the
|
|
17
|
+
* one that gets missed is a stray line that corrupts a parse — the exact failure mode being fixed.
|
|
18
|
+
* `console.error`/`console.warn` are untouched (already stderr), and the payload is written through a
|
|
19
|
+
* captured reference to the real `console.log`, so nothing can intercept it back.
|
|
20
|
+
*/
|
|
21
|
+
export function jsonMode(flags) {
|
|
22
|
+
return flags.json !== undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run `body` and, under `--json`, print whatever it returns as the sole contents of stdout.
|
|
26
|
+
*
|
|
27
|
+
* `body` receives an `emit` it may call to contribute the payload incrementally — for a command that
|
|
28
|
+
* discovers its value midway (a deploy learning its address) and would otherwise have to restructure
|
|
29
|
+
* to return it at the end. The last `emit` wins; a returned value overrides both.
|
|
30
|
+
*
|
|
31
|
+
* Without `--json` this is a plain pass-through: zero behaviour change on the human path.
|
|
32
|
+
*/
|
|
33
|
+
export async function withJson(flags, body) {
|
|
34
|
+
let payload;
|
|
35
|
+
const emit = (p) => {
|
|
36
|
+
payload = p;
|
|
37
|
+
};
|
|
38
|
+
if (!jsonMode(flags)) {
|
|
39
|
+
await body(emit);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const realLog = console.log;
|
|
43
|
+
// Route human narration to stderr. Mirrors console.log's own formatting closely enough for
|
|
44
|
+
// progress text; nothing structured goes through here.
|
|
45
|
+
console.log = (...args) => process.stderr.write(args.map((a) => String(a)).join(' ') + '\n');
|
|
46
|
+
try {
|
|
47
|
+
const returned = await body(emit);
|
|
48
|
+
const out = returned ?? payload;
|
|
49
|
+
// A command that emitted nothing is a bug in that command, not a silent empty object — say so on
|
|
50
|
+
// stderr and leave stdout empty rather than writing `{}` that a caller would trust.
|
|
51
|
+
if (out === undefined) {
|
|
52
|
+
process.stderr.write('abx: --json produced no payload for this command (please report it)\n');
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
realLog(JSON.stringify(out, null, 2));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
console.log = realLog;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** BigInt-safe JSON: bigints become decimal strings rather than throwing. Every on-chain number a
|
|
63
|
+
* payload carries (supply, a token id, a block) arrives as a bigint, and `JSON.stringify` refuses
|
|
64
|
+
* them outright — so a payload builder that forgets one would fail at the last line of a deploy. */
|
|
65
|
+
export function jsonSafe(value) {
|
|
66
|
+
return JSON.parse(JSON.stringify(value, (_k, v) => (typeof v === 'bigint' ? v.toString() : v)));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=jsonout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonout.js","sourceRoot":"","sources":["../src/jsonout.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAY;IACnC,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAY,EACZ,IAAuD;IAEvD,IAAI,OAAsB,CAAC;IAC3B,MAAM,IAAI,G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AC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC;AACvG,CAAC"}
|
package/dist/kind.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized token-kind detection — one shared probe for the six concrete ABX token types, from
|
|
3
|
+
* three plain `eth_call`s (no events, no local index). Before this existed, the same "is this a
|
|
4
|
+
* 721 or an edition, and which concrete type" question was answered by ad-hoc, slightly different
|
|
5
|
+
* probes scattered across `commands/project.ts` (`state`), `commands/scaffold.ts`
|
|
6
|
+
* (`assertMintableSeries`), and `ownerops.ts` (the `set-param-hooks` guard) — this gives it one
|
|
7
|
+
* name and one place to live, so a new call site (mint/transfer/minter kind-awareness) doesn't
|
|
8
|
+
* grow a fourth copy.
|
|
9
|
+
*
|
|
10
|
+
* The discriminator mirrors the SDK's `ProjectState.contractType` union (reconstruct.ts) exactly,
|
|
11
|
+
* but this is a LIVE probe, not an event fold: `state`, `mint-page`, and the owner-op guards need a
|
|
12
|
+
* snapshot with no local index and no getLogs scan.
|
|
13
|
+
*
|
|
14
|
+
* ERC-165 0xd9b67a26 (ERC-1155) → the edition family (OneOfOneEdition / EditionImage / EditionCode)
|
|
15
|
+
* maxInvocations() → present on the multi-id twins (Series/SeriesCode, EditionImage/Code)
|
|
16
|
+
* the Params/ConfigurableParams surface (`paramHooks()`) → present only on the two code twins
|
|
17
|
+
*
|
|
18
|
+
* Every probe is defensive (try/catch → false) — a getter absent because the extension isn't
|
|
19
|
+
* composed and a getter absent because there's no contract at that address read identically here;
|
|
20
|
+
* callers that need to tell those apart already do so before reaching for a kind (e.g. `state`'s
|
|
21
|
+
* own `no ABX contract state at …` check).
|
|
22
|
+
*/
|
|
23
|
+
import type { Address, PublicClient } from 'viem';
|
|
24
|
+
/** Mirrors the SDK's `ProjectState.contractType` (reconstruct.ts) — the 721 ladder and its
|
|
25
|
+
* ERC-1155 edition twin, one rung apart. */
|
|
26
|
+
export type TokenKind = '1of1' | 'series' | 'code' | '1of1-edition' | 'edition' | 'edition-code';
|
|
27
|
+
export interface TokenKindInfo {
|
|
28
|
+
kind: TokenKind;
|
|
29
|
+
/** The single fact most call sites actually branch on — true for the three ERC-1155 twins. */
|
|
30
|
+
isEdition: boolean;
|
|
31
|
+
/** The concrete contract name, for a readout ("EditionImage (edition) state"). */
|
|
32
|
+
label: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Which of the six concrete ABX token types `address` is — the shared discriminator every command
|
|
36
|
+
* that branches on kind should call instead of re-deriving its own probe. Three live `eth_call`s,
|
|
37
|
+
* in the order that lets each short-circuit the next: ERC-165 first (edition family or not), then
|
|
38
|
+
* `maxInvocations()` (multi-id or not), then the Params surface (code or not).
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectTokenKind(client: PublicClient, address: Address): Promise<TokenKindInfo>;
|
|
41
|
+
/** Convenience for a call site that only needs the one boolean (is this an ERC-1155 edition, at
|
|
42
|
+
* all) — the cheapest single probe, so a guard that doesn't need the full breakdown doesn't pay
|
|
43
|
+
* for the other two calls. */
|
|
44
|
+
export declare function isEditionContract(client: PublicClient, address: Address): Promise<boolean>;
|
|
45
|
+
/** Human, one-line description of a kind — `"EditionImage (edition)"`, `"SeriesImage (series)"` —
|
|
46
|
+
* the shared phrasing for a readout header (`state`, `tokens`). */
|
|
47
|
+
export declare function describeKind(info: TokenKindInfo): string;
|
|
48
|
+
//# sourceMappingURL=kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../src/kind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,MAAM,CAAC;AAEhD;6CAC6C;AAC7C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,GAAG,cAAc,CAAC;AAEjG,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,8FAA8F;IAC9F,SAAS,EAAE,OAAO,CAAC;IACnB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;CACf;AAyCD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAWpG;AAED;;+BAE+B;AAC/B,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhG;AAED;oEACoE;AACpE,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD"}
|
package/dist/kind.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** ERC-165 id of ERC-1155 itself — what sorts a clone into the edition family (anchors.ts's
|
|
2
|
+
* `ERC1155_INTERFACE_ID`, restated here rather than imported: it's a fixed standard id, not SDK
|
|
3
|
+
* surface). */
|
|
4
|
+
const ERC1155_INTERFACE_ID = '0xd9b67a26';
|
|
5
|
+
const KIND_PROBE_ABI = [
|
|
6
|
+
{ type: 'function', name: 'supportsInterface', stateMutability: 'view', inputs: [{ type: 'bytes4' }], outputs: [{ type: 'bool' }] },
|
|
7
|
+
{ type: 'function', name: 'maxInvocations', stateMutability: 'view', inputs: [], outputs: [{ type: 'uint256' }] },
|
|
8
|
+
{ type: 'function', name: 'paramHooks', stateMutability: 'view', inputs: [], outputs: [{ type: 'address' }, { type: 'address' }, { type: 'address' }] },
|
|
9
|
+
];
|
|
10
|
+
async function supportsErc1155(client, address) {
|
|
11
|
+
try {
|
|
12
|
+
return (await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'supportsInterface', args: [ERC1155_INTERFACE_ID] }));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function hasMaxInvocations(client, address) {
|
|
19
|
+
try {
|
|
20
|
+
await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'maxInvocations' });
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The Params/ConfigurableParams surface probe — `paramHooks()` exists only on SeriesCode/
|
|
28
|
+
* EditionCode (mirrors the exact check `ownerops.ts`'s `cmdSetParamHooks` already ran ad-hoc). */
|
|
29
|
+
async function hasConfigurableParams(client, address) {
|
|
30
|
+
try {
|
|
31
|
+
await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'paramHooks' });
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Which of the six concrete ABX token types `address` is — the shared discriminator every command
|
|
40
|
+
* that branches on kind should call instead of re-deriving its own probe. Three live `eth_call`s,
|
|
41
|
+
* in the order that lets each short-circuit the next: ERC-165 first (edition family or not), then
|
|
42
|
+
* `maxInvocations()` (multi-id or not), then the Params surface (code or not).
|
|
43
|
+
*/
|
|
44
|
+
export async function detectTokenKind(client, address) {
|
|
45
|
+
const isEdition = await supportsErc1155(client, address);
|
|
46
|
+
const capped = await hasMaxInvocations(client, address);
|
|
47
|
+
if (isEdition) {
|
|
48
|
+
if (!capped)
|
|
49
|
+
return { kind: '1of1-edition', isEdition: true, label: 'OneOfOneEdition' };
|
|
50
|
+
const code = await hasConfigurableParams(client, address);
|
|
51
|
+
return code ? { kind: 'edition-code', isEdition: true, label: 'EditionCode' } : { kind: 'edition', isEdition: true, label: 'EditionImage' };
|
|
52
|
+
}
|
|
53
|
+
if (!capped)
|
|
54
|
+
return { kind: '1of1', isEdition: false, label: 'OneOfOneImage' };
|
|
55
|
+
const code = await hasConfigurableParams(client, address);
|
|
56
|
+
return code ? { kind: 'code', isEdition: false, label: 'SeriesCode' } : { kind: 'series', isEdition: false, label: 'SeriesImage' };
|
|
57
|
+
}
|
|
58
|
+
/** Convenience for a call site that only needs the one boolean (is this an ERC-1155 edition, at
|
|
59
|
+
* all) — the cheapest single probe, so a guard that doesn't need the full breakdown doesn't pay
|
|
60
|
+
* for the other two calls. */
|
|
61
|
+
export async function isEditionContract(client, address) {
|
|
62
|
+
return supportsErc1155(client, address);
|
|
63
|
+
}
|
|
64
|
+
/** Human, one-line description of a kind — `"EditionImage (edition)"`, `"SeriesImage (series)"` —
|
|
65
|
+
* the shared phrasing for a readout header (`state`, `tokens`). */
|
|
66
|
+
export function describeKind(info) {
|
|
67
|
+
return `${info.label} (${info.kind === '1of1' ? '1/1' : info.kind === '1of1-edition' ? 'edition' : info.kind})`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=kind.js.map
|
package/dist/kind.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.js","sourceRoot":"","sources":["../src/kind.ts"],"names":[],"mappings":"AAoCA;;gBAEgB;AAChB,MAAM,oBAAoB,GAAG,YAAqB,CAAC;AAEnD,MAAM,cAAc,GAAG;IACrB,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,EAAC;IAC7H,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC,EAAC;IAC7G,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAA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