@secondlayer/stacks 6.2.2 → 6.4.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 (78) hide show
  1. package/dist/shared/{stacks-esm-8f5catbf.js → stacks-esm-1mybf3yt.js} +2 -2
  2. package/dist/shared/{stacks-esm-tdrdye4y.js → stacks-esm-4ja7b0px.js} +2 -2
  3. package/dist/shared/{stacks-esm-t88hc019.js → stacks-esm-5qdnx2q9.js} +3 -3
  4. package/dist/shared/{stacks-esm-b54n1jdx.js → stacks-esm-6qv8gjes.js} +6 -6
  5. package/dist/shared/stacks-esm-6qv8gjes.js.map +12 -0
  6. package/dist/shared/{stacks-esm-a20wyky3.js → stacks-esm-896kv9yv.js} +2 -2
  7. package/dist/shared/{stacks-esm-exgw8j2j.js → stacks-esm-bragecm9.js} +7 -7
  8. package/dist/shared/{stacks-esm-hkw1kvd4.js → stacks-esm-gs60rd15.js} +7 -4
  9. package/dist/shared/{stacks-esm-hkw1kvd4.js.map → stacks-esm-gs60rd15.js.map} +3 -3
  10. package/dist/shared/{stacks-esm-xcd4sv1h.js → stacks-esm-hcjqgrtm.js} +5 -5
  11. package/dist/shared/{stacks-esm-pq0e379d.js → stacks-esm-hv11fdgy.js} +3 -3
  12. package/dist/shared/{stacks-esm-1b2rhv6y.js → stacks-esm-w36fvdxx.js} +2 -2
  13. package/dist/shared/{stacks-esm-7n5wd5md.js → stacks-esm-w8kswk0r.js} +5 -5
  14. package/dist/shared/{stacks-esm-0pc6tmf0.js → stacks-esm-x8gjr2v6.js} +2 -2
  15. package/dist/shared/{stacks-esm-nt5hf8ht.js → stacks-esm-z0rq3ejt.js} +44 -21
  16. package/dist/shared/stacks-esm-z0rq3ejt.js.map +12 -0
  17. package/dist/shared/{stacks-esm-p3zypwsw.js → stacks-esm-zwbhghxb.js} +2 -2
  18. package/dist/src/actions/index.cjs +6 -3
  19. package/dist/src/actions/index.cjs.map +3 -3
  20. package/dist/src/actions/index.js +10 -10
  21. package/dist/src/bitcoin/index.cjs +48 -21
  22. package/dist/src/bitcoin/index.cjs.map +4 -4
  23. package/dist/src/bitcoin/index.d.cts +13 -1
  24. package/dist/src/bitcoin/index.d.ts +13 -1
  25. package/dist/src/bitcoin/index.js +9 -7
  26. package/dist/src/bitcoin/index.js.map +2 -2
  27. package/dist/src/bns/index.cjs +6 -3
  28. package/dist/src/bns/index.cjs.map +3 -3
  29. package/dist/src/bns/index.js +10 -10
  30. package/dist/src/clarity/index.cjs +6 -3
  31. package/dist/src/clarity/index.cjs.map +3 -3
  32. package/dist/src/clarity/index.js +4 -4
  33. package/dist/src/filters/index.cjs +5 -5
  34. package/dist/src/filters/index.cjs.map +3 -3
  35. package/dist/src/filters/index.d.cts +6 -0
  36. package/dist/src/filters/index.d.ts +6 -0
  37. package/dist/src/filters/index.js +1 -1
  38. package/dist/src/index.cjs +10 -7
  39. package/dist/src/index.cjs.map +4 -4
  40. package/dist/src/index.d.cts +6 -0
  41. package/dist/src/index.d.ts +6 -0
  42. package/dist/src/index.js +9 -9
  43. package/dist/src/postconditions/index.cjs +6 -3
  44. package/dist/src/postconditions/index.cjs.map +3 -3
  45. package/dist/src/postconditions/index.js +3 -3
  46. package/dist/src/pox/index.cjs +6 -3
  47. package/dist/src/pox/index.cjs.map +3 -3
  48. package/dist/src/pox/index.js +8 -8
  49. package/dist/src/pox5/index.cjs +47 -21
  50. package/dist/src/pox5/index.cjs.map +4 -4
  51. package/dist/src/pox5/index.js +10 -10
  52. package/dist/src/sbtc/index.cjs +6 -3
  53. package/dist/src/sbtc/index.cjs.map +3 -3
  54. package/dist/src/sbtc/index.js +7 -7
  55. package/dist/src/simnet/index.cjs +6 -16
  56. package/dist/src/simnet/index.cjs.map +3 -3
  57. package/dist/src/simnet/index.js +6 -16
  58. package/dist/src/simnet/index.js.map +3 -3
  59. package/dist/src/stackingdao/index.cjs +6 -3
  60. package/dist/src/stackingdao/index.cjs.map +3 -3
  61. package/dist/src/stackingdao/index.js +8 -8
  62. package/dist/src/transactions/index.cjs +6 -3
  63. package/dist/src/transactions/index.cjs.map +3 -3
  64. package/dist/src/transactions/index.js +3 -3
  65. package/package.json +1 -1
  66. package/dist/shared/stacks-esm-b54n1jdx.js.map +0 -12
  67. package/dist/shared/stacks-esm-nt5hf8ht.js.map +0 -12
  68. /package/dist/shared/{stacks-esm-8f5catbf.js.map → stacks-esm-1mybf3yt.js.map} +0 -0
  69. /package/dist/shared/{stacks-esm-tdrdye4y.js.map → stacks-esm-4ja7b0px.js.map} +0 -0
  70. /package/dist/shared/{stacks-esm-t88hc019.js.map → stacks-esm-5qdnx2q9.js.map} +0 -0
  71. /package/dist/shared/{stacks-esm-a20wyky3.js.map → stacks-esm-896kv9yv.js.map} +0 -0
  72. /package/dist/shared/{stacks-esm-exgw8j2j.js.map → stacks-esm-bragecm9.js.map} +0 -0
  73. /package/dist/shared/{stacks-esm-xcd4sv1h.js.map → stacks-esm-hcjqgrtm.js.map} +0 -0
  74. /package/dist/shared/{stacks-esm-pq0e379d.js.map → stacks-esm-hv11fdgy.js.map} +0 -0
  75. /package/dist/shared/{stacks-esm-1b2rhv6y.js.map → stacks-esm-w36fvdxx.js.map} +0 -0
  76. /package/dist/shared/{stacks-esm-7n5wd5md.js.map → stacks-esm-w8kswk0r.js.map} +0 -0
  77. /package/dist/shared/{stacks-esm-0pc6tmf0.js.map → stacks-esm-x8gjr2v6.js.map} +0 -0
  78. /package/dist/shared/{stacks-esm-p3zypwsw.js.map → stacks-esm-zwbhghxb.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  import"../../shared/stacks-esm-7a0ehykf.js";
2
2
  import"../../shared/stacks-esm-kbz5s6v8.js";
3
- import"../../shared/stacks-esm-hkw1kvd4.js";
4
- import"../../shared/stacks-esm-a20wyky3.js";
5
- import"../../shared/stacks-esm-p3zypwsw.js";
6
- import"../../shared/stacks-esm-pq0e379d.js";
3
+ import"../../shared/stacks-esm-gs60rd15.js";
4
+ import"../../shared/stacks-esm-896kv9yv.js";
5
+ import"../../shared/stacks-esm-zwbhghxb.js";
6
+ import"../../shared/stacks-esm-hv11fdgy.js";
7
7
  import {
8
8
  Pc2
9
- } from "../../shared/stacks-esm-1b2rhv6y.js";
9
+ } from "../../shared/stacks-esm-w36fvdxx.js";
10
10
  import"../../shared/stacks-esm-e2qhfgke.js";
11
11
  import {
12
12
  POX_CONTRACTS2,
@@ -18,9 +18,9 @@ import {
18
18
  import {
19
19
  getContract2,
20
20
  resolveNetworkContract
21
- } from "../../shared/stacks-esm-7n5wd5md.js";
22
- import"../../shared/stacks-esm-xcd4sv1h.js";
23
- import"../../shared/stacks-esm-0pc6tmf0.js";
21
+ } from "../../shared/stacks-esm-w8kswk0r.js";
22
+ import"../../shared/stacks-esm-hcjqgrtm.js";
23
+ import"../../shared/stacks-esm-x8gjr2v6.js";
24
24
 
25
25
  // src/pox/abi.ts
26
26
  var POX_ABI = {
@@ -1137,11 +1137,14 @@ function readCV(reader, depth = 0) {
1137
1137
  case "err":
1138
1138
  return responseErrorCV(readCV(reader, depth + 1));
1139
1139
  case "address":
1140
- return standardPrincipalCV(readAddress(reader));
1140
+ return { type: "address", value: readAddress(reader) };
1141
1141
  case "contract": {
1142
1142
  const addr = readAddress(reader);
1143
1143
  const name = readLPString(reader);
1144
- return contractPrincipalCV(addr, name);
1144
+ if (new TextEncoder().encode(name).byteLength >= 128) {
1145
+ throw new Error("Contract name must be less than 128 bytes");
1146
+ }
1147
+ return { type: "contract", value: `${addr}.${name}` };
1145
1148
  }
1146
1149
  case "list": {
1147
1150
  const len = reader.readUInt32BE();
@@ -5452,6 +5455,14 @@ function rootFromProof(leafInternal, proof) {
5452
5455
  }
5453
5456
 
5454
5457
  // src/bitcoin/proof.ts
5458
+ class BitcoinSourceError extends Error {
5459
+ code;
5460
+ name = "BitcoinSourceError";
5461
+ constructor(code, message) {
5462
+ super(message);
5463
+ this.code = code;
5464
+ }
5465
+ }
5455
5466
  function normalizeTxid2(txid) {
5456
5467
  return without0x(txid).toLowerCase();
5457
5468
  }
@@ -5528,22 +5539,32 @@ function bitcoinRpcSource(config) {
5528
5539
  const basic = typeof config.auth === "string" ? config.auth : btoa(`${config.auth.username}:${config.auth.password}`);
5529
5540
  headers.authorization = `Basic ${basic}`;
5530
5541
  }
5531
- const res = await doFetch(config.url, {
5532
- method: "POST",
5533
- headers,
5534
- body: JSON.stringify({
5535
- jsonrpc: "1.0",
5536
- id: "secondlayer",
5537
- method,
5538
- params: rpcParams
5539
- })
5540
- });
5541
- if (!res.ok) {
5542
- throw new Error(`bitcoin rpc ${method} failed: HTTP ${res.status}`);
5542
+ let res;
5543
+ try {
5544
+ res = await doFetch(config.url, {
5545
+ method: "POST",
5546
+ headers,
5547
+ body: JSON.stringify({
5548
+ jsonrpc: "1.0",
5549
+ id: "secondlayer",
5550
+ method,
5551
+ params: rpcParams
5552
+ })
5553
+ });
5554
+ } catch (error) {
5555
+ throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: ${error instanceof Error ? error.message : "network error"}`);
5556
+ }
5557
+ let json;
5558
+ try {
5559
+ json = await res.json();
5560
+ } catch {
5561
+ throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: HTTP ${res.status}`);
5543
5562
  }
5544
- const json = await res.json();
5545
5563
  if (json.error) {
5546
- throw new Error(`bitcoin rpc ${method} error: ${json.error.message}`);
5564
+ throw new BitcoinSourceError(json.error.code === -5 ? "not-found" : "unavailable", `bitcoin rpc ${method} error: ${json.error.message}`);
5565
+ }
5566
+ if (!res.ok) {
5567
+ throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: HTTP ${res.status}`);
5547
5568
  }
5548
5569
  return json.result;
5549
5570
  }
@@ -5557,7 +5578,7 @@ function bitcoinRpcSource(config) {
5557
5578
  true
5558
5579
  ]);
5559
5580
  if (!tx.blockhash) {
5560
- throw new Error(`tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`);
5581
+ throw new BitcoinSourceError("unconfirmed", `tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`);
5561
5582
  }
5562
5583
  const block = await rpc("getblock", [
5563
5584
  tx.blockhash,
@@ -5578,9 +5599,14 @@ function esploraSource(config) {
5578
5599
  const doFetch = config.fetch ?? fetch;
5579
5600
  const base = config.url.replace(/\/+$/, "");
5580
5601
  async function get(path) {
5581
- const res = await doFetch(`${base}${path}`);
5602
+ let res;
5603
+ try {
5604
+ res = await doFetch(`${base}${path}`);
5605
+ } catch (error) {
5606
+ throw new BitcoinSourceError("unavailable", `esplora GET ${path} failed: ${error instanceof Error ? error.message : "network error"}`);
5607
+ }
5582
5608
  if (!res.ok) {
5583
- throw new Error(`esplora GET ${path} failed: HTTP ${res.status}`);
5609
+ throw new BitcoinSourceError(res.status === 404 ? "not-found" : "unavailable", `esplora GET ${path} failed: HTTP ${res.status}`);
5584
5610
  }
5585
5611
  return res;
5586
5612
  }
@@ -5591,7 +5617,7 @@ function esploraSource(config) {
5591
5617
  async getBlockForTx(txid) {
5592
5618
  const status = await (await get(`/tx/${txid}`)).json();
5593
5619
  if (!status.status.confirmed) {
5594
- throw new Error(`tx ${txid} is unconfirmed`);
5620
+ throw new BitcoinSourceError("unconfirmed", `tx ${txid} is unconfirmed`);
5595
5621
  }
5596
5622
  const blockHashHex = status.status.block_hash;
5597
5623
  const header = (await (await get(`/block/${blockHashHex}/header`)).text()).trim();
@@ -6137,5 +6163,5 @@ function parseSignerCalldata(calldata) {
6137
6163
  };
6138
6164
  }
6139
6165
 
6140
- //# debugId=5713B30E41D0F0B964756E2164756E21
6166
+ //# debugId=3EA2E5A9FF8158F764756E2164756E21
6141
6167
  //# sourceMappingURL=index.cjs.map