@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
@@ -18,13 +18,13 @@ function bytesToHex(bytes) {
18
18
  return hex;
19
19
  }
20
20
  function hexToBytes(hex) {
21
- hex = without0x(hex);
22
- if (hex.length % 2)
23
- hex = `0${hex}`;
24
- const array = new Uint8Array(hex.length / 2);
21
+ let h = without0x(hex);
22
+ if (h.length % 2)
23
+ h = `0${h}`;
24
+ const array = new Uint8Array(h.length / 2);
25
25
  for (let i = 0;i < array.length; i++) {
26
26
  const j = i * 2;
27
- const byte = Number.parseInt(hex.slice(j, j + 2), 16);
27
+ const byte = Number.parseInt(h.slice(j, j + 2), 16);
28
28
  if (Number.isNaN(byte) || byte < 0)
29
29
  throw new Error("Invalid byte sequence");
30
30
  array[i] = byte;
@@ -140,15 +140,16 @@ function c32normalize(input) {
140
140
  return input.toUpperCase().replace(/O/g, "0").replace(/L|I/g, "1");
141
141
  }
142
142
  function c32encode(inputHex) {
143
- if (inputHex.length % 2 !== 0)
144
- inputHex = `0${inputHex}`;
145
- inputHex = inputHex.toLowerCase();
143
+ let hex = inputHex;
144
+ if (hex.length % 2 !== 0)
145
+ hex = `0${hex}`;
146
+ hex = hex.toLowerCase();
146
147
  const res = [];
147
148
  let carry = 0;
148
- for (let i = inputHex.length - 1;i >= 0; i--) {
149
+ for (let i = hex.length - 1;i >= 0; i--) {
149
150
  if (carry < 4) {
150
- const currentCode = HEX.indexOf(inputHex[i]) >> carry;
151
- const nextCode = i !== 0 ? HEX.indexOf(inputHex[i - 1]) : 0;
151
+ const currentCode = HEX.indexOf(hex[i]) >> carry;
152
+ const nextCode = i !== 0 ? HEX.indexOf(hex[i - 1]) : 0;
152
153
  const nextBits = 1 + carry;
153
154
  const nextLowBits = nextCode % (1 << nextBits) << 5 - nextBits;
154
155
  res.unshift(C32[currentCode + nextLowBits]);
@@ -161,7 +162,7 @@ function c32encode(inputHex) {
161
162
  while (leadingZeros < res.length && res[leadingZeros] === "0")
162
163
  leadingZeros++;
163
164
  const stripped = res.slice(leadingZeros);
164
- const bytes = hexToBytes(inputHex);
165
+ const bytes = hexToBytes(hex);
165
166
  let zeroBytesCount = 0;
166
167
  while (zeroBytesCount < bytes.length && bytes[zeroBytesCount] === 0)
167
168
  zeroBytesCount++;
@@ -169,21 +170,21 @@ function c32encode(inputHex) {
169
170
  return [...prefix, ...stripped].join("");
170
171
  }
171
172
  function c32decode(c32input) {
172
- c32input = c32normalize(c32input);
173
- if (!c32input.match(`^[${C32}]*$`))
173
+ const input = c32normalize(c32input);
174
+ if (!input.match(`^[${C32}]*$`))
174
175
  throw new Error("Not a c32-encoded string");
175
- const zeroPrefix = c32input.match(`^${C32[0]}*`);
176
- const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0].length : 0;
176
+ const zeroPrefix = input.match(`^${C32[0]}*`);
177
+ const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]?.length : 0;
177
178
  const res = [];
178
179
  let carry = 0;
179
180
  let carryBits = 0;
180
- for (let i = c32input.length - 1;i >= 0; i--) {
181
+ for (let i = input.length - 1;i >= 0; i--) {
181
182
  if (carryBits === 4) {
182
183
  res.unshift(HEX[carry]);
183
184
  carryBits = 0;
184
185
  carry = 0;
185
186
  }
186
- const currentValue = (C32.indexOf(c32input[i]) << carryBits) + carry;
187
+ const currentValue = (C32.indexOf(input[i]) << carryBits) + carry;
187
188
  res.unshift(HEX[currentValue % 16]);
188
189
  carryBits += 1;
189
190
  carry = currentValue >> 4;
@@ -209,19 +210,19 @@ function c32checkEncode(version, data) {
209
210
  throw new Error("Invalid version (must be between 0 and 31)");
210
211
  if (!data.match(/^[0-9a-fA-F]*$/))
211
212
  throw new Error("Invalid data (not a hex string)");
212
- data = data.toLowerCase();
213
- if (data.length % 2 !== 0)
214
- data = `0${data}`;
213
+ let d = data.toLowerCase();
214
+ if (d.length % 2 !== 0)
215
+ d = `0${d}`;
215
216
  let versionHex = version.toString(16);
216
217
  if (versionHex.length === 1)
217
218
  versionHex = `0${versionHex}`;
218
- const checksumHex = c32checksum(`${versionHex}${data}`);
219
- return `${C32[version]}${c32encode(`${data}${checksumHex}`)}`;
219
+ const checksumHex = c32checksum(`${versionHex}${d}`);
220
+ return `${C32[version]}${c32encode(`${d}${checksumHex}`)}`;
220
221
  }
221
222
  function c32checkDecode(c32data) {
222
- c32data = c32normalize(c32data);
223
- const dataHex = c32decode(c32data.slice(1));
224
- const version = C32.indexOf(c32data[0]);
223
+ const normalized = c32normalize(c32data);
224
+ const dataHex = c32decode(normalized.slice(1));
225
+ const version = C32.indexOf(normalized[0]);
225
226
  const checksum = dataHex.slice(-8);
226
227
  let versionHex = version.toString(16);
227
228
  if (versionHex.length === 1)
@@ -346,7 +347,7 @@ function serializeCVBytes(value) {
346
347
  return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
347
348
  }
348
349
  default:
349
- throw new Error(`Cannot serialize unknown clarity type`);
350
+ throw new Error("Cannot serialize unknown clarity type");
350
351
  }
351
352
  }
352
353
 
@@ -453,12 +454,11 @@ function serializeSpendingCondition(condition) {
453
454
  }
454
455
  function serializeAuthField(field) {
455
456
  if (field.type === "publicKey") {
456
- const typeId = field.pubKeyEncoding === 0 ? 0 : 1;
457
- return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
458
- } else {
459
- const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
460
- return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
457
+ const typeId2 = field.pubKeyEncoding === 0 ? 0 : 1;
458
+ return concatBytes(writeUInt8(typeId2), hexToBytes(field.data));
461
459
  }
460
+ const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
461
+ return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
462
462
  }
463
463
  function serializeAuthorization(auth) {
464
464
  const parts = [writeUInt8(auth.authType)];
@@ -592,7 +592,7 @@ async function estimateFee(client, params) {
592
592
  method: "POST",
593
593
  body: {
594
594
  estimated_len: Math.ceil(txHex.length / 2),
595
- transaction_payload: "0x" + payloadHex
595
+ transaction_payload: `0x${payloadHex}`
596
596
  }
597
597
  });
598
598
  return (data.estimations ?? []).map((e) => ({
@@ -694,12 +694,13 @@ var MAX_U128 = BigInt("0xffffffffffffffffffffffffffffffff");
694
694
  var MIN_I128 = BigInt("-170141183460469231731687303715884105728");
695
695
  var MAX_I128 = BigInt("0x7fffffffffffffffffffffffffffffff");
696
696
  function intCV(value) {
697
- if (typeof value === "string" && value.toLowerCase().startsWith("0x")) {
698
- value = bytesToTwosBigInt(hexToBytes(value));
697
+ let v = value;
698
+ if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
699
+ v = bytesToTwosBigInt(hexToBytes(v));
699
700
  }
700
- if (value instanceof Uint8Array)
701
- value = bytesToTwosBigInt(value);
702
- const n = intToBigInt(value);
701
+ if (v instanceof Uint8Array)
702
+ v = bytesToTwosBigInt(v);
703
+ const n = intToBigInt(v);
703
704
  if (n > MAX_I128)
704
705
  throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);
705
706
  if (n < MIN_I128)
@@ -1081,7 +1082,8 @@ function hashP2PKH(input) {
1081
1082
  // src/transactions/authorization.ts
1082
1083
  etc.hmacSha256Sync = (key, ...msgs) => {
1083
1084
  const h = hmac.create(sha2563, key);
1084
- msgs.forEach((msg) => h.update(msg));
1085
+ for (const msg of msgs)
1086
+ h.update(msg);
1085
1087
  return h.digest();
1086
1088
  };
1087
1089
  var EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));
@@ -2017,9 +2019,6 @@ async function simulateTransaction(client, params) {
2017
2019
  // src/errors/websocket.ts
2018
2020
  class WebSocketError extends BaseError {
2019
2021
  name = "WebSocketError";
2020
- constructor(message, options) {
2021
- super(message, options);
2022
- }
2023
2022
  }
2024
2023
 
2025
2024
  // src/subscriptions/actions.ts
@@ -2431,5 +2430,5 @@ export {
2431
2430
  bnsResolve
2432
2431
  };
2433
2432
 
2434
- //# debugId=233963F854D70C5B64756E2164756E21
2433
+ //# debugId=D11981BB65E0A0F464756E2164756E21
2435
2434
  //# sourceMappingURL=index.js.map