@secondlayer/stacks 6.5.4 → 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 (103) hide show
  1. package/dist/shared/{stacks-esm-17adzt3x.js → stacks-esm-0t9vwtwh.js} +9 -9
  2. package/dist/shared/{stacks-esm-s3natb0x.js → stacks-esm-1f46cr7b.js} +8 -8
  3. package/dist/shared/{stacks-esm-s3natb0x.js.map → stacks-esm-1f46cr7b.js.map} +3 -3
  4. package/dist/shared/{stacks-esm-2cac1jn9.js → stacks-esm-2z40q8gs.js} +4 -4
  5. package/dist/shared/{stacks-esm-ev07d2aw.js → stacks-esm-4rjjsz3p.js} +3 -3
  6. package/dist/shared/{stacks-esm-5eq7meyt.js → stacks-esm-8p8xy3dz.js} +16 -4
  7. package/dist/shared/stacks-esm-8p8xy3dz.js.map +12 -0
  8. package/dist/shared/{stacks-esm-h82jj95c.js → stacks-esm-9ptct1c4.js} +3 -3
  9. package/dist/shared/{stacks-esm-qasbsv66.js → stacks-esm-a7apmjbk.js} +2 -2
  10. package/dist/shared/{stacks-esm-1nfzrepv.js → stacks-esm-brtqryjb.js} +4 -4
  11. package/dist/shared/{stacks-esm-pc20c78w.js → stacks-esm-e63kx7dq.js} +3 -3
  12. package/dist/shared/{stacks-esm-tsb8h0yr.js → stacks-esm-eep45e8s.js} +2 -2
  13. package/dist/shared/{stacks-esm-wnxhfx93.js → stacks-esm-fmq4j4ez.js} +2 -2
  14. package/dist/shared/{stacks-esm-7tc40d6t.js → stacks-esm-h60faj2n.js} +2 -2
  15. package/dist/shared/{stacks-esm-6zfssx7v.js → stacks-esm-hcaycch3.js} +3 -3
  16. package/dist/shared/{stacks-esm-cs4419br.js → stacks-esm-jwgtksgq.js} +32 -15
  17. package/dist/shared/stacks-esm-jwgtksgq.js.map +15 -0
  18. package/dist/shared/{stacks-esm-jm688fhe.js → stacks-esm-m8ph0bvw.js} +19 -11
  19. package/dist/shared/{stacks-esm-jm688fhe.js.map → stacks-esm-m8ph0bvw.js.map} +4 -4
  20. package/dist/shared/{stacks-esm-hm7kb2cp.js → stacks-esm-mqhwqhq4.js} +4 -4
  21. package/dist/shared/{stacks-esm-tfechw5c.js → stacks-esm-nqkwt2z7.js} +2 -2
  22. package/dist/shared/{stacks-esm-mmvrwreq.js → stacks-esm-wjg9aer9.js} +4 -4
  23. package/dist/shared/{stacks-esm-scq242d9.js → stacks-esm-zsdw7fq3.js} +3 -3
  24. package/dist/src/accounts/index.cjs +14 -2
  25. package/dist/src/accounts/index.cjs.map +3 -3
  26. package/dist/src/accounts/index.js +2 -2
  27. package/dist/src/actions/index.cjs +52 -16
  28. package/dist/src/actions/index.cjs.map +8 -8
  29. package/dist/src/actions/index.d.cts +2 -0
  30. package/dist/src/actions/index.d.ts +2 -0
  31. package/dist/src/actions/index.js +12 -12
  32. package/dist/src/bitcoin/index.cjs +41 -13
  33. package/dist/src/bitcoin/index.cjs.map +5 -5
  34. package/dist/src/bitcoin/index.js +10 -10
  35. package/dist/src/bns/index.cjs +52 -16
  36. package/dist/src/bns/index.cjs.map +8 -8
  37. package/dist/src/bns/index.js +12 -12
  38. package/dist/src/clarity/index.cjs +41 -13
  39. package/dist/src/clarity/index.cjs.map +5 -5
  40. package/dist/src/clarity/index.js +6 -6
  41. package/dist/src/connect/index.cjs +30 -7
  42. package/dist/src/connect/index.cjs.map +5 -5
  43. package/dist/src/connect/index.js +30 -7
  44. package/dist/src/connect/index.js.map +5 -5
  45. package/dist/src/connect/walletconnect/index.cjs +3 -1
  46. package/dist/src/connect/walletconnect/index.cjs.map +3 -3
  47. package/dist/src/connect/walletconnect/index.js +3 -1
  48. package/dist/src/connect/walletconnect/index.js.map +3 -3
  49. package/dist/src/filters/index.cjs +14 -2
  50. package/dist/src/filters/index.cjs.map +3 -3
  51. package/dist/src/filters/index.js +3 -3
  52. package/dist/src/index.cjs +75 -20
  53. package/dist/src/index.cjs.map +9 -9
  54. package/dist/src/index.d.cts +8 -0
  55. package/dist/src/index.d.ts +8 -0
  56. package/dist/src/index.js +40 -14
  57. package/dist/src/index.js.map +4 -4
  58. package/dist/src/postconditions/index.cjs +41 -13
  59. package/dist/src/postconditions/index.cjs.map +5 -5
  60. package/dist/src/postconditions/index.js +5 -5
  61. package/dist/src/pox/index.cjs +52 -16
  62. package/dist/src/pox/index.cjs.map +8 -8
  63. package/dist/src/pox/index.js +12 -12
  64. package/dist/src/pox5/index.cjs +52 -16
  65. package/dist/src/pox5/index.cjs.map +8 -8
  66. package/dist/src/pox5/index.js +14 -14
  67. package/dist/src/sbtc/index.cjs +52 -16
  68. package/dist/src/sbtc/index.cjs.map +8 -8
  69. package/dist/src/sbtc/index.js +12 -12
  70. package/dist/src/simnet/index.cjs +44 -16
  71. package/dist/src/simnet/index.cjs.map +5 -5
  72. package/dist/src/simnet/index.js +44 -16
  73. package/dist/src/simnet/index.js.map +5 -5
  74. package/dist/src/stackingdao/index.cjs +52 -16
  75. package/dist/src/stackingdao/index.cjs.map +8 -8
  76. package/dist/src/stackingdao/index.js +10 -10
  77. package/dist/src/transactions/index.cjs +44 -16
  78. package/dist/src/transactions/index.cjs.map +5 -5
  79. package/dist/src/transactions/index.js +5 -5
  80. package/dist/src/utils/index.cjs +20 -3
  81. package/dist/src/utils/index.cjs.map +4 -4
  82. package/dist/src/utils/index.d.cts +8 -1
  83. package/dist/src/utils/index.d.ts +8 -1
  84. package/dist/src/utils/index.js +9 -4
  85. package/dist/src/utils/index.js.map +3 -3
  86. package/package.json +2 -2
  87. package/dist/shared/stacks-esm-5eq7meyt.js.map +0 -12
  88. package/dist/shared/stacks-esm-cs4419br.js.map +0 -15
  89. /package/dist/shared/{stacks-esm-17adzt3x.js.map → stacks-esm-0t9vwtwh.js.map} +0 -0
  90. /package/dist/shared/{stacks-esm-2cac1jn9.js.map → stacks-esm-2z40q8gs.js.map} +0 -0
  91. /package/dist/shared/{stacks-esm-ev07d2aw.js.map → stacks-esm-4rjjsz3p.js.map} +0 -0
  92. /package/dist/shared/{stacks-esm-h82jj95c.js.map → stacks-esm-9ptct1c4.js.map} +0 -0
  93. /package/dist/shared/{stacks-esm-qasbsv66.js.map → stacks-esm-a7apmjbk.js.map} +0 -0
  94. /package/dist/shared/{stacks-esm-1nfzrepv.js.map → stacks-esm-brtqryjb.js.map} +0 -0
  95. /package/dist/shared/{stacks-esm-pc20c78w.js.map → stacks-esm-e63kx7dq.js.map} +0 -0
  96. /package/dist/shared/{stacks-esm-tsb8h0yr.js.map → stacks-esm-eep45e8s.js.map} +0 -0
  97. /package/dist/shared/{stacks-esm-wnxhfx93.js.map → stacks-esm-fmq4j4ez.js.map} +0 -0
  98. /package/dist/shared/{stacks-esm-7tc40d6t.js.map → stacks-esm-h60faj2n.js.map} +0 -0
  99. /package/dist/shared/{stacks-esm-6zfssx7v.js.map → stacks-esm-hcaycch3.js.map} +0 -0
  100. /package/dist/shared/{stacks-esm-hm7kb2cp.js.map → stacks-esm-mqhwqhq4.js.map} +0 -0
  101. /package/dist/shared/{stacks-esm-tfechw5c.js.map → stacks-esm-nqkwt2z7.js.map} +0 -0
  102. /package/dist/shared/{stacks-esm-mmvrwreq.js.map → stacks-esm-wjg9aer9.js.map} +0 -0
  103. /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) {
@@ -3274,6 +3302,13 @@ function assertNoFeeTierForProvider(fee) {
3274
3302
  throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
3275
3303
  }
3276
3304
  }
3305
+ function resolveCallArgs(params) {
3306
+ const { args, functionArgs } = params;
3307
+ if (args !== undefined && functionArgs !== undefined) {
3308
+ throw new Error("Pass args or functionArgs, not both (functionArgs is deprecated)");
3309
+ }
3310
+ return args ?? functionArgs ?? [];
3311
+ }
3277
3312
 
3278
3313
  // src/actions/wallet/callContract.ts
3279
3314
  async function callContract(client, params) {
@@ -3281,12 +3316,13 @@ async function callContract(client, params) {
3281
3316
  if (!account)
3282
3317
  throw new Error("Account required");
3283
3318
  const [contractAddress, contractName] = parseContractId(params.contract);
3319
+ const args = resolveCallArgs(params);
3284
3320
  if (isProviderAccount(account)) {
3285
3321
  assertNoFeeTierForProvider(params.fee);
3286
3322
  const result = await account.provider.request("stx_callContract", {
3287
3323
  contract: params.contract,
3288
3324
  functionName: params.functionName,
3289
- functionArgs: params.functionArgs ?? []
3325
+ functionArgs: args
3290
3326
  });
3291
3327
  return result.txid;
3292
3328
  }
@@ -3298,7 +3334,7 @@ async function callContract(client, params) {
3298
3334
  contractAddress,
3299
3335
  contractName,
3300
3336
  functionName: params.functionName,
3301
- functionArgs: params.functionArgs ?? [],
3337
+ functionArgs: args,
3302
3338
  fee: needsFeeResolution ? 0n : params.fee,
3303
3339
  nonce,
3304
3340
  publicKey: account.publicKey,
@@ -3380,7 +3416,7 @@ function getContract(params) {
3380
3416
  return callContract(client, {
3381
3417
  contract: contractId,
3382
3418
  functionName: fn.name,
3383
- functionArgs: clarityArgs,
3419
+ args: clarityArgs,
3384
3420
  ...options
3385
3421
  });
3386
3422
  };
@@ -5044,5 +5080,5 @@ function bns() {
5044
5080
  });
5045
5081
  }
5046
5082
 
5047
- //# debugId=5A8AEE94E03DCA9364756E2164756E21
5083
+ //# debugId=3B65CDE034385B7364756E2164756E21
5048
5084
  //# sourceMappingURL=index.cjs.map