@secondlayer/stacks 4.2.0 → 4.3.0

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.
Files changed (62) hide show
  1. package/dist/shared/stacks-03vfm21t.cjs +222 -0
  2. package/dist/shared/stacks-03vfm21t.cjs.map +12 -0
  3. package/dist/shared/stacks-0eatsx6d.cjs +25 -0
  4. package/dist/shared/stacks-0eatsx6d.cjs.map +10 -0
  5. package/dist/shared/stacks-1arrcd11.js.map +2 -2
  6. package/dist/shared/{stacks-mrk6tkkh.cjs → stacks-3mt2q2na.cjs} +26 -2
  7. package/dist/shared/{stacks-mrk6tkkh.cjs.map → stacks-3mt2q2na.cjs.map} +1 -1
  8. package/dist/shared/{stacks-rndfw2vh.js → stacks-7wkf2rph.js} +3 -26
  9. package/dist/shared/{stacks-rndfw2vh.js.map → stacks-7wkf2rph.js.map} +3 -5
  10. package/dist/shared/stacks-8pfdscq6.js +52 -0
  11. package/dist/shared/stacks-8pfdscq6.js.map +12 -0
  12. package/dist/shared/stacks-e4xn4m7j.js +27 -0
  13. package/dist/shared/stacks-e4xn4m7j.js.map +10 -0
  14. package/dist/shared/stacks-enpj9krt.cjs.map +2 -2
  15. package/dist/shared/{stacks-9qcr921s.cjs → stacks-kem68d80.cjs} +3 -3
  16. package/dist/shared/stacks-kem68d80.cjs.map +10 -0
  17. package/dist/shared/stacks-wdp5yr8n.cjs +39 -0
  18. package/dist/shared/stacks-wdp5yr8n.cjs.map +12 -0
  19. package/dist/shared/{stacks-0nedd34w.cjs → stacks-ycbq8pf7.cjs} +2 -25
  20. package/dist/shared/{stacks-0nedd34w.cjs.map → stacks-ycbq8pf7.cjs.map} +3 -5
  21. package/dist/shared/{stacks-rpqtgpyj.js → stacks-zcpvzbr0.js} +3 -3
  22. package/dist/shared/stacks-zcpvzbr0.js.map +10 -0
  23. package/dist/shared/stacks-ztzygy90.js +237 -0
  24. package/dist/shared/stacks-ztzygy90.js.map +12 -0
  25. package/dist/src/actions/index.js +5 -5
  26. package/dist/src/actions/index.js.map +1 -1
  27. package/dist/src/bitcoin/index.cjs +1 -217
  28. package/dist/src/bitcoin/index.cjs.map +3 -5
  29. package/dist/src/bitcoin/index.js +11 -223
  30. package/dist/src/bitcoin/index.js.map +3 -5
  31. package/dist/src/bns/index.js +1 -1
  32. package/dist/src/clarity/index.d.cts +1 -1
  33. package/dist/src/clarity/index.d.ts +1 -1
  34. package/dist/src/index.js +5 -5
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/postconditions/index.d.cts +3 -2
  37. package/dist/src/postconditions/index.d.ts +3 -2
  38. package/dist/src/postconditions/index.js +1 -1
  39. package/dist/src/pox/index.cjs +1 -24
  40. package/dist/src/pox/index.cjs.map +3 -4
  41. package/dist/src/pox/index.js +8 -25
  42. package/dist/src/pox/index.js.map +3 -4
  43. package/dist/src/pox5/index.cjs +1118 -204
  44. package/dist/src/pox5/index.cjs.map +13 -8
  45. package/dist/src/pox5/index.d.cts +618 -162
  46. package/dist/src/pox5/index.d.ts +618 -162
  47. package/dist/src/pox5/index.js +1136 -208
  48. package/dist/src/pox5/index.js.map +13 -8
  49. package/dist/src/stackingdao/index.js +1 -1
  50. package/dist/src/tools/index.cjs.map +2 -2
  51. package/dist/src/tools/index.js.map +2 -2
  52. package/package.json +4 -3
  53. package/dist/shared/stacks-2evvn48s.js +0 -22
  54. package/dist/shared/stacks-2evvn48s.js.map +0 -10
  55. package/dist/shared/stacks-3kj51c6p.cjs +0 -16
  56. package/dist/shared/stacks-3kj51c6p.cjs.map +0 -10
  57. package/dist/shared/stacks-9qcr921s.cjs.map +0 -10
  58. package/dist/shared/stacks-rdgg7mj3.js +0 -7
  59. package/dist/shared/stacks-rdgg7mj3.js.map +0 -10
  60. package/dist/shared/stacks-rpqtgpyj.js.map +0 -10
  61. package/dist/shared/stacks-wscmfs7q.cjs +0 -5
  62. package/dist/shared/stacks-wscmfs7q.cjs.map +0 -10
@@ -0,0 +1,222 @@
1
+ // src/bitcoin/merkle.ts
2
+ function hashPair(left, right) {
3
+ return doubleSha256(concatBytes(left, right));
4
+ }
5
+ function nextLevel(level) {
6
+ const next = [];
7
+ for (let i = 0;i < level.length; i += 2) {
8
+ const left = level[i];
9
+ if (left === undefined)
10
+ throw new Error("merkle: missing left node");
11
+ const right = level[i + 1] ?? left;
12
+ next.push(hashPair(left, right));
13
+ }
14
+ return next;
15
+ }
16
+ function merkleRoot(txidsInternal) {
17
+ if (txidsInternal.length === 0) {
18
+ throw new Error("merkleRoot: empty tx list");
19
+ }
20
+ let level = txidsInternal.slice();
21
+ while (level.length > 1) {
22
+ level = nextLevel(level);
23
+ }
24
+ const root = level[0];
25
+ if (root === undefined)
26
+ throw new Error("merkleRoot: no root");
27
+ return root;
28
+ }
29
+ function buildMerkleProof(txidsInternal, txIndex) {
30
+ const txCount = txidsInternal.length;
31
+ if (txCount === 0) {
32
+ throw new Error("buildMerkleProof: empty tx list");
33
+ }
34
+ if (txIndex < 0 || txIndex >= txCount) {
35
+ throw new Error(`buildMerkleProof: txIndex ${txIndex} out of range for ${txCount} txs`);
36
+ }
37
+ const siblings = [];
38
+ let index = txIndex;
39
+ let level = txidsInternal.slice();
40
+ while (level.length > 1) {
41
+ const isRight = index % 2 === 1;
42
+ const siblingIndex = isRight ? index - 1 : index + 1;
43
+ const self = level[index];
44
+ if (self === undefined)
45
+ throw new Error("buildMerkleProof: missing node");
46
+ siblings.push(level[siblingIndex] ?? self);
47
+ level = nextLevel(level);
48
+ index = Math.floor(index / 2);
49
+ }
50
+ return { siblings, txIndex, txCount };
51
+ }
52
+ function rootFromProof(leafInternal, proof) {
53
+ let hash = leafInternal;
54
+ let index = proof.txIndex;
55
+ for (const sibling of proof.siblings) {
56
+ hash = index % 2 === 1 ? hashPair(sibling, hash) : hashPair(hash, sibling);
57
+ index = Math.floor(index / 2);
58
+ }
59
+ return hash;
60
+ }
61
+
62
+ // src/bitcoin/proof.ts
63
+ function normalizeTxid(txid) {
64
+ return without0x(txid).toLowerCase();
65
+ }
66
+ function assembleBlockForTx(args) {
67
+ const txIndex = args.txidsDisplay.indexOf(normalizeTxid(args.txid));
68
+ if (txIndex < 0) {
69
+ throw new Error(`tx ${args.txid} not found in block ${args.blockId}`);
70
+ }
71
+ return {
72
+ header: hexToBytes(args.headerHex),
73
+ height: args.height,
74
+ txidsInternal: args.txidsDisplay.map((t) => reverseBytes(hexToBytes(t))),
75
+ txIndex
76
+ };
77
+ }
78
+ async function buildTxProof(source, params) {
79
+ const { txid, vout } = params;
80
+ const want = normalizeTxid(txid);
81
+ const [rawTx, block] = await Promise.all([
82
+ source.getRawTx(txid),
83
+ source.getBlockForTx(txid)
84
+ ]);
85
+ const parsed = parseBitcoinTx(rawTx);
86
+ const gotDisplay = bytesToHex(reverseBytes(parsed.txidInternal));
87
+ if (gotDisplay !== want) {
88
+ throw new Error(`source returned a tx whose id ${gotDisplay} does not match requested ${want}`);
89
+ }
90
+ const atIndex = block.txidsInternal[block.txIndex];
91
+ if (!atIndex || bytesToHex(atIndex) !== bytesToHex(parsed.txidInternal)) {
92
+ throw new Error(`source txIndex ${block.txIndex} does not point at tx ${want}`);
93
+ }
94
+ const merkle = buildMerkleProof(block.txidsInternal, block.txIndex);
95
+ const headerRoot = parseBlockHeader(block.header).merkleRoot;
96
+ const computed = rootFromProof(parsed.txidInternal, merkle);
97
+ if (bytesToHex(computed) !== bytesToHex(headerRoot)) {
98
+ throw new Error("constructed merkle proof does not reconcile with the block header merkle root");
99
+ }
100
+ return {
101
+ rawTx,
102
+ txidInternal: parsed.txidInternal,
103
+ vout,
104
+ merkle,
105
+ header: block.header,
106
+ height: block.height
107
+ };
108
+ }
109
+ function fallbackProofSource(sources) {
110
+ if (sources.length === 0) {
111
+ throw new Error("fallbackProofSource: at least one source is required");
112
+ }
113
+ async function firstSuccess(fn) {
114
+ let lastError;
115
+ for (const source of sources) {
116
+ try {
117
+ return await fn(source);
118
+ } catch (error) {
119
+ lastError = error;
120
+ }
121
+ }
122
+ throw lastError;
123
+ }
124
+ return {
125
+ getRawTx: (txid) => firstSuccess((s) => s.getRawTx(txid)),
126
+ getBlockForTx: (txid) => firstSuccess((s) => s.getBlockForTx(txid))
127
+ };
128
+ }
129
+ function bitcoinRpcSource(config) {
130
+ const doFetch = config.fetch ?? fetch;
131
+ async function rpc(method, rpcParams) {
132
+ const headers = {
133
+ "content-type": "application/json"
134
+ };
135
+ if (config.auth) {
136
+ const basic = typeof config.auth === "string" ? config.auth : btoa(`${config.auth.username}:${config.auth.password}`);
137
+ headers.authorization = `Basic ${basic}`;
138
+ }
139
+ const res = await doFetch(config.url, {
140
+ method: "POST",
141
+ headers,
142
+ body: JSON.stringify({
143
+ jsonrpc: "1.0",
144
+ id: "secondlayer",
145
+ method,
146
+ params: rpcParams
147
+ })
148
+ });
149
+ if (!res.ok) {
150
+ throw new Error(`bitcoin rpc ${method} failed: HTTP ${res.status}`);
151
+ }
152
+ const json = await res.json();
153
+ if (json.error) {
154
+ throw new Error(`bitcoin rpc ${method} error: ${json.error.message}`);
155
+ }
156
+ return json.result;
157
+ }
158
+ return {
159
+ async getRawTx(txid) {
160
+ return hexToBytes(await rpc("getrawtransaction", [txid, false]));
161
+ },
162
+ async getBlockForTx(txid) {
163
+ const tx = await rpc("getrawtransaction", [
164
+ txid,
165
+ true
166
+ ]);
167
+ if (!tx.blockhash) {
168
+ throw new Error(`tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`);
169
+ }
170
+ const block = await rpc("getblock", [
171
+ tx.blockhash,
172
+ 1
173
+ ]);
174
+ const header = await rpc("getblockheader", [tx.blockhash, false]);
175
+ return assembleBlockForTx({
176
+ txid,
177
+ blockId: tx.blockhash,
178
+ headerHex: header,
179
+ height: block.height,
180
+ txidsDisplay: block.tx
181
+ });
182
+ }
183
+ };
184
+ }
185
+ function esploraSource(config) {
186
+ const doFetch = config.fetch ?? fetch;
187
+ const base = config.url.replace(/\/+$/, "");
188
+ async function get(path) {
189
+ const res = await doFetch(`${base}${path}`);
190
+ if (!res.ok) {
191
+ throw new Error(`esplora GET ${path} failed: HTTP ${res.status}`);
192
+ }
193
+ return res;
194
+ }
195
+ return {
196
+ async getRawTx(txid) {
197
+ return hexToBytes((await (await get(`/tx/${txid}/hex`)).text()).trim());
198
+ },
199
+ async getBlockForTx(txid) {
200
+ const status = await (await get(`/tx/${txid}`)).json();
201
+ if (!status.status.confirmed) {
202
+ throw new Error(`tx ${txid} is unconfirmed`);
203
+ }
204
+ const blockHashHex = status.status.block_hash;
205
+ const header = (await (await get(`/block/${blockHashHex}/header`)).text()).trim();
206
+ const txids = await (await get(`/block/${blockHashHex}/txids`)).json();
207
+ return assembleBlockForTx({
208
+ txid,
209
+ blockId: blockHashHex,
210
+ headerHex: header,
211
+ height: status.status.block_height,
212
+ txidsDisplay: txids
213
+ });
214
+ }
215
+ };
216
+ }
217
+
218
+ // src/epochs.ts
219
+ var EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET = 960230;
220
+
221
+ //# debugId=CE288481C610C7EC64756E2164756E21
222
+ //# sourceMappingURL=stacks-03vfm21t.cjs.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/bitcoin/merkle.ts", "../src/bitcoin/proof.ts", "../src/epochs.ts"],
4
+ "sourcesContent": [
5
+ "import { concatBytes } from \"../utils/encoding.ts\";\nimport { doubleSha256 } from \"./serialize.ts\";\n\n/**\n * A Bitcoin merkle inclusion proof, shaped for the SIP-044 `verify-merkle-proof`\n * built-in: `(leaf-hash, root-hash, tx-index, tx-count, sibling-hashes)`.\n *\n * - `siblings` are the sibling node hashes from the leaf up to (excluding) the\n * root, in *internal* byte order — never reversed.\n * - `txCount` (not tree-depth) pins the canonical tree shape; the built-in\n * rejects any proof whose length differs from `ceil(log2(tx-count))`.\n */\nexport interface MerkleProof {\n\tsiblings: Uint8Array[];\n\ttxIndex: number;\n\ttxCount: number;\n}\n\n/** Combine an ordered pair of nodes into their parent hash. */\nfunction hashPair(left: Uint8Array, right: Uint8Array): Uint8Array {\n\treturn doubleSha256(concatBytes(left, right));\n}\n\n/** Collapse one merkle level into the next, duplicating the last node if odd. */\nfunction nextLevel(level: Uint8Array[]): Uint8Array[] {\n\tconst next: Uint8Array[] = [];\n\tfor (let i = 0; i < level.length; i += 2) {\n\t\tconst left = level[i];\n\t\tif (left === undefined) throw new Error(\"merkle: missing left node\");\n\t\t// Bitcoin duplicates the final node when a level has an odd count.\n\t\tconst right = level[i + 1] ?? left;\n\t\tnext.push(hashPair(left, right));\n\t}\n\treturn next;\n}\n\n/**\n * Compute the merkle root over txids in *internal* byte order. The result is\n * also internal order — it matches the `merkle-root` field read straight out of\n * an 80-byte block header, so it can be cross-checked against the header before\n * a proof is trusted.\n */\nexport function merkleRoot(txidsInternal: Uint8Array[]): Uint8Array {\n\tif (txidsInternal.length === 0) {\n\t\tthrow new Error(\"merkleRoot: empty tx list\");\n\t}\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tlevel = nextLevel(level);\n\t}\n\tconst root = level[0];\n\tif (root === undefined) throw new Error(\"merkleRoot: no root\");\n\treturn root;\n}\n\n/**\n * Build the merkle inclusion proof for the tx at `txIndex`. Sibling count is\n * exactly `ceil(log2(txCount))`, as the SIP-044 built-in requires.\n */\nexport function buildMerkleProof(\n\ttxidsInternal: Uint8Array[],\n\ttxIndex: number,\n): MerkleProof {\n\tconst txCount = txidsInternal.length;\n\tif (txCount === 0) {\n\t\tthrow new Error(\"buildMerkleProof: empty tx list\");\n\t}\n\tif (txIndex < 0 || txIndex >= txCount) {\n\t\tthrow new Error(\n\t\t\t`buildMerkleProof: txIndex ${txIndex} out of range for ${txCount} txs`,\n\t\t);\n\t}\n\n\tconst siblings: Uint8Array[] = [];\n\tlet index = txIndex;\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tconst isRight = index % 2 === 1;\n\t\tconst siblingIndex = isRight ? index - 1 : index + 1;\n\t\tconst self = level[index];\n\t\tif (self === undefined) throw new Error(\"buildMerkleProof: missing node\");\n\t\t// When the node is the last of an odd level, it is paired with itself.\n\t\tsiblings.push(level[siblingIndex] ?? self);\n\t\tlevel = nextLevel(level);\n\t\tindex = Math.floor(index / 2);\n\t}\n\n\treturn { siblings, txIndex, txCount };\n}\n\n/**\n * Recompute the merkle root from a leaf + its proof — the same fold the on-chain\n * `verify-merkle-proof` performs. Use it off-chain to self-check a constructed\n * proof against the header's merkle root before submitting a contract call.\n */\nexport function rootFromProof(\n\tleafInternal: Uint8Array,\n\tproof: MerkleProof,\n): Uint8Array {\n\tlet hash = leafInternal;\n\tlet index = proof.txIndex;\n\tfor (const sibling of proof.siblings) {\n\t\thash = index % 2 === 1 ? hashPair(sibling, hash) : hashPair(hash, sibling);\n\t\tindex = Math.floor(index / 2);\n\t}\n\treturn hash;\n}\n",
6
+ "import { bytesToHex, hexToBytes, without0x } from \"../utils/encoding.ts\";\nimport { type MerkleProof, buildMerkleProof, rootFromProof } from \"./merkle.ts\";\nimport { parseBitcoinTx, parseBlockHeader, reverseBytes } from \"./serialize.ts\";\n\n/**\n * A self-contained Bitcoin SPV proof: everything the SIP-044 built-ins need to\n * prove a tx (and one of its outputs) is committed in a confirmed block. Hashes\n * are internal byte order throughout.\n */\nexport interface SpvProof {\n\trawTx: Uint8Array;\n\t/** The tx's txid, internal order — the merkle leaf. */\n\ttxidInternal: Uint8Array;\n\t/** Output index of interest, if the proof targets a specific output. */\n\tvout?: number;\n\tmerkle: MerkleProof;\n\t/** The 80-byte block header that commits the tx. */\n\theader: Uint8Array;\n\t/** Bitcoin block height. */\n\theight: number;\n}\n\n/** The block context a `ProofSource` resolves for a confirmed tx. */\nexport interface BlockForTx {\n\t/** 80-byte block header. */\n\theader: Uint8Array;\n\theight: number;\n\t/** All of the block's txids, internal order, in block order. */\n\ttxidsInternal: Uint8Array[];\n\t/** Index of the target tx within the block. */\n\ttxIndex: number;\n}\n\n/**\n * Where proof inputs come from. The default is the integrator's own Bitcoin node\n * (`bitcoinRpcSource`) — trustless; a hosted Esplora-compatible endpoint\n * (`esploraSource`) is the fallback. `buildTxProof` independently re-checks\n * whatever a source returns, so a wrong or hostile source fails loudly rather\n * than producing a bad proof.\n */\nexport interface ProofSource {\n\t/** Raw (serialized) tx bytes for a txid (display-order hex). */\n\tgetRawTx(txid: string): Promise<Uint8Array>;\n\t/** The confirming block's header, height, and txid set for a txid. */\n\tgetBlockForTx(txid: string): Promise<BlockForTx>;\n}\n\nfunction normalizeTxid(txid: string): string {\n\treturn without0x(txid).toLowerCase();\n}\n\n/**\n * Locate `txid` in a block's txid set and assemble its `BlockForTx`. Owns the\n * display→internal byte-order reversal (`reverseBytes`) so the ProofSources\n * can't drift on the one operation a silent merkle-root mismatch would hide.\n * `txidsDisplay` are display-order hex txids as returned by Core / Esplora.\n */\nfunction assembleBlockForTx(args: {\n\ttxid: string;\n\tblockId: string;\n\theaderHex: string;\n\theight: number;\n\ttxidsDisplay: string[];\n}): BlockForTx {\n\tconst txIndex = args.txidsDisplay.indexOf(normalizeTxid(args.txid));\n\tif (txIndex < 0) {\n\t\tthrow new Error(`tx ${args.txid} not found in block ${args.blockId}`);\n\t}\n\treturn {\n\t\theader: hexToBytes(args.headerHex),\n\t\theight: args.height,\n\t\ttxidsInternal: args.txidsDisplay.map((t) => reverseBytes(hexToBytes(t))),\n\t\ttxIndex,\n\t};\n}\n\n/**\n * Assemble an `SpvProof` for a txid from a `ProofSource`, validating every claim\n * the source makes:\n * - the returned raw tx actually hashes to the requested txid,\n * - the claimed `txIndex` points at that txid in the block, and\n * - the resulting merkle proof folds back to the block header's merkle root.\n * Any mismatch throws — the proof is never returned half-trusted.\n */\nexport async function buildTxProof(\n\tsource: ProofSource,\n\tparams: { txid: string; vout?: number },\n): Promise<SpvProof> {\n\tconst { txid, vout } = params;\n\tconst want = normalizeTxid(txid);\n\n\tconst [rawTx, block] = await Promise.all([\n\t\tsource.getRawTx(txid),\n\t\tsource.getBlockForTx(txid),\n\t]);\n\n\tconst parsed = parseBitcoinTx(rawTx);\n\tconst gotDisplay = bytesToHex(reverseBytes(parsed.txidInternal));\n\tif (gotDisplay !== want) {\n\t\tthrow new Error(\n\t\t\t`source returned a tx whose id ${gotDisplay} does not match requested ${want}`,\n\t\t);\n\t}\n\n\tconst atIndex = block.txidsInternal[block.txIndex];\n\tif (!atIndex || bytesToHex(atIndex) !== bytesToHex(parsed.txidInternal)) {\n\t\tthrow new Error(\n\t\t\t`source txIndex ${block.txIndex} does not point at tx ${want}`,\n\t\t);\n\t}\n\n\tconst merkle = buildMerkleProof(block.txidsInternal, block.txIndex);\n\n\tconst headerRoot = parseBlockHeader(block.header).merkleRoot;\n\tconst computed = rootFromProof(parsed.txidInternal, merkle);\n\tif (bytesToHex(computed) !== bytesToHex(headerRoot)) {\n\t\tthrow new Error(\n\t\t\t\"constructed merkle proof does not reconcile with the block header merkle root\",\n\t\t);\n\t}\n\n\treturn {\n\t\trawTx,\n\t\ttxidInternal: parsed.txidInternal,\n\t\tvout,\n\t\tmerkle,\n\t\theader: block.header,\n\t\theight: block.height,\n\t};\n}\n\n/**\n * Compose sources into an ordered fallback chain: each call tries them in turn\n * and returns the first success, throwing the last error if all fail. Put the\n * trustless integrator node first and a hosted endpoint last.\n */\nexport function fallbackProofSource(sources: ProofSource[]): ProofSource {\n\tif (sources.length === 0) {\n\t\tthrow new Error(\"fallbackProofSource: at least one source is required\");\n\t}\n\tasync function firstSuccess<T>(\n\t\tfn: (s: ProofSource) => Promise<T>,\n\t): Promise<T> {\n\t\tlet lastError: unknown;\n\t\tfor (const source of sources) {\n\t\t\ttry {\n\t\t\t\treturn await fn(source);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\treturn {\n\t\tgetRawTx: (txid) => firstSuccess((s) => s.getRawTx(txid)),\n\t\tgetBlockForTx: (txid) => firstSuccess((s) => s.getBlockForTx(txid)),\n\t};\n}\n\nexport interface BitcoinRpcConfig {\n\t/** Bitcoin Core JSON-RPC endpoint URL. */\n\turl: string;\n\t/** Basic auth — `{ username, password }` or a pre-encoded base64 string. */\n\tauth?: { username: string; password: string } | string;\n\t/** Override the fetch implementation (testing / custom agents). */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by the integrator's own Bitcoin Core node over\n * JSON-RPC. This is the trustless default. The node must run with `-txindex`\n * (or the tx must be in the mempool's block view) so `getrawtransaction` can\n * resolve the confirming block.\n */\nexport function bitcoinRpcSource(config: BitcoinRpcConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\n\tasync function rpc<T>(method: string, rpcParams: unknown[]): Promise<T> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"content-type\": \"application/json\",\n\t\t};\n\t\tif (config.auth) {\n\t\t\tconst basic =\n\t\t\t\ttypeof config.auth === \"string\"\n\t\t\t\t\t? config.auth\n\t\t\t\t\t: btoa(`${config.auth.username}:${config.auth.password}`);\n\t\t\theaders.authorization = `Basic ${basic}`;\n\t\t}\n\t\tconst res = await doFetch(config.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: \"1.0\",\n\t\t\t\tid: \"secondlayer\",\n\t\t\t\tmethod,\n\t\t\t\tparams: rpcParams,\n\t\t\t}),\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} failed: HTTP ${res.status}`);\n\t\t}\n\t\tconst json = (await res.json()) as {\n\t\t\tresult: T;\n\t\t\terror: { message: string } | null;\n\t\t};\n\t\tif (json.error) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} error: ${json.error.message}`);\n\t\t}\n\t\treturn json.result;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes(await rpc<string>(\"getrawtransaction\", [txid, false]));\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst tx = await rpc<{ blockhash?: string }>(\"getrawtransaction\", [\n\t\t\t\ttxid,\n\t\t\t\ttrue,\n\t\t\t]);\n\t\t\tif (!tx.blockhash) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst block = await rpc<{ tx: string[]; height: number }>(\"getblock\", [\n\t\t\t\ttx.blockhash,\n\t\t\t\t1,\n\t\t\t]);\n\t\t\tconst header = await rpc<string>(\"getblockheader\", [tx.blockhash, false]);\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: tx.blockhash,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: block.height,\n\t\t\t\ttxidsDisplay: block.tx,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport interface EsploraConfig {\n\t/** Esplora REST base URL, e.g. `https://blockstream.info/api` or a self-hosted instance. */\n\turl: string;\n\t/** Override the fetch implementation. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by an Esplora REST API (self-hosted, or a hosted\n * provider as a fallback). Provider-agnostic: any Esplora-compatible endpoint\n * works. Use as the hosted fallback behind `bitcoinRpcSource`.\n */\nexport function esploraSource(config: EsploraConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\tconst base = config.url.replace(/\\/+$/, \"\");\n\n\tasync function get(path: string): Promise<Response> {\n\t\tconst res = await doFetch(`${base}${path}`);\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`esplora GET ${path} failed: HTTP ${res.status}`);\n\t\t}\n\t\treturn res;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes((await (await get(`/tx/${txid}/hex`)).text()).trim());\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst status = (await (await get(`/tx/${txid}`)).json()) as {\n\t\t\t\tstatus: {\n\t\t\t\t\tconfirmed: boolean;\n\t\t\t\t\tblock_height: number;\n\t\t\t\t\tblock_hash: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tif (!status.status.confirmed) {\n\t\t\t\tthrow new Error(`tx ${txid} is unconfirmed`);\n\t\t\t}\n\t\t\tconst blockHashHex = status.status.block_hash;\n\t\t\tconst header = (\n\t\t\t\tawait (await get(`/block/${blockHashHex}/header`)).text()\n\t\t\t).trim();\n\t\t\tconst txids = (await (\n\t\t\t\tawait get(`/block/${blockHashHex}/txids`)\n\t\t\t).json()) as string[];\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: blockHashHex,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: status.status.block_height,\n\t\t\t\ttxidsDisplay: txids,\n\t\t\t});\n\t\t},\n\t};\n}\n",
7
+ "/**\n * Stacks hard-fork epoch activation heights, as Bitcoin burn block heights.\n *\n * Epoch 4.0 carries both SIP-044 (the native Bitcoin SPV built-ins / Clarity 6)\n * and SIP-045 (`pox-5` Bitcoin Staking) — one fork, one height. Keep it here so\n * the two modules can never disagree.\n */\n\n/**\n * Epoch 4.0 activation height on mainnet — Bitcoin block 960,230 (~2026-07-30\n * AM UTC, per the stacks-core 4.0.1 release notes).\n *\n * Only mainnet has a fixed height. On other networks, read it from the node\n * (`getPox5Activation` for pox-5) or pass it explicitly.\n */\nexport const EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET = 960_230;\n"
8
+ ],
9
+ "mappings": ";AAmBA,SAAS,QAAQ,CAAC,MAAkB,OAA+B;AAAA,EAClE,OAAO,aAAa,YAAY,MAAM,KAAK,CAAC;AAAA;AAI7C,SAAS,SAAS,CAAC,OAAmC;AAAA,EACrD,MAAM,OAAqB,CAAC;AAAA,EAC5B,SAAS,IAAI,EAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AAAA,IACzC,MAAM,OAAO,MAAM;AAAA,IACnB,IAAI,SAAS;AAAA,MAAW,MAAM,IAAI,MAAM,2BAA2B;AAAA,IAEnE,MAAM,QAAQ,MAAM,IAAI,MAAM;AAAA,IAC9B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+ name: "pox-4"
6
+ },
7
+ testnet: {
8
+ address: "ST000000000000000000002AMW42H",
9
+ name: "pox-4"
10
+ }
11
+ };
12
+ var MIN_LOCK_PERIOD = 1;
13
+ var MAX_LOCK_PERIOD = 12;
14
+ var POX_ADDRESS_VERSION = {
15
+ p2pkh: 0,
16
+ p2sh: 1,
17
+ p2sh_p2wpkh: 2,
18
+ p2sh_p2wsh: 3,
19
+ p2wpkh: 4,
20
+ p2wsh: 5,
21
+ p2tr: 6
22
+ };
23
+
24
+ //# debugId=48EC81222A69A61C64756E2164756E21
25
+ //# sourceMappingURL=stacks-0eatsx6d.cjs.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/pox/constants.ts"],
4
+ "sourcesContent": [
5
+ "export const POX_CONTRACTS = {\n\tmainnet: {\n\t\taddress: \"SP000000000000000000002Q6VF78\",\n\t\tname: \"pox-4\",\n\t},\n\ttestnet: {\n\t\taddress: \"ST000000000000000000002AMW42H\",\n\t\tname: \"pox-4\",\n\t},\n} as const;\n\nexport const MIN_LOCK_PERIOD = 1;\nexport const MAX_LOCK_PERIOD = 12;\n\n/** PoX address version bytes (maps to Bitcoin address types) */\nexport const POX_ADDRESS_VERSION = {\n\t/** P2PKH - legacy addresses starting with \"1\" */\n\tp2pkh: 0x00,\n\t/** P2SH - script hash addresses starting with \"3\" */\n\tp2sh: 0x01,\n\t/** P2SH-P2WPKH - nested segwit */\n\tp2sh_p2wpkh: 0x02,\n\t/** P2SH-P2WSH - nested segwit script */\n\tp2sh_p2wsh: 0x03,\n\t/** P2WPKH - native segwit \"bc1q\" (20-byte hash) */\n\tp2wpkh: 0x04,\n\t/** P2WSH - native segwit \"bc1q\" (32-byte hash) */\n\tp2wsh: 0x05,\n\t/** P2TR - taproot \"bc1p\" (32-byte key) */\n\tp2tr: 0x06,\n} as const;\n"
6
+ ],
7
+ "mappings": ";AAAO,IAAM,gBAAgB;AAAA,EAC5B,SAAS;AAAA,IACR,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,SAAS;AAAA,IACR,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AACD;AAEO,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAGxB,IAAM,sBAAsB;AAAA,EAElC,OAAO;AAAA,EAEP,MAAM;AAAA,EAEN,aAAa;AAAA,EAEb,YAAY;AAAA,EAEZ,QAAQ;AAAA,EAER,OAAO;AAAA,EAEP,MAAM;AACP;",
8
+ "debugId": "48EC81222A69A61C64756E2164756E21",
9
+ "names": []
10
+ }
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/clarity/structuredData.ts"],
4
4
  "sourcesContent": [
5
- "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type { ClarityValue, TupleCV } from \"./types.ts\";\n\n/** asciiToBytes(\"SIP018\") */\nexport const SIP018_PREFIX = new Uint8Array([\n\t0x53, 0x49, 0x50, 0x30, 0x31, 0x38,\n]);\n\n/** sha256(serialize(cv)) — inner hash used by SIP-018. */\nexport function hashStructuredData(structuredData: ClarityValue): Uint8Array {\n\treturn sha256(serializeCVBytes(structuredData));\n}\n\nfunction isDomain(value: ClarityValue): value is TupleCV {\n\tif (value.type !== \"tuple\") return false;\n\tconst { name, version, \"chain-id\": chainId } = value.value;\n\treturn (\n\t\tname?.type === \"ascii\" &&\n\t\tversion?.type === \"ascii\" &&\n\t\tchainId?.type === \"uint\"\n\t);\n}\n\n/**\n * SIP-018 encoding: `\"SIP018\" || sha256(serialize(domain)) || sha256(serialize(message))`.\n * The signature is over `sha256` of this buffer.\n */\nexport function encodeStructuredData(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\tif (!isDomain(opts.domain)) {\n\t\tthrow new Error(\n\t\t\t\"domain must be a tuple { name: ascii, version: ascii, chain-id: uint }\",\n\t\t);\n\t}\n\treturn concatBytes(\n\t\tSIP018_PREFIX,\n\t\thashStructuredData(opts.domain),\n\t\thashStructuredData(opts.message),\n\t);\n}\n\n/** SIP-018 message hash: sha256(encodeStructuredData(...)). */\nexport function structuredDataHash(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\treturn sha256(encodeStructuredData(opts));\n}\n\n/**\n * Sign a SIP-018 structured message. Returns a 65-byte recoverable signature\n * in RSV order (recovery byte last) — the layout contracts expect.\n */\nexport async function signStructuredData(\n\taccount: LocalAccount,\n\topts: { message: ClarityValue; domain: ClarityValue },\n): Promise<string> {\n\tconst vrs = await account.sign(structuredDataHash(opts));\n\tif (vrs.length !== 65) {\n\t\tthrow new Error(\n\t\t\t`Expected 65-byte recoverable signature, got ${vrs.length}`,\n\t\t);\n\t}\n\treturn bytesToHex(concatBytes(vrs.slice(1), vrs.slice(0, 1)));\n}\n"
5
+ "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type { ClarityValue, TupleCV } from \"./types.ts\";\n\n/** asciiToBytes(\"SIP018\") */\nexport const SIP018_PREFIX: Uint8Array = new Uint8Array([\n\t0x53, 0x49, 0x50, 0x30, 0x31, 0x38,\n]);\n\n/** sha256(serialize(cv)) — inner hash used by SIP-018. */\nexport function hashStructuredData(structuredData: ClarityValue): Uint8Array {\n\treturn sha256(serializeCVBytes(structuredData));\n}\n\nfunction isDomain(value: ClarityValue): value is TupleCV {\n\tif (value.type !== \"tuple\") return false;\n\tconst { name, version, \"chain-id\": chainId } = value.value;\n\treturn (\n\t\tname?.type === \"ascii\" &&\n\t\tversion?.type === \"ascii\" &&\n\t\tchainId?.type === \"uint\"\n\t);\n}\n\n/**\n * SIP-018 encoding: `\"SIP018\" || sha256(serialize(domain)) || sha256(serialize(message))`.\n * The signature is over `sha256` of this buffer.\n */\nexport function encodeStructuredData(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\tif (!isDomain(opts.domain)) {\n\t\tthrow new Error(\n\t\t\t\"domain must be a tuple { name: ascii, version: ascii, chain-id: uint }\",\n\t\t);\n\t}\n\treturn concatBytes(\n\t\tSIP018_PREFIX,\n\t\thashStructuredData(opts.domain),\n\t\thashStructuredData(opts.message),\n\t);\n}\n\n/** SIP-018 message hash: sha256(encodeStructuredData(...)). */\nexport function structuredDataHash(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\treturn sha256(encodeStructuredData(opts));\n}\n\n/**\n * Sign a SIP-018 structured message. Returns a 65-byte recoverable signature\n * in RSV order (recovery byte last) — the layout contracts expect.\n */\nexport async function signStructuredData(\n\taccount: LocalAccount,\n\topts: { message: ClarityValue; domain: ClarityValue },\n): Promise<string> {\n\tconst vrs = await account.sign(structuredDataHash(opts));\n\tif (vrs.length !== 65) {\n\t\tthrow new Error(\n\t\t\t`Expected 65-byte recoverable signature, got ${vrs.length}`,\n\t\t);\n\t}\n\treturn bytesToHex(concatBytes(vrs.slice(1), vrs.slice(0, 1)));\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;AAAA;AAOO,IAAM,gBAAgB,IAAI,WAAW;AAAA,EAC3C;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAC/B,CAAC;AAGM,SAAS,kBAAkB,CAAC,gBAA0C;AAAA,EAC5E,OAAO,OAAO,iBAAiB,cAAc,CAAC;AAAA;AAG/C,SAAS,QAAQ,CAAC,OAAuC;AAAA,EACxD,IAAI,MAAM,SAAS;AAAA,IAAS,OAAO;AAAA,EACnC,QAAQ,MAAM,SAAS,YAAY,YAAY,MAAM;AAAA,EACrD,OACC,MAAM,SAAS,WACf,SAAS,SAAS,WAClB,SAAS,SAAS;AAAA;AAQb,SAAS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AAIM,SAAS,kBAAkB,CAAC,MAGpB;AAAA,EACd,OAAO,OAAO,qBAAqB,IAAI,CAAC;AAAA;AAOzC,eAAsB,kBAAkB,CACvC,SACA,MACkB;AAAA,EAClB,MAAM,MAAM,MAAM,QAAQ,KAAK,mBAAmB,IAAI,CAAC;AAAA,EACvD,IAAI,IAAI,WAAW,IAAI;AAAA,IACtB,MAAM,IAAI,MACT,+CAA+C,IAAI,QACpD;AAAA,EACD;AAAA,EACA,OAAO,WAAW,YAAY,IAAI,MAAM,CAAC,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;AAAA;",
8
8
  "debugId": "196BB7249717D5DE64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,6 @@
1
1
  var import_node_module = require("node:module");
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,6 +8,28 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  function __accessProp(key) {
7
9
  return this[key];
8
10
  }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
13
+ var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
21
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
22
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ if (canCache)
30
+ cache.set(mod, to);
31
+ return to;
32
+ };
9
33
  var __toCommonJS = (from) => {
10
34
  var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
35
  if (entry)
@@ -37,5 +61,5 @@ var __export = (target, all) => {
37
61
  });
38
62
  };
39
63
 
40
- //# debugId=E83B2B767716458C64756E2164756E21
41
- //# sourceMappingURL=stacks-mrk6tkkh.cjs.map
64
+ //# debugId=0673EC2C98346F8D64756E2164756E21
65
+ //# sourceMappingURL=stacks-3mt2q2na.cjs.map
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "E83B2B767716458C64756E2164756E21",
7
+ "debugId": "0673EC2C98346F8D64756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -75,18 +75,6 @@ async function getAccountInfo(client, params) {
75
75
  };
76
76
  }
77
77
 
78
- // src/actions/public/getBalance.ts
79
- async function getBalance(client, params) {
80
- const data = await client.request(`/v2/accounts/${params.address}`, {
81
- method: "GET"
82
- });
83
- const balance = data?.balance;
84
- if (typeof balance !== "string" && typeof balance !== "number") {
85
- throw new MalformedResponseError(`getBalance: /v2/accounts/${params.address} response is missing "balance"`);
86
- }
87
- return BigInt(balance);
88
- }
89
-
90
78
  // src/actions/public/getBlock.ts
91
79
  async function getBlock(client, params) {
92
80
  if (params?.hash) {
@@ -123,17 +111,6 @@ async function getContractSource(client, params) {
123
111
  }
124
112
  }
125
113
 
126
- // src/actions/public/getDataVar.ts
127
- async function getDataVar(client, params) {
128
- const [address, name] = parseContractId(params.contract);
129
- const path = `/v2/data_var/${address}/${name}/${params.varName}?proof=0`;
130
- const data = await client.request(path, { method: "GET" });
131
- if (typeof data?.data !== "string") {
132
- throw new MalformedResponseError(`getDataVar: /v2/data_var/${address}/${name}/${params.varName} response is missing "data"`);
133
- }
134
- return deserializeCVBytes(data.data);
135
- }
136
-
137
114
  // src/actions/public/getMempoolStats.ts
138
115
  async function getMempoolStats(client) {
139
116
  return client.request("/extended/v1/tx/mempool/stats", { method: "GET" });
@@ -393,7 +370,7 @@ async function transferStx(client, params) {
393
370
  });
394
371
  }
395
372
 
396
- export { getAccountHistory, getAccountInfo, getBalance, getBlock, getContractAbi, getContractSource, getDataVar, getMempoolStats, getNftHoldings, getRawBlock, getTransaction, SimulationError, simulateCall, simulateTransaction, deployContract, signMessage, signTransactionAction, sponsorTransaction, transferStx };
373
+ export { getAccountHistory, getAccountInfo, getBlock, getContractAbi, getContractSource, getMempoolStats, getNftHoldings, getRawBlock, getTransaction, SimulationError, simulateCall, simulateTransaction, deployContract, signMessage, signTransactionAction, sponsorTransaction, transferStx };
397
374
 
398
- //# debugId=3B1054F9CA6D878664756E2164756E21
399
- //# sourceMappingURL=stacks-rndfw2vh.js.map
375
+ //# debugId=0B1CF001297B4A1064756E2164756E21
376
+ //# sourceMappingURL=stacks-7wkf2rph.js.map
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/actions/public/getAccountHistory.ts", "../src/actions/public/getAccountInfo.ts", "../src/actions/public/getBalance.ts", "../src/actions/public/getBlock.ts", "../src/actions/public/getContractAbi.ts", "../src/actions/public/getContractSource.ts", "../src/actions/public/getDataVar.ts", "../src/actions/public/getMempoolStats.ts", "../src/actions/public/getNftHoldings.ts", "../src/actions/public/getRawBlock.ts", "../src/actions/public/getTransaction.ts", "../src/errors/simulation.ts", "../src/actions/public/simulateCall.ts", "../src/actions/public/simulateTransaction.ts", "../src/actions/wallet/deployContract.ts", "../src/actions/wallet/signMessage.ts", "../src/actions/wallet/signTransaction.ts", "../src/actions/wallet/sponsorTransaction.ts", "../src/actions/wallet/transferStx.ts"],
3
+ "sources": ["../src/actions/public/getAccountHistory.ts", "../src/actions/public/getAccountInfo.ts", "../src/actions/public/getBlock.ts", "../src/actions/public/getContractAbi.ts", "../src/actions/public/getContractSource.ts", "../src/actions/public/getMempoolStats.ts", "../src/actions/public/getNftHoldings.ts", "../src/actions/public/getRawBlock.ts", "../src/actions/public/getTransaction.ts", "../src/errors/simulation.ts", "../src/actions/public/simulateCall.ts", "../src/actions/public/simulateTransaction.ts", "../src/actions/wallet/deployContract.ts", "../src/actions/wallet/signMessage.ts", "../src/actions/wallet/signTransaction.ts", "../src/actions/wallet/sponsorTransaction.ts", "../src/actions/wallet/transferStx.ts"],
4
4
  "sourcesContent": [
5
5
  "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetAccountHistoryParams = {\n\taddress: string;\n\t/** Capped at 50. Default 20. */\n\tlimit?: number;\n};\n\nexport type AccountHistoryResponse = {\n\tresults: unknown[];\n\ttotal: number;\n};\n\n/** Paginated transaction history for a principal (Hiro extended API). */\nexport async function getAccountHistory(\n\tclient: Client,\n\tparams: GetAccountHistoryParams,\n): Promise<AccountHistoryResponse> {\n\tconst limit = Math.min(params.limit ?? 20, 50);\n\treturn client.request(\n\t\t`/extended/v2/addresses/${params.address}/transactions?limit=${limit}`,\n\t\t{ method: \"GET\" },\n\t);\n}\n",
6
6
  "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport type GetAccountInfoParams = {\n\taddress: string;\n};\n\nexport type AccountInfo = {\n\tbalance: bigint;\n\tnonce: bigint;\n\tbalanceProof: string;\n\tnonceProof: string;\n};\n\nexport async function getAccountInfo(\n\tclient: Client,\n\tparams: GetAccountInfoParams,\n): Promise<AccountInfo> {\n\tconst data = await client.request(`/v2/accounts/${params.address}?proof=1`, {\n\t\tmethod: \"GET\",\n\t});\n\tconst balance = (data as { balance?: unknown })?.balance;\n\tconst nonce = (data as { nonce?: unknown })?.nonce;\n\tif (\n\t\t(typeof balance !== \"string\" && typeof balance !== \"number\") ||\n\t\t(typeof nonce !== \"string\" && typeof nonce !== \"number\")\n\t) {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getAccountInfo: /v2/accounts/${params.address} response is missing \"balance\" or \"nonce\"`,\n\t\t);\n\t}\n\treturn {\n\t\tbalance: BigInt(balance),\n\t\tnonce: BigInt(nonce),\n\t\tbalanceProof: data.balance_proof ?? \"\",\n\t\tnonceProof: data.nonce_proof ?? \"\",\n\t};\n}\n",
7
- "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport type GetBalanceParams = {\n\taddress: string;\n};\n\nexport async function getBalance(\n\tclient: Client,\n\tparams: GetBalanceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\tconst balance = (data as { balance?: unknown })?.balance;\n\tif (typeof balance !== \"string\" && typeof balance !== \"number\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getBalance: /v2/accounts/${params.address} response is missing \"balance\"`,\n\t\t);\n\t}\n\treturn BigInt(balance);\n}\n",
8
7
  "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetBlockParams = {\n\theight?: number;\n\thash?: string;\n};\n\nexport async function getBlock(\n\tclient: Client,\n\tparams?: GetBlockParams,\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n): Promise<any> {\n\tif (params?.hash) {\n\t\treturn client.request(`/extended/v2/blocks/${params.hash}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\tif (params?.height !== undefined) {\n\t\treturn client.request(`/extended/v2/blocks/${params.height}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\t// Latest block\n\treturn client.request(\"/extended/v2/blocks?limit=1\", { method: \"GET\" });\n}\n",
9
8
  "import type { Client } from \"../../clients/types.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetContractAbiParams = {\n\tcontract: string; // \"address.name\"\n};\n\nexport async function getContractAbi(\n\tclient: Client,\n\tparams: GetContractAbiParams,\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n): Promise<any> {\n\tconst [address, name] = parseContractId(params.contract);\n\treturn client.request(`/v2/contracts/interface/${address}/${name}`, {\n\t\tmethod: \"GET\",\n\t});\n}\n",
10
9
  "import type { Client } from \"../../clients/types.ts\";\nimport { HttpRequestError } from \"../../errors/http.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetContractSourceParams = {\n\tcontract: string; // \"address.name\"\n};\n\nexport type ContractSourceResponse = {\n\tsource: string;\n\tpublish_height: number;\n\tmarf_proof?: string;\n};\n\n/**\n * Fetch a deployed contract's Clarity source. Node-RPC only (`/v2/contracts/source`)\n * — not available through Hiro's extended API or a tenant proxy, so `client`\n * must be configured against a direct node transport. Returns `null` when the\n * node has no source for the contract.\n */\nexport async function getContractSource(\n\tclient: Client,\n\tparams: GetContractSourceParams,\n): Promise<ContractSourceResponse | null> {\n\tconst [address, name] = parseContractId(params.contract);\n\ttry {\n\t\tconst data = (await client.request(\n\t\t\t`/v2/contracts/source/${address}/${name}`,\n\t\t\t{ method: \"GET\" },\n\t\t)) as Partial<ContractSourceResponse> | undefined;\n\t\treturn data?.source ? (data as ContractSourceResponse) : null;\n\t} catch (error) {\n\t\tif (error instanceof HttpRequestError && error.status === 404) return null;\n\t\tthrow error;\n\t}\n}\n",
11
- "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetDataVarParams = {\n\tcontract: string; // \"address.name\"\n\tvarName: string;\n};\n\nexport async function getDataVar<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: GetDataVarParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst path = `/v2/data_var/${address}/${name}/${params.varName}?proof=0`;\n\n\tconst data = await client.request(path, { method: \"GET\" });\n\n\tif (typeof data?.data !== \"string\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getDataVar: /v2/data_var/${address}/${name}/${params.varName} response is missing \"data\"`,\n\t\t);\n\t}\n\treturn deserializeCVBytes<T>(data.data);\n}\n",
12
10
  "import type { Client } from \"../../clients/types.ts\";\n\n/**\n * Current mempool statistics: pending count, fee distribution, age buckets\n * (Hiro extended API).\n */\nexport async function getMempoolStats(\n\tclient: Client,\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n): Promise<any> {\n\treturn client.request(\"/extended/v1/tx/mempool/stats\", { method: \"GET\" });\n}\n",
13
11
  "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetNftHoldingsParams = {\n\taddress: string;\n\t/** Capped at 50. Default 20. */\n\tlimit?: number;\n};\n\nexport type NftHoldingsResponse = {\n\tresults: unknown[];\n\ttotal: number;\n};\n\n/** NFT holdings for a principal across all collections (Hiro extended API). */\nexport async function getNftHoldings(\n\tclient: Client,\n\tparams: GetNftHoldingsParams,\n): Promise<NftHoldingsResponse> {\n\tconst limit = Math.min(params.limit ?? 20, 50);\n\treturn client.request(\n\t\t`/extended/v1/tokens/nft/holdings?principal=${encodeURIComponent(params.address)}&limit=${limit}`,\n\t\t{ method: \"GET\" },\n\t);\n}\n",
14
12
  "import type { Client } from \"../../clients/types.ts\";\nimport { HttpRequestError } from \"../../errors/http.ts\";\n\nexport type GetRawBlockParams = {\n\theight: number;\n};\n\n/**\n * Raw node RPC block shape (`/v2/blocks/{height}`) — distinct from\n * {@link getBlock}'s Hiro extended-API shape. Carries consensus/identity\n * fields (`index_block_hash`, `miner_txid`, ...) that the indexed API doesn't\n * expose, for trust-minimized use cases (e.g. block-header proofs) that can't\n * rely on a third-party indexer.\n */\nexport type RawBlockResponse = {\n\thash: string;\n\theight: number;\n\tparent_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string;\n\tburn_block_time: number;\n\tindex_block_hash: string;\n\tparent_index_block_hash: string;\n\tminer_txid: string;\n\ttxs: string[];\n};\n\n/**\n * Fetch a block by height directly from a stacks-node (not Hiro's extended\n * API — see {@link getBlock} for that). Returns `null` when the node has no\n * block at that height.\n */\nexport async function getRawBlock(\n\tclient: Client,\n\tparams: GetRawBlockParams,\n): Promise<RawBlockResponse | null> {\n\ttry {\n\t\tconst data = (await client.request(`/v2/blocks/${params.height}`, {\n\t\t\tmethod: \"GET\",\n\t\t})) as Partial<RawBlockResponse> | undefined;\n\t\treturn data?.hash ? (data as RawBlockResponse) : null;\n\t} catch (error) {\n\t\tif (error instanceof HttpRequestError && error.status === 404) return null;\n\t\tthrow error;\n\t}\n}\n",
@@ -22,7 +20,7 @@
22
20
  "import type { Client } from \"../../clients/types.ts\";\nimport { createSingleSigSpendingCondition } from \"../../transactions/authorization.ts\";\nimport { signSponsorWithAccount } from \"../../transactions/signer.ts\";\nimport {\n\tAuthType,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"../../transactions/types.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { intToBigInt } from \"../../utils/encoding.ts\";\nimport { resolveNonce } from \"./nonceManager.ts\";\nimport { type FeeParam, isProviderAccount, resolveFee } from \"./utils.ts\";\n\nexport type SponsorTransactionParams = {\n\ttransaction: StacksTransaction;\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n};\n\n/** Sponsor a transaction: set sponsor spending condition, sign as sponsor */\nexport async function sponsorTransaction(\n\tclient: Client,\n\tparams: SponsorTransactionParams,\n): Promise<StacksTransaction> {\n\tconst { transaction } = params;\n\n\tif (transaction.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must have sponsored authorization\");\n\t}\n\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\tif (isProviderAccount(account)) {\n\t\tthrow new Error(\"Provider accounts cannot sponsor transactions\");\n\t}\n\n\t// Resolve sponsor nonce\n\tconst nonce =\n\t\tparams.nonce != null\n\t\t\t? intToBigInt(params.nonce)\n\t\t\t: await resolveNonce(client, account.address);\n\n\t// Resolve sponsor fee. Estimation failure falls back to the minimum relay\n\t// fee instead of 0 (a 0-fee tx would be rejected at broadcast).\n\tconst fee = await resolveFee(client, transaction, params.fee);\n\n\t// Create sponsor spending condition\n\tconst sponsorCondition = createSingleSigSpendingCondition(\n\t\taccount.publicKey,\n\t\tnonce,\n\t\tfee,\n\t);\n\n\t// Set sponsor spending condition on the tx\n\tconst auth = transaction.auth as SponsoredAuthorization;\n\tconst sponsored: StacksTransaction = {\n\t\t...transaction,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: sponsorCondition,\n\t\t},\n\t};\n\n\t// Sign as sponsor\n\treturn signSponsorWithAccount(sponsored, account);\n}\n",
23
21
  "import type { Client } from \"../../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../../postconditions/types.ts\";\nimport { buildTokenTransfer } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport { validateStacksAddress } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { broadcastWithNonceReset, resolveNonce } from \"./nonceManager.ts\";\nimport {\n\ttype FeeParam,\n\tassertNoFeeTierForProvider,\n\tisFeeTier,\n\tisProviderAccount,\n\tresolveFee,\n\tsetUnsignedFee,\n} from \"./utils.ts\";\n\nexport type TransferStxParams = {\n\tto: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n};\n\n/** Build, sign, and broadcast an STX transfer */\nexport async function transferStx(\n\tclient: Client,\n\tparams: TransferStxParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\tif (!validateStacksAddress(params.to))\n\t\tthrow new Error(`Invalid recipient address: ${params.to}`);\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tassertNoFeeTierForProvider(params.fee);\n\t\tconst result = await account.provider.request(\"stx_transferStx\", {\n\t\t\trecipient: params.to,\n\t\t\tamount: String(params.amount),\n\t\t\tmemo: params.memo,\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst nonce = params.nonce ?? (await resolveNonce(client, account.address));\n\n\tconst needsFeeResolution = params.fee === undefined || isFeeTier(params.fee);\n\n\tconst unsigned = buildTokenTransfer({\n\t\trecipient: params.to,\n\t\tamount: params.amount,\n\t\tmemo: params.memo,\n\t\tfee: needsFeeResolution ? 0n : (params.fee as IntegerType),\n\t\tnonce,\n\t\tpublicKey: account.publicKey,\n\t\tchain: client.chain,\n\t\tpostConditionMode: params.postConditionMode,\n\t\tpostConditions: params.postConditions,\n\t});\n\n\tif (needsFeeResolution) {\n\t\tsetUnsignedFee(unsigned, await resolveFee(client, unsigned, params.fee));\n\t}\n\n\tconst signed = await signTransactionWithAccount(unsigned, account);\n\treturn broadcastWithNonceReset(client, {\n\t\ttransaction: signed,\n\t\taddress: account.address,\n\t});\n}\n"
24
22
  ],
25
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,eAAsB,iBAAiB,CACtC,QACA,QACkC;AAAA,EAClC,MAAM,QAAQ,KAAK,IAAI,OAAO,SAAS,IAAI,EAAE;AAAA,EAC7C,OAAO,OAAO,QACb,0BAA0B,OAAO,8BAA8B,SAC/D,EAAE,QAAQ,MAAM,CACjB;AAAA;;;ACRD,eAAsB,cAAc,CACnC,QACA,QACuB;AAAA,EACvB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,mBAAmB;AAAA,IAC3E,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,MAAM,UAAW,MAAgC;AAAA,EACjD,MAAM,QAAS,MAA8B;AAAA,EAC7C,IACE,OAAO,YAAY,YAAY,OAAO,YAAY,YAClD,OAAO,UAAU,YAAY,OAAO,UAAU,UAC9C;AAAA,IACD,MAAM,IAAI,uBACT,gCAAgC,OAAO,kDACxC;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,SAAS,OAA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AAO;AAAA,IACvC;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB,OAAO,OAAO;AAAA,IACd,mBAAmB,OAAO;AAAA,IAC1B,gBAAgB,OAAO;AAAA,EACxB,CAAC;AAAA,EAED,IAAI,oBAAoB;AAAA,IACvB,eAAe,UAAU,MAAM,WAAW,QAAQ,UAAU,OAAO,GAAG,CAAC;AAAA,EACxE;AAAA,EAEA,MAAM,SAAS,MAAM,2BAA2B,UAAU,OAAO;AAAA,EACjE,OAAO,wBAAwB,QAAQ;AAAA,IACtC,aAAa;AAAA,IACb,SAAS,QAAQ;AAAA,EAClB,CAAC;AAAA;",
24
+ "debugId": "0B1CF001297B4A1064756E2164756E21",
27
25
  "names": []
28
26
  }
@@ -0,0 +1,52 @@
1
+ import {
2
+ MalformedResponseError,
3
+ readContract
4
+ } from "./stacks-27fmgajb.js";
5
+ import {
6
+ deserializeCVBytes
7
+ } from "./stacks-ttdk2g2f.js";
8
+ import {
9
+ parseContractId
10
+ } from "./stacks-bfan7ex7.js";
11
+
12
+ // src/actions/public/getBalance.ts
13
+ async function getBalance(client, params) {
14
+ const data = await client.request(`/v2/accounts/${params.address}`, {
15
+ method: "GET"
16
+ });
17
+ const balance = data?.balance;
18
+ if (typeof balance !== "string" && typeof balance !== "number") {
19
+ throw new MalformedResponseError(`getBalance: /v2/accounts/${params.address} response is missing "balance"`);
20
+ }
21
+ return BigInt(balance);
22
+ }
23
+
24
+ // src/actions/public/getDataVar.ts
25
+ async function getDataVar(client, params) {
26
+ const [address, name] = parseContractId(params.contract);
27
+ const path = `/v2/data_var/${address}/${name}/${params.varName}?proof=0`;
28
+ const data = await client.request(path, { method: "GET" });
29
+ if (typeof data?.data !== "string") {
30
+ throw new MalformedResponseError(`getDataVar: /v2/data_var/${address}/${name}/${params.varName} response is missing "data"`);
31
+ }
32
+ return deserializeCVBytes(data.data);
33
+ }
34
+
35
+ // src/actions/public/multicall.ts
36
+ async function multicall(client, params) {
37
+ const { calls, allowFailure = true } = params;
38
+ if (allowFailure) {
39
+ const settled = await Promise.allSettled(calls.map((call) => readContract(client, call)));
40
+ return settled.map((r) => r.status === "fulfilled" ? { status: "success", result: r.value } : {
41
+ status: "failure",
42
+ error: r.reason instanceof Error ? r.reason : new Error(String(r.reason))
43
+ });
44
+ }
45
+ const results = await Promise.all(calls.map((call) => readContract(client, call)));
46
+ return results;
47
+ }
48
+
49
+ export { getBalance, getDataVar, multicall };
50
+
51
+ //# debugId=FB2239917577E3D764756E2164756E21
52
+ //# sourceMappingURL=stacks-8pfdscq6.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/public/getBalance.ts", "../src/actions/public/getDataVar.ts", "../src/actions/public/multicall.ts"],
4
+ "sourcesContent": [
5
+ "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport type GetBalanceParams = {\n\taddress: string;\n};\n\nexport async function getBalance(\n\tclient: Client,\n\tparams: GetBalanceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\tconst balance = (data as { balance?: unknown })?.balance;\n\tif (typeof balance !== \"string\" && typeof balance !== \"number\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getBalance: /v2/accounts/${params.address} response is missing \"balance\"`,\n\t\t);\n\t}\n\treturn BigInt(balance);\n}\n",
6
+ "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetDataVarParams = {\n\tcontract: string; // \"address.name\"\n\tvarName: string;\n};\n\nexport async function getDataVar<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: GetDataVarParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst path = `/v2/data_var/${address}/${name}/${params.varName}?proof=0`;\n\n\tconst data = await client.request(path, { method: \"GET\" });\n\n\tif (typeof data?.data !== \"string\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getDataVar: /v2/data_var/${address}/${name}/${params.varName} response is missing \"data\"`,\n\t\t);\n\t}\n\treturn deserializeCVBytes<T>(data.data);\n}\n",
7
+ "import type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { readContract } from \"./readContract.ts\";\n\nexport type MulticallCall = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n};\n\nexport type MulticallParams<TAllowFailure extends boolean = true> = {\n\tcalls: readonly MulticallCall[];\n\tallowFailure?: TAllowFailure;\n};\n\nexport type MulticallSuccessResult = {\n\tstatus: \"success\";\n\tresult: ClarityValue;\n};\nexport type MulticallFailureResult = { status: \"failure\"; error: Error };\n\nexport type MulticallResult<T extends boolean> = T extends true\n\t? (MulticallSuccessResult | MulticallFailureResult)[]\n\t: ClarityValue[];\n\nexport async function multicall<TAllowFailure extends boolean = true>(\n\tclient: Client,\n\tparams: MulticallParams<TAllowFailure>,\n): Promise<MulticallResult<TAllowFailure>> {\n\tconst { calls, allowFailure = true } = params;\n\n\tif (allowFailure) {\n\t\tconst settled = await Promise.allSettled(\n\t\t\tcalls.map((call) => readContract(client, call)),\n\t\t);\n\t\treturn settled.map((r) =>\n\t\t\tr.status === \"fulfilled\"\n\t\t\t\t? { status: \"success\" as const, result: r.value }\n\t\t\t\t: {\n\t\t\t\t\t\tstatus: \"failure\" as const,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\tr.reason instanceof Error\n\t\t\t\t\t\t\t\t? r.reason\n\t\t\t\t\t\t\t\t: new Error(String(r.reason)),\n\t\t\t\t\t},\n\t\t) as MulticallResult<TAllowFailure>;\n\t}\n\n\tconst results = await Promise.all(\n\t\tcalls.map((call) => readContract(client, call)),\n\t);\n\treturn results as MulticallResult<TAllowFailure>;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MAAM,IAAI,CAAC,SAAS,aAAa,QAAQ,IAAI,CAAC,CAC/C;AAAA,EACA,OAAO;AAAA;",
10
+ "debugId": "FB2239917577E3D764756E2164756E21",
11
+ "names": []
12
+ }
@@ -0,0 +1,27 @@
1
+ // src/pox/constants.ts
2
+ var POX_CONTRACTS = {
3
+ mainnet: {
4
+ address: "SP000000000000000000002Q6VF78",
5
+ name: "pox-4"
6
+ },
7
+ testnet: {
8
+ address: "ST000000000000000000002AMW42H",
9
+ name: "pox-4"
10
+ }
11
+ };
12
+ var MIN_LOCK_PERIOD = 1;
13
+ var MAX_LOCK_PERIOD = 12;
14
+ var POX_ADDRESS_VERSION = {
15
+ p2pkh: 0,
16
+ p2sh: 1,
17
+ p2sh_p2wpkh: 2,
18
+ p2sh_p2wsh: 3,
19
+ p2wpkh: 4,
20
+ p2wsh: 5,
21
+ p2tr: 6
22
+ };
23
+
24
+ export { POX_CONTRACTS, MIN_LOCK_PERIOD, MAX_LOCK_PERIOD, POX_ADDRESS_VERSION };
25
+
26
+ //# debugId=34013459785D74E764756E2164756E21
27
+ //# sourceMappingURL=stacks-e4xn4m7j.js.map