@secondlayer/stacks 4.3.2 → 5.0.1
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/README.md +27 -11
- package/dist/shared/{stacks-bfan7ex7.js → stacks-4d7c3x27.js} +5 -5
- package/dist/shared/{stacks-bfan7ex7.js.map → stacks-4d7c3x27.js.map} +3 -3
- package/dist/shared/{stacks-709tra19.js → stacks-4hs8r4q2.js} +16 -2
- package/dist/shared/stacks-4hs8r4q2.js.map +10 -0
- package/dist/shared/{stacks-w23294am.js → stacks-51ybf135.js} +3 -3
- package/dist/shared/{stacks-0jk7vd8r.cjs → stacks-69nq48jp.js} +120 -17
- package/dist/shared/stacks-69nq48jp.js.map +15 -0
- package/dist/shared/{stacks-8pfdscq6.js → stacks-6gavarmy.js} +37 -9
- package/dist/shared/stacks-6gavarmy.js.map +12 -0
- package/dist/shared/{stacks-gxq2pbky.js → stacks-71k0vmct.js} +65 -8
- package/dist/shared/stacks-71k0vmct.js.map +13 -0
- package/dist/shared/{stacks-7wkf2rph.js → stacks-7bqkf3b0.js} +86 -71
- package/dist/shared/{stacks-7wkf2rph.js.map → stacks-7bqkf3b0.js.map} +9 -10
- package/dist/shared/{stacks-zcpvzbr0.js → stacks-8brgfvqx.js} +3 -3
- package/dist/shared/{stacks-4vzmhw3q.cjs → stacks-8vzxax5e.cjs} +13 -3
- package/dist/shared/stacks-8vzxax5e.cjs.map +10 -0
- package/dist/shared/{stacks-hnqt5rz4.js → stacks-9c1yam8b.js} +3 -3
- package/dist/shared/{stacks-bnbdqznq.cjs → stacks-bdgh9n83.cjs} +11 -10
- package/dist/shared/{stacks-bnbdqznq.cjs.map → stacks-bdgh9n83.cjs.map} +3 -3
- package/dist/shared/{stacks-fb75yew8.js → stacks-db3kwavg.cjs} +346 -138
- package/dist/shared/stacks-db3kwavg.cjs.map +23 -0
- package/dist/shared/{stacks-jpt52csy.js → stacks-e3nwm1dz.js} +14 -17
- package/dist/shared/stacks-e3nwm1dz.js.map +10 -0
- package/dist/shared/{stacks-ta1gar0b.cjs → stacks-ee53k9j2.cjs} +62 -6
- package/dist/shared/stacks-ee53k9j2.cjs.map +13 -0
- package/dist/shared/{stacks-27fmgajb.js → stacks-ga026yxz.js} +9 -9
- package/dist/shared/{stacks-27fmgajb.js.map → stacks-ga026yxz.js.map} +3 -3
- package/dist/shared/{stacks-nyaw1z2a.cjs → stacks-ggdz96r1.cjs} +4 -4
- package/dist/shared/{stacks-nyaw1z2a.cjs.map → stacks-ggdz96r1.cjs.map} +3 -3
- package/dist/shared/{stacks-08y0y0t7.js → stacks-gjz26k6b.js} +2 -2
- package/dist/shared/{stacks-x5386y2y.cjs → stacks-gza2n1zs.cjs} +5 -5
- package/dist/shared/{stacks-x5386y2y.cjs.map → stacks-gza2n1zs.cjs.map} +3 -3
- package/dist/shared/{stacks-ztzygy90.js → stacks-mftyrc60.js} +2 -2
- package/dist/shared/stacks-n4d8j8q3.js +801 -0
- package/dist/shared/stacks-n4d8j8q3.js.map +23 -0
- package/dist/shared/{stacks-ycbq8pf7.cjs → stacks-p337hp6m.cjs} +74 -59
- package/dist/shared/{stacks-ycbq8pf7.cjs.map → stacks-p337hp6m.cjs.map} +9 -10
- package/dist/shared/{stacks-ttdk2g2f.js → stacks-s5vej5z6.cjs} +92 -41
- package/dist/shared/stacks-s5vej5z6.cjs.map +15 -0
- package/dist/shared/stacks-sdqkapct.cjs +67 -0
- package/dist/shared/stacks-sdqkapct.cjs.map +12 -0
- package/dist/shared/{stacks-1arrcd11.js → stacks-v2rfr46a.js} +2 -2
- package/dist/shared/{stacks-9mqveyjv.cjs → stacks-w9t61fra.cjs} +7 -10
- package/dist/shared/stacks-w9t61fra.cjs.map +10 -0
- package/dist/shared/{stacks-tjjnkt3r.js → stacks-wxfd6r4b.js} +2 -2
- package/dist/shared/{stacks-4z72akdf.js → stacks-x0qqwrev.js} +3 -3
- package/dist/shared/{stacks-gck1sq7h.cjs → stacks-xjkn3en1.cjs} +16 -2
- package/dist/shared/stacks-xjkn3en1.cjs.map +10 -0
- package/dist/shared/stacks-xnrywjf1.cjs +131 -0
- package/dist/shared/stacks-xnrywjf1.cjs.map +11 -0
- package/dist/shared/stacks-yajyej2y.js +139 -0
- package/dist/shared/stacks-yajyej2y.js.map +11 -0
- package/dist/shared/{stacks-913a2rx7.js → stacks-yvb7rvwk.js} +13 -3
- package/dist/shared/stacks-yvb7rvwk.js.map +10 -0
- package/dist/shared/{stacks-0cdm20eh.js → stacks-z90xdr1x.js} +7 -11
- package/dist/shared/{stacks-0cdm20eh.js.map → stacks-z90xdr1x.js.map} +3 -3
- package/dist/src/accounts/index.js +2 -3
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +2 -1
- package/dist/src/actions/index.cjs.map +1 -1
- package/dist/src/actions/index.d.cts +108 -20
- package/dist/src/actions/index.d.ts +108 -20
- package/dist/src/actions/index.js +17 -15
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.d.cts +27 -0
- package/dist/src/bitcoin/index.d.ts +27 -0
- package/dist/src/bitcoin/index.js +10 -11
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.d.cts +27 -0
- package/dist/src/bns/index.d.ts +27 -0
- package/dist/src/bns/index.js +13 -13
- package/dist/src/bns/index.js.map +1 -1
- package/dist/src/clarity/index.js +7 -6
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +44 -30
- package/dist/src/connect/index.cjs.map +7 -7
- package/dist/src/connect/index.d.cts +16 -1
- package/dist/src/connect/index.d.ts +16 -1
- package/dist/src/connect/index.js +44 -30
- package/dist/src/connect/index.js.map +7 -7
- package/dist/src/connect/walletconnect/index.cjs +49 -413
- package/dist/src/connect/walletconnect/index.cjs.map +4 -4
- package/dist/src/connect/walletconnect/index.js +47 -411
- package/dist/src/connect/walletconnect/index.js.map +4 -4
- package/dist/src/filters/index.js +2 -2
- package/dist/src/index.cjs +49 -124
- package/dist/src/index.cjs.map +6 -8
- package/dist/src/index.d.cts +163 -54
- package/dist/src/index.d.ts +163 -54
- package/dist/src/index.js +79 -147
- package/dist/src/index.js.map +6 -8
- package/dist/src/postconditions/index.js +6 -5
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +7 -83
- package/dist/src/pox/index.cjs.map +3 -3
- package/dist/src/pox/index.d.cts +32 -1
- package/dist/src/pox/index.d.ts +32 -1
- package/dist/src/pox/index.js +22 -102
- package/dist/src/pox/index.js.map +3 -3
- package/dist/src/pox5/index.cjs +4 -112
- package/dist/src/pox5/index.cjs.map +3 -4
- package/dist/src/pox5/index.d.cts +27 -0
- package/dist/src/pox5/index.d.ts +27 -0
- package/dist/src/pox5/index.js +20 -131
- package/dist/src/pox5/index.js.map +3 -4
- package/dist/src/sbtc/index.cjs +2 -27
- package/dist/src/sbtc/index.cjs.map +3 -3
- package/dist/src/sbtc/index.d.cts +30 -2
- package/dist/src/sbtc/index.d.ts +30 -2
- package/dist/src/sbtc/index.js +15 -45
- package/dist/src/sbtc/index.js.map +3 -3
- package/dist/src/stackingdao/index.d.cts +27 -0
- package/dist/src/stackingdao/index.d.ts +27 -0
- package/dist/src/stackingdao/index.js +11 -11
- package/dist/src/stackingdao/index.js.map +1 -1
- package/dist/src/subscriptions/index.d.cts +27 -0
- package/dist/src/subscriptions/index.d.ts +27 -0
- package/dist/src/subscriptions/index.js +2 -2
- package/dist/src/tools/btc/index.cjs.map +2 -2
- package/dist/src/tools/btc/index.js.map +2 -2
- package/dist/src/tools/index.cjs +629 -392
- package/dist/src/tools/index.cjs.map +30 -28
- package/dist/src/tools/index.d.cts +44 -0
- package/dist/src/tools/index.d.ts +44 -0
- package/dist/src/tools/index.js +628 -391
- package/dist/src/tools/index.js.map +30 -28
- package/dist/src/transactions/index.js +6 -5
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.d.cts +2 -5
- package/dist/src/utils/index.d.ts +2 -5
- package/dist/src/utils/index.js +2 -2
- package/package.json +18 -7
- package/dist/shared/stacks-0eatsx6d.cjs +0 -25
- package/dist/shared/stacks-0eatsx6d.cjs.map +0 -10
- package/dist/shared/stacks-0jk7vd8r.cjs.map +0 -14
- package/dist/shared/stacks-4vzmhw3q.cjs.map +0 -10
- package/dist/shared/stacks-5nmz5ad9.js +0 -409
- package/dist/shared/stacks-5nmz5ad9.js.map +0 -10
- package/dist/shared/stacks-709tra19.js.map +0 -10
- package/dist/shared/stacks-8pfdscq6.js.map +0 -12
- package/dist/shared/stacks-913a2rx7.js.map +0 -10
- package/dist/shared/stacks-9mqveyjv.cjs.map +0 -10
- package/dist/shared/stacks-e4xn4m7j.js +0 -27
- package/dist/shared/stacks-e4xn4m7j.js.map +0 -10
- package/dist/shared/stacks-fb75yew8.js.map +0 -21
- package/dist/shared/stacks-gck1sq7h.cjs.map +0 -10
- package/dist/shared/stacks-gxq2pbky.js.map +0 -13
- package/dist/shared/stacks-jpt52csy.js.map +0 -10
- package/dist/shared/stacks-mnnhpex3.cjs +0 -407
- package/dist/shared/stacks-mnnhpex3.cjs.map +0 -10
- package/dist/shared/stacks-ta1gar0b.cjs.map +0 -13
- package/dist/shared/stacks-tdsp5gsb.cjs +0 -527
- package/dist/shared/stacks-tdsp5gsb.cjs.map +0 -21
- package/dist/shared/stacks-ttdk2g2f.js.map +0 -14
- package/dist/shared/stacks-wdp5yr8n.cjs +0 -39
- package/dist/shared/stacks-wdp5yr8n.cjs.map +0 -12
- /package/dist/shared/{stacks-w23294am.js.map → stacks-51ybf135.js.map} +0 -0
- /package/dist/shared/{stacks-zcpvzbr0.js.map → stacks-8brgfvqx.js.map} +0 -0
- /package/dist/shared/{stacks-hnqt5rz4.js.map → stacks-9c1yam8b.js.map} +0 -0
- /package/dist/shared/{stacks-08y0y0t7.js.map → stacks-gjz26k6b.js.map} +0 -0
- /package/dist/shared/{stacks-ztzygy90.js.map → stacks-mftyrc60.js.map} +0 -0
- /package/dist/shared/{stacks-1arrcd11.js.map → stacks-v2rfr46a.js.map} +0 -0
- /package/dist/shared/{stacks-tjjnkt3r.js.map → stacks-wxfd6r4b.js.map} +0 -0
- /package/dist/shared/{stacks-4z72akdf.js.map → stacks-x0qqwrev.js.map} +0 -0
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ const balance = await client.getBalance({
|
|
|
38
38
|
| `@secondlayer/stacks/utils` | Encoding, hashing, addresses, unit formatting |
|
|
39
39
|
| `@secondlayer/stacks/bitcoin` | Trust-minimized Bitcoin SPV — proof construction, Clarity codecs, verifier (SIP-044) |
|
|
40
40
|
| `@secondlayer/stacks/pox5` | PoX-5 Bitcoin Staking (SIP-045) — bonds, staking, lockup scripts, signer grants |
|
|
41
|
+
| `@secondlayer/stacks/sbtc` | `sbtc()` client extension: sBTC deposits, balances, withdrawals |
|
|
42
|
+
| `@secondlayer/stacks/filters` | Event and transaction filter builders, re-exported from the root |
|
|
41
43
|
|
|
42
44
|
### Frozen modules
|
|
43
45
|
|
|
@@ -59,9 +61,18 @@ multi-broadcast gap, which is why it lives here rather than being deferred to
|
|
|
59
61
|
| `@secondlayer/stacks/pox` | PoX stacking — solo and delegated |
|
|
60
62
|
| `@secondlayer/stacks/stackingdao` | StackingDAO liquid staking (STX/stSTX) |
|
|
61
63
|
|
|
64
|
+
### Deprecated: `/tools` and `/tools/btc`
|
|
65
|
+
|
|
66
|
+
Give your agent Stacks reads through [`@secondlayer/mcp`](https://www.npmjs.com/package/@secondlayer/mcp) instead. The two AI SDK tool entries below still import, and stay until the next major, but they get no new tools. The tradeoff of keeping them: `ai` and `zod` are now optional peer dependencies, so a project that imports either entry installs both itself; a project that only reads contracts installs neither.
|
|
67
|
+
|
|
68
|
+
| Module | Description |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `@secondlayer/stacks/tools` | **Deprecated.** AI SDK `tool()` set for Stacks reads. Bare exports read `STACKS_NETWORK` (or `STACKS_CHAIN`) and `STACKS_NODE_RPC_URL`, `SL_API_URL` or `STACKS_RPC_URL`; `createStacksTools(client)` binds your own client |
|
|
71
|
+
| `@secondlayer/stacks/tools/btc` | **Deprecated.** AI SDK `tool()` set for Bitcoin reads via mempool.space (`BTC_MEMPOOL_URL` overrides the host) |
|
|
72
|
+
|
|
62
73
|
## Fee tiers
|
|
63
74
|
|
|
64
|
-
Every send action takes `fee` as an exact amount **or a named tier
|
|
75
|
+
Every send action takes `fee` as an exact amount **or a named tier**: `'min' | 'low' | 'mid' | 'high'`. Tiers map to the node's three estimations; `'min'` is the minimum relay fee (1 uSTX per serialized byte), computed offline with no round-trip. Omitting `fee` estimates mid. When the node answers `NoEstimateAvailable` (a quiet chain or fresh devnet with no fee history), the SDK falls back to `'min'` instead of failing; `resolveFee` returns `{ fee, tier }` so you can see which happened. Any other estimator failure (timeout, 5xx, auth) throws rather than silently under-paying, and the nonce reserved for that send is handed back.
|
|
65
76
|
|
|
66
77
|
```ts
|
|
67
78
|
await client.transferStx({ to, amount: 1000n, fee: "low" });
|
|
@@ -73,7 +84,7 @@ await client.callContract({ contract, functionName: "mint", fee: "min" });
|
|
|
73
84
|
`waitForTransactionReceipt` polls until a transaction is mined (optionally N confirmations deep) and returns a normalized receipt with the decoded Clarity result. It rejects with typed errors when the tx aborts (`TransactionAbortedError`, receipt attached), drops from the mempool (`TransactionDroppedError`), or times out — and it re-reads block placement every cycle, so reorgs don't strand the wait.
|
|
74
85
|
|
|
75
86
|
```ts
|
|
76
|
-
const
|
|
87
|
+
const txid = await client.callContract({ contract, functionName: "mint" });
|
|
77
88
|
const receipt = await client.waitForTransactionReceipt({ txid, confirmations: 2 });
|
|
78
89
|
receipt.result; // decoded ClarityValue
|
|
79
90
|
|
|
@@ -81,20 +92,22 @@ receipt.result; // decoded ClarityValue
|
|
|
81
92
|
const { receipt } = await sendTransaction(client, { transaction, wait: 2 });
|
|
82
93
|
```
|
|
83
94
|
|
|
84
|
-
Status reads are pluggable, like nonce sources: the default reads `/extended/v1/tx` on your transport host; `indexTxSource()` reads Secondlayer
|
|
95
|
+
Status reads are pluggable, like nonce sources: the default reads `/extended/v1/tx` on your transport host; `indexTxSource()` reads `/v1/index/transactions` on your Secondlayer instance, which returns the chain tip in the same response, so N-confirmation waits cost one request per poll. The index only knows mined transactions, so with this source the dropped-grace window defaults to the full `timeout` instead of 30s. Without `baseUrl` the transport URL is assumed to be your instance: a Hiro transport throws up front, and a host that answers `/v1/index` with a non-JSON 404 (a bare stacks-node) throws on the first poll instead of waiting out the timeout. A `baseUrl` other than the transport host reuses the transport's retry and timeout policy only; the transport's `apiKey` and `fetchOptions` stay with the transport host. Rejection reasons are typed too: `BroadcastError.reason` is a literal union of all 26 stacks-node rejection strings (with `reasonData` and `txid` attached).
|
|
85
96
|
|
|
86
97
|
## Errors
|
|
87
98
|
|
|
88
|
-
The HTTP transport throws a typed `HttpRequestError` (`.status` attached) on any non-2xx response instead of handing back the error body as if it were a successful result
|
|
99
|
+
The HTTP transport throws a typed `HttpRequestError` (`.status`, `.url`, `.method` attached) on any non-2xx response instead of handing back the error body as if it were a successful result, and it retries `429`s, not just `5xx`/network errors. One `timeout` covers each attempt end to end, headers and body, so a stalled response rejects with `TimeoutError` (`.url`, `.method`, `.timeout`, `.attempt`) instead of hanging. Pass `signal` on any request to cancel from your side; a caller abort is never retried. Broadcasts are sent once (`retryCount: 0`): re-posting a transaction the node may already hold would surface as a nonce conflict, so a timed-out broadcast checks whether the node knows the tx before failing. `MalformedResponseError` throws from `getBalance`, `getAccountInfo`, `getMapEntry`, `getBlockHeight`, and `getBurnBlockHeight` when the node's response is missing an expected field, instead of failing with an opaque native error (`BigInt(undefined)` and friends). Both are exported from `@secondlayer/stacks`. Every error carries a stable `code` (`HTTP_REQUEST_ERROR`, `TIMEOUT_ERROR`, `MALFORMED_RESPONSE_ERROR`, ...) that also appears in `toJSON()`, so a handler can branch on it without an `instanceof` chain and without parsing a message that may be reworded.
|
|
89
100
|
|
|
90
101
|
```ts
|
|
91
|
-
import { HttpRequestError, MalformedResponseError } from "@secondlayer/stacks";
|
|
102
|
+
import { BaseError, HttpRequestError, MalformedResponseError, TimeoutError } from "@secondlayer/stacks";
|
|
92
103
|
|
|
93
104
|
try {
|
|
94
105
|
await client.getBalance({ address });
|
|
95
106
|
} catch (e) {
|
|
96
107
|
if (e instanceof HttpRequestError) e.status; // non-2xx from the node/API
|
|
108
|
+
if (e instanceof TimeoutError) e.url; // headers or body did not arrive in time
|
|
97
109
|
if (e instanceof MalformedResponseError) { /* response shape didn't match */ }
|
|
110
|
+
if (e instanceof BaseError) e.code; // "TIMEOUT_ERROR", stable across releases and minification (derived from `name`, not the class)
|
|
98
111
|
}
|
|
99
112
|
```
|
|
100
113
|
|
|
@@ -151,7 +164,7 @@ if (await client.pox5.isActive()) {
|
|
|
151
164
|
}
|
|
152
165
|
```
|
|
153
166
|
|
|
154
|
-
Every wallet action (`setupBond`, `registerForBond`, `stake`, `unstake`, `unstakeSbtc`, `claimRewards`, `grantSignerKey`, …) inherits fee tiers, nonce management, and typed errors from the client. `client.pox5.getStakerState(staker)` returns a staker's whole position
|
|
167
|
+
Every wallet action (`setupBond`, `registerForBond`, `stake`, `unstake`, `unstakeSbtc`, `claimRewards`, `grantSignerKey`, …) inherits fee tiers, nonce management, and typed errors from the client. `client.pox5.getStakerState(staker)` returns a staker's whole position (staker info, bond membership, custodied sBTC, current cycle) in one call (four parallel reads under the hood; Stacks nodes have no batch RPC, and `multicall` caps reads in flight at 8 by default via `concurrency`). Individual reads return typed JS values decoded via the module's committed pox-5 ABI (bigints, camelCase tuples, `null` for absent optionals), and every action's arguments are checked against that ABI at compile time.
|
|
155
168
|
|
|
156
169
|
### Off-chain L1 tooling — works before activation
|
|
157
170
|
|
|
@@ -185,7 +198,7 @@ await Promise.all(
|
|
|
185
198
|
);
|
|
186
199
|
```
|
|
187
200
|
|
|
188
|
-
Passing an explicit `nonce` always bypasses the manager. The defaults are node-agnostic and in-memory
|
|
201
|
+
Passing an explicit `nonce` always bypasses the manager. The defaults are node-agnostic and in-memory, with zero external dependencies. A send that fails before the node accepts it (fee estimate outage, `FeeTooLow`, transport error) hands its nonce back, so the next send reuses it instead of leaving a gap the mempool cannot chain past. Custom stores opt in by implementing `release(key, nonce)`; the bundled memory, Redis and Postgres stores already do.
|
|
189
202
|
|
|
190
203
|
### Multiple processes / smart wallets
|
|
191
204
|
|
|
@@ -203,7 +216,7 @@ const nonceManager = createNonceManager({
|
|
|
203
216
|
|
|
204
217
|
### Mempool-aware sources (optional)
|
|
205
218
|
|
|
206
|
-
By default the floor is the node's confirmed nonce. To make it mempool-aware
|
|
219
|
+
By default the floor is the node's confirmed nonce. To make it mempool-aware, and to auto-fill the freed nonce of a dropped transaction, swap the source. `indexSource` reads your Secondlayer instance's mempool through the client transport (retries, timeout and `Authorization: Bearer` included), `hiroNonceSource` reads Hiro's, or bring your own pending feed with `mempoolAwareSource`:
|
|
207
220
|
|
|
208
221
|
```ts
|
|
209
222
|
import {
|
|
@@ -212,7 +225,10 @@ import {
|
|
|
212
225
|
startNonceReconciler,
|
|
213
226
|
} from "@secondlayer/stacks";
|
|
214
227
|
|
|
215
|
-
// indexSource() | hiroNonceSource({ baseUrl }) | mempoolAwareSource({ getPending })
|
|
228
|
+
// indexSource({ baseUrl?, apiKey? }) | hiroNonceSource({ baseUrl }) | mempoolAwareSource({ getPending })
|
|
229
|
+
// baseUrl defaults to the transport URL; pass it when the transport is not your instance.
|
|
230
|
+
// A missing URL, a Hiro transport, or a host without /v1/index rejects instead of
|
|
231
|
+
// silently falling back to the confirmed nonce; a 5xx or timeout still degrades.
|
|
216
232
|
const source = indexSource();
|
|
217
233
|
const nonceManager = createNonceManager({ source });
|
|
218
234
|
|
|
@@ -357,12 +373,12 @@ SDK (gzipped) 23.8 KB 189 KB
|
|
|
357
373
|
+ WalletConnect v2 +25.5 KB (included)
|
|
358
374
|
─────────────────── ───────────────────
|
|
359
375
|
Total 46.1 KB 536 KB ← 11.6x
|
|
360
|
-
Dependencies
|
|
376
|
+
Dependencies 8 294 ← 37x
|
|
361
377
|
node_modules 7 MB 351 MB ← 50x
|
|
362
378
|
Polyfills needed none Buffer, crypto
|
|
363
379
|
Packages to install 1 5+
|
|
364
380
|
```
|
|
365
381
|
|
|
366
|
-
|
|
382
|
+
8 runtime deps, all `@noble`/`@scure`: `@noble/hashes`, `@noble/secp256k1`, `@noble/curves`, `@noble/ciphers`, `@scure/base`, `@scure/bip32`, `@scure/bip39`, `@scure/btc-signer`. `ai` and `zod` are optional peers, pulled in only by the deprecated `/tools` entries.
|
|
367
383
|
|
|
368
384
|
Connect and WalletConnect are separate entry points — import only what you use. An app that just reads contracts pays 23.8 KB. Full wallet connection + WC v2 pays 46.1 KB. The equivalent stacks.js setup is 536 KB regardless.
|
|
@@ -51,10 +51,10 @@ function parsePrincipal(value) {
|
|
|
51
51
|
return { address, contractName };
|
|
52
52
|
}
|
|
53
53
|
function parseContractId(contractId) {
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
54
|
+
const parsed = parsePrincipal(contractId);
|
|
55
|
+
if (!parsed?.contractName)
|
|
56
56
|
throw new Error(`Invalid contract identifier: ${contractId}`);
|
|
57
|
-
return [address,
|
|
57
|
+
return [parsed.address, parsed.contractName];
|
|
58
58
|
}
|
|
59
59
|
function isClarityName(name) {
|
|
60
60
|
const regex = /^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$/;
|
|
@@ -80,5 +80,5 @@ function getContractAddress(deployer, contractName) {
|
|
|
80
80
|
|
|
81
81
|
export { MAX_U128, MAX_I128, MIN_I128, AddressVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, MICROSTX_PER_STX, publicKeyToAddress, CONTRACT_NAME_REGEX, validateStacksAddress, isValidAddress, parsePrincipal, parseContractId, isClarityName, isAddressEqual, addressToVersion, getContractAddress };
|
|
82
82
|
|
|
83
|
-
//# debugId=
|
|
84
|
-
//# sourceMappingURL=stacks-
|
|
83
|
+
//# debugId=0B54120C08BE628064756E2164756E21
|
|
84
|
+
//# sourceMappingURL=stacks-4d7c3x27.js.map
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"sources": ["../src/utils/constants.ts", "../src/utils/address.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"// Clarity integer bounds\nexport const MAX_U128: bigint = (1n << 128n) - 1n;\nexport const MAX_I128: bigint = (1n << 127n) - 1n;\nexport const MIN_I128: bigint = -(1n << 127n);\n\n/** C32-encoded address version bytes for single-sig and multi-sig on each network. */\nexport const AddressVersion = {\n\tMainnetSingleSig: 22,\n\tMainnetMultiSig: 20,\n\tTestnetSingleSig: 26,\n\tTestnetMultiSig: 21,\n} as const;\nexport type AddressVersion =\n\t(typeof AddressVersion)[keyof typeof AddressVersion];\n\n/** Mainnet burn address (all-zero hash160). */\nexport const ZERO_ADDRESS = \"SP000000000000000000002Q6VF78\";\n/** Testnet burn address (all-zero hash160). */\nexport const TESTNET_ZERO_ADDRESS = \"ST000000000000000000002AMW42H\";\n\n/** Number of microSTX per 1 STX (10^6). */\nexport const MICROSTX_PER_STX = 1_000_000n;\n",
|
|
6
|
-
"import { c32address, c32addressDecode } from \"./c32.ts\";\nimport { AddressVersion } from \"./constants.ts\";\nimport { bytesToHex, hexToBytes, without0x } from \"./encoding.ts\";\nimport { hash160 } from \"./hash.ts\";\n\nexport { c32address, c32addressDecode };\n\n/**\n * Derive the single-sig Stacks address for a compressed public key.\n */\nexport function publicKeyToAddress(\n\tpublicKey: string | Uint8Array,\n\tnetwork: \"mainnet\" | \"testnet\" = \"mainnet\",\n): string {\n\tconst bytes =\n\t\ttypeof publicKey === \"string\"\n\t\t\t? hexToBytes(without0x(publicKey))\n\t\t\t: publicKey;\n\tconst version =\n\t\tnetwork === \"mainnet\"\n\t\t\t? AddressVersion.MainnetSingleSig\n\t\t\t: AddressVersion.TestnetSingleSig;\n\treturn c32address(version, bytesToHex(hash160(bytes)));\n}\n\n/** Clarity contract-name grammar: leading letter, then letters/digits/`-`/`_`.\n * Underscore is legal (SIP-002) and deployed contracts use it — matches the\n * pattern the Index API already accepts for contract ids. */\nexport const CONTRACT_NAME_REGEX: RegExp = /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;\n\nexport function validateStacksAddress(address: string): boolean {\n\ttry {\n\t\tc32addressDecode(address);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Alias for validateStacksAddress — matches future.md naming. */\nexport const isValidAddress: (address: string) => boolean =\n\tvalidateStacksAddress;\n\n/** Parse a principal into its parts, or null when malformed. The single\n * definition of \"valid principal\" for this package: exactly one optional\n * `.name` segment (never two), a c32-decodable address, and a contract name\n * matching the Clarity grammar. */\nexport function parsePrincipal(\n\tvalue: string,\n): { address: string; contractName?: string } | null {\n\tconst parts = value.split(\".\");\n\tif (parts.length > 2) return null;\n\tconst [address, contractName] = parts as [string, string | undefined];\n\tif (!validateStacksAddress(address)) return null;\n\tif (contractName === undefined) return { address };\n\tif (!CONTRACT_NAME_REGEX.test(contractName)) return null;\n\treturn { address, contractName };\n}\n\nexport function parseContractId(contractId: string): [string, string] {\n\tconst
|
|
6
|
+
"import { c32address, c32addressDecode } from \"./c32.ts\";\nimport { AddressVersion } from \"./constants.ts\";\nimport { bytesToHex, hexToBytes, without0x } from \"./encoding.ts\";\nimport { hash160 } from \"./hash.ts\";\n\nexport { c32address, c32addressDecode };\n\n/**\n * Derive the single-sig Stacks address for a compressed public key.\n */\nexport function publicKeyToAddress(\n\tpublicKey: string | Uint8Array,\n\tnetwork: \"mainnet\" | \"testnet\" = \"mainnet\",\n): string {\n\tconst bytes =\n\t\ttypeof publicKey === \"string\"\n\t\t\t? hexToBytes(without0x(publicKey))\n\t\t\t: publicKey;\n\tconst version =\n\t\tnetwork === \"mainnet\"\n\t\t\t? AddressVersion.MainnetSingleSig\n\t\t\t: AddressVersion.TestnetSingleSig;\n\treturn c32address(version, bytesToHex(hash160(bytes)));\n}\n\n/** Clarity contract-name grammar: leading letter, then letters/digits/`-`/`_`.\n * Underscore is legal (SIP-002) and deployed contracts use it — matches the\n * pattern the Index API already accepts for contract ids. */\nexport const CONTRACT_NAME_REGEX: RegExp = /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;\n\nexport function validateStacksAddress(address: string): boolean {\n\ttry {\n\t\tc32addressDecode(address);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Alias for validateStacksAddress — matches future.md naming. */\nexport const isValidAddress: (address: string) => boolean =\n\tvalidateStacksAddress;\n\n/** Parse a principal into its parts, or null when malformed. The single\n * definition of \"valid principal\" for this package: exactly one optional\n * `.name` segment (never two), a c32-decodable address, and a contract name\n * matching the Clarity grammar. */\nexport function parsePrincipal(\n\tvalue: string,\n): { address: string; contractName?: string } | null {\n\tconst parts = value.split(\".\");\n\tif (parts.length > 2) return null;\n\tconst [address, contractName] = parts as [string, string | undefined];\n\tif (!validateStacksAddress(address)) return null;\n\tif (contractName === undefined) return { address };\n\tif (!CONTRACT_NAME_REGEX.test(contractName)) return null;\n\treturn { address, contractName };\n}\n\n/** Split `address.name` into its parts. Throws on anything `parsePrincipal`\n * rejects, and on a bare address with no contract name. */\nexport function parseContractId(contractId: string): [string, string] {\n\tconst parsed = parsePrincipal(contractId);\n\tif (!parsed?.contractName)\n\t\tthrow new Error(`Invalid contract identifier: ${contractId}`);\n\treturn [parsed.address, parsed.contractName];\n}\n\nexport function isClarityName(name: string): boolean {\n\tconst regex = /^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$/;\n\treturn regex.test(name) && name.length < 128;\n}\n\n/**\n * Compare two Stacks addresses for equality (case-insensitive, version-aware).\n * Throws if either address is invalid.\n */\nexport function isAddressEqual(a: string, b: string): boolean {\n\tconst [versionA, hashA] = c32addressDecode(a);\n\tconst [versionB, hashB] = c32addressDecode(b);\n\treturn versionA === versionB && hashA.toLowerCase() === hashB.toLowerCase();\n}\n\n/** Extract the version byte from a Stacks address (22, 20, 26, or 21). */\nexport function addressToVersion(address: string): number {\n\treturn c32addressDecode(address)[0];\n}\n\n/**\n * Build a contract address from deployer + contract name.\n * Validates both parts; returns `deployer.contractName`.\n */\nexport function getContractAddress(\n\tdeployer: string,\n\tcontractName: string,\n): string {\n\tif (!validateStacksAddress(deployer)) {\n\t\tthrow new Error(`Invalid deployer address: ${deployer}`);\n\t}\n\tif (!isClarityName(contractName)) {\n\t\tthrow new Error(`Invalid contract name: ${contractName}`);\n\t}\n\treturn `${deployer}.${contractName}`;\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;AACO,IAAM,YAAoB,MAAM,QAAQ;AACxC,IAAM,YAAoB,MAAM,QAAQ;AACxC,IAAM,WAAmB,EAAE,MAAM;AAGjC,IAAM,iBAAiB;AAAA,EAC7B,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,iBAAiB;AAClB;AAKO,IAAM,eAAe;AAErB,IAAM,uBAAuB;AAG7B,IAAM,mBAAmB;;;ACXzB,SAAS,kBAAkB,CACjC,WACA,UAAiC,WACxB;AAAA,EACT,MAAM,QACL,OAAO,cAAc,WAClB,WAAW,UAAU,SAAS,CAAC,IAC/B;AAAA,EACJ,MAAM,UACL,YAAY,YACT,eAAe,mBACf,eAAe;AAAA,EACnB,OAAO,WAAW,SAAS,WAAW,QAAQ,KAAK,CAAC,CAAC;AAAA;AAM/C,IAAM,sBAA8B;AAEpC,SAAS,qBAAqB,CAAC,SAA0B;AAAA,EAC/D,IAAI;AAAA,IACH,iBAAiB,OAAO;AAAA,IACxB,OAAO;AAAA,IACN,MAAM;AAAA,IACP,OAAO;AAAA;AAAA;AAKF,IAAM,iBACZ;AAMM,SAAS,cAAc,CAC7B,OACoD;AAAA,EACpD,MAAM,QAAQ,MAAM,MAAM,GAAG;AAAA,EAC7B,IAAI,MAAM,SAAS;AAAA,IAAG,OAAO;AAAA,EAC7B,OAAO,SAAS,gBAAgB;AAAA,EAChC,IAAI,CAAC,sBAAsB,OAAO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AK,YAAY;AAAA,IAAG,OAAO;AAAA,EACpD,OAAO,EAAE,SAAS,aAAa;AAAA;AAKzB,SAAS,eAAe,CAAC,YAAsC;AAAA,EACrE,MAAM,SAAS,eAAe,UAAU;AAAA,EACxC,IAAI,CAAC,QAAQ;AAAA,IACZ,MAAM,IAAI,MAAM,gCAAgC,YAAY;AAAA,EAC7D,OAAO,CAAC,OAAO,SAAS,OAAO,YAAY;AAAA;AAGrC,SAAS,aAAa,CAAC,MAAuB;AAAA,EACpD,MAAM,QAAQ;AAAA,EACd,OAAO,MAAM,KAAK,IAAI,KAAK,KAAK,SAAS;AAAA;AAOnC,SAAS,cAAc,CAAC,GAAW,GAAoB;AAAA,EAC7D,OAAO,UAAU,SAAS,iBAAiB,CAAC;AAAA,EAC5C,OAAO,UAAU,SAAS,iBAAiB,CAAC;AAAA,EAC5C,OAAO,aAAa,YAAY,MAAM,YAAY,MAAM,MAAM,YAAY;AAAA;AAIpE,SAAS,gBAAgB,CAAC,SAAyB;AAAA,EACzD,OAAO,iBAAiB,OAAO,EAAE;AAAA;AAO3B,SAAS,kBAAkB,CACjC,UACA,cACS;AAAA,EACT,IAAI,CAAC,sBAAsB,QAAQ,GAAG;AAAA,IACrC,MAAM,IAAI,MAAM,6BAA6B,UAAU;AAAA,EACxD;AAAA,EACA,IAAI,CAAC,cAAc,YAAY,GAAG;AAAA,IACjC,MAAM,IAAI,MAAM,0BAA0B,cAAc;AAAA,EACzD;AAAA,EACA,OAAO,GAAG,YAAY;AAAA;",
|
|
9
|
+
"debugId": "0B54120C08BE628064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/errors/base.ts
|
|
2
|
+
function codeFromName(name) {
|
|
3
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
4
|
+
}
|
|
5
|
+
|
|
2
6
|
class BaseError extends Error {
|
|
3
7
|
name = "StacksError";
|
|
8
|
+
#code;
|
|
4
9
|
shortMessage;
|
|
5
10
|
details;
|
|
6
11
|
constructor(shortMessage, options) {
|
|
@@ -10,12 +15,21 @@ class BaseError extends Error {
|
|
|
10
15
|
${options.details}` : ""
|
|
11
16
|
].join("");
|
|
12
17
|
super(message, { cause: options?.cause });
|
|
18
|
+
if (options?.code !== undefined)
|
|
19
|
+
this.#code = options.code;
|
|
13
20
|
this.shortMessage = shortMessage;
|
|
14
21
|
this.details = options?.details;
|
|
15
22
|
}
|
|
23
|
+
get code() {
|
|
24
|
+
return this.#code ?? codeFromName(this.name);
|
|
25
|
+
}
|
|
26
|
+
set code(value) {
|
|
27
|
+
this.#code = value;
|
|
28
|
+
}
|
|
16
29
|
toJSON() {
|
|
17
30
|
return {
|
|
18
31
|
name: this.name,
|
|
32
|
+
code: this.code,
|
|
19
33
|
message: this.message,
|
|
20
34
|
shortMessage: this.shortMessage,
|
|
21
35
|
details: this.details,
|
|
@@ -26,5 +40,5 @@ ${options.details}` : ""
|
|
|
26
40
|
|
|
27
41
|
export { BaseError };
|
|
28
42
|
|
|
29
|
-
//# debugId=
|
|
30
|
-
//# sourceMappingURL=stacks-
|
|
43
|
+
//# debugId=EE4BB444CE3D1BB664756E2164756E21
|
|
44
|
+
//# sourceMappingURL=stacks-4hs8r4q2.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/base.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Derive a stable machine-readable code from an error's `name` field:\n * `HttpRequestError` becomes `HTTP_REQUEST_ERROR`. `name` is a string\n * literal each class sets, so the code survives a bundler that mangles\n * class names. Branch on `code` instead of parsing `message`, which is\n * free to change.\n */\nfunction codeFromName(name: string): string {\n\treturn name\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1_$2\")\n\t\t.toUpperCase();\n}\n\nexport class BaseError extends Error {\n\toverride name = \"StacksError\";\n\t#code?: string;\n\tshortMessage: string;\n\tdetails?: string;\n\n\tconstructor(\n\t\tshortMessage: string,\n\t\toptions?: { cause?: Error; details?: string; code?: string },\n\t) {\n\t\tconst message = [\n\t\t\tshortMessage,\n\t\t\toptions?.details ? `\\n${options.details}` : \"\",\n\t\t].join(\"\");\n\n\t\tsuper(message, { cause: options?.cause });\n\t\tif (options?.code !== undefined) this.#code = options.code;\n\t\tthis.shortMessage = shortMessage;\n\t\tthis.details = options?.details;\n\t}\n\n\t/**\n\t * Stable identifier for programmatic handling; survives message\n\t * rewording and minification. An explicit `code` option wins, else it\n\t * is derived from `name` (`TimeoutError` gives `TIMEOUT_ERROR`).\n\t */\n\tget code(): string {\n\t\treturn this.#code ?? codeFromName(this.name);\n\t}\n\n\tset code(value: string) {\n\t\tthis.#code = value;\n\t}\n\n\ttoJSON(): {\n\t\tname: string;\n\t\tcode: string;\n\t\tmessage: string;\n\t\tshortMessage: string;\n\t\tdetails: string | undefined;\n\t\tcause: string | undefined;\n\t} {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tshortMessage: this.shortMessage,\n\t\t\tdetails: this.details,\n\t\t\tcause: this.cause instanceof Error ? this.cause.message : undefined,\n\t\t};\n\t}\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAOA,SAAS,YAAY,CAAC,MAAsB;AAAA,EAC3C,OAAO,KACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,yBAAyB,OAAO,EACxC,YAAY;AAAA;AAAA;AAGR,MAAM,kBAAkB,MAAM;AAAA,EAC3B,OAAO;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EAEA,WAAW,CACV,cACA,SACC;AAAA,IACD,MAAM,UAAU;AAAA,MACf;AAAA,MACA,SAAS,UAAU;AAAA,EAAK,QAAQ,YAAY;AAAA,IAC7C,EAAE,KAAK,EAAE;AAAA,IAET,MAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AAAA,IACxC,IAAI,SAAS,SAAS;AAAA,MAAW,KAAK,QAAQ,QAAQ;AAAA,IACtD,KAAK,eAAe;AAAA,IACpB,KAAK,UAAU,SAAS;AAAA;AAAA,MAQrB,IAAI,GAAW;AAAA,IAClB,OAAO,KAAK,SAAS,aAAa,KAAK,IAAI;AAAA;AAAA,MAGxC,IAAI,CAAC,OAAe;AAAA,IACvB,KAAK,QAAQ;AAAA;AAAA,EAGd,MAAM,GAOJ;AAAA,IACD,OAAO;AAAA,MACN,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,cAAc,KAAK;AAAA,MACnB,SAAS,KAAK;AAAA,MACd,OAAO,KAAK,iBAAiB,QAAQ,KAAK,MAAM,UAAU;AAAA,IAC3D;AAAA;AAEF;",
|
|
8
|
+
"debugId": "EE4BB444CE3D1BB664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
readCV,
|
|
5
5
|
readLPString,
|
|
6
6
|
serializeCVBytes
|
|
7
|
-
} from "./stacks-
|
|
7
|
+
} from "./stacks-69nq48jp.js";
|
|
8
8
|
import {
|
|
9
9
|
parseContractId
|
|
10
|
-
} from "./stacks-
|
|
10
|
+
} from "./stacks-4d7c3x27.js";
|
|
11
11
|
import {
|
|
12
12
|
asciiToBytes,
|
|
13
13
|
bytesToAscii,
|
|
@@ -757,4 +757,4 @@ function postConditionToHex(pc) {
|
|
|
757
757
|
export { AuthType, PayloadType, ClarityVersion, AnchorMode, PostConditionModeWire, AddressHashMode, PubKeyEncoding, FungibleConditionCode, NonFungibleConditionCode, PoxConditionCode, PostConditionPrincipalId, AssetType, AuthFieldType, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, COINBASE_BYTES_LENGTH, VRF_PROOF_BYTES_LENGTH, MICROBLOCK_HEADER_BYTES_LENGTH, TenureChangeCause, serializePostConditionWire, serializePayload, clearTxCache, serializeTransaction, serializeTransactionHex, deserializePostConditionWire, deserializeTransaction, parsePostConditionAmount, convertPostCondition, wireToPostCondition, fromHex, postConditionToHex };
|
|
758
758
|
|
|
759
759
|
//# debugId=0727B877F1BE3A9864756E2164756E21
|
|
760
|
-
//# sourceMappingURL=stacks-
|
|
760
|
+
//# sourceMappingURL=stacks-51ybf135.js.map
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseError
|
|
3
|
+
} from "./stacks-4hs8r4q2.js";
|
|
4
|
+
import {
|
|
5
|
+
isClarityName,
|
|
6
|
+
parsePrincipal
|
|
7
|
+
} from "./stacks-4d7c3x27.js";
|
|
8
|
+
import {
|
|
9
|
+
asciiToBytes,
|
|
10
|
+
bigIntToBytes,
|
|
11
|
+
bytesToAscii,
|
|
12
|
+
bytesToHex,
|
|
13
|
+
bytesToTwosBigInt,
|
|
14
|
+
bytesToUtf8,
|
|
15
|
+
c32address,
|
|
16
|
+
c32addressDecode,
|
|
17
|
+
concatBytes,
|
|
18
|
+
hexToBytes,
|
|
19
|
+
intToBigInt,
|
|
20
|
+
intToHex,
|
|
21
|
+
toTwos,
|
|
22
|
+
utf8ToBytes,
|
|
23
|
+
without0x,
|
|
24
|
+
writeUInt32BE
|
|
25
|
+
} from "./stacks-qs5fzts5.js";
|
|
26
|
+
|
|
1
27
|
// src/clarity/types.ts
|
|
2
28
|
var ClarityWireType = {
|
|
3
29
|
int: 0,
|
|
@@ -82,7 +108,7 @@ function serializeCVBytes(value) {
|
|
|
82
108
|
return withTypeId(value.type, concatBytes(...parts));
|
|
83
109
|
}
|
|
84
110
|
case "tuple": {
|
|
85
|
-
const keys = Object.keys(value.value).sort((a, b) => a
|
|
111
|
+
const keys = Object.keys(value.value).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
86
112
|
const parts = [writeUInt32BE(keys.length)];
|
|
87
113
|
for (const key of keys) {
|
|
88
114
|
parts.push(serializeLPString(key));
|
|
@@ -106,6 +132,59 @@ function serializeCV(value) {
|
|
|
106
132
|
return bytesToHex(serializeCVBytes(value));
|
|
107
133
|
}
|
|
108
134
|
|
|
135
|
+
// src/errors/transaction.ts
|
|
136
|
+
class TransactionError extends BaseError {
|
|
137
|
+
name = "TransactionError";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
class BroadcastError extends BaseError {
|
|
141
|
+
name = "BroadcastError";
|
|
142
|
+
txid;
|
|
143
|
+
reason;
|
|
144
|
+
reasonData;
|
|
145
|
+
constructor(message, options) {
|
|
146
|
+
super(message, options);
|
|
147
|
+
this.txid = options?.txid;
|
|
148
|
+
this.reason = options?.reason;
|
|
149
|
+
this.reasonData = options?.reasonData;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
class TransactionAbortedError extends BaseError {
|
|
154
|
+
name = "TransactionAbortedError";
|
|
155
|
+
receipt;
|
|
156
|
+
constructor(message, options) {
|
|
157
|
+
super(message, options);
|
|
158
|
+
this.receipt = options.receipt;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
class TransactionDroppedError extends BaseError {
|
|
163
|
+
name = "TransactionDroppedError";
|
|
164
|
+
txid;
|
|
165
|
+
constructor(message, options) {
|
|
166
|
+
super(message, options);
|
|
167
|
+
this.txid = options.txid;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
class WaitForTransactionTimeoutError extends BaseError {
|
|
172
|
+
name = "WaitForTransactionTimeoutError";
|
|
173
|
+
txid;
|
|
174
|
+
constructor(message, options) {
|
|
175
|
+
super(message, options);
|
|
176
|
+
this.txid = options.txid;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
class SerializationError extends BaseError {
|
|
181
|
+
name = "SerializationError";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
class SigningError extends BaseError {
|
|
185
|
+
name = "SigningError";
|
|
186
|
+
}
|
|
187
|
+
|
|
109
188
|
// src/utils/bytes-reader.ts
|
|
110
189
|
class BytesReader {
|
|
111
190
|
data;
|
|
@@ -113,23 +192,32 @@ class BytesReader {
|
|
|
113
192
|
constructor(data) {
|
|
114
193
|
this.data = data;
|
|
115
194
|
}
|
|
195
|
+
remaining() {
|
|
196
|
+
return this.data.length - this.offset;
|
|
197
|
+
}
|
|
198
|
+
ensure(length) {
|
|
199
|
+
if (this.offset + length > this.data.length) {
|
|
200
|
+
throw new SerializationError(`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
116
203
|
readUInt8() {
|
|
204
|
+
this.ensure(1);
|
|
117
205
|
return this.data[this.offset++];
|
|
118
206
|
}
|
|
119
207
|
readUInt16BE() {
|
|
208
|
+
this.ensure(2);
|
|
120
209
|
const val = (this.data[this.offset] << 8 | this.data[this.offset + 1]) >>> 0;
|
|
121
210
|
this.offset += 2;
|
|
122
211
|
return val;
|
|
123
212
|
}
|
|
124
213
|
readUInt32BE() {
|
|
214
|
+
this.ensure(4);
|
|
125
215
|
const val = (this.data[this.offset] << 24 | this.data[this.offset + 1] << 16 | this.data[this.offset + 2] << 8 | this.data[this.offset + 3]) >>> 0;
|
|
126
216
|
this.offset += 4;
|
|
127
217
|
return val;
|
|
128
218
|
}
|
|
129
219
|
readBytes(length) {
|
|
130
|
-
|
|
131
|
-
throw new Error(`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`);
|
|
132
|
-
}
|
|
220
|
+
this.ensure(length);
|
|
133
221
|
const slice = this.data.slice(this.offset, this.offset + length);
|
|
134
222
|
this.offset += length;
|
|
135
223
|
return slice;
|
|
@@ -153,7 +241,18 @@ function readLPString(reader, prefixBytes = 1) {
|
|
|
153
241
|
}
|
|
154
242
|
return bytesToUtf8(reader.readBytes(length));
|
|
155
243
|
}
|
|
156
|
-
|
|
244
|
+
var MAX_CV_DEPTH = 64;
|
|
245
|
+
var MIN_LIST_ITEM_BYTES = 1;
|
|
246
|
+
var MIN_TUPLE_ENTRY_BYTES = 2;
|
|
247
|
+
function checkCount(reader, count, minBytes) {
|
|
248
|
+
if (count * minBytes > reader.remaining()) {
|
|
249
|
+
throw new SerializationError(`Clarity value declares ${count} elements but only ${reader.remaining()} bytes remain`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function readCV(reader, depth = 0) {
|
|
253
|
+
if (depth > MAX_CV_DEPTH) {
|
|
254
|
+
throw new SerializationError(`Clarity value nests deeper than ${MAX_CV_DEPTH} levels`);
|
|
255
|
+
}
|
|
157
256
|
const typeByte = reader.readUInt8();
|
|
158
257
|
const type = clarityTypeFromByte(typeByte);
|
|
159
258
|
switch (type) {
|
|
@@ -172,11 +271,11 @@ function readCV(reader) {
|
|
|
172
271
|
case "none":
|
|
173
272
|
return noneCV();
|
|
174
273
|
case "some":
|
|
175
|
-
return someCV(readCV(reader));
|
|
274
|
+
return someCV(readCV(reader, depth + 1));
|
|
176
275
|
case "ok":
|
|
177
|
-
return responseOkCV(readCV(reader));
|
|
276
|
+
return responseOkCV(readCV(reader, depth + 1));
|
|
178
277
|
case "err":
|
|
179
|
-
return responseErrorCV(readCV(reader));
|
|
278
|
+
return responseErrorCV(readCV(reader, depth + 1));
|
|
180
279
|
case "address":
|
|
181
280
|
return standardPrincipalCV(readAddress(reader));
|
|
182
281
|
case "contract": {
|
|
@@ -186,18 +285,20 @@ function readCV(reader) {
|
|
|
186
285
|
}
|
|
187
286
|
case "list": {
|
|
188
287
|
const len = reader.readUInt32BE();
|
|
288
|
+
checkCount(reader, len, MIN_LIST_ITEM_BYTES);
|
|
189
289
|
const items = [];
|
|
190
290
|
for (let i = 0;i < len; i++) {
|
|
191
|
-
items.push(readCV(reader));
|
|
291
|
+
items.push(readCV(reader, depth + 1));
|
|
192
292
|
}
|
|
193
293
|
return listCV(items);
|
|
194
294
|
}
|
|
195
295
|
case "tuple": {
|
|
196
296
|
const len = reader.readUInt32BE();
|
|
297
|
+
checkCount(reader, len, MIN_TUPLE_ENTRY_BYTES);
|
|
197
298
|
const data = {};
|
|
198
299
|
for (let i = 0;i < len; i++) {
|
|
199
300
|
const key = readLPString(reader);
|
|
200
|
-
data[key] = readCV(reader);
|
|
301
|
+
data[key] = readCV(reader, depth + 1);
|
|
201
302
|
}
|
|
202
303
|
return tupleCV(data);
|
|
203
304
|
}
|
|
@@ -210,7 +311,7 @@ function readCV(reader) {
|
|
|
210
311
|
return stringUtf8CV(bytesToUtf8(reader.readBytes(len)));
|
|
211
312
|
}
|
|
212
313
|
default:
|
|
213
|
-
throw new
|
|
314
|
+
throw new SerializationError(`Cannot deserialize unknown clarity type: ${type}`);
|
|
214
315
|
}
|
|
215
316
|
}
|
|
216
317
|
function deserializeCVBytes(input) {
|
|
@@ -303,10 +404,10 @@ var Cl = {
|
|
|
303
404
|
uint: uintCV,
|
|
304
405
|
bool: boolCV,
|
|
305
406
|
principal(address) {
|
|
306
|
-
const
|
|
307
|
-
if (!
|
|
308
|
-
throw new Error(
|
|
309
|
-
return
|
|
407
|
+
const parsed = parsePrincipal(address);
|
|
408
|
+
if (!parsed)
|
|
409
|
+
throw new Error(`Invalid principal: ${address}`);
|
|
410
|
+
return parsed.contractName ? contractPrincipalCV(parsed.address, parsed.contractName) : standardPrincipalCV(parsed.address);
|
|
310
411
|
},
|
|
311
412
|
address(address) {
|
|
312
413
|
return Cl.principal(address);
|
|
@@ -331,5 +432,7 @@ var Cl = {
|
|
|
331
432
|
deserialize: deserializeCVBytes
|
|
332
433
|
};
|
|
333
434
|
|
|
334
|
-
|
|
335
|
-
|
|
435
|
+
export { ClarityWireType, clarityTypeFromByte, serializeCVBytes, serializeCV, TransactionError, BroadcastError, TransactionAbortedError, TransactionDroppedError, WaitForTransactionTimeoutError, SerializationError, SigningError, BytesReader, intCV, uintCV, trueCV, falseCV, boolCV, bufferCV, standardPrincipalCV, contractPrincipalCV, noneCV, someCV, responseOkCV, responseErrorCV, listCV, tupleCV, stringAsciiCV, stringUtf8CV, Cl, readAddress, readLPString, readCV, deserializeCVBytes, deserializeCV };
|
|
436
|
+
|
|
437
|
+
//# debugId=1F993877333185EB64756E2164756E21
|
|
438
|
+
//# sourceMappingURL=stacks-69nq48jp.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/clarity/types.ts", "../src/clarity/serialize.ts", "../src/errors/transaction.ts", "../src/utils/bytes-reader.ts", "../src/clarity/deserialize.ts", "../src/clarity/values.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export type ClarityType =\n\t| \"int\"\n\t| \"uint\"\n\t| \"buffer\"\n\t| \"true\"\n\t| \"false\"\n\t| \"address\"\n\t| \"contract\"\n\t| \"ok\"\n\t| \"err\"\n\t| \"none\"\n\t| \"some\"\n\t| \"list\"\n\t| \"tuple\"\n\t| \"ascii\"\n\t| \"utf8\";\n\n/** Wire type IDs matching the Stacks binary format (SIP-005) */\nexport const ClarityWireType = {\n\tint: 0x00,\n\tuint: 0x01,\n\tbuffer: 0x02,\n\ttrue: 0x03,\n\tfalse: 0x04,\n\taddress: 0x05,\n\tcontract: 0x06,\n\tok: 0x07,\n\terr: 0x08,\n\tnone: 0x09,\n\tsome: 0x0a,\n\tlist: 0x0b,\n\ttuple: 0x0c,\n\tascii: 0x0d,\n\tutf8: 0x0e,\n} as const satisfies Record<ClarityType, number>;\n\n/** Reverse lookup: wire byte → ClarityType string */\nconst wireTypeToClarity = Object.fromEntries(\n\tObject.entries(ClarityWireType).map(([k, v]) => [v, k]),\n) as Record<number, ClarityType>;\n\nexport function clarityTypeFromByte(byte: number): ClarityType {\n\tconst type = wireTypeToClarity[byte];\n\tif (!type) throw new Error(`Unknown clarity wire type: ${byte}`);\n\treturn type;\n}\n\n// CV types\n\nexport type IntCV = { readonly type: \"int\"; readonly value: bigint };\nexport type UIntCV = { readonly type: \"uint\"; readonly value: bigint };\nexport type BooleanCV = TrueCV | FalseCV;\nexport type TrueCV = { readonly type: \"true\" };\nexport type FalseCV = { readonly type: \"false\" };\nexport type BufferCV = { readonly type: \"buffer\"; readonly value: string }; // hex\nexport type NoneCV = { readonly type: \"none\" };\nexport type SomeCV = {\n\treadonly type: \"some\";\n\treadonly value: ClarityValue;\n};\nexport type OptionalCV = NoneCV | SomeCV;\nexport type ResponseOkCV = {\n\treadonly type: \"ok\";\n\treadonly value: ClarityValue;\n};\nexport type ResponseErrorCV = {\n\treadonly type: \"err\";\n\treadonly value: ClarityValue;\n};\nexport type ResponseCV = ResponseOkCV | ResponseErrorCV;\nexport type StandardPrincipalCV = {\n\treadonly type: \"address\";\n\treadonly value: string;\n};\nexport type ContractPrincipalCV = {\n\treadonly type: \"contract\";\n\treadonly value: string; // \"address.name\"\n};\nexport type PrincipalCV = StandardPrincipalCV | ContractPrincipalCV;\nexport type ListCV = {\n\ttype: \"list\";\n\tvalue: ClarityValue[];\n};\nexport type TupleData = {\n\t[key: string]: ClarityValue;\n};\nexport type TupleCV = {\n\ttype: \"tuple\";\n\tvalue: TupleData;\n};\nexport type StringAsciiCV = {\n\treadonly type: \"ascii\";\n\treadonly value: string;\n};\nexport type StringUtf8CV = {\n\treadonly type: \"utf8\";\n\treadonly value: string;\n};\n\nexport type ClarityValue =\n\t| IntCV\n\t| UIntCV\n\t| BooleanCV\n\t| BufferCV\n\t| NoneCV\n\t| SomeCV\n\t| ResponseOkCV\n\t| ResponseErrorCV\n\t| StandardPrincipalCV\n\t| ContractPrincipalCV\n\t| ListCV\n\t| TupleCV\n\t| StringAsciiCV\n\t| StringUtf8CV;\n",
|
|
6
|
+
"import { c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\tasciiToBytes,\n\tbigIntToBytes,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n\ttoTwos,\n\tutf8ToBytes,\n\twriteUInt32BE,\n} from \"../utils/encoding.ts\";\nimport {\n\ttype ClarityType,\n\ttype ClarityValue,\n\tClarityWireType,\n} from \"./types.ts\";\n\nconst CLARITY_INT_SIZE = 128n;\nconst CLARITY_INT_BYTE_SIZE = 16;\n\nfunction typeIdByte(type: ClarityType): number {\n\treturn ClarityWireType[type];\n}\n\nfunction withTypeId(type: ClarityType, bytes: Uint8Array): Uint8Array {\n\treturn concatBytes(new Uint8Array([typeIdByte(type)]), bytes);\n}\n\nfunction serializeAddress(c32Address: string): Uint8Array {\n\tconst [version, hash160] = c32addressDecode(c32Address);\n\treturn concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n\tconst content = utf8ToBytes(str);\n\tconst lengthPrefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n\treturn concatBytes(lengthPrefix, content);\n}\n\nexport function serializeCVBytes(value: ClarityValue): Uint8Array {\n\tswitch (value.type) {\n\t\tcase \"true\":\n\t\tcase \"false\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"int\": {\n\t\t\tconst bytes = bigIntToBytes(\n\t\t\t\ttoTwos(BigInt(value.value), CLARITY_INT_SIZE),\n\t\t\t\tCLARITY_INT_BYTE_SIZE,\n\t\t\t);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"uint\": {\n\t\t\tconst bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"buffer\": {\n\t\t\tconst bufBytes = hexToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(bufBytes.length), bufBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"some\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"ok\":\n\t\tcase \"err\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"address\":\n\t\t\treturn withTypeId(value.type, serializeAddress(value.value));\n\n\t\tcase \"contract\": {\n\t\t\tconst [addr, name] = value.value.split(\".\");\n\t\t\tif (!addr || !name)\n\t\t\t\tthrow new Error(`Invalid contract principal: ${value.value}`);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(serializeAddress(addr), serializeLPString(name)),\n\t\t\t);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(value.value.length)];\n\t\t\tfor (const item of value.value) {\n\t\t\t\tparts.push(serializeCVBytes(item));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\t// Clarity orders tuple fields as a BTreeMap over the raw name bytes.\n\t\t\t// Code-unit comparison equals byte order for the ASCII name grammar;\n\t\t\t// localeCompare does not, and would change the SIP-018 hash.\n\t\t\tconst keys = Object.keys(value.value).sort((a, b) =>\n\t\t\t\ta < b ? -1 : a > b ? 1 : 0,\n\t\t\t);\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(keys.length)];\n\t\t\tfor (const key of keys) {\n\t\t\t\tparts.push(serializeLPString(key));\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tparts.push(serializeCVBytes(value.value[key]!));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst strBytes = asciiToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst strBytes = utf8ToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Cannot serialize unknown clarity type\");\n\t}\n}\n\nexport function serializeCV(value: ClarityValue): string {\n\treturn bytesToHex(serializeCVBytes(value));\n}\n",
|
|
7
|
+
"import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n\toverride name = \"TransactionError\";\n}\n\n/**\n * Rejection reasons a stacks-node returns from `POST /v2/transactions`.\n * Wire strings from stacks-core `MemPoolRejection::into_json`\n * (`stackslib/src/chainstate/stacks/db/blocks.rs`).\n */\nexport type TxRejectionReason =\n\t| \"Serialization\"\n\t| \"Deserialization\"\n\t| \"SignatureValidation\"\n\t| \"BadNonce\"\n\t| \"ConflictingNonceInMempool\"\n\t| \"TooMuchChaining\"\n\t| \"FeeTooLow\"\n\t| \"NotEnoughFunds\"\n\t| \"NoSuchContract\"\n\t| \"NoSuchPublicFunction\"\n\t| \"BadFunctionArgument\"\n\t| \"ContractAlreadyExists\"\n\t| \"BadTransactionVersion\"\n\t| \"TransferRecipientCannotEqualSender\"\n\t| \"TransferAmountMustBePositive\"\n\t| \"PoisonMicroblocksDoNotConflict\"\n\t| \"PoisonMicroblockHasUnknownPubKeyHash\"\n\t| \"PoisonMicroblockIsInvalid\"\n\t| \"BadAddressVersionByte\"\n\t| \"NoCoinbaseViaMempool\"\n\t| \"NoTenureChangeViaMempool\"\n\t| \"EstimatorError\"\n\t| \"TemporarilyBlacklisted\"\n\t| \"ServerFailureNoSuchChainTip\"\n\t| \"ServerFailureDatabase\"\n\t| \"ServerFailureOther\";\n\nexport class BroadcastError extends BaseError {\n\toverride name = \"BroadcastError\";\n\ttxid?: string;\n\t// `(string & {})` keeps forward-compat with reasons newer nodes may add\n\t// while preserving literal-union completions.\n\treason?: TxRejectionReason | (string & {});\n\t/** Node-provided detail; shape varies per reason (see stacks-core RPC docs). */\n\treasonData?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: {\n\t\t\tcause?: Error;\n\t\t\ttxid?: string;\n\t\t\treason?: string;\n\t\t\treasonData?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.txid = options?.txid;\n\t\tthis.reason = options?.reason;\n\t\tthis.reasonData = options?.reasonData;\n\t}\n}\n\n/** The transaction was mined but its execution aborted (runtime error or failed post-condition). */\nexport class TransactionAbortedError extends BaseError {\n\toverride name = \"TransactionAbortedError\";\n\t/** The abort receipt (status, block info, raw source response). */\n\treceipt: unknown;\n\n\tconstructor(message: string, options: { receipt: unknown; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.receipt = options.receipt;\n\t}\n}\n\n/** The transaction left the mempool without being mined (dropped/replaced). */\nexport class TransactionDroppedError extends BaseError {\n\toverride name = \"TransactionDroppedError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\n/** waitForTransactionReceipt gave up before the tx reached the requested state. */\nexport class WaitForTransactionTimeoutError extends BaseError {\n\toverride name = \"WaitForTransactionTimeoutError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\nexport class SerializationError extends BaseError {\n\toverride name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n\toverride name = \"SigningError\";\n}\n",
|
|
8
|
+
"import { SerializationError } from \"../errors/transaction.ts\";\nimport { bytesToHex } from \"./encoding.ts\";\n\nexport class BytesReader {\n\tprivate data: Uint8Array;\n\tpublic offset = 0;\n\n\tconstructor(data: Uint8Array) {\n\t\tthis.data = data;\n\t}\n\n\t/** Bytes left after the cursor. */\n\tremaining(): number {\n\t\treturn this.data.length - this.offset;\n\t}\n\n\tprivate ensure(length: number): void {\n\t\tif (this.offset + length > this.data.length) {\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treadUInt8(): number {\n\t\tthis.ensure(1);\n\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\treturn this.data[this.offset++]!;\n\t}\n\n\treadUInt16BE(): number {\n\t\tthis.ensure(2);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 8) | this.data[this.offset + 1]!) >>> 0;\n\t\tthis.offset += 2;\n\t\treturn val;\n\t}\n\n\treadUInt32BE(): number {\n\t\tthis.ensure(4);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 24) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 1]! << 16) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 2]! << 8) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\tthis.data[this.offset + 3]!) >>>\n\t\t\t0;\n\t\tthis.offset += 4;\n\t\treturn val;\n\t}\n\n\treadBytes(length: number): Uint8Array {\n\t\tthis.ensure(length);\n\t\tconst slice = this.data.slice(this.offset, this.offset + length);\n\t\tthis.offset += length;\n\t\treturn slice;\n\t}\n\n\treadBigUInt64BE(): bigint {\n\t\tconst hex = bytesToHex(this.readBytes(8));\n\t\treturn hex.length > 0 ? BigInt(`0x${hex}`) : 0n;\n\t}\n}\n",
|
|
9
|
+
"import { SerializationError } from \"../errors/transaction.ts\";\nimport { BytesReader } from \"../utils/bytes-reader.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToAscii,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\tbytesToUtf8,\n\thexToBytes,\n\twithout0x,\n} from \"../utils/encoding.ts\";\nimport { type ClarityValue, clarityTypeFromByte } from \"./types.ts\";\nimport {\n\tbufferCV,\n\tcontractPrincipalCV,\n\tfalseCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstandardPrincipalCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttrueCV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\n\nexport function readAddress(reader: BytesReader): string {\n\tconst version = reader.readUInt8();\n\tconst hash160 = bytesToHex(reader.readBytes(20));\n\treturn c32address(version, hash160);\n}\n\nexport function readLPString(reader: BytesReader, prefixBytes = 1): string {\n\tlet length = 0;\n\tfor (let i = 0; i < prefixBytes; i++) {\n\t\tlength = (length << 8) | reader.readUInt8();\n\t}\n\treturn bytesToUtf8(reader.readBytes(length));\n}\n\n/** Deepest nesting the deserializer follows before refusing the input. Clarity\n * itself caps value nesting far below this, so honest data never hits it;\n * hostile bytes that repeat `some`/`ok`/`list` would otherwise blow the stack. */\nexport const MAX_CV_DEPTH = 64;\n\n/** Every list item and tuple entry costs at least this many bytes on the wire\n * (a type byte, plus a name-length byte for tuple entries), so a declared\n * count that outruns the remaining bytes is corrupt before any allocation. */\nconst MIN_LIST_ITEM_BYTES = 1;\nconst MIN_TUPLE_ENTRY_BYTES = 2;\n\nfunction checkCount(reader: BytesReader, count: number, minBytes: number) {\n\tif (count * minBytes > reader.remaining()) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value declares ${count} elements but only ${reader.remaining()} bytes remain`,\n\t\t);\n\t}\n}\n\nexport function readCV(reader: BytesReader, depth = 0): ClarityValue {\n\tif (depth > MAX_CV_DEPTH) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value nests deeper than ${MAX_CV_DEPTH} levels`,\n\t\t);\n\t}\n\tconst typeByte = reader.readUInt8();\n\tconst type = clarityTypeFromByte(typeByte);\n\n\tswitch (type) {\n\t\tcase \"int\":\n\t\t\treturn intCV(bytesToTwosBigInt(reader.readBytes(16)));\n\n\t\tcase \"uint\":\n\t\t\treturn uintCV(reader.readBytes(16));\n\n\t\tcase \"true\":\n\t\t\treturn trueCV();\n\n\t\tcase \"false\":\n\t\t\treturn falseCV();\n\n\t\tcase \"buffer\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn bufferCV(reader.readBytes(len));\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn noneCV();\n\n\t\tcase \"some\":\n\t\t\treturn someCV(readCV(reader, depth + 1));\n\n\t\tcase \"ok\":\n\t\t\treturn responseOkCV(readCV(reader, depth + 1));\n\n\t\tcase \"err\":\n\t\t\treturn responseErrorCV(readCV(reader, depth + 1));\n\n\t\tcase \"address\":\n\t\t\treturn standardPrincipalCV(readAddress(reader));\n\n\t\tcase \"contract\": {\n\t\t\tconst addr = readAddress(reader);\n\t\t\tconst name = readLPString(reader);\n\t\t\treturn contractPrincipalCV(addr, name);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_LIST_ITEM_BYTES);\n\t\t\tconst items: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\titems.push(readCV(reader, depth + 1));\n\t\t\t}\n\t\t\treturn listCV(items);\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_TUPLE_ENTRY_BYTES);\n\t\t\tconst data: Record<string, ClarityValue> = {};\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tconst key = readLPString(reader);\n\t\t\t\tdata[key] = readCV(reader, depth + 1);\n\t\t\t}\n\t\t\treturn tupleCV(data);\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringAsciiCV(bytesToAscii(reader.readBytes(len)));\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringUtf8CV(bytesToUtf8(reader.readBytes(len)));\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Cannot deserialize unknown clarity type: ${type}`,\n\t\t\t);\n\t}\n}\n\nexport function deserializeCVBytes<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\treturn readCV(new BytesReader(bytes)) as T;\n}\n\nexport function deserializeCV<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\treturn deserializeCVBytes(input);\n}\n",
|
|
10
|
+
"import { isClarityName, parsePrincipal } from \"../utils/address.ts\";\nimport { c32address, c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\ttype IntegerType,\n\tasciiToBytes,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\thexToBytes,\n\tintToBigInt,\n\tutf8ToBytes,\n} from \"../utils/encoding.ts\";\nimport { deserializeCVBytes } from \"./deserialize.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type {\n\tBooleanCV,\n\tBufferCV,\n\tClarityValue,\n\tContractPrincipalCV,\n\tFalseCV,\n\tIntCV,\n\tListCV,\n\tNoneCV,\n\tResponseErrorCV,\n\tResponseOkCV,\n\tSomeCV,\n\tStandardPrincipalCV,\n\tStringAsciiCV,\n\tStringUtf8CV,\n\tTrueCV,\n\tTupleCV,\n\tTupleData,\n\tUIntCV,\n} from \"./types.ts\";\n\nconst MAX_U128 = BigInt(\"0xffffffffffffffffffffffffffffffff\");\nconst MIN_I128 = BigInt(\"-170141183460469231731687303715884105728\");\nconst MAX_I128 = BigInt(\"0x7fffffffffffffffffffffffffffffff\");\n\n// Primitives\n\nexport function intCV(value: IntegerType): IntCV {\n\tlet v: IntegerType = value;\n\tif (typeof v === \"string\" && v.toLowerCase().startsWith(\"0x\")) {\n\t\tv = bytesToTwosBigInt(hexToBytes(v));\n\t}\n\tif (v instanceof Uint8Array) v = bytesToTwosBigInt(v);\n\tconst n = intToBigInt(v);\n\tif (n > MAX_I128) throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);\n\tif (n < MIN_I128) throw new RangeError(`Int below min i128: ${MIN_I128}`);\n\treturn { type: \"int\", value: n };\n}\n\nexport function uintCV(value: IntegerType): UIntCV {\n\tconst n = intToBigInt(value);\n\tif (n < 0n)\n\t\tthrow new RangeError(\"Cannot construct unsigned int from negative value\");\n\tif (n > MAX_U128) throw new RangeError(`UInt exceeds max u128: ${MAX_U128}`);\n\treturn { type: \"uint\", value: n };\n}\n\nexport const trueCV = (): TrueCV => ({ type: \"true\" });\nexport const falseCV = (): FalseCV => ({ type: \"false\" });\nexport const boolCV = (v: boolean): BooleanCV => (v ? trueCV() : falseCV());\n\nexport function bufferCV(buffer: Uint8Array): BufferCV {\n\tif (buffer.byteLength > 1_048_576) {\n\t\tthrow new Error(\"Buffer exceeds max size of 1MB\");\n\t}\n\treturn { type: \"buffer\", value: bytesToHex(buffer) };\n}\n\nexport function standardPrincipalCV(address: string): StandardPrincipalCV {\n\t// Validate by decoding\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\treturn { type: \"address\", value: normalized };\n}\n\nexport function contractPrincipalCV(\n\taddress: string,\n\tcontractName: string,\n): ContractPrincipalCV {\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\tif (utf8ToBytes(contractName).byteLength >= 128) {\n\t\tthrow new Error(\"Contract name must be less than 128 bytes\");\n\t}\n\treturn { type: \"contract\", value: `${normalized}.${contractName}` };\n}\n\nexport function noneCV(): NoneCV {\n\treturn { type: \"none\" };\n}\n\nexport function someCV(value: ClarityValue): SomeCV {\n\treturn { type: \"some\", value };\n}\n\nexport function responseOkCV(value: ClarityValue): ResponseOkCV {\n\treturn { type: \"ok\", value };\n}\n\nexport function responseErrorCV(value: ClarityValue): ResponseErrorCV {\n\treturn { type: \"err\", value };\n}\n\nexport function listCV(values: ClarityValue[]): ListCV {\n\treturn { type: \"list\", value: values };\n}\n\nexport function tupleCV(data: TupleData): TupleCV {\n\tfor (const key in data) {\n\t\tif (!isClarityName(key)) {\n\t\t\tthrow new Error(`\"${key}\" is not a valid Clarity name`);\n\t\t}\n\t}\n\treturn { type: \"tuple\", value: data };\n}\n\nexport function stringAsciiCV(value: string): StringAsciiCV {\n\treturn { type: \"ascii\", value };\n}\n\nexport function stringUtf8CV(value: string): StringUtf8CV {\n\treturn { type: \"utf8\", value };\n}\n\n// Cl namespace — clean API\n\nexport const Cl: {\n\treadonly int: (value: IntegerType) => IntCV;\n\treadonly uint: (value: IntegerType) => UIntCV;\n\treadonly bool: (v: boolean) => BooleanCV;\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\treadonly contractPrincipal: (\n\t\taddress: string,\n\t\tcontractName: string,\n\t) => ContractPrincipalCV;\n\treadonly standardPrincipal: (address: string) => StandardPrincipalCV;\n\treadonly buffer: (buffer: Uint8Array) => BufferCV;\n\treadonly bufferFromHex: (hex: string) => BufferCV;\n\treadonly bufferFromAscii: (ascii: string) => BufferCV;\n\treadonly bufferFromUtf8: (utf8: string) => BufferCV;\n\treadonly none: () => NoneCV;\n\treadonly some: (value: ClarityValue) => SomeCV;\n\treadonly ok: (value: ClarityValue) => ResponseOkCV;\n\treadonly error: (value: ClarityValue) => ResponseErrorCV;\n\treadonly list: (values: ClarityValue[]) => ListCV;\n\treadonly tuple: (data: TupleData) => TupleCV;\n\treadonly stringAscii: (value: string) => StringAsciiCV;\n\treadonly stringUtf8: (value: string) => StringUtf8CV;\n\tserialize(value: ClarityValue): string;\n\treadonly deserialize: (bytes: Uint8Array) => ClarityValue;\n} = {\n\tint: intCV,\n\tuint: uintCV,\n\tbool: boolCV,\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\tconst parsed = parsePrincipal(address);\n\t\tif (!parsed) throw new Error(`Invalid principal: ${address}`);\n\t\treturn parsed.contractName\n\t\t\t? contractPrincipalCV(parsed.address, parsed.contractName)\n\t\t\t: standardPrincipalCV(parsed.address);\n\t},\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\treturn Cl.principal(address);\n\t},\n\tcontractPrincipal: contractPrincipalCV,\n\tstandardPrincipal: standardPrincipalCV,\n\tbuffer: bufferCV,\n\tbufferFromHex: (hex: string): BufferCV => bufferCV(hexToBytes(hex)),\n\tbufferFromAscii: (ascii: string): BufferCV => bufferCV(asciiToBytes(ascii)),\n\tbufferFromUtf8: (utf8: string): BufferCV => bufferCV(utf8ToBytes(utf8)),\n\tnone: noneCV,\n\tsome: someCV,\n\tok: responseOkCV,\n\terror: responseErrorCV,\n\tlist: listCV,\n\ttuple: tupleCV,\n\tstringAscii: stringAsciiCV,\n\tstringUtf8: stringUtf8CV,\n\tserialize(value: ClarityValue): string {\n\t\treturn bytesToHex(serializeCVBytes(value));\n\t},\n\tdeserialize: deserializeCVBytes,\n} as const;\n"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,kBAAkB;AAAA,EAC9B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AACP;AAGA,IAAM,oBAAoB,OAAO,YAChC,OAAO,QAAQ,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CACvD;AAEO,SAAS,mBAAmB,CAAC,MAA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