@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/onchain-uri.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The on-chain tokenURI lane for code projects (`abx deploy-code --onchain-uri`) — pure leg
|
|
3
|
-
* composition + the verify-time honesty reads, all unit-testable with a mocked client.
|
|
4
|
-
*
|
|
5
|
-
* The lane (specs/protocol/code-projects.md → "The canonical generator — AbxGenerator" +
|
|
6
|
-
* specs/protocol/onchain-metadata.md → "URI resolution"): the collection-scope `animation_url`
|
|
7
|
-
* field points at the canonical generator via the `renderer` representation
|
|
8
|
-
* (`abi.encode(address)`), the `params.keys` contract param enumerates the declared param
|
|
9
|
-
* surface (the params store is unenumerable by design — the generator reads this CSV to build
|
|
10
|
-
* on-chain tokenData), and the token's `tokenURIRenderer` toggles tokenURI to the canonical
|
|
11
|
-
* on-chain metadata renderer. All three ride the EXISTING setup multicall, before the mints.
|
|
12
|
-
*/
|
|
13
|
-
import { encodeFunctionData, toHex, zeroAddress } from 'viem';
|
|
14
|
-
import { decodeFieldRenderer, decodeTag, encodeFieldRenderer, encodeTag, readGeneratorStatus, resolveGenerator, seriesCodeAbi, METADATA_FIELD as F, METADATA_REPRESENTATION as R, DEP_RESOLUTION, } from '@artblocks/abx-sdk';
|
|
15
|
-
/** The self-referential key: the CSV lists it too (the resolver's tokenData carries every
|
|
16
|
-
* evented param — including `params.keys` itself — so the generator must list it to stay
|
|
17
|
-
* byte-aligned; inputsHash parity is load-bearing). */
|
|
18
|
-
export const PARAMS_KEYS = 'params.keys';
|
|
19
|
-
/** ≤ this many chars rides as a literal readable-ASCII bytes32; longer takes the data path. */
|
|
20
|
-
export const PARAMS_KEYS_LITERAL_MAX = 31;
|
|
21
|
-
/**
|
|
22
|
-
* Compose the `params.keys` CSV: every param key the deploy writes ∪ the `--schema` keys ∪
|
|
23
|
-
* `params.keys` itself — deduped, sorted lexicographically, comma-joined. Sorted because the
|
|
24
|
-
* canonical tokenData serialization sorts keys; deterministic composition keeps the value
|
|
25
|
-
* reproducible from the same flags.
|
|
26
|
-
*/
|
|
27
|
-
export function composeParamsKeys(writtenParamKeys, schemaKeys) {
|
|
28
|
-
const keys = new Set([...writtenParamKeys, ...schemaKeys, PARAMS_KEYS]);
|
|
29
|
-
return [...keys]
|
|
30
|
-
.map((k) => k.trim())
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.sort()
|
|
33
|
-
.filter((k, i, all) => i === 0 || k !== all[i - 1])
|
|
34
|
-
.join(',');
|
|
35
|
-
}
|
|
36
|
-
/** Whether a CSV fits the literal bytes32 lane (printable ASCII, ≤ 31 bytes). */
|
|
37
|
-
export function paramsKeysIsLiteral(csv) {
|
|
38
|
-
return csv.length <= PARAMS_KEYS_LITERAL_MAX && /^[\x20-\x7e]+$/.test(csv);
|
|
39
|
-
}
|
|
40
|
-
/** The `params.keys` write leg: `setContractParam` (literal bytes32) when the CSV fits,
|
|
41
|
-
* else `setContractParamData` (one blob; hash evented — the generator reads it back whole). */
|
|
42
|
-
export function paramsKeysCall(csv) {
|
|
43
|
-
if (paramsKeysIsLiteral(csv)) {
|
|
44
|
-
return {
|
|
45
|
-
call: encodeFunctionData({
|
|
46
|
-
abi: seriesCodeAbi,
|
|
47
|
-
functionName: 'setContractParam',
|
|
48
|
-
args: [encodeTag(PARAMS_KEYS), encodeTag(csv)],
|
|
49
|
-
}),
|
|
50
|
-
encoding: 'literal',
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
call: encodeFunctionData({
|
|
55
|
-
abi: seriesCodeAbi,
|
|
56
|
-
functionName: 'setContractParamData',
|
|
57
|
-
args: [encodeTag(PARAMS_KEYS), toHex(csv)],
|
|
58
|
-
}),
|
|
59
|
-
encoding: 'data',
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The `--onchain-uri` legs of the setup multicall, in order:
|
|
64
|
-
* 1. collection-scope `animation_url` field → representation `renderer`,
|
|
65
|
-
* value `abi.encode(generator)` (the canonical generator computes the live view on-chain);
|
|
66
|
-
* 2. the `params.keys` contract param (the generator's tokenData enumeration seam);
|
|
67
|
-
* 3. `setTokenURIRenderer(metadataRenderer)` — tokenURI resolves ON-CHAIN from here on;
|
|
68
|
-
* 4. `setContractURIRenderer(metadataRenderer)` — contractURI too (parity with the 1/1 lane).
|
|
69
|
-
* Placed BEFORE the mint legs so every token is born with the on-chain lane fully configured.
|
|
70
|
-
*/
|
|
71
|
-
export function onchainUriSetupCalls(args) {
|
|
72
|
-
const { call: paramsLeg, encoding } = paramsKeysCall(args.paramsKeys);
|
|
73
|
-
const calls = [];
|
|
74
|
-
// The `animation_url` leg points at the generator (which computes the doc from a PROGRAM). A
|
|
75
|
-
// renderer-only drop (in-chain SVG, no program) has no generator — and baking this leg at a ZERO
|
|
76
|
-
// generator would make the metadata renderer staticcall a codeless address and REVERT every
|
|
77
|
-
// tokenURI. So emit it only when there's a real generator; otherwise there's simply no animation_url
|
|
78
|
-
// (optional by spec — the metadata renderer omits an unset field).
|
|
79
|
-
if (args.generator !== zeroAddress) {
|
|
80
|
-
calls.push(encodeFunctionData({
|
|
81
|
-
abi: seriesCodeAbi,
|
|
82
|
-
functionName: 'setContractField',
|
|
83
|
-
args: [encodeTag(F.animationUrl), encodeTag(R.renderer), encodeFieldRenderer(args.generator)],
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
calls.push(paramsLeg, encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setTokenURIRenderer', args: [args.metadataRenderer] }), encodeFunctionData({ abi: seriesCodeAbi, functionName: 'setContractURIRenderer', args: [args.metadataRenderer] }));
|
|
87
|
-
return { calls, paramsKeysEncoding: encoding };
|
|
88
|
-
}
|
|
89
|
-
// ── the chain-complete expectation (deploy-time, from the P1 dependency report) ──
|
|
90
|
-
/** What the deploy can honestly promise about the generator's template branch, derived from
|
|
91
|
-
* the selection-time dependency report (never a new RPC): chain-complete iff every registry
|
|
92
|
-
* dep has proven ON-CHAIN bytes (OnChain refs read their data contract directly, so they
|
|
93
|
-
* count as on-chain; `abx verify` is the from-chain confirmation either way). */
|
|
94
|
-
export function expectedChainComplete(deps, checks) {
|
|
95
|
-
if (deps.length === 0)
|
|
96
|
-
return { expected: true, detail: 'no dependencies — the document assembles from the script chunks alone' };
|
|
97
|
-
const registryDeps = deps.filter((d) => d.resolution === DEP_RESOLUTION.registry);
|
|
98
|
-
if (registryDeps.length === 0) {
|
|
99
|
-
return { expected: true, detail: 'all dependencies are on-chain data contracts (read directly)' };
|
|
100
|
-
}
|
|
101
|
-
const byDep = new Map(checks.map((c) => [c.dep, c]));
|
|
102
|
-
const cdnOnly = [];
|
|
103
|
-
const missing = [];
|
|
104
|
-
let unknown = false;
|
|
105
|
-
for (const d of registryDeps) {
|
|
106
|
-
const chk = byDep.get(d.display);
|
|
107
|
-
if (!chk || chk.status === 'skipped')
|
|
108
|
-
unknown = true;
|
|
109
|
-
else if (chk.status === 'not-found')
|
|
110
|
-
missing.push(d.display);
|
|
111
|
-
else if (!chk.details.availableOnChain)
|
|
112
|
-
cdnOnly.push(d.display);
|
|
113
|
-
}
|
|
114
|
-
if (missing.length)
|
|
115
|
-
return { expected: false, detail: `${missing.join(', ')} not on the registry — the generator will emit an unresolved marker` };
|
|
116
|
-
if (cdnOnly.length)
|
|
117
|
-
return { expected: false, detail: `${cdnOnly.join(', ')} CDN-served (the normal production path) — serves fine, NOT chain-complete` };
|
|
118
|
-
if (unknown)
|
|
119
|
-
return { expected: null, detail: 'registry check was skipped (RPC unreachable) — `abx verify` reads the truth from chain' };
|
|
120
|
-
return { expected: true, detail: 'every dependency has ON-CHAIN bytes — no server, gateway, or CDN in the graph' };
|
|
121
|
-
}
|
|
122
|
-
// ── verify: the honesty reads (`onChainStatus` + a tokenURI probe) ─────────────
|
|
123
|
-
/** The generator this project's on-chain lane actually uses: the collection `animation_url`
|
|
124
|
-
* field's `renderer` value when set (that address is what the metadata renderer staticcalls),
|
|
125
|
-
* else the chain's canonical generator. Null when neither exists. */
|
|
126
|
-
export function generatorFor(state, override) {
|
|
127
|
-
const field = state.collectionFields.find((f) => f.field === F.animationUrl && f.representation === R.renderer);
|
|
128
|
-
if (field) {
|
|
129
|
-
try {
|
|
130
|
-
return decodeFieldRenderer(field.value);
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
/* malformed value — fall through to the manifest */
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return resolveGenerator(state.chainId, override) ?? null;
|
|
137
|
-
}
|
|
138
|
-
/** Whether verify should run the on-chain-URI report: the tokenURIRenderer toggle is on, or
|
|
139
|
-
* the collection `animation` field points at a field renderer (the generator). */
|
|
140
|
-
export function hasOnChainUriLane(state) {
|
|
141
|
-
const rendererSet = !!state.tokenURIRenderer && state.tokenURIRenderer !== zeroAddress;
|
|
142
|
-
const animationRenderer = state.collectionFields.some((f) => f.field === F.animationUrl && f.representation === R.renderer);
|
|
143
|
-
return rendererSet || animationRenderer;
|
|
144
|
-
}
|
|
145
|
-
const erc721TokenUriAbi = [
|
|
146
|
-
{
|
|
147
|
-
type: 'function',
|
|
148
|
-
name: 'tokenURI',
|
|
149
|
-
stateMutability: 'view',
|
|
150
|
-
inputs: [{ name: 'id', type: 'uint256' }],
|
|
151
|
-
outputs: [{ name: '', type: 'string' }],
|
|
152
|
-
},
|
|
153
|
-
];
|
|
154
|
-
/** An HTML comment marker the generator emits on degradation (`<!-- abx:… -->`), or null. */
|
|
155
|
-
function degradationMarker(html) {
|
|
156
|
-
const m = /<!--\s*abx:[^>]*-->/.exec(html);
|
|
157
|
-
return m ? m[0] : null;
|
|
158
|
-
}
|
|
159
|
-
function probeAnimation(animationUrl) {
|
|
160
|
-
if (!animationUrl)
|
|
161
|
-
return { form: 'missing' };
|
|
162
|
-
const dataHtml = /^data:text\/html;base64,(.*)$/.exec(animationUrl);
|
|
163
|
-
if (dataHtml) {
|
|
164
|
-
const html = Buffer.from(dataHtml[1], 'base64').toString('utf8');
|
|
165
|
-
return { form: 'data-html', bytes: Buffer.byteLength(html), marker: degradationMarker(html) };
|
|
166
|
-
}
|
|
167
|
-
if (animationUrl.startsWith('data:'))
|
|
168
|
-
return { form: 'data-other', prefix: animationUrl.slice(0, 40) };
|
|
169
|
-
return { form: 'url', url: animationUrl };
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The verify-time on-chain-URI report: `generator.onChainStatus(token)` (branch ·
|
|
173
|
-
* chain-completeness · unresolved refs · URL budget) plus a `tokenURI` probe of the lowest
|
|
174
|
-
* minted token — decoded, with the `animation_url` form checked against the branch.
|
|
175
|
-
*/
|
|
176
|
-
export async function onChainUriReport(client, state, generatorOverride) {
|
|
177
|
-
const generator = generatorFor(state, generatorOverride);
|
|
178
|
-
if (!generator) {
|
|
179
|
-
throw new Error(`no AbxGenerator known for chain ${state.chainId} — set ABX_GENERATOR=0x… (or update @artblocks/abx-sdk's deployments manifest)`);
|
|
180
|
-
}
|
|
181
|
-
const status = await readGeneratorStatus(client, generator, state.address);
|
|
182
|
-
const minted = state.tokens.filter((t) => t.minted).map((t) => BigInt(t.tokenId));
|
|
183
|
-
let probe = null;
|
|
184
|
-
if (minted.length) {
|
|
185
|
-
const tokenId = minted.reduce((a, b) => (b < a ? b : a));
|
|
186
|
-
const uri = (await client.readContract({
|
|
187
|
-
address: state.address,
|
|
188
|
-
abi: erc721TokenUriAbi,
|
|
189
|
-
functionName: 'tokenURI',
|
|
190
|
-
args: [tokenId],
|
|
191
|
-
}));
|
|
192
|
-
const m = /^data:application\/json;base64,(.*)$/.exec(uri);
|
|
193
|
-
let animation = { form: 'missing' };
|
|
194
|
-
if (m) {
|
|
195
|
-
try {
|
|
196
|
-
const json = JSON.parse(Buffer.from(m[1], 'base64').toString('utf8'));
|
|
197
|
-
animation = probeAnimation(typeof json.animation_url === 'string' ? json.animation_url : undefined);
|
|
198
|
-
}
|
|
199
|
-
catch {
|
|
200
|
-
/* undecodable JSON — reported as onChainJson with a missing animation */
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
probe = { tokenId: tokenId.toString(), onChainJson: !!m, uriPrefix: uri.slice(0, 48), animation };
|
|
204
|
-
}
|
|
205
|
-
return { generator, status, probe };
|
|
206
|
-
}
|
|
207
|
-
// ── the configure-param nudge (params.keys drift) ──────────────────────────────
|
|
208
|
-
/**
|
|
209
|
-
* After a param write: if the project's `params.keys` CSV exists but doesn't list the
|
|
210
|
-
* configured key, the on-chain generator's tokenData will silently omit it (breaking byte
|
|
211
|
-
* parity with the resolver's). Returns the fixed CSV to suggest, or null when no nudge is
|
|
212
|
-
* warranted (no CSV = not on the on-chain lane; already listed = fine).
|
|
213
|
-
*/
|
|
214
|
-
export function paramsKeysNudge(existingCsv, configuredKey) {
|
|
215
|
-
if (existingCsv === null || configuredKey === PARAMS_KEYS)
|
|
216
|
-
return null;
|
|
217
|
-
const listed = existingCsv.split(',').map((k) => k.trim()).filter(Boolean);
|
|
218
|
-
if (listed.includes(configuredKey))
|
|
219
|
-
return null;
|
|
220
|
-
return composeParamsKeys([...listed, configuredKey], []);
|
|
221
|
-
}
|
|
222
|
-
/** Read the project's `params.keys` contract param from chain (literal or data-backed);
|
|
223
|
-
* null when unset. Best-effort — callers must treat a throw as "no nudge". */
|
|
224
|
-
export async function readParamsKeys(client, contract) {
|
|
225
|
-
const [value, valueIsHash, isSet] = (await client.readContract({
|
|
226
|
-
address: contract,
|
|
227
|
-
abi: seriesCodeAbi,
|
|
228
|
-
functionName: 'contractParam',
|
|
229
|
-
args: [encodeTag(PARAMS_KEYS)],
|
|
230
|
-
}));
|
|
231
|
-
if (!isSet)
|
|
232
|
-
return null;
|
|
233
|
-
if (!valueIsHash)
|
|
234
|
-
return decodeTag(value);
|
|
235
|
-
const data = (await client.readContract({
|
|
236
|
-
address: contract,
|
|
237
|
-
abi: seriesCodeAbi,
|
|
238
|
-
functionName: 'contractParamData',
|
|
239
|
-
args: [encodeTag(PARAMS_KEYS)],
|
|
240
|
-
}));
|
|
241
|
-
return Buffer.from(data.slice(2), 'hex').toString('utf8');
|
|
242
|
-
}
|
|
243
|
-
//# sourceMappingURL=onchain-uri.js.map
|
package/dist/onchain-uri.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onchain-uri.js","sourceRoot":"","sources":["../src/onchain-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAC,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAC,MAAM,MAAM,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB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AAO,CAAC,CAAC;IAC3E,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,iBAAiB,CAAC,CAAC,GAAG,MAAM,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED;+EAC+E;AAC/E,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAA2B,EAAE,QAAiB;IACjF,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;QAC7D,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,aAAa;QAClB,YAAY,EAAE,eAAe;QAC7B,IAAI,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;KAC/B,CAAC,CAA4B,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;QACtC,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,aAAa;QAClB,YAAY,EAAE,mBAAmB;QACjC,IAAI,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;KAC/B,CAAC,CAAQ,CAAC;IACX,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/upload.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `abx storage upload` core — upload ONE file and return a public locator that PRESERVES the
|
|
3
|
-
* filename, so the declared mimeType survives when the locator is later attached (`abx attach`).
|
|
4
|
-
* The on-chain metadata field has no MIME slot: the URL extension IS the type declaration, so a
|
|
5
|
-
* bare content-addressed locator (`ar://<txid>`, `<gw>/ipfs/<cid>`) — which has no extension —
|
|
6
|
-
* would make the attached artifact `application/octet-stream`. Extracted from main.ts so the
|
|
7
|
-
* capability-based branch (the exact bug this guards) is unit-testable with fake backends.
|
|
8
|
-
*/
|
|
9
|
-
import type { StorageBackend, StoredContent } from '@artblocks/abx-storage';
|
|
10
|
-
export interface UploadResult {
|
|
11
|
-
/** A fetchable public URL for the file. */
|
|
12
|
-
locator: string;
|
|
13
|
-
/** True when `locator` carries the filename (extension → correct declared type on attach). */
|
|
14
|
-
filenamePreserved: boolean;
|
|
15
|
-
/** Set when we had to fall back to a bare (extension-less) locator — the caller warns. */
|
|
16
|
-
fallbackReason?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Store `content` under `name` and return the best available public locator. Preference order:
|
|
20
|
-
* 1. path-addressed host (cloud/S3/R2): the object key IS the filename → `<publicBase>/<name>`.
|
|
21
|
-
* 2. content-addressed host with directory support (ipfs/arweave): wrap the single file in a
|
|
22
|
-
* one-entry directory → `<base>/<name>` (filename preserved).
|
|
23
|
-
* 3. bare content-addressed locator (e.g. kubo IPFS with no dir-add): `<gw>/ipfs/<cid>` — no
|
|
24
|
-
* extension; `filenamePreserved: false` so the caller can warn about the octet-stream type.
|
|
25
|
-
* Throws for a backend that can't produce any public URL (e.g. `fs`).
|
|
26
|
-
*/
|
|
27
|
-
export declare function uploadAndLocate(backend: StorageBackend, name: string, content: StoredContent): Promise<UploadResult>;
|
|
28
|
-
//# sourceMappingURL=upload.d.ts.map
|
package/dist/upload.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,8FAA8F;IAC9F,iBAAiB,EAAE,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAyB1H"}
|
package/dist/upload.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { hashContent } from '@artblocks/abx-storage';
|
|
2
|
-
const trimSlash = (s) => s.replace(/\/+$/, '');
|
|
3
|
-
/**
|
|
4
|
-
* Store `content` under `name` and return the best available public locator. Preference order:
|
|
5
|
-
* 1. path-addressed host (cloud/S3/R2): the object key IS the filename → `<publicBase>/<name>`.
|
|
6
|
-
* 2. content-addressed host with directory support (ipfs/arweave): wrap the single file in a
|
|
7
|
-
* one-entry directory → `<base>/<name>` (filename preserved).
|
|
8
|
-
* 3. bare content-addressed locator (e.g. kubo IPFS with no dir-add): `<gw>/ipfs/<cid>` — no
|
|
9
|
-
* extension; `filenamePreserved: false` so the caller can warn about the octet-stream type.
|
|
10
|
-
* Throws for a backend that can't produce any public URL (e.g. `fs`).
|
|
11
|
-
*/
|
|
12
|
-
export async function uploadAndLocate(backend, name, content) {
|
|
13
|
-
if (backend.publicBase && backend.putObject) {
|
|
14
|
-
await backend.putObject(name, content);
|
|
15
|
-
return { locator: `${trimSlash(backend.publicBase)}/${name}`, filenamePreserved: true };
|
|
16
|
-
}
|
|
17
|
-
if (backend.putDirectory && backend.locator) {
|
|
18
|
-
try {
|
|
19
|
-
const { base } = await backend.putDirectory([{ name, bytes: content.bytes, contentType: content.contentType }]);
|
|
20
|
-
return { locator: `${trimSlash(base)}/${name}`, filenamePreserved: true };
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
const hash = hashContent(content.bytes);
|
|
24
|
-
await backend.put(hash, content);
|
|
25
|
-
const loc = await backend.locator(hash);
|
|
26
|
-
if (!loc)
|
|
27
|
-
throw e;
|
|
28
|
-
return { locator: loc, filenamePreserved: false, fallbackReason: e.message };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (backend.locator) {
|
|
32
|
-
const hash = hashContent(content.bytes);
|
|
33
|
-
await backend.put(hash, content);
|
|
34
|
-
const loc = await backend.locator(hash);
|
|
35
|
-
if (!loc)
|
|
36
|
-
throw new Error(`backend '${backend.id}' stored the file but returned no durable locator`);
|
|
37
|
-
return { locator: loc, filenamePreserved: false };
|
|
38
|
-
}
|
|
39
|
-
throw new Error(`backend '${backend.id}' can't produce a public URL for an attached file — use ipfs, arweave, or cloud (with a public base).`);
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=upload.js.map
|
package/dist/upload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAWnD,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAuB,EAAE,IAAY,EAAE,OAAsB;IACjG,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,EAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAC,CAAC;IACxF,CAAC;IACD,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM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