@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
@@ -1,26 +1,26 @@
1
- import"../../shared/stacks-esm-5eq7meyt.js";
2
- import"../../shared/stacks-esm-7tc40d6t.js";
3
- import"../../shared/stacks-esm-cs4419br.js";
4
- import"../../shared/stacks-esm-ev07d2aw.js";
5
- import"../../shared/stacks-esm-2cac1jn9.js";
6
- import"../../shared/stacks-esm-mmvrwreq.js";
1
+ import"../../shared/stacks-esm-8p8xy3dz.js";
2
+ import"../../shared/stacks-esm-h60faj2n.js";
3
+ import"../../shared/stacks-esm-jwgtksgq.js";
4
+ import"../../shared/stacks-esm-4rjjsz3p.js";
5
+ import"../../shared/stacks-esm-2z40q8gs.js";
6
+ import"../../shared/stacks-esm-wjg9aer9.js";
7
7
  import {
8
8
  Pc2
9
- } from "../../shared/stacks-esm-h82jj95c.js";
10
- import"../../shared/stacks-esm-tfechw5c.js";
9
+ } from "../../shared/stacks-esm-9ptct1c4.js";
10
+ import"../../shared/stacks-esm-nqkwt2z7.js";
11
11
  import {
12
12
  POX_CONTRACTS2,
13
13
  MIN_LOCK_PERIOD2,
14
14
  MAX_LOCK_PERIOD2,
15
15
  POX_ADDRESS_VERSION2,
16
16
  parseBtcAddress2
17
- } from "../../shared/stacks-esm-tsb8h0yr.js";
17
+ } from "../../shared/stacks-esm-eep45e8s.js";
18
18
  import {
19
19
  getContract2,
20
20
  resolveNetworkContract
21
- } from "../../shared/stacks-esm-s3natb0x.js";
22
- import"../../shared/stacks-esm-jm688fhe.js";
23
- import"../../shared/stacks-esm-hm7kb2cp.js";
21
+ } from "../../shared/stacks-esm-1f46cr7b.js";
22
+ import"../../shared/stacks-esm-m8ph0bvw.js";
23
+ import"../../shared/stacks-esm-mqhwqhq4.js";
24
24
 
25
25
  // src/pox/abi.ts
26
26
  var POX_ABI = {
@@ -508,6 +508,8 @@ function bytesToHex(bytes) {
508
508
  }
509
509
  function hexToBytes(hex) {
510
510
  let h = without0x(hex);
511
+ if (!/^[0-9a-fA-F]*$/.test(h))
512
+ throw new Error("Invalid byte sequence");
511
513
  if (h.length % 2)
512
514
  h = `0${h}`;
513
515
  const array = new Uint8Array(h.length / 2);
@@ -539,6 +541,13 @@ function asciiToBytes(str) {
539
541
  }
540
542
  return bytes;
541
543
  }
544
+ function isAscii(str) {
545
+ for (let i = 0;i < str.length; i++) {
546
+ if (str.charCodeAt(i) > 127)
547
+ return false;
548
+ }
549
+ return true;
550
+ }
542
551
  function bytesToAscii(bytes) {
543
552
  return String.fromCharCode(...bytes);
544
553
  }
@@ -557,8 +566,11 @@ function concatBytes(...arrays) {
557
566
  function intToBigInt(value) {
558
567
  if (typeof value === "bigint")
559
568
  return value;
560
- if (typeof value === "string")
569
+ if (typeof value === "string") {
570
+ if (value.trim() === "")
571
+ throw new SyntaxError("Cannot convert an empty string to an integer");
561
572
  return BigInt(value);
573
+ }
562
574
  if (typeof value === "number") {
563
575
  if (!Number.isInteger(value))
564
576
  throw new RangeError("Values of type 'number' must be an integer.");
@@ -899,6 +911,10 @@ function getContractAddress(deployer, contractName) {
899
911
  // src/clarity/serialize.ts
900
912
  var CLARITY_INT_SIZE = 128n;
901
913
  var CLARITY_INT_BYTE_SIZE = 16;
914
+ var MAX_U1282 = (1n << 128n) - 1n;
915
+ var MAX_I1282 = (1n << 127n) - 1n;
916
+ var MIN_I1282 = -(1n << 127n);
917
+ var MAX_STRING_BYTES = 1048576;
902
918
  function typeIdByte(type) {
903
919
  return ClarityWireType[type];
904
920
  }
@@ -920,11 +936,17 @@ function serializeCVBytes(value) {
920
936
  case "false":
921
937
  return new Uint8Array([typeIdByte(value.type)]);
922
938
  case "int": {
923
- const bytes = bigIntToBytes(toTwos(BigInt(value.value), CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
939
+ const n = BigInt(value.value);
940
+ if (n > MAX_I1282 || n < MIN_I1282)
941
+ throw new RangeError(`Int is outside i128: ${n}`);
942
+ const bytes = bigIntToBytes(toTwos(n, CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
924
943
  return withTypeId(value.type, bytes);
925
944
  }
926
945
  case "uint": {
927
- const bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);
946
+ const n = BigInt(value.value);
947
+ if (n < 0n || n > MAX_U1282)
948
+ throw new RangeError(`UInt is outside u128: ${n}`);
949
+ const bytes = bigIntToBytes(n, CLARITY_INT_BYTE_SIZE);
928
950
  return withTypeId(value.type, bytes);
929
951
  }
930
952
  case "buffer": {
@@ -963,6 +985,8 @@ function serializeCVBytes(value) {
963
985
  return withTypeId(value.type, concatBytes(...parts));
964
986
  }
965
987
  case "ascii": {
988
+ if (!isAscii(value.value))
989
+ throw new Error("string-ascii holds only ASCII characters");
966
990
  const strBytes = asciiToBytes(value.value);
967
991
  return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
968
992
  }
@@ -979,9 +1003,9 @@ function serializeCV(value) {
979
1003
  }
980
1004
 
981
1005
  // src/clarity/values.ts
982
- var MAX_U1282 = BigInt("0xffffffffffffffffffffffffffffffff");
983
- var MIN_I1282 = BigInt("-170141183460469231731687303715884105728");
984
- var MAX_I1282 = BigInt("0x7fffffffffffffffffffffffffffffff");
1006
+ var MAX_U1283 = BigInt("0xffffffffffffffffffffffffffffffff");
1007
+ var MIN_I1283 = BigInt("-170141183460469231731687303715884105728");
1008
+ var MAX_I1283 = BigInt("0x7fffffffffffffffffffffffffffffff");
985
1009
  function intCV(value) {
986
1010
  let v = value;
987
1011
  if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
@@ -990,18 +1014,18 @@ function intCV(value) {
990
1014
  if (v instanceof Uint8Array)
991
1015
  v = bytesToTwosBigInt(v);
992
1016
  const n = intToBigInt(v);
993
- if (n > MAX_I1282)
994
- throw new RangeError(`Int exceeds max i128: ${MAX_I1282}`);
995
- if (n < MIN_I1282)
996
- throw new RangeError(`Int below min i128: ${MIN_I1282}`);
1017
+ if (n > MAX_I1283)
1018
+ throw new RangeError(`Int exceeds max i128: ${MAX_I1283}`);
1019
+ if (n < MIN_I1283)
1020
+ throw new RangeError(`Int below min i128: ${MIN_I1283}`);
997
1021
  return { type: "int", value: n };
998
1022
  }
999
1023
  function uintCV(value) {
1000
1024
  const n = intToBigInt(value);
1001
1025
  if (n < 0n)
1002
1026
  throw new RangeError("Cannot construct unsigned int from negative value");
1003
- if (n > MAX_U1282)
1004
- throw new RangeError(`UInt exceeds max u128: ${MAX_U1282}`);
1027
+ if (n > MAX_U1283)
1028
+ throw new RangeError(`UInt exceeds max u128: ${MAX_U1283}`);
1005
1029
  return { type: "uint", value: n };
1006
1030
  }
1007
1031
  var trueCV = () => ({ type: "true" });
@@ -1050,6 +1074,10 @@ function tupleCV(data) {
1050
1074
  return { type: "tuple", value: data };
1051
1075
  }
1052
1076
  function stringAsciiCV(value) {
1077
+ if (!isAscii(value))
1078
+ throw new Error("string-ascii holds only ASCII characters");
1079
+ if (value.length > MAX_STRING_BYTES)
1080
+ throw new Error(`string-ascii exceeds max size of ${MAX_STRING_BYTES} bytes`);
1053
1081
  return { type: "ascii", value };
1054
1082
  }
1055
1083
  function stringUtf8CV(value) {
@@ -3503,6 +3531,13 @@ function assertNoFeeTierForProvider(fee) {
3503
3531
  throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
3504
3532
  }
3505
3533
  }
3534
+ function resolveCallArgs(params) {
3535
+ const { args, functionArgs } = params;
3536
+ if (args !== undefined && functionArgs !== undefined) {
3537
+ throw new Error("Pass args or functionArgs, not both (functionArgs is deprecated)");
3538
+ }
3539
+ return args ?? functionArgs ?? [];
3540
+ }
3506
3541
 
3507
3542
  // src/actions/wallet/callContract.ts
3508
3543
  async function callContract(client, params) {
@@ -3510,12 +3545,13 @@ async function callContract(client, params) {
3510
3545
  if (!account)
3511
3546
  throw new Error("Account required");
3512
3547
  const [contractAddress, contractName] = parseContractId(params.contract);
3548
+ const args = resolveCallArgs(params);
3513
3549
  if (isProviderAccount(account)) {
3514
3550
  assertNoFeeTierForProvider(params.fee);
3515
3551
  const result = await account.provider.request("stx_callContract", {
3516
3552
  contract: params.contract,
3517
3553
  functionName: params.functionName,
3518
- functionArgs: params.functionArgs ?? []
3554
+ functionArgs: args
3519
3555
  });
3520
3556
  return result.txid;
3521
3557
  }
@@ -3527,7 +3563,7 @@ async function callContract(client, params) {
3527
3563
  contractAddress,
3528
3564
  contractName,
3529
3565
  functionName: params.functionName,
3530
- functionArgs: params.functionArgs ?? [],
3566
+ functionArgs: args,
3531
3567
  fee: needsFeeResolution ? 0n : params.fee,
3532
3568
  nonce,
3533
3569
  publicKey: account.publicKey,
@@ -3609,7 +3645,7 @@ function getContract(params) {
3609
3645
  return callContract(client, {
3610
3646
  contract: contractId,
3611
3647
  functionName: fn.name,
3612
- functionArgs: clarityArgs,
3648
+ args: clarityArgs,
3613
3649
  ...options
3614
3650
  });
3615
3651
  };
@@ -6166,5 +6202,5 @@ function parseSignerCalldata(calldata) {
6166
6202
  };
6167
6203
  }
6168
6204
 
6169
- //# debugId=0C3339AEA1AAF38B64756E2164756E21
6205
+ //# debugId=E525360E2DA4A64764756E2164756E21
6170
6206
  //# sourceMappingURL=index.cjs.map