@artblocks/abx-sdk 0.1.0-alpha.3 → 0.1.0-alpha.31
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 +79 -0
- package/README.md +130 -0
- package/dist/abi/generated.d.ts +8502 -129
- package/dist/abi/generated.d.ts.map +1 -1
- package/dist/abi/generated.js +40 -22
- package/dist/abi/generated.js.map +1 -1
- package/dist/abi/index.d.ts +2645 -168
- package/dist/abi/index.d.ts.map +1 -1
- package/dist/abi/index.js +34 -7
- package/dist/abi/index.js.map +1 -1
- package/dist/anchors.d.ts +318 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +701 -0
- package/dist/anchors.js.map +1 -0
- package/dist/chains.d.ts +19 -9
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +31 -15
- package/dist/chains.js.map +1 -1
- package/dist/chunks.d.ts +123 -27
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +124 -9
- package/dist/chunks.js.map +1 -1
- package/dist/clients.d.ts +23 -11
- package/dist/clients.d.ts.map +1 -1
- package/dist/clients.js +17 -18
- package/dist/clients.js.map +1 -1
- package/dist/create2.d.ts +84 -1
- package/dist/create2.d.ts.map +1 -1
- package/dist/create2.js +158 -2
- package/dist/create2.js.map +1 -1
- package/dist/creator-token.d.ts +132 -0
- package/dist/creator-token.d.ts.map +1 -0
- package/dist/creator-token.js +183 -0
- package/dist/creator-token.js.map +1 -0
- package/dist/deploy.d.ts +234 -14
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +289 -111
- package/dist/deploy.js.map +1 -1
- package/dist/deployments.d.ts +85 -5
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +159 -30
- package/dist/deployments.js.map +1 -1
- package/dist/deps.d.ts +123 -6
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +249 -7
- package/dist/deps.js.map +1 -1
- package/dist/env.d.ts +5 -4
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -5
- package/dist/env.js.map +1 -1
- package/dist/errors.d.ts +109 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +148 -0
- package/dist/errors.js.map +1 -0
- package/dist/execute.d.ts +118 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +159 -0
- package/dist/execute.js.map +1 -0
- package/dist/gateways.d.ts +79 -0
- package/dist/gateways.d.ts.map +1 -0
- package/dist/gateways.js +156 -0
- package/dist/gateways.js.map +1 -0
- package/dist/generator-document.d.ts +57 -0
- package/dist/generator-document.d.ts.map +1 -0
- package/dist/generator-document.js +123 -0
- package/dist/generator-document.js.map +1 -0
- package/dist/generator.d.ts +44 -2
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +29 -0
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +48 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +295 -0
- package/dist/inspect.js.map +1 -0
- package/dist/migrate.d.ts +41 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +142 -0
- package/dist/migrate.js.map +1 -0
- package/dist/mime.d.ts +11 -0
- package/dist/mime.d.ts.map +1 -0
- package/dist/mime.js +40 -0
- package/dist/mime.js.map +1 -0
- package/dist/node.d.ts +69 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +92 -0
- package/dist/node.js.map +1 -0
- package/dist/onchain-uri.d.ts +110 -0
- package/dist/onchain-uri.d.ts.map +1 -0
- package/dist/onchain-uri.js +276 -0
- package/dist/onchain-uri.js.map +1 -0
- package/dist/ops.d.ts +507 -14
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +850 -34
- package/dist/ops.js.map +1 -1
- package/dist/policy.d.ts +57 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +35 -0
- package/dist/policy.js.map +1 -0
- package/dist/probe.d.ts +58 -0
- package/dist/probe.d.ts.map +1 -1
- package/dist/probe.js +190 -9
- package/dist/probe.js.map +1 -1
- package/dist/reconstruct.d.ts +141 -3
- package/dist/reconstruct.d.ts.map +1 -1
- package/dist/reconstruct.js +479 -100
- package/dist/reconstruct.js.map +1 -1
- package/dist/resume.d.ts +140 -0
- package/dist/resume.d.ts.map +1 -0
- package/dist/resume.js +146 -0
- package/dist/resume.js.map +1 -0
- package/dist/script-chunks.d.ts +105 -0
- package/dist/script-chunks.d.ts.map +1 -0
- package/dist/script-chunks.js +158 -0
- package/dist/script-chunks.js.map +1 -0
- package/dist/service.d.ts +151 -9
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +103 -11
- package/dist/service.js.map +1 -1
- package/dist/spine.d.ts +47 -4
- package/dist/spine.d.ts.map +1 -1
- package/dist/spine.js +0 -0
- package/dist/spine.js.map +1 -1
- package/dist/staging.d.ts +139 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +139 -0
- package/dist/staging.js.map +1 -0
- package/dist/token.d.ts +11 -1
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +32 -1
- package/dist/token.js.map +1 -1
- package/dist/tokendata.d.ts +63 -3
- package/dist/tokendata.d.ts.map +1 -1
- package/dist/tokendata.js +81 -19
- package/dist/tokendata.js.map +1 -1
- package/dist/tokens.d.ts +119 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +317 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +107 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts +74 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +106 -0
- package/dist/util.js.map +1 -0
- package/package.json +15 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @artblocks/abx-sdk
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.31
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c068a0f: Add `probeChunkStore` — a fail-closed sibling to `ensureChunkStore` that resolves whether a usable
|
|
8
|
+
on-chain chunk store exists (configured address, has code, answers the current `writeContent` ABI)
|
|
9
|
+
without ever sending a transaction or deploying one. Returns a typed verdict (`ok` / `unconfigured` /
|
|
10
|
+
`no-code` / `incompatible` / `unreachable`) instead of throwing, so a request-scoped or read-only
|
|
11
|
+
service can call it at startup and branch on the reason.
|
|
12
|
+
- c068a0f: Local data-directory resolution (`.abx-self-host` / `ABX_DATA_DIR`) is now centralized in one SDK
|
|
13
|
+
resolver (`resolveDataDir` from `@artblocks/abx-sdk/node`) instead of five independent copies of the
|
|
14
|
+
same fallback across the CLI, indexer, and storage packages — the setup that could silently split a
|
|
15
|
+
project's SQLite projection from its managed Arweave key into two different directories.
|
|
16
|
+
|
|
17
|
+
A handful of READ commands (`status`, `state`, `verify`, `doctor`, `capabilities`, `tokens`,
|
|
18
|
+
`tokenuri`, `contracturi`, `inspect`, `minter show`) now search upward from the current directory,
|
|
19
|
+
git-style, for an already-existing `.abx-self-host` before falling back to creating one at cwd —
|
|
20
|
+
bounded at the home directory, a `.git` repository root, or the filesystem root, and never crossing
|
|
21
|
+
into an unrelated directory tree. Running one of these from a project subdirectory (e.g. a
|
|
22
|
+
`contracts/` folder) now finds the same node a run from the project root would, instead of quietly
|
|
23
|
+
reporting an empty one. `abx status`'s existing `data: <path>` line — and a new one-line notice —
|
|
24
|
+
name the directory whenever it was found this way. Every WRITE command is unaffected: it always
|
|
25
|
+
resolves strictly to the current directory, exactly as before, so nothing is ever created somewhere
|
|
26
|
+
you didn't `cd` into. `ABX_DATA_DIR`, when set, still always wins outright and disables the search
|
|
27
|
+
entirely.
|
|
28
|
+
|
|
29
|
+
- c068a0f: `deploy-code --resume <address>` now works against an EditionCode (`--copies`) target, not just
|
|
30
|
+
SeriesCode. The mint leg diffs per id against that id's own `totalSupply(id)` — pass the same
|
|
31
|
+
content flags the original deploy used, plus `--mint-count`/`--mint-amount` if it premint any ids.
|
|
32
|
+
- c068a0f: `reconstructProject()` and `reconstructIncremental()` accept `toBlock: 'safe' | 'finalized'` in
|
|
33
|
+
addition to a literal block number and the existing `'latest'` default. The tag is resolved to a
|
|
34
|
+
concrete inclusive block number (via the new `resolveBlockTag()`) before any `eth_getLogs` scan
|
|
35
|
+
starts, and that number — never the tag — is what lands in the persisted `ProjectState.toBlock`. An
|
|
36
|
+
RPC that doesn't support the requested tag throws the new `BlockTagUnavailableError` instead of
|
|
37
|
+
silently falling back to `latest`. `SelfHostIndexer#reindex` gained a matching `blockTag` option.
|
|
38
|
+
Existing callers (the `'latest'`/unset default) are unaffected.
|
|
39
|
+
|
|
40
|
+
`abx index --to-block safe|finalized` stops a re-index at a reorg-safe boundary.
|
|
41
|
+
|
|
42
|
+
- c068a0f: Add `abx replace-script <address> --script <file>` — a safe, first-class way to replace an UNLOCKED
|
|
43
|
+
code project's on-chain program (`SeriesCode`/`EditionCode`, before `abx lock-script`). It refuses
|
|
44
|
+
outright on a locked script or a non-code target, diffs the replacement by content against what's
|
|
45
|
+
on-chain (an index that already matches is never re-sent), handles a smaller replacement by queuing
|
|
46
|
+
the trailing `removeLastScriptChunk` calls it needs, folds every write and remove into ONE atomic
|
|
47
|
+
transaction (a revert can never leave a half-applied script), and reads the completed script back to
|
|
48
|
+
verify it reassembles exactly to the file before reporting success. Supports `--dry-run` and every
|
|
49
|
+
signing lane.
|
|
50
|
+
|
|
51
|
+
The SDK gains the primitives this is built on: `prepareSetScriptChunk`/`prepareRemoveLastScriptChunk`
|
|
52
|
+
(no `prepare*` wrapper existed for `OnChainScript.sol`'s writers before this — every caller hand-
|
|
53
|
+
encoded `encodeFunctionData`), plus `planScriptReplace`/`verifyScriptReplace`, which take a small
|
|
54
|
+
reader interface (mirroring `resume.ts`'s own reader seam) so the diff and post-write verification
|
|
55
|
+
are testable without a chain.
|
|
56
|
+
|
|
57
|
+
- c068a0f: Additive for SDK consumers — a new exported function, nothing existing changed shape or behavior.
|
|
58
|
+
|
|
59
|
+
`abx verify` now compares a collection's actual `tokenURIRenderer` and `animation_url` generator
|
|
60
|
+
pointers against the current canonical singletons for its chain, reporting each as current or
|
|
61
|
+
not-current (never treating an older-but-working deployment as broken). Adds the SDK helper
|
|
62
|
+
`isCurrentGenerator` alongside the existing `isCurrentRenderer` probe.
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- c068a0f: `decodeReader` now requires the canonical `abi.encode(address reader, address pointer)`
|
|
67
|
+
shape — exactly two 32-byte words, each zero-padded — and rejects truncated, trailing-byte,
|
|
68
|
+
or double-encoded `reader` field values with an actionable error instead of silently
|
|
69
|
+
decoding a wrong address pair.
|
|
70
|
+
|
|
71
|
+
## 0.1.0-alpha.30
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- 64248d9: Establish the public source baseline and refresh dependency constraints.
|
|
76
|
+
|
|
77
|
+
## Unreleased
|
|
78
|
+
|
|
79
|
+
Public release history begins here.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @artblocks/abx-sdk
|
|
2
|
+
|
|
3
|
+
The neutral, low-level TypeScript library for the ABX protocol — deploy, reconstruct from chain,
|
|
4
|
+
resolve a token, verify content. It picks no provider, no UX, and (beyond a default chain target)
|
|
5
|
+
no chain. Every ABX surface is built on this: the [`abx` CLI](https://docs.abx.io/docs/using-abx/installation)
|
|
6
|
+
is a shell over it, the reference resolver reads through it, and a competing provider can import
|
|
7
|
+
this same public library. If you're scripting one-off operations, the CLI is usually faster to
|
|
8
|
+
reach for — install with `abx skill install` and let an agent drive it. Reach for the SDK when you're
|
|
9
|
+
building something programmatic: a server, a mint endpoint, a scheduled job.
|
|
10
|
+
|
|
11
|
+
ESM-only, built on [viem](https://viem.sh), requires Node 22.13+. The package's main entry is
|
|
12
|
+
**browser-safe** — bundled and tested under `platform: 'browser'` on every change.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @artblocks/abx-sdk viem
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { makePublicClient, ensureFactory, deployOneOfOne } from '@artblocks/abx-sdk';
|
|
22
|
+
import { oneOfOneImageAbi } from '@artblocks/abx-sdk/abi';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## The send-injection model
|
|
26
|
+
|
|
27
|
+
Every write returns a `PreparedTx` — unsigned, with a human-readable `summary`/`fields` for a sign
|
|
28
|
+
page. The SDK never signs or broadcasts; it takes one function you provide:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
type SendTx = (tx: PreparedTx) => Promise<TransactionReceipt>;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Every `deploy*`/`ensure*`/`prepare*`-and-execute function takes a `SendTx` as an argument, so how a
|
|
35
|
+
transaction gets signed is entirely your call:
|
|
36
|
+
|
|
37
|
+
- **`makeHotSender({ wallet, account, publicClient, onEvent? })`** — for an env/hot key. Pins the
|
|
38
|
+
nonce once (a distributed RPC can briefly serve a stale count right after a send, so it tracks the
|
|
39
|
+
nonce locally rather than re-reading it), detects an `eth_estimateGas` that came back impossibly
|
|
40
|
+
low (a sign the node hasn't seen a just-deployed target's code yet) and retries rather than sending
|
|
41
|
+
an under-funded transaction, and throws a typed `TxRevertedError` — never reports a burned,
|
|
42
|
+
reverted transaction as "confirmed."
|
|
43
|
+
- **Bring your own** — a browser wallet, a Safe/multisig flow, a queue you drain later. Anything
|
|
44
|
+
that signs a `PreparedTx.data` and returns a `TransactionReceipt` works.
|
|
45
|
+
|
|
46
|
+
Sequences: `runPrepared(txs, send)` sends a list in order. `batchOps(ops)` collapses same-target
|
|
47
|
+
runs into one `Multicallable.multicall` transaction — several owner edits become one signature,
|
|
48
|
+
all-or-nothing.
|
|
49
|
+
|
|
50
|
+
## Worked example: deploy → upload → mint → read
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import {
|
|
54
|
+
makePublicClient, makeWalletClient, makeHotSender,
|
|
55
|
+
ensureFactory, deployOneOfOne, saltFor, predictClone,
|
|
56
|
+
prepareMint, runPrepared, listTokens, reconstructProject, readSaleConfig,
|
|
57
|
+
encodeTag, type OneOfOneInitParams,
|
|
58
|
+
} from '@artblocks/abx-sdk';
|
|
59
|
+
import { resolveBackend, uploadAndLocate } from '@artblocks/abx-storage';
|
|
60
|
+
import { zeroAddress, toHex } from 'viem';
|
|
61
|
+
|
|
62
|
+
const publicClient = makePublicClient({ chainKey: 'base-sepolia' });
|
|
63
|
+
const { wallet, account } = makeWalletClient({ chainKey: 'base-sepolia' }); // reads ABX_DEPLOYER_PK
|
|
64
|
+
const send = makeHotSender({ wallet, account, publicClient });
|
|
65
|
+
|
|
66
|
+
// 1. Deploy — resolve (or bootstrap) the chain's trust anchor, then deploy a clone.
|
|
67
|
+
const factory = await ensureFactory(publicClient, send, { chainId: 84532 });
|
|
68
|
+
const salt = saltFor(account.address); // front-run-proof: reserves the address to this signer
|
|
69
|
+
const clone = await predictClone(publicClient, { factory, salt });
|
|
70
|
+
|
|
71
|
+
// 2. Upload — put the image somewhere fetchable before baking its URL on-chain.
|
|
72
|
+
const backend = resolveBackend({ backend: 'ipfs' }); // or 'cloud' / 'arweave' / 'fs'
|
|
73
|
+
const bytes = new Uint8Array(/* … read your file … */);
|
|
74
|
+
const { locator } = await uploadAndLocate(backend, 'art.png', { bytes, contentType: 'image/png' });
|
|
75
|
+
|
|
76
|
+
const params: OneOfOneInitParams = {
|
|
77
|
+
owner: account.address,
|
|
78
|
+
mintTo: zeroAddress, // defer minting to step 3
|
|
79
|
+
name: 'My Piece', symbol: 'MYPC',
|
|
80
|
+
tokenURIBase: '', tokenURIRenderer: zeroAddress,
|
|
81
|
+
contractURIBase: '', contractURIRenderer: zeroAddress,
|
|
82
|
+
royaltyReceiver: account.address, royaltyBps: 500,
|
|
83
|
+
transferValidator: zeroAddress, // plain ERC-721; see ERC-721C in the site docs to opt in
|
|
84
|
+
tokenFields: [
|
|
85
|
+
// Bake the uploaded locator on-chain as the `image` field (an ipfs:// URI here; `arweave`/
|
|
86
|
+
// `url`/`keccak256` are the other off-chain representations — see the site docs for the choice,
|
|
87
|
+
// and `stageFieldContent` to put the bytes fully on-chain instead).
|
|
88
|
+
{ field: encodeTag('image'), representation: encodeTag('ipfs'), value: toHex(locator) },
|
|
89
|
+
],
|
|
90
|
+
contractFields: [],
|
|
91
|
+
};
|
|
92
|
+
const { txHash } = await deployOneOfOne(send, publicClient, { factory, params, salt });
|
|
93
|
+
|
|
94
|
+
// 3. Mint — deploy deferred it (mintTo was the zero address), so mint explicitly.
|
|
95
|
+
await runPrepared([prepareMint({ contract: clone, to: account.address, chainId: 84532 })], send);
|
|
96
|
+
|
|
97
|
+
// 4. Read — straight from chain, no indexer required.
|
|
98
|
+
const listing = await listTokens(publicClient, clone); // owners, seeds, params
|
|
99
|
+
const state = await reconstructProject(publicClient, { // full protocol state
|
|
100
|
+
address: clone, fromBlock: (await publicClient.getBlockNumber()) - 100n,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`encodeTag`/`decodeTag` (from the same package) turn a field name like `"image"` into the
|
|
105
|
+
`bytes32` tag the contract expects — spelled out above only so the snippet is self-contained.
|
|
106
|
+
Selling through the shared fixed-price minter is `prepareConfigureSale` + `preparePurchase` +
|
|
107
|
+
`readSaleConfig(publicClient, minter, clone)` — see the [SDK reference](https://docs.abx.io/docs/reference/sdk)
|
|
108
|
+
for the full surface (Series, code/generative projects, on-chain content staging, ERC-721C, and more).
|
|
109
|
+
|
|
110
|
+
## Browser use
|
|
111
|
+
|
|
112
|
+
The package's main entry (`.`) has **no Node-only imports** — it's bundled under
|
|
113
|
+
`platform: 'browser'` and asserted clean of `node:*` resolution on every change. In a browser:
|
|
114
|
+
|
|
115
|
+
- Pass `rpcUrls: [...]` explicitly to `makePublicClient`/`makeWalletClient` — there's no `process.env`
|
|
116
|
+
to fall back to, and the SDK never assumes one.
|
|
117
|
+
- Sign with a connected wallet (build the `SendTx` yourself around it) rather than `makeHotSender`,
|
|
118
|
+
which expects a local `WalletClient` backed by a key.
|
|
119
|
+
- **Never** import `@artblocks/abx-sdk/node` — that subpath is the *only* place `.env` loading lives
|
|
120
|
+
(`loadDotEnv`, needs `node:fs`/`node:path`) and it will break a browser bundle. A host (a CLI, a
|
|
121
|
+
server) calls `loadDotEnv()` once at startup; the SDK core just reads whatever's already in
|
|
122
|
+
`process.env` via a tiny `readEnv` that's a no-op outside Node.
|
|
123
|
+
|
|
124
|
+
The only signing-key env var the SDK ever reads is `ABX_DEPLOYER_PK` (via `makeWalletClient`/
|
|
125
|
+
`envSigningKey`) — and only as a *fallback* when you don't pass `privateKey`/`rpcUrls` explicitly.
|
|
126
|
+
|
|
127
|
+
## More
|
|
128
|
+
|
|
129
|
+
Full API documentation by task (deploy, sell, operate, read, embed in a browser, talk to a resolver)
|
|
130
|
+
is in the [SDK reference](https://docs.abx.io/docs/reference/sdk).
|