@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.
- package/dist/shared/{stacks-esm-17adzt3x.js → stacks-esm-0t9vwtwh.js} +9 -9
- package/dist/shared/{stacks-esm-s3natb0x.js → stacks-esm-1f46cr7b.js} +8 -8
- package/dist/shared/{stacks-esm-s3natb0x.js.map → stacks-esm-1f46cr7b.js.map} +3 -3
- package/dist/shared/{stacks-esm-2cac1jn9.js → stacks-esm-2z40q8gs.js} +4 -4
- package/dist/shared/{stacks-esm-ev07d2aw.js → stacks-esm-4rjjsz3p.js} +3 -3
- package/dist/shared/{stacks-esm-5eq7meyt.js → stacks-esm-8p8xy3dz.js} +16 -4
- package/dist/shared/stacks-esm-8p8xy3dz.js.map +12 -0
- package/dist/shared/{stacks-esm-h82jj95c.js → stacks-esm-9ptct1c4.js} +3 -3
- package/dist/shared/{stacks-esm-qasbsv66.js → stacks-esm-a7apmjbk.js} +2 -2
- package/dist/shared/{stacks-esm-1nfzrepv.js → stacks-esm-brtqryjb.js} +4 -4
- package/dist/shared/{stacks-esm-pc20c78w.js → stacks-esm-e63kx7dq.js} +3 -3
- package/dist/shared/{stacks-esm-tsb8h0yr.js → stacks-esm-eep45e8s.js} +2 -2
- package/dist/shared/{stacks-esm-wnxhfx93.js → stacks-esm-fmq4j4ez.js} +2 -2
- package/dist/shared/{stacks-esm-7tc40d6t.js → stacks-esm-h60faj2n.js} +2 -2
- package/dist/shared/{stacks-esm-6zfssx7v.js → stacks-esm-hcaycch3.js} +3 -3
- package/dist/shared/{stacks-esm-cs4419br.js → stacks-esm-jwgtksgq.js} +32 -15
- package/dist/shared/stacks-esm-jwgtksgq.js.map +15 -0
- package/dist/shared/{stacks-esm-jm688fhe.js → stacks-esm-m8ph0bvw.js} +19 -11
- package/dist/shared/{stacks-esm-jm688fhe.js.map → stacks-esm-m8ph0bvw.js.map} +4 -4
- package/dist/shared/{stacks-esm-hm7kb2cp.js → stacks-esm-mqhwqhq4.js} +4 -4
- package/dist/shared/{stacks-esm-tfechw5c.js → stacks-esm-nqkwt2z7.js} +2 -2
- package/dist/shared/{stacks-esm-mmvrwreq.js → stacks-esm-wjg9aer9.js} +4 -4
- package/dist/shared/{stacks-esm-scq242d9.js → stacks-esm-zsdw7fq3.js} +3 -3
- package/dist/src/accounts/index.cjs +14 -2
- package/dist/src/accounts/index.cjs.map +3 -3
- package/dist/src/accounts/index.js +2 -2
- package/dist/src/actions/index.cjs +52 -16
- package/dist/src/actions/index.cjs.map +8 -8
- package/dist/src/actions/index.d.cts +2 -0
- package/dist/src/actions/index.d.ts +2 -0
- package/dist/src/actions/index.js +12 -12
- package/dist/src/bitcoin/index.cjs +41 -13
- package/dist/src/bitcoin/index.cjs.map +5 -5
- package/dist/src/bitcoin/index.js +10 -10
- package/dist/src/bns/index.cjs +52 -16
- package/dist/src/bns/index.cjs.map +8 -8
- package/dist/src/bns/index.js +12 -12
- package/dist/src/clarity/index.cjs +41 -13
- package/dist/src/clarity/index.cjs.map +5 -5
- package/dist/src/clarity/index.js +6 -6
- package/dist/src/connect/index.cjs +30 -7
- package/dist/src/connect/index.cjs.map +5 -5
- package/dist/src/connect/index.js +30 -7
- package/dist/src/connect/index.js.map +5 -5
- package/dist/src/connect/walletconnect/index.cjs +3 -1
- package/dist/src/connect/walletconnect/index.cjs.map +3 -3
- package/dist/src/connect/walletconnect/index.js +3 -1
- package/dist/src/connect/walletconnect/index.js.map +3 -3
- package/dist/src/filters/index.cjs +14 -2
- package/dist/src/filters/index.cjs.map +3 -3
- package/dist/src/filters/index.js +3 -3
- package/dist/src/index.cjs +75 -20
- package/dist/src/index.cjs.map +9 -9
- package/dist/src/index.d.cts +8 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +40 -14
- package/dist/src/index.js.map +4 -4
- package/dist/src/postconditions/index.cjs +41 -13
- package/dist/src/postconditions/index.cjs.map +5 -5
- package/dist/src/postconditions/index.js +5 -5
- package/dist/src/pox/index.cjs +52 -16
- package/dist/src/pox/index.cjs.map +8 -8
- package/dist/src/pox/index.js +12 -12
- package/dist/src/pox5/index.cjs +52 -16
- package/dist/src/pox5/index.cjs.map +8 -8
- package/dist/src/pox5/index.js +14 -14
- package/dist/src/sbtc/index.cjs +52 -16
- package/dist/src/sbtc/index.cjs.map +8 -8
- package/dist/src/sbtc/index.js +12 -12
- package/dist/src/simnet/index.cjs +44 -16
- package/dist/src/simnet/index.cjs.map +5 -5
- package/dist/src/simnet/index.js +44 -16
- package/dist/src/simnet/index.js.map +5 -5
- package/dist/src/stackingdao/index.cjs +52 -16
- package/dist/src/stackingdao/index.cjs.map +8 -8
- package/dist/src/stackingdao/index.js +10 -10
- package/dist/src/transactions/index.cjs +44 -16
- package/dist/src/transactions/index.cjs.map +5 -5
- package/dist/src/transactions/index.js +5 -5
- package/dist/src/utils/index.cjs +20 -3
- package/dist/src/utils/index.cjs.map +4 -4
- package/dist/src/utils/index.d.cts +8 -1
- package/dist/src/utils/index.d.ts +8 -1
- package/dist/src/utils/index.js +9 -4
- package/dist/src/utils/index.js.map +3 -3
- package/package.json +2 -2
- package/dist/shared/stacks-esm-5eq7meyt.js.map +0 -12
- package/dist/shared/stacks-esm-cs4419br.js.map +0 -15
- /package/dist/shared/{stacks-esm-17adzt3x.js.map → stacks-esm-0t9vwtwh.js.map} +0 -0
- /package/dist/shared/{stacks-esm-2cac1jn9.js.map → stacks-esm-2z40q8gs.js.map} +0 -0
- /package/dist/shared/{stacks-esm-ev07d2aw.js.map → stacks-esm-4rjjsz3p.js.map} +0 -0
- /package/dist/shared/{stacks-esm-h82jj95c.js.map → stacks-esm-9ptct1c4.js.map} +0 -0
- /package/dist/shared/{stacks-esm-qasbsv66.js.map → stacks-esm-a7apmjbk.js.map} +0 -0
- /package/dist/shared/{stacks-esm-1nfzrepv.js.map → stacks-esm-brtqryjb.js.map} +0 -0
- /package/dist/shared/{stacks-esm-pc20c78w.js.map → stacks-esm-e63kx7dq.js.map} +0 -0
- /package/dist/shared/{stacks-esm-tsb8h0yr.js.map → stacks-esm-eep45e8s.js.map} +0 -0
- /package/dist/shared/{stacks-esm-wnxhfx93.js.map → stacks-esm-fmq4j4ez.js.map} +0 -0
- /package/dist/shared/{stacks-esm-7tc40d6t.js.map → stacks-esm-h60faj2n.js.map} +0 -0
- /package/dist/shared/{stacks-esm-6zfssx7v.js.map → stacks-esm-hcaycch3.js.map} +0 -0
- /package/dist/shared/{stacks-esm-hm7kb2cp.js.map → stacks-esm-mqhwqhq4.js.map} +0 -0
- /package/dist/shared/{stacks-esm-tfechw5c.js.map → stacks-esm-nqkwt2z7.js.map} +0 -0
- /package/dist/shared/{stacks-esm-mmvrwreq.js.map → stacks-esm-wjg9aer9.js.map} +0 -0
- /package/dist/shared/{stacks-esm-scq242d9.js.map → stacks-esm-zsdw7fq3.js.map} +0 -0
package/dist/src/pox/index.cjs
CHANGED
|
@@ -108,6 +108,8 @@ function bytesToHex(bytes) {
|
|
|
108
108
|
}
|
|
109
109
|
function hexToBytes(hex) {
|
|
110
110
|
let h = without0x(hex);
|
|
111
|
+
if (!/^[0-9a-fA-F]*$/.test(h))
|
|
112
|
+
throw new Error("Invalid byte sequence");
|
|
111
113
|
if (h.length % 2)
|
|
112
114
|
h = `0${h}`;
|
|
113
115
|
const array = new Uint8Array(h.length / 2);
|
|
@@ -139,6 +141,13 @@ function asciiToBytes(str) {
|
|
|
139
141
|
}
|
|
140
142
|
return bytes;
|
|
141
143
|
}
|
|
144
|
+
function isAscii(str) {
|
|
145
|
+
for (let i = 0;i < str.length; i++) {
|
|
146
|
+
if (str.charCodeAt(i) > 127)
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
142
151
|
function bytesToAscii(bytes) {
|
|
143
152
|
return String.fromCharCode(...bytes);
|
|
144
153
|
}
|
|
@@ -157,8 +166,11 @@ function concatBytes(...arrays) {
|
|
|
157
166
|
function intToBigInt(value) {
|
|
158
167
|
if (typeof value === "bigint")
|
|
159
168
|
return value;
|
|
160
|
-
if (typeof value === "string")
|
|
169
|
+
if (typeof value === "string") {
|
|
170
|
+
if (value.trim() === "")
|
|
171
|
+
throw new SyntaxError("Cannot convert an empty string to an integer");
|
|
161
172
|
return BigInt(value);
|
|
173
|
+
}
|
|
162
174
|
if (typeof value === "number") {
|
|
163
175
|
if (!Number.isInteger(value))
|
|
164
176
|
throw new RangeError("Values of type 'number' must be an integer.");
|
|
@@ -768,6 +780,10 @@ function deserializeCV(input) {
|
|
|
768
780
|
// src/clarity/serialize.ts
|
|
769
781
|
var CLARITY_INT_SIZE = 128n;
|
|
770
782
|
var CLARITY_INT_BYTE_SIZE = 16;
|
|
783
|
+
var MAX_U1282 = (1n << 128n) - 1n;
|
|
784
|
+
var MAX_I1282 = (1n << 127n) - 1n;
|
|
785
|
+
var MIN_I1282 = -(1n << 127n);
|
|
786
|
+
var MAX_STRING_BYTES = 1048576;
|
|
771
787
|
function typeIdByte(type) {
|
|
772
788
|
return ClarityWireType[type];
|
|
773
789
|
}
|
|
@@ -789,11 +805,17 @@ function serializeCVBytes(value) {
|
|
|
789
805
|
case "false":
|
|
790
806
|
return new Uint8Array([typeIdByte(value.type)]);
|
|
791
807
|
case "int": {
|
|
792
|
-
const
|
|
808
|
+
const n = BigInt(value.value);
|
|
809
|
+
if (n > MAX_I1282 || n < MIN_I1282)
|
|
810
|
+
throw new RangeError(`Int is outside i128: ${n}`);
|
|
811
|
+
const bytes = bigIntToBytes(toTwos(n, CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
|
|
793
812
|
return withTypeId(value.type, bytes);
|
|
794
813
|
}
|
|
795
814
|
case "uint": {
|
|
796
|
-
const
|
|
815
|
+
const n = BigInt(value.value);
|
|
816
|
+
if (n < 0n || n > MAX_U1282)
|
|
817
|
+
throw new RangeError(`UInt is outside u128: ${n}`);
|
|
818
|
+
const bytes = bigIntToBytes(n, CLARITY_INT_BYTE_SIZE);
|
|
797
819
|
return withTypeId(value.type, bytes);
|
|
798
820
|
}
|
|
799
821
|
case "buffer": {
|
|
@@ -832,6 +854,8 @@ function serializeCVBytes(value) {
|
|
|
832
854
|
return withTypeId(value.type, concatBytes(...parts));
|
|
833
855
|
}
|
|
834
856
|
case "ascii": {
|
|
857
|
+
if (!isAscii(value.value))
|
|
858
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
835
859
|
const strBytes = asciiToBytes(value.value);
|
|
836
860
|
return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
|
|
837
861
|
}
|
|
@@ -848,9 +872,9 @@ function serializeCV(value) {
|
|
|
848
872
|
}
|
|
849
873
|
|
|
850
874
|
// src/clarity/values.ts
|
|
851
|
-
var
|
|
852
|
-
var
|
|
853
|
-
var
|
|
875
|
+
var MAX_U1283 = BigInt("0xffffffffffffffffffffffffffffffff");
|
|
876
|
+
var MIN_I1283 = BigInt("-170141183460469231731687303715884105728");
|
|
877
|
+
var MAX_I1283 = BigInt("0x7fffffffffffffffffffffffffffffff");
|
|
854
878
|
function intCV(value) {
|
|
855
879
|
let v = value;
|
|
856
880
|
if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
|
|
@@ -859,18 +883,18 @@ function intCV(value) {
|
|
|
859
883
|
if (v instanceof Uint8Array)
|
|
860
884
|
v = bytesToTwosBigInt(v);
|
|
861
885
|
const n = intToBigInt(v);
|
|
862
|
-
if (n >
|
|
863
|
-
throw new RangeError(`Int exceeds max i128: ${
|
|
864
|
-
if (n <
|
|
865
|
-
throw new RangeError(`Int below min i128: ${
|
|
886
|
+
if (n > MAX_I1283)
|
|
887
|
+
throw new RangeError(`Int exceeds max i128: ${MAX_I1283}`);
|
|
888
|
+
if (n < MIN_I1283)
|
|
889
|
+
throw new RangeError(`Int below min i128: ${MIN_I1283}`);
|
|
866
890
|
return { type: "int", value: n };
|
|
867
891
|
}
|
|
868
892
|
function uintCV(value) {
|
|
869
893
|
const n = intToBigInt(value);
|
|
870
894
|
if (n < 0n)
|
|
871
895
|
throw new RangeError("Cannot construct unsigned int from negative value");
|
|
872
|
-
if (n >
|
|
873
|
-
throw new RangeError(`UInt exceeds max u128: ${
|
|
896
|
+
if (n > MAX_U1283)
|
|
897
|
+
throw new RangeError(`UInt exceeds max u128: ${MAX_U1283}`);
|
|
874
898
|
return { type: "uint", value: n };
|
|
875
899
|
}
|
|
876
900
|
var trueCV = () => ({ type: "true" });
|
|
@@ -919,6 +943,10 @@ function tupleCV(data) {
|
|
|
919
943
|
return { type: "tuple", value: data };
|
|
920
944
|
}
|
|
921
945
|
function stringAsciiCV(value) {
|
|
946
|
+
if (!isAscii(value))
|
|
947
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
948
|
+
if (value.length > MAX_STRING_BYTES)
|
|
949
|
+
throw new Error(`string-ascii exceeds max size of ${MAX_STRING_BYTES} bytes`);
|
|
922
950
|
return { type: "ascii", value };
|
|
923
951
|
}
|
|
924
952
|
function stringUtf8CV(value) {
|
|
@@ -3188,6 +3216,13 @@ function assertNoFeeTierForProvider(fee) {
|
|
|
3188
3216
|
throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
|
|
3189
3217
|
}
|
|
3190
3218
|
}
|
|
3219
|
+
function resolveCallArgs(params) {
|
|
3220
|
+
const { args, functionArgs } = params;
|
|
3221
|
+
if (args !== undefined && functionArgs !== undefined) {
|
|
3222
|
+
throw new Error("Pass args or functionArgs, not both (functionArgs is deprecated)");
|
|
3223
|
+
}
|
|
3224
|
+
return args ?? functionArgs ?? [];
|
|
3225
|
+
}
|
|
3191
3226
|
|
|
3192
3227
|
// src/actions/wallet/callContract.ts
|
|
3193
3228
|
async function callContract(client, params) {
|
|
@@ -3195,12 +3230,13 @@ async function callContract(client, params) {
|
|
|
3195
3230
|
if (!account)
|
|
3196
3231
|
throw new Error("Account required");
|
|
3197
3232
|
const [contractAddress, contractName] = parseContractId(params.contract);
|
|
3233
|
+
const args = resolveCallArgs(params);
|
|
3198
3234
|
if (isProviderAccount(account)) {
|
|
3199
3235
|
assertNoFeeTierForProvider(params.fee);
|
|
3200
3236
|
const result = await account.provider.request("stx_callContract", {
|
|
3201
3237
|
contract: params.contract,
|
|
3202
3238
|
functionName: params.functionName,
|
|
3203
|
-
functionArgs:
|
|
3239
|
+
functionArgs: args
|
|
3204
3240
|
});
|
|
3205
3241
|
return result.txid;
|
|
3206
3242
|
}
|
|
@@ -3212,7 +3248,7 @@ async function callContract(client, params) {
|
|
|
3212
3248
|
contractAddress,
|
|
3213
3249
|
contractName,
|
|
3214
3250
|
functionName: params.functionName,
|
|
3215
|
-
functionArgs:
|
|
3251
|
+
functionArgs: args,
|
|
3216
3252
|
fee: needsFeeResolution ? 0n : params.fee,
|
|
3217
3253
|
nonce,
|
|
3218
3254
|
publicKey: account.publicKey,
|
|
@@ -3294,7 +3330,7 @@ function getContract(params) {
|
|
|
3294
3330
|
return callContract(client, {
|
|
3295
3331
|
contract: contractId,
|
|
3296
3332
|
functionName: fn.name,
|
|
3297
|
-
|
|
3333
|
+
args: clarityArgs,
|
|
3298
3334
|
...options
|
|
3299
3335
|
});
|
|
3300
3336
|
};
|
|
@@ -4278,5 +4314,5 @@ function pox() {
|
|
|
4278
4314
|
});
|
|
4279
4315
|
}
|
|
4280
4316
|
|
|
4281
|
-
//# debugId=
|
|
4317
|
+
//# debugId=B4F3DFE632ED1D2D64756E2164756E21
|
|
4282
4318
|
//# sourceMappingURL=index.cjs.map
|