@secondlayer/stacks 6.6.0 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/shared/{stacks-esm-p3rrvmd8.js → stacks-esm-0t9vwtwh.js} +9 -9
  2. package/dist/shared/{stacks-esm-75qv0d9h.js → stacks-esm-1f46cr7b.js} +6 -6
  3. package/dist/shared/{stacks-esm-2cac1jn9.js → stacks-esm-2z40q8gs.js} +4 -4
  4. package/dist/shared/{stacks-esm-ev07d2aw.js → stacks-esm-4rjjsz3p.js} +3 -3
  5. package/dist/shared/{stacks-esm-5eq7meyt.js → stacks-esm-8p8xy3dz.js} +16 -4
  6. package/dist/shared/stacks-esm-8p8xy3dz.js.map +12 -0
  7. package/dist/shared/{stacks-esm-h82jj95c.js → stacks-esm-9ptct1c4.js} +3 -3
  8. package/dist/shared/{stacks-esm-qasbsv66.js → stacks-esm-a7apmjbk.js} +2 -2
  9. package/dist/shared/{stacks-esm-1nfzrepv.js → stacks-esm-brtqryjb.js} +4 -4
  10. package/dist/shared/{stacks-esm-pc20c78w.js → stacks-esm-e63kx7dq.js} +3 -3
  11. package/dist/shared/{stacks-esm-tsb8h0yr.js → stacks-esm-eep45e8s.js} +2 -2
  12. package/dist/shared/{stacks-esm-wnxhfx93.js → stacks-esm-fmq4j4ez.js} +2 -2
  13. package/dist/shared/{stacks-esm-7tc40d6t.js → stacks-esm-h60faj2n.js} +2 -2
  14. package/dist/shared/{stacks-esm-6zfssx7v.js → stacks-esm-hcaycch3.js} +3 -3
  15. package/dist/shared/{stacks-esm-cs4419br.js → stacks-esm-jwgtksgq.js} +32 -15
  16. package/dist/shared/stacks-esm-jwgtksgq.js.map +15 -0
  17. package/dist/shared/{stacks-esm-8chm2wtn.js → stacks-esm-m8ph0bvw.js} +7 -7
  18. package/dist/shared/{stacks-esm-hm7kb2cp.js → stacks-esm-mqhwqhq4.js} +4 -4
  19. package/dist/shared/{stacks-esm-tfechw5c.js → stacks-esm-nqkwt2z7.js} +2 -2
  20. package/dist/shared/{stacks-esm-mmvrwreq.js → stacks-esm-wjg9aer9.js} +4 -4
  21. package/dist/shared/{stacks-esm-scq242d9.js → stacks-esm-zsdw7fq3.js} +3 -3
  22. package/dist/src/accounts/index.cjs +14 -2
  23. package/dist/src/accounts/index.cjs.map +3 -3
  24. package/dist/src/accounts/index.js +2 -2
  25. package/dist/src/actions/index.cjs +41 -13
  26. package/dist/src/actions/index.cjs.map +5 -5
  27. package/dist/src/actions/index.js +12 -12
  28. package/dist/src/bitcoin/index.cjs +41 -13
  29. package/dist/src/bitcoin/index.cjs.map +5 -5
  30. package/dist/src/bitcoin/index.js +10 -10
  31. package/dist/src/bns/index.cjs +41 -13
  32. package/dist/src/bns/index.cjs.map +5 -5
  33. package/dist/src/bns/index.js +12 -12
  34. package/dist/src/clarity/index.cjs +41 -13
  35. package/dist/src/clarity/index.cjs.map +5 -5
  36. package/dist/src/clarity/index.js +6 -6
  37. package/dist/src/connect/index.cjs +30 -7
  38. package/dist/src/connect/index.cjs.map +5 -5
  39. package/dist/src/connect/index.js +30 -7
  40. package/dist/src/connect/index.js.map +5 -5
  41. package/dist/src/connect/walletconnect/index.cjs +3 -1
  42. package/dist/src/connect/walletconnect/index.cjs.map +3 -3
  43. package/dist/src/connect/walletconnect/index.js +3 -1
  44. package/dist/src/connect/walletconnect/index.js.map +3 -3
  45. package/dist/src/filters/index.cjs +14 -2
  46. package/dist/src/filters/index.cjs.map +3 -3
  47. package/dist/src/filters/index.js +3 -3
  48. package/dist/src/index.cjs +44 -16
  49. package/dist/src/index.cjs.map +5 -5
  50. package/dist/src/index.js +11 -11
  51. package/dist/src/postconditions/index.cjs +41 -13
  52. package/dist/src/postconditions/index.cjs.map +5 -5
  53. package/dist/src/postconditions/index.js +5 -5
  54. package/dist/src/pox/index.cjs +41 -13
  55. package/dist/src/pox/index.cjs.map +5 -5
  56. package/dist/src/pox/index.js +12 -12
  57. package/dist/src/pox5/index.cjs +41 -13
  58. package/dist/src/pox5/index.cjs.map +5 -5
  59. package/dist/src/pox5/index.js +14 -14
  60. package/dist/src/sbtc/index.cjs +41 -13
  61. package/dist/src/sbtc/index.cjs.map +5 -5
  62. package/dist/src/sbtc/index.js +12 -12
  63. package/dist/src/simnet/index.cjs +44 -16
  64. package/dist/src/simnet/index.cjs.map +5 -5
  65. package/dist/src/simnet/index.js +44 -16
  66. package/dist/src/simnet/index.js.map +5 -5
  67. package/dist/src/stackingdao/index.cjs +41 -13
  68. package/dist/src/stackingdao/index.cjs.map +5 -5
  69. package/dist/src/stackingdao/index.js +10 -10
  70. package/dist/src/transactions/index.cjs +44 -16
  71. package/dist/src/transactions/index.cjs.map +5 -5
  72. package/dist/src/transactions/index.js +5 -5
  73. package/dist/src/utils/index.cjs +14 -2
  74. package/dist/src/utils/index.cjs.map +3 -3
  75. package/dist/src/utils/index.js +2 -2
  76. package/package.json +1 -1
  77. package/dist/shared/stacks-esm-5eq7meyt.js.map +0 -12
  78. package/dist/shared/stacks-esm-cs4419br.js.map +0 -15
  79. /package/dist/shared/{stacks-esm-p3rrvmd8.js.map → stacks-esm-0t9vwtwh.js.map} +0 -0
  80. /package/dist/shared/{stacks-esm-75qv0d9h.js.map → stacks-esm-1f46cr7b.js.map} +0 -0
  81. /package/dist/shared/{stacks-esm-2cac1jn9.js.map → stacks-esm-2z40q8gs.js.map} +0 -0
  82. /package/dist/shared/{stacks-esm-ev07d2aw.js.map → stacks-esm-4rjjsz3p.js.map} +0 -0
  83. /package/dist/shared/{stacks-esm-h82jj95c.js.map → stacks-esm-9ptct1c4.js.map} +0 -0
  84. /package/dist/shared/{stacks-esm-qasbsv66.js.map → stacks-esm-a7apmjbk.js.map} +0 -0
  85. /package/dist/shared/{stacks-esm-1nfzrepv.js.map → stacks-esm-brtqryjb.js.map} +0 -0
  86. /package/dist/shared/{stacks-esm-pc20c78w.js.map → stacks-esm-e63kx7dq.js.map} +0 -0
  87. /package/dist/shared/{stacks-esm-tsb8h0yr.js.map → stacks-esm-eep45e8s.js.map} +0 -0
  88. /package/dist/shared/{stacks-esm-wnxhfx93.js.map → stacks-esm-fmq4j4ez.js.map} +0 -0
  89. /package/dist/shared/{stacks-esm-7tc40d6t.js.map → stacks-esm-h60faj2n.js.map} +0 -0
  90. /package/dist/shared/{stacks-esm-6zfssx7v.js.map → stacks-esm-hcaycch3.js.map} +0 -0
  91. /package/dist/shared/{stacks-esm-8chm2wtn.js.map → stacks-esm-m8ph0bvw.js.map} +0 -0
  92. /package/dist/shared/{stacks-esm-hm7kb2cp.js.map → stacks-esm-mqhwqhq4.js.map} +0 -0
  93. /package/dist/shared/{stacks-esm-tfechw5c.js.map → stacks-esm-nqkwt2z7.js.map} +0 -0
  94. /package/dist/shared/{stacks-esm-mmvrwreq.js.map → stacks-esm-wjg9aer9.js.map} +0 -0
  95. /package/dist/shared/{stacks-esm-scq242d9.js.map → stacks-esm-zsdw7fq3.js.map} +0 -0
@@ -194,6 +194,8 @@ function bytesToHex(bytes) {
194
194
  }
195
195
  function hexToBytes(hex) {
196
196
  let h = without0x(hex);
197
+ if (!/^[0-9a-fA-F]*$/.test(h))
198
+ throw new Error("Invalid byte sequence");
197
199
  if (h.length % 2)
198
200
  h = `0${h}`;
199
201
  const array = new Uint8Array(h.length / 2);
@@ -225,6 +227,13 @@ function asciiToBytes(str) {
225
227
  }
226
228
  return bytes;
227
229
  }
230
+ function isAscii(str) {
231
+ for (let i = 0;i < str.length; i++) {
232
+ if (str.charCodeAt(i) > 127)
233
+ return false;
234
+ }
235
+ return true;
236
+ }
228
237
  function bytesToAscii(bytes) {
229
238
  return String.fromCharCode(...bytes);
230
239
  }
@@ -243,8 +252,11 @@ function concatBytes(...arrays) {
243
252
  function intToBigInt(value) {
244
253
  if (typeof value === "bigint")
245
254
  return value;
246
- if (typeof value === "string")
255
+ if (typeof value === "string") {
256
+ if (value.trim() === "")
257
+ throw new SyntaxError("Cannot convert an empty string to an integer");
247
258
  return BigInt(value);
259
+ }
248
260
  if (typeof value === "number") {
249
261
  if (!Number.isInteger(value))
250
262
  throw new RangeError("Values of type 'number' must be an integer.");
@@ -854,6 +866,10 @@ function deserializeCV(input) {
854
866
  // src/clarity/serialize.ts
855
867
  var CLARITY_INT_SIZE = 128n;
856
868
  var CLARITY_INT_BYTE_SIZE = 16;
869
+ var MAX_U1282 = (1n << 128n) - 1n;
870
+ var MAX_I1282 = (1n << 127n) - 1n;
871
+ var MIN_I1282 = -(1n << 127n);
872
+ var MAX_STRING_BYTES = 1048576;
857
873
  function typeIdByte(type) {
858
874
  return ClarityWireType[type];
859
875
  }
@@ -875,11 +891,17 @@ function serializeCVBytes(value) {
875
891
  case "false":
876
892
  return new Uint8Array([typeIdByte(value.type)]);
877
893
  case "int": {
878
- const bytes = bigIntToBytes(toTwos(BigInt(value.value), CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
894
+ const n = BigInt(value.value);
895
+ if (n > MAX_I1282 || n < MIN_I1282)
896
+ throw new RangeError(`Int is outside i128: ${n}`);
897
+ const bytes = bigIntToBytes(toTwos(n, CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
879
898
  return withTypeId(value.type, bytes);
880
899
  }
881
900
  case "uint": {
882
- const bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);
901
+ const n = BigInt(value.value);
902
+ if (n < 0n || n > MAX_U1282)
903
+ throw new RangeError(`UInt is outside u128: ${n}`);
904
+ const bytes = bigIntToBytes(n, CLARITY_INT_BYTE_SIZE);
883
905
  return withTypeId(value.type, bytes);
884
906
  }
885
907
  case "buffer": {
@@ -918,6 +940,8 @@ function serializeCVBytes(value) {
918
940
  return withTypeId(value.type, concatBytes(...parts));
919
941
  }
920
942
  case "ascii": {
943
+ if (!isAscii(value.value))
944
+ throw new Error("string-ascii holds only ASCII characters");
921
945
  const strBytes = asciiToBytes(value.value);
922
946
  return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
923
947
  }
@@ -934,9 +958,9 @@ function serializeCV(value) {
934
958
  }
935
959
 
936
960
  // src/clarity/values.ts
937
- var MAX_U1282 = BigInt("0xffffffffffffffffffffffffffffffff");
938
- var MIN_I1282 = BigInt("-170141183460469231731687303715884105728");
939
- var MAX_I1282 = BigInt("0x7fffffffffffffffffffffffffffffff");
961
+ var MAX_U1283 = BigInt("0xffffffffffffffffffffffffffffffff");
962
+ var MIN_I1283 = BigInt("-170141183460469231731687303715884105728");
963
+ var MAX_I1283 = BigInt("0x7fffffffffffffffffffffffffffffff");
940
964
  function intCV(value) {
941
965
  let v = value;
942
966
  if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
@@ -945,18 +969,18 @@ function intCV(value) {
945
969
  if (v instanceof Uint8Array)
946
970
  v = bytesToTwosBigInt(v);
947
971
  const n = intToBigInt(v);
948
- if (n > MAX_I1282)
949
- throw new RangeError(`Int exceeds max i128: ${MAX_I1282}`);
950
- if (n < MIN_I1282)
951
- throw new RangeError(`Int below min i128: ${MIN_I1282}`);
972
+ if (n > MAX_I1283)
973
+ throw new RangeError(`Int exceeds max i128: ${MAX_I1283}`);
974
+ if (n < MIN_I1283)
975
+ throw new RangeError(`Int below min i128: ${MIN_I1283}`);
952
976
  return { type: "int", value: n };
953
977
  }
954
978
  function uintCV(value) {
955
979
  const n = intToBigInt(value);
956
980
  if (n < 0n)
957
981
  throw new RangeError("Cannot construct unsigned int from negative value");
958
- if (n > MAX_U1282)
959
- throw new RangeError(`UInt exceeds max u128: ${MAX_U1282}`);
982
+ if (n > MAX_U1283)
983
+ throw new RangeError(`UInt exceeds max u128: ${MAX_U1283}`);
960
984
  return { type: "uint", value: n };
961
985
  }
962
986
  var trueCV = () => ({ type: "true" });
@@ -1005,6 +1029,10 @@ function tupleCV(data) {
1005
1029
  return { type: "tuple", value: data };
1006
1030
  }
1007
1031
  function stringAsciiCV(value) {
1032
+ if (!isAscii(value))
1033
+ throw new Error("string-ascii holds only ASCII characters");
1034
+ if (value.length > MAX_STRING_BYTES)
1035
+ throw new Error(`string-ascii exceeds max size of ${MAX_STRING_BYTES} bytes`);
1008
1036
  return { type: "ascii", value };
1009
1037
  }
1010
1038
  function stringUtf8CV(value) {
@@ -5052,5 +5080,5 @@ function bns() {
5052
5080
  });
5053
5081
  }
5054
5082
 
5055
- //# debugId=A9DAE49794B4075B64756E2164756E21
5083
+ //# debugId=3B65CDE034385B7364756E2164756E21
5056
5084
  //# sourceMappingURL=index.cjs.map