@secondlayer/stacks 2.0.0 → 2.1.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 (99) hide show
  1. package/dist/shared/{stacks-0nfexv24.cjs → stacks-0jk7vd8r.cjs} +9 -8
  2. package/dist/shared/{stacks-0nfexv24.cjs.map → stacks-0jk7vd8r.cjs.map} +5 -5
  3. package/dist/shared/{stacks-wjem3xw9.js → stacks-0zysn74p.js} +11 -10
  4. package/dist/shared/{stacks-wjem3xw9.js.map → stacks-0zysn74p.js.map} +5 -5
  5. package/dist/shared/stacks-14pgpkrr.cjs.map +6 -6
  6. package/dist/shared/{stacks-s7z5q8be.js → stacks-2h8d2y27.js} +29 -28
  7. package/dist/shared/stacks-2h8d2y27.js.map +11 -0
  8. package/dist/shared/{stacks-96d6m1zy.js → stacks-3erxq8wh.js} +6 -6
  9. package/dist/shared/{stacks-96d6m1zy.js.map → stacks-3erxq8wh.js.map} +4 -4
  10. package/dist/shared/{stacks-ra02bpny.cjs → stacks-3y058qda.cjs} +29 -28
  11. package/dist/shared/stacks-3y058qda.cjs.map +11 -0
  12. package/dist/shared/{stacks-s10yb9gz.js → stacks-6xmk24yw.js} +2 -2
  13. package/dist/shared/{stacks-70p84bgg.js → stacks-7tn3zsbe.js} +3 -3
  14. package/dist/shared/stacks-7tn3zsbe.js.map +10 -0
  15. package/dist/shared/{stacks-y5262j0z.cjs → stacks-8e4k5qnm.cjs} +4 -4
  16. package/dist/shared/{stacks-y5262j0z.cjs.map → stacks-8e4k5qnm.cjs.map} +4 -4
  17. package/dist/shared/stacks-9z833ww5.js +409 -0
  18. package/dist/shared/stacks-9z833ww5.js.map +10 -0
  19. package/dist/shared/{stacks-5tprhns9.cjs → stacks-dpxnxhqb.cjs} +2 -5
  20. package/dist/shared/{stacks-5tprhns9.cjs.map → stacks-dpxnxhqb.cjs.map} +3 -3
  21. package/dist/shared/{stacks-4x2bcc2k.js → stacks-fy5h5qyx.js} +7 -7
  22. package/dist/shared/{stacks-4x2bcc2k.js.map → stacks-fy5h5qyx.js.map} +6 -6
  23. package/dist/shared/{stacks-zf7rbpzp.js → stacks-g7ffp8aj.js} +3 -3
  24. package/dist/shared/{stacks-zf7rbpzp.js.map → stacks-g7ffp8aj.js.map} +2 -2
  25. package/dist/shared/{stacks-1s5w4ncf.js → stacks-g7ys594x.js} +7 -7
  26. package/dist/shared/{stacks-1s5w4ncf.js.map → stacks-g7ys594x.js.map} +4 -4
  27. package/dist/shared/{stacks-09wa7ewe.js → stacks-kmnthgj7.js} +12 -12
  28. package/dist/shared/stacks-kmnthgj7.js.map +15 -0
  29. package/dist/shared/{stacks-je937aas.js → stacks-kmshch4q.js} +3 -3
  30. package/dist/shared/stacks-mnnhpex3.cjs +407 -0
  31. package/dist/shared/stacks-mnnhpex3.cjs.map +10 -0
  32. package/dist/shared/{stacks-y3dh7hv1.js → stacks-tjjnkt3r.js} +2 -5
  33. package/dist/shared/{stacks-y3dh7hv1.js.map → stacks-tjjnkt3r.js.map} +3 -3
  34. package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
  35. package/dist/shared/stacks-wyxj879g.cjs.map +2 -2
  36. package/dist/shared/{stacks-rwfgts3s.js → stacks-xxn5ma6g.js} +2 -2
  37. package/dist/shared/{stacks-17sdtaxg.cjs → stacks-xxvz1x0f.cjs} +8 -8
  38. package/dist/shared/stacks-xxvz1x0f.cjs.map +15 -0
  39. package/dist/shared/{stacks-s30kkvm8.js → stacks-y2p4h5ks.js} +4 -4
  40. package/dist/shared/{stacks-znrb59ce.cjs → stacks-y3nbm8bw.cjs} +3 -3
  41. package/dist/shared/{stacks-znrb59ce.cjs.map → stacks-y3nbm8bw.cjs.map} +4 -4
  42. package/dist/src/accounts/index.cjs +3 -2
  43. package/dist/src/accounts/index.cjs.map +3 -3
  44. package/dist/src/accounts/index.js +5 -4
  45. package/dist/src/accounts/index.js.map +3 -3
  46. package/dist/src/actions/index.js +11 -11
  47. package/dist/src/bns/index.cjs +2 -4
  48. package/dist/src/bns/index.cjs.map +4 -4
  49. package/dist/src/bns/index.js +12 -14
  50. package/dist/src/bns/index.js.map +4 -4
  51. package/dist/src/clarity/index.js +5 -5
  52. package/dist/src/connect/index.cjs +17 -17
  53. package/dist/src/connect/index.cjs.map +7 -7
  54. package/dist/src/connect/index.js +17 -17
  55. package/dist/src/connect/index.js.map +7 -7
  56. package/dist/src/connect/walletconnect/index.cjs +16 -13
  57. package/dist/src/connect/walletconnect/index.cjs.map +9 -9
  58. package/dist/src/connect/walletconnect/index.js +16 -13
  59. package/dist/src/connect/walletconnect/index.js.map +9 -9
  60. package/dist/src/index.cjs +4 -4
  61. package/dist/src/index.cjs.map +8 -8
  62. package/dist/src/index.d.cts +0 -4
  63. package/dist/src/index.d.ts +0 -4
  64. package/dist/src/index.js +13 -13
  65. package/dist/src/index.js.map +8 -8
  66. package/dist/src/postconditions/index.js +3 -3
  67. package/dist/src/pox/index.cjs +3 -408
  68. package/dist/src/pox/index.cjs.map +4 -5
  69. package/dist/src/pox/index.js +16 -417
  70. package/dist/src/pox/index.js.map +4 -5
  71. package/dist/src/sbtc/index.cjs +270 -0
  72. package/dist/src/sbtc/index.cjs.map +14 -0
  73. package/dist/src/sbtc/index.d.cts +399 -0
  74. package/dist/src/sbtc/index.d.ts +399 -0
  75. package/dist/src/sbtc/index.js +286 -0
  76. package/dist/src/sbtc/index.js.map +14 -0
  77. package/dist/src/stackingdao/index.cjs +7 -7
  78. package/dist/src/stackingdao/index.cjs.map +3 -3
  79. package/dist/src/stackingdao/index.js +16 -16
  80. package/dist/src/stackingdao/index.js.map +3 -3
  81. package/dist/src/subscriptions/index.js +1 -1
  82. package/dist/src/tools/btc/index.cjs.map +2 -2
  83. package/dist/src/tools/btc/index.js.map +2 -2
  84. package/dist/src/tools/index.cjs +42 -43
  85. package/dist/src/tools/index.cjs.map +23 -23
  86. package/dist/src/tools/index.js +42 -43
  87. package/dist/src/tools/index.js.map +23 -23
  88. package/dist/src/transactions/index.js +6 -6
  89. package/dist/src/utils/index.js +3 -3
  90. package/package.json +6 -1
  91. package/dist/shared/stacks-09wa7ewe.js.map +0 -15
  92. package/dist/shared/stacks-17sdtaxg.cjs.map +0 -15
  93. package/dist/shared/stacks-70p84bgg.js.map +0 -10
  94. package/dist/shared/stacks-ra02bpny.cjs.map +0 -11
  95. package/dist/shared/stacks-s7z5q8be.js.map +0 -11
  96. /package/dist/shared/{stacks-s10yb9gz.js.map → stacks-6xmk24yw.js.map} +0 -0
  97. /package/dist/shared/{stacks-je937aas.js.map → stacks-kmshch4q.js.map} +0 -0
  98. /package/dist/shared/{stacks-rwfgts3s.js.map → stacks-xxn5ma6g.js.map} +0 -0
  99. /package/dist/shared/{stacks-s30kkvm8.js.map → stacks-y2p4h5ks.js.map} +0 -0
@@ -71,13 +71,13 @@ function bytesToHex(bytes) {
71
71
  return hex;
72
72
  }
73
73
  function hexToBytes(hex) {
74
- hex = without0x(hex);
75
- if (hex.length % 2)
76
- hex = `0${hex}`;
77
- const array = new Uint8Array(hex.length / 2);
74
+ let h = without0x(hex);
75
+ if (h.length % 2)
76
+ h = `0${h}`;
77
+ const array = new Uint8Array(h.length / 2);
78
78
  for (let i = 0;i < array.length; i++) {
79
79
  const j = i * 2;
80
- const byte = Number.parseInt(hex.slice(j, j + 2), 16);
80
+ const byte = Number.parseInt(h.slice(j, j + 2), 16);
81
81
  if (Number.isNaN(byte) || byte < 0)
82
82
  throw new Error("Invalid byte sequence");
83
83
  array[i] = byte;
@@ -193,15 +193,16 @@ function c32normalize(input) {
193
193
  return input.toUpperCase().replace(/O/g, "0").replace(/L|I/g, "1");
194
194
  }
195
195
  function c32encode(inputHex) {
196
- if (inputHex.length % 2 !== 0)
197
- inputHex = `0${inputHex}`;
198
- inputHex = inputHex.toLowerCase();
196
+ let hex = inputHex;
197
+ if (hex.length % 2 !== 0)
198
+ hex = `0${hex}`;
199
+ hex = hex.toLowerCase();
199
200
  const res = [];
200
201
  let carry = 0;
201
- for (let i = inputHex.length - 1;i >= 0; i--) {
202
+ for (let i = hex.length - 1;i >= 0; i--) {
202
203
  if (carry < 4) {
203
- const currentCode = HEX.indexOf(inputHex[i]) >> carry;
204
- const nextCode = i !== 0 ? HEX.indexOf(inputHex[i - 1]) : 0;
204
+ const currentCode = HEX.indexOf(hex[i]) >> carry;
205
+ const nextCode = i !== 0 ? HEX.indexOf(hex[i - 1]) : 0;
205
206
  const nextBits = 1 + carry;
206
207
  const nextLowBits = nextCode % (1 << nextBits) << 5 - nextBits;
207
208
  res.unshift(C32[currentCode + nextLowBits]);
@@ -214,7 +215,7 @@ function c32encode(inputHex) {
214
215
  while (leadingZeros < res.length && res[leadingZeros] === "0")
215
216
  leadingZeros++;
216
217
  const stripped = res.slice(leadingZeros);
217
- const bytes = hexToBytes(inputHex);
218
+ const bytes = hexToBytes(hex);
218
219
  let zeroBytesCount = 0;
219
220
  while (zeroBytesCount < bytes.length && bytes[zeroBytesCount] === 0)
220
221
  zeroBytesCount++;
@@ -222,21 +223,21 @@ function c32encode(inputHex) {
222
223
  return [...prefix, ...stripped].join("");
223
224
  }
224
225
  function c32decode(c32input) {
225
- c32input = c32normalize(c32input);
226
- if (!c32input.match(`^[${C32}]*$`))
226
+ const input = c32normalize(c32input);
227
+ if (!input.match(`^[${C32}]*$`))
227
228
  throw new Error("Not a c32-encoded string");
228
- const zeroPrefix = c32input.match(`^${C32[0]}*`);
229
- const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0].length : 0;
229
+ const zeroPrefix = input.match(`^${C32[0]}*`);
230
+ const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]?.length : 0;
230
231
  const res = [];
231
232
  let carry = 0;
232
233
  let carryBits = 0;
233
- for (let i = c32input.length - 1;i >= 0; i--) {
234
+ for (let i = input.length - 1;i >= 0; i--) {
234
235
  if (carryBits === 4) {
235
236
  res.unshift(HEX[carry]);
236
237
  carryBits = 0;
237
238
  carry = 0;
238
239
  }
239
- const currentValue = (C32.indexOf(c32input[i]) << carryBits) + carry;
240
+ const currentValue = (C32.indexOf(input[i]) << carryBits) + carry;
240
241
  res.unshift(HEX[currentValue % 16]);
241
242
  carryBits += 1;
242
243
  carry = currentValue >> 4;
@@ -262,19 +263,19 @@ function c32checkEncode(version, data) {
262
263
  throw new Error("Invalid version (must be between 0 and 31)");
263
264
  if (!data.match(/^[0-9a-fA-F]*$/))
264
265
  throw new Error("Invalid data (not a hex string)");
265
- data = data.toLowerCase();
266
- if (data.length % 2 !== 0)
267
- data = `0${data}`;
266
+ let d = data.toLowerCase();
267
+ if (d.length % 2 !== 0)
268
+ d = `0${d}`;
268
269
  let versionHex = version.toString(16);
269
270
  if (versionHex.length === 1)
270
271
  versionHex = `0${versionHex}`;
271
- const checksumHex = c32checksum(`${versionHex}${data}`);
272
- return `${C32[version]}${c32encode(`${data}${checksumHex}`)}`;
272
+ const checksumHex = c32checksum(`${versionHex}${d}`);
273
+ return `${C32[version]}${c32encode(`${d}${checksumHex}`)}`;
273
274
  }
274
275
  function c32checkDecode(c32data) {
275
- c32data = c32normalize(c32data);
276
- const dataHex = c32decode(c32data.slice(1));
277
- const version = C32.indexOf(c32data[0]);
276
+ const normalized = c32normalize(c32data);
277
+ const dataHex = c32decode(normalized.slice(1));
278
+ const version = C32.indexOf(normalized[0]);
278
279
  const checksum = dataHex.slice(-8);
279
280
  let versionHex = version.toString(16);
280
281
  if (versionHex.length === 1)
@@ -399,7 +400,7 @@ function serializeCVBytes(value) {
399
400
  return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
400
401
  }
401
402
  default:
402
- throw new Error(`Cannot serialize unknown clarity type`);
403
+ throw new Error("Cannot serialize unknown clarity type");
403
404
  }
404
405
  }
405
406
 
@@ -506,12 +507,11 @@ function serializeSpendingCondition(condition) {
506
507
  }
507
508
  function serializeAuthField(field) {
508
509
  if (field.type === "publicKey") {
509
- const typeId = field.pubKeyEncoding === 0 ? 0 : 1;
510
- return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
511
- } else {
512
- const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
513
- return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
510
+ const typeId2 = field.pubKeyEncoding === 0 ? 0 : 1;
511
+ return concatBytes(writeUInt8(typeId2), hexToBytes(field.data));
514
512
  }
513
+ const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
514
+ return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
515
515
  }
516
516
  function serializeAuthorization(auth) {
517
517
  const parts = [writeUInt8(auth.authType)];
@@ -645,7 +645,7 @@ async function estimateFee(client, params) {
645
645
  method: "POST",
646
646
  body: {
647
647
  estimated_len: Math.ceil(txHex.length / 2),
648
- transaction_payload: "0x" + payloadHex
648
+ transaction_payload: `0x${payloadHex}`
649
649
  }
650
650
  });
651
651
  return (data.estimations ?? []).map((e) => ({
@@ -747,12 +747,13 @@ var MAX_U128 = BigInt("0xffffffffffffffffffffffffffffffff");
747
747
  var MIN_I128 = BigInt("-170141183460469231731687303715884105728");
748
748
  var MAX_I128 = BigInt("0x7fffffffffffffffffffffffffffffff");
749
749
  function intCV(value) {
750
- if (typeof value === "string" && value.toLowerCase().startsWith("0x")) {
751
- value = bytesToTwosBigInt(hexToBytes(value));
750
+ let v = value;
751
+ if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
752
+ v = bytesToTwosBigInt(hexToBytes(v));
752
753
  }
753
- if (value instanceof Uint8Array)
754
- value = bytesToTwosBigInt(value);
755
- const n = intToBigInt(value);
754
+ if (v instanceof Uint8Array)
755
+ v = bytesToTwosBigInt(v);
756
+ const n = intToBigInt(v);
756
757
  if (n > MAX_I128)
757
758
  throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);
758
759
  if (n < MIN_I128)
@@ -1134,7 +1135,8 @@ function hashP2PKH(input) {
1134
1135
  // src/transactions/authorization.ts
1135
1136
  import_secp256k1.etc.hmacSha256Sync = (key, ...msgs) => {
1136
1137
  const h = import_hmac.hmac.create(import_sha24.sha256, key);
1137
- msgs.forEach((msg) => h.update(msg));
1138
+ for (const msg of msgs)
1139
+ h.update(msg);
1138
1140
  return h.digest();
1139
1141
  };
1140
1142
  var EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));
@@ -2067,9 +2069,6 @@ async function simulateTransaction(client, params) {
2067
2069
  // src/errors/websocket.ts
2068
2070
  class WebSocketError extends BaseError {
2069
2071
  name = "WebSocketError";
2070
- constructor(message, options) {
2071
- super(message, options);
2072
- }
2073
2072
  }
2074
2073
 
2075
2074
  // src/subscriptions/actions.ts
@@ -2466,5 +2465,5 @@ var getNftHoldings = import_ai.tool({
2466
2465
  execute: ({ principal, limit }) => nftHoldings(getDefaultPublicClient(), principal, limit)
2467
2466
  });
2468
2467
 
2469
- //# debugId=78ADB847A6E583D464756E2164756E21
2468
+ //# debugId=5BBF31DE9C4100A864756E2164756E21
2470
2469
  //# sourceMappingURL=index.cjs.map