@artblocks/abx-cli 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 +16 -0
- package/assets/renderer-scaffold/README.md +29 -11
- package/assets/renderer-scaffold/foundry.toml +1 -0
- package/assets/renderer-scaffold/remappings.txt +1 -1
- package/assets/renderer-scaffold/script/DeployHooks.s.sol +24 -0
- package/assets/renderer-scaffold/src/MyHooks.sol +20 -0
- package/assets/renderer-scaffold/src/MyRenderer.sol +4 -4
- package/assets/renderer-scaffold/src/MyTraits.sol +2 -2
- package/assets/renderer-scaffold/test/MyRenderer.t.sol +60 -3
- package/dist/bin.d.ts +26 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +63 -0
- package/dist/bin.js.map +1 -0
- package/dist/capabilities.d.ts +94 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +135 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/commands/auth.d.ts +54 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +447 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/deploy.d.ts +242 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +4763 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/feedback.d.ts +7 -0
- package/dist/commands/feedback.d.ts.map +1 -0
- package/dist/commands/feedback.js +147 -0
- package/dist/commands/feedback.js.map +1 -0
- package/dist/commands/project.d.ts +257 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +1414 -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 +701 -0
- package/dist/commands/reads.js.map +1 -0
- package/dist/commands/scaffold.d.ts +89 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/scaffold.js +733 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/commands/service.d.ts +67 -0
- package/dist/commands/service.d.ts.map +1 -0
- package/dist/commands/service.js +741 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/storage.d.ts +51 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +370 -0
- package/dist/commands/storage.js.map +1 -0
- package/dist/commands/submit-app.d.ts +59 -0
- package/dist/commands/submit-app.d.ts.map +1 -0
- package/dist/commands/submit-app.js +513 -0
- package/dist/commands/submit-app.js.map +1 -0
- package/dist/config.d.ts +90 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +284 -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 +390 -0
- package/dist/conformance.js.map +1 -0
- package/dist/contract-read-error.d.ts +5 -0
- package/dist/contract-read-error.d.ts.map +1 -0
- package/dist/contract-read-error.js +37 -0
- package/dist/contract-read-error.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/flag-allowlists.d.ts +53 -0
- package/dist/flag-allowlists.d.ts.map +1 -0
- package/dist/flag-allowlists.js +180 -0
- package/dist/flag-allowlists.js.map +1 -0
- package/dist/flags.d.ts +41 -0
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +111 -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 +57 -0
- package/dist/kind.d.ts.map +1 -0
- package/dist/kind.js +122 -0
- package/dist/kind.js.map +1 -0
- package/dist/main.js +747 -4838
- 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 +241 -54
- package/dist/mintpage.js.map +1 -1
- package/dist/output.d.ts +179 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +780 -0
- package/dist/output.js.map +1 -0
- package/dist/ownerops.d.ts +312 -57
- package/dist/ownerops.d.ts.map +1 -1
- package/dist/ownerops.js +1808 -357
- package/dist/ownerops.js.map +1 -1
- package/dist/preview.d.ts +23 -5
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +95 -43
- package/dist/preview.js.map +1 -1
- 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 +3 -13
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +19 -21
- package/dist/provision.js.map +1 -1
- package/dist/remote.d.ts +157 -52
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +435 -46
- package/dist/remote.js.map +1 -1
- package/dist/riskgate.d.ts +62 -0
- package/dist/riskgate.d.ts.map +1 -0
- package/dist/riskgate.js +234 -0
- package/dist/riskgate.js.map +1 -0
- package/dist/scaffold.d.ts +12 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +56 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/schema.d.ts +36 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +121 -26
- package/dist/schema.js.map +1 -1
- package/dist/script-chunks.d.ts +8 -0
- package/dist/script-chunks.d.ts.map +1 -0
- package/dist/script-chunks.js +35 -0
- package/dist/script-chunks.js.map +1 -0
- 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 +84 -15
- package/dist/signer.js.map +1 -1
- package/dist/update-check.d.ts +86 -5
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +161 -20
- package/dist/update-check.js.map +1 -1
- package/package.json +13 -12
- package/skill/SKILL.md +179 -347
- package/skill/agents/openai.yaml +4 -0
- package/skill/reference/capabilities.md +188 -0
- package/skill/reference/code.md +211 -0
- package/skill/reference/creator-token.md +94 -0
- package/skill/reference/deploy.md +167 -0
- package/skill/reference/diagnose.md +165 -0
- package/skill/reference/hosting.md +161 -94
- package/skill/reference/operate.md +181 -0
- package/skill/reference/services.md +121 -0
- package/skill/reference/setup.md +140 -36
- package/assets/renderer-scaffold/src/interfaces/IAbxFieldRenderer.sol +0 -32
- package/assets/renderer-scaffold/src/interfaces/IAbxParams.sol +0 -26
- 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/skill/reference/code-projects.md +0 -246
- package/skill/reference/operating.md +0 -116
- package/skill/reference/troubleshooting.md +0 -28
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,GAAG,CAAC,CAAI,EAAE,EAAE;QACpB,OAAO,GAAG,CAAC,CAAC;IACd,CAAC,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,CAAC,IAAI,CA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|
+
* 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 treats a genuine revert/no-data response as "getter absent", but propagates RPC and
|
|
19
|
+
* transport failures. Conflating those cases silently downgraded a Series to `1of1` whenever a
|
|
20
|
+
* public endpoint transiently failed `maxInvocations()`. A no-code address still makes every getter
|
|
21
|
+
* truthfully absent, so the existence check lives HERE, once, ahead of the probes — every call site
|
|
22
|
+
* inherits it and cannot forget it.
|
|
23
|
+
*/
|
|
24
|
+
import type { Address, PublicClient } from 'viem';
|
|
25
|
+
/** Mirrors the SDK's `ProjectState.contractType` (reconstruct.ts) — the 721 ladder and its
|
|
26
|
+
* ERC-1155 edition twin, one rung apart. */
|
|
27
|
+
export type TokenKind = '1of1' | 'series' | 'code' | '1of1-edition' | 'edition' | 'edition-code';
|
|
28
|
+
export interface TokenKindInfo {
|
|
29
|
+
kind: TokenKind;
|
|
30
|
+
/** The single fact most call sites actually branch on — true for the three ERC-1155 twins. */
|
|
31
|
+
isEdition: boolean;
|
|
32
|
+
/** The concrete contract name, for a readout ("EditionImage (edition) state"). */
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Which of the six concrete ABX token types `address` is — the shared discriminator every command
|
|
37
|
+
* that branches on kind should call instead of re-deriving its own probe. Three live `eth_call`s,
|
|
38
|
+
* in the order that lets each short-circuit the next: ERC-165 first (edition family or not), then
|
|
39
|
+
* `maxInvocations()` (multi-id or not), then the Params surface (code or not).
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectTokenKind(client: PublicClient, address: Address): Promise<TokenKindInfo>;
|
|
42
|
+
/** Convenience for a call site that only needs the one boolean (is this an ERC-1155 edition, at
|
|
43
|
+
* all) — the cheapest single probe, so a guard that doesn't need the full breakdown doesn't pay
|
|
44
|
+
* for the other two calls. */
|
|
45
|
+
export declare function isEditionContract(client: PublicClient, address: Address): Promise<boolean>;
|
|
46
|
+
/** Human, one-line description of a kind — `"EditionImage (edition)"`, `"SeriesImage (series)"` —
|
|
47
|
+
* the shared phrasing for a readout header (`state`, `tokens`). */
|
|
48
|
+
export declare function describeKind(info: TokenKindInfo): string;
|
|
49
|
+
/** The ConfigurableParams / PostParams surface — SeriesCode and EditionCode only. */
|
|
50
|
+
export declare function hasParamsSurface(info: TokenKindInfo): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Refuse a PostParams command (set-schema / configure-param / retire-param) against a contract
|
|
53
|
+
* that does not compose ConfigurableParams — before any signing prompt, and as a capability
|
|
54
|
+
* mismatch rather than a raw viem revert. Same probe `set-param-hooks` already ran.
|
|
55
|
+
*/
|
|
56
|
+
export declare function assertHasParamsSurface(client: PublicClient, address: Address, what: string): Promise<TokenKindInfo>;
|
|
57
|
+
//# sourceMappingURL=kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../src/kind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,MAAM,CAAC;AAGhD;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;AA+ED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAYpG;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;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,CASxB"}
|
package/dist/kind.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isMissingContractCapability, isRpcReadFailure } from './contract-read-error.js';
|
|
2
|
+
/** ERC-165 id of ERC-1155 itself — what sorts a clone into the edition family (anchors.ts's
|
|
3
|
+
* `ERC1155_INTERFACE_ID`, restated here rather than imported: it's a fixed standard id, not SDK
|
|
4
|
+
* surface). */
|
|
5
|
+
const ERC1155_INTERFACE_ID = '0xd9b67a26';
|
|
6
|
+
const KIND_PROBE_ABI = [
|
|
7
|
+
{ type: 'function', name: 'supportsInterface', stateMutability: 'view', inputs: [{ type: 'bytes4' }], outputs: [{ type: 'bool' }] },
|
|
8
|
+
{ type: 'function', name: 'maxInvocations', stateMutability: 'view', inputs: [], outputs: [{ type: 'uint256' }] },
|
|
9
|
+
{ type: 'function', name: 'paramHooks', stateMutability: 'view', inputs: [], outputs: [{ type: 'address' }, { type: 'address' }, { type: 'address' }] },
|
|
10
|
+
];
|
|
11
|
+
function capabilityMissOrThrow(client, address, error) {
|
|
12
|
+
if (isMissingContractCapability(error))
|
|
13
|
+
return false;
|
|
14
|
+
if (isRpcReadFailure(error)) {
|
|
15
|
+
const chain = client.chain?.name ?? 'the active chain';
|
|
16
|
+
throw new Error(`could not detect the token type for ${address} on ${chain} — the RPC answered block/code requests but failed eth_call ` +
|
|
17
|
+
`(rate-limited or backend unhealthy). This is not a contract verdict; check the configured RPC URLs.`, { cause: error });
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Refuse to infer a kind for an address that holds no contract. Without this the three negative
|
|
23
|
+
* probes below are indistinguishable from "nothing deployed here", and the ladder's `1of1` default
|
|
24
|
+
* becomes a confident lie about a specific contract type (see the file docstring).
|
|
25
|
+
*
|
|
26
|
+
* Deliberately silent when the check itself can't run (an RPC hiccup → `getCode` throws): a network
|
|
27
|
+
* blip must not become a "no contract" claim, so we fall through to the probes exactly as before and
|
|
28
|
+
* let whatever the caller was doing surface its own error. Same stance as `assertContractExists`.
|
|
29
|
+
*/
|
|
30
|
+
async function assertHasCode(client, address) {
|
|
31
|
+
let code;
|
|
32
|
+
try {
|
|
33
|
+
code = await client.getCode({ address });
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return; // can't tell — don't manufacture a verdict
|
|
37
|
+
}
|
|
38
|
+
if (code && code !== '0x')
|
|
39
|
+
return;
|
|
40
|
+
const chain = client.chain?.name ?? 'the active chain';
|
|
41
|
+
throw new Error(`no contract at ${address} on ${chain} — so there is no token type to read. ` +
|
|
42
|
+
`Check the address, and check the network: a contract that lives on another chain reads as empty here ` +
|
|
43
|
+
`(the chain is picked with ABX_CHAIN; base-sepolia is the default). Owner ops run AFTER deploy.`);
|
|
44
|
+
}
|
|
45
|
+
async function supportsErc1155(client, address) {
|
|
46
|
+
try {
|
|
47
|
+
return (await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'supportsInterface', args: [ERC1155_INTERFACE_ID] }));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return capabilityMissOrThrow(client, address, error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function hasMaxInvocations(client, address) {
|
|
54
|
+
try {
|
|
55
|
+
await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'maxInvocations' });
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return capabilityMissOrThrow(client, address, error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The Params/ConfigurableParams surface probe — `paramHooks()` exists only on SeriesCode/
|
|
63
|
+
* EditionCode (mirrors the exact check `ownerops.ts`'s `cmdSetParamHooks` already ran ad-hoc). */
|
|
64
|
+
async function hasConfigurableParams(client, address) {
|
|
65
|
+
try {
|
|
66
|
+
await client.readContract({ address, abi: KIND_PROBE_ABI, functionName: 'paramHooks' });
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return capabilityMissOrThrow(client, address, error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Which of the six concrete ABX token types `address` is — the shared discriminator every command
|
|
75
|
+
* that branches on kind should call instead of re-deriving its own probe. Three live `eth_call`s,
|
|
76
|
+
* in the order that lets each short-circuit the next: ERC-165 first (edition family or not), then
|
|
77
|
+
* `maxInvocations()` (multi-id or not), then the Params surface (code or not).
|
|
78
|
+
*/
|
|
79
|
+
export async function detectTokenKind(client, address) {
|
|
80
|
+
await assertHasCode(client, address);
|
|
81
|
+
const isEdition = await supportsErc1155(client, address);
|
|
82
|
+
const capped = await hasMaxInvocations(client, address);
|
|
83
|
+
if (isEdition) {
|
|
84
|
+
if (!capped)
|
|
85
|
+
return { kind: '1of1-edition', isEdition: true, label: 'OneOfOneEdition' };
|
|
86
|
+
const code = await hasConfigurableParams(client, address);
|
|
87
|
+
return code ? { kind: 'edition-code', isEdition: true, label: 'EditionCode' } : { kind: 'edition', isEdition: true, label: 'EditionImage' };
|
|
88
|
+
}
|
|
89
|
+
if (!capped)
|
|
90
|
+
return { kind: '1of1', isEdition: false, label: 'OneOfOneImage' };
|
|
91
|
+
const code = await hasConfigurableParams(client, address);
|
|
92
|
+
return code ? { kind: 'code', isEdition: false, label: 'SeriesCode' } : { kind: 'series', isEdition: false, label: 'SeriesImage' };
|
|
93
|
+
}
|
|
94
|
+
/** Convenience for a call site that only needs the one boolean (is this an ERC-1155 edition, at
|
|
95
|
+
* all) — the cheapest single probe, so a guard that doesn't need the full breakdown doesn't pay
|
|
96
|
+
* for the other two calls. */
|
|
97
|
+
export async function isEditionContract(client, address) {
|
|
98
|
+
return supportsErc1155(client, address);
|
|
99
|
+
}
|
|
100
|
+
/** Human, one-line description of a kind — `"EditionImage (edition)"`, `"SeriesImage (series)"` —
|
|
101
|
+
* the shared phrasing for a readout header (`state`, `tokens`). */
|
|
102
|
+
export function describeKind(info) {
|
|
103
|
+
return `${info.label} (${info.kind === '1of1' ? '1/1' : info.kind === '1of1-edition' ? 'edition' : info.kind})`;
|
|
104
|
+
}
|
|
105
|
+
/** The ConfigurableParams / PostParams surface — SeriesCode and EditionCode only. */
|
|
106
|
+
export function hasParamsSurface(info) {
|
|
107
|
+
return info.kind === 'code' || info.kind === 'edition-code';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Refuse a PostParams command (set-schema / configure-param / retire-param) against a contract
|
|
111
|
+
* that does not compose ConfigurableParams — before any signing prompt, and as a capability
|
|
112
|
+
* mismatch rather than a raw viem revert. Same probe `set-param-hooks` already ran.
|
|
113
|
+
*/
|
|
114
|
+
export async function assertHasParamsSurface(client, address, what) {
|
|
115
|
+
const kind = await detectTokenKind(client, address);
|
|
116
|
+
if (!hasParamsSurface(kind)) {
|
|
117
|
+
throw new Error(`${address} exposes no PostParams — ${what} is a SeriesCode/EditionCode feature. ` +
|
|
118
|
+
`${kind.label} has no configurable params.`);
|
|
119
|
+
}
|
|
120
|
+
return kind;
|
|
121
|
+
}
|
|
122
|
+
//# 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":"AAwBA,OAAO,EAAC,2BAA2B,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAcvF;;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,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,EAAE,EAAC,IA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