@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/pox5/index.js
CHANGED
|
@@ -3,48 +3,48 @@ import {
|
|
|
3
3
|
hexToBytes2,
|
|
4
4
|
concatBytes2,
|
|
5
5
|
intToBigInt2
|
|
6
|
-
} from "../../shared/stacks-esm-
|
|
6
|
+
} from "../../shared/stacks-esm-8p8xy3dz.js";
|
|
7
7
|
import {
|
|
8
8
|
serializeCVBytes2,
|
|
9
9
|
Cl2,
|
|
10
10
|
deserializeCVBytes2
|
|
11
|
-
} from "../../shared/stacks-esm-
|
|
12
|
-
import"../../shared/stacks-esm-
|
|
13
|
-
import"../../shared/stacks-esm-
|
|
14
|
-
import"../../shared/stacks-esm-
|
|
15
|
-
import"../../shared/stacks-esm-
|
|
11
|
+
} from "../../shared/stacks-esm-jwgtksgq.js";
|
|
12
|
+
import"../../shared/stacks-esm-h60faj2n.js";
|
|
13
|
+
import"../../shared/stacks-esm-4rjjsz3p.js";
|
|
14
|
+
import"../../shared/stacks-esm-2z40q8gs.js";
|
|
15
|
+
import"../../shared/stacks-esm-wjg9aer9.js";
|
|
16
16
|
import {
|
|
17
17
|
parseBitcoinTx2,
|
|
18
18
|
stripWitness2,
|
|
19
19
|
BITCOIN_NETWORK_PARAMS
|
|
20
|
-
} from "../../shared/stacks-esm-
|
|
20
|
+
} from "../../shared/stacks-esm-nqkwt2z7.js";
|
|
21
21
|
import {
|
|
22
22
|
structuredDataHash2
|
|
23
|
-
} from "../../shared/stacks-esm-
|
|
23
|
+
} from "../../shared/stacks-esm-zsdw7fq3.js";
|
|
24
24
|
import {
|
|
25
25
|
canonicalizeBtcAddress,
|
|
26
26
|
parseBtcAddress2,
|
|
27
27
|
stringifyBtcAddress2,
|
|
28
28
|
BtcAddress2
|
|
29
|
-
} from "../../shared/stacks-esm-
|
|
29
|
+
} from "../../shared/stacks-esm-eep45e8s.js";
|
|
30
30
|
import {
|
|
31
31
|
buildTxProof2
|
|
32
|
-
} from "../../shared/stacks-esm-
|
|
32
|
+
} from "../../shared/stacks-esm-e63kx7dq.js";
|
|
33
33
|
import {
|
|
34
34
|
EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET2
|
|
35
35
|
} from "../../shared/stacks-esm-51sysw9g.js";
|
|
36
36
|
import {
|
|
37
37
|
getContract2
|
|
38
|
-
} from "../../shared/stacks-esm-
|
|
38
|
+
} from "../../shared/stacks-esm-1f46cr7b.js";
|
|
39
39
|
import {
|
|
40
40
|
getBalance2,
|
|
41
41
|
getDataVar2,
|
|
42
42
|
multicall2
|
|
43
|
-
} from "../../shared/stacks-esm-
|
|
43
|
+
} from "../../shared/stacks-esm-brtqryjb.js";
|
|
44
44
|
import {
|
|
45
45
|
getMapEntry2
|
|
46
|
-
} from "../../shared/stacks-esm-
|
|
47
|
-
import"../../shared/stacks-esm-
|
|
46
|
+
} from "../../shared/stacks-esm-m8ph0bvw.js";
|
|
47
|
+
import"../../shared/stacks-esm-mqhwqhq4.js";
|
|
48
48
|
|
|
49
49
|
// src/pox5/constants.ts
|
|
50
50
|
var POX5_CONTRACT_NAME = "pox-5";
|
package/dist/src/sbtc/index.cjs
CHANGED
|
@@ -110,6 +110,8 @@ function bytesToHex(bytes) {
|
|
|
110
110
|
}
|
|
111
111
|
function hexToBytes(hex) {
|
|
112
112
|
let h = without0x(hex);
|
|
113
|
+
if (!/^[0-9a-fA-F]*$/.test(h))
|
|
114
|
+
throw new Error("Invalid byte sequence");
|
|
113
115
|
if (h.length % 2)
|
|
114
116
|
h = `0${h}`;
|
|
115
117
|
const array = new Uint8Array(h.length / 2);
|
|
@@ -141,6 +143,13 @@ function asciiToBytes(str) {
|
|
|
141
143
|
}
|
|
142
144
|
return bytes;
|
|
143
145
|
}
|
|
146
|
+
function isAscii(str) {
|
|
147
|
+
for (let i = 0;i < str.length; i++) {
|
|
148
|
+
if (str.charCodeAt(i) > 127)
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
144
153
|
function bytesToAscii(bytes) {
|
|
145
154
|
return String.fromCharCode(...bytes);
|
|
146
155
|
}
|
|
@@ -159,8 +168,11 @@ function concatBytes(...arrays) {
|
|
|
159
168
|
function intToBigInt(value) {
|
|
160
169
|
if (typeof value === "bigint")
|
|
161
170
|
return value;
|
|
162
|
-
if (typeof value === "string")
|
|
171
|
+
if (typeof value === "string") {
|
|
172
|
+
if (value.trim() === "")
|
|
173
|
+
throw new SyntaxError("Cannot convert an empty string to an integer");
|
|
163
174
|
return BigInt(value);
|
|
175
|
+
}
|
|
164
176
|
if (typeof value === "number") {
|
|
165
177
|
if (!Number.isInteger(value))
|
|
166
178
|
throw new RangeError("Values of type 'number' must be an integer.");
|
|
@@ -770,6 +782,10 @@ function deserializeCV(input) {
|
|
|
770
782
|
// src/clarity/serialize.ts
|
|
771
783
|
var CLARITY_INT_SIZE = 128n;
|
|
772
784
|
var CLARITY_INT_BYTE_SIZE = 16;
|
|
785
|
+
var MAX_U1282 = (1n << 128n) - 1n;
|
|
786
|
+
var MAX_I1282 = (1n << 127n) - 1n;
|
|
787
|
+
var MIN_I1282 = -(1n << 127n);
|
|
788
|
+
var MAX_STRING_BYTES = 1048576;
|
|
773
789
|
function typeIdByte(type) {
|
|
774
790
|
return ClarityWireType[type];
|
|
775
791
|
}
|
|
@@ -791,11 +807,17 @@ function serializeCVBytes(value) {
|
|
|
791
807
|
case "false":
|
|
792
808
|
return new Uint8Array([typeIdByte(value.type)]);
|
|
793
809
|
case "int": {
|
|
794
|
-
const
|
|
810
|
+
const n = BigInt(value.value);
|
|
811
|
+
if (n > MAX_I1282 || n < MIN_I1282)
|
|
812
|
+
throw new RangeError(`Int is outside i128: ${n}`);
|
|
813
|
+
const bytes = bigIntToBytes(toTwos(n, CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
|
|
795
814
|
return withTypeId(value.type, bytes);
|
|
796
815
|
}
|
|
797
816
|
case "uint": {
|
|
798
|
-
const
|
|
817
|
+
const n = BigInt(value.value);
|
|
818
|
+
if (n < 0n || n > MAX_U1282)
|
|
819
|
+
throw new RangeError(`UInt is outside u128: ${n}`);
|
|
820
|
+
const bytes = bigIntToBytes(n, CLARITY_INT_BYTE_SIZE);
|
|
799
821
|
return withTypeId(value.type, bytes);
|
|
800
822
|
}
|
|
801
823
|
case "buffer": {
|
|
@@ -834,6 +856,8 @@ function serializeCVBytes(value) {
|
|
|
834
856
|
return withTypeId(value.type, concatBytes(...parts));
|
|
835
857
|
}
|
|
836
858
|
case "ascii": {
|
|
859
|
+
if (!isAscii(value.value))
|
|
860
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
837
861
|
const strBytes = asciiToBytes(value.value);
|
|
838
862
|
return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
|
|
839
863
|
}
|
|
@@ -850,9 +874,9 @@ function serializeCV(value) {
|
|
|
850
874
|
}
|
|
851
875
|
|
|
852
876
|
// src/clarity/values.ts
|
|
853
|
-
var
|
|
854
|
-
var
|
|
855
|
-
var
|
|
877
|
+
var MAX_U1283 = BigInt("0xffffffffffffffffffffffffffffffff");
|
|
878
|
+
var MIN_I1283 = BigInt("-170141183460469231731687303715884105728");
|
|
879
|
+
var MAX_I1283 = BigInt("0x7fffffffffffffffffffffffffffffff");
|
|
856
880
|
function intCV(value) {
|
|
857
881
|
let v = value;
|
|
858
882
|
if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
|
|
@@ -861,18 +885,18 @@ function intCV(value) {
|
|
|
861
885
|
if (v instanceof Uint8Array)
|
|
862
886
|
v = bytesToTwosBigInt(v);
|
|
863
887
|
const n = intToBigInt(v);
|
|
864
|
-
if (n >
|
|
865
|
-
throw new RangeError(`Int exceeds max i128: ${
|
|
866
|
-
if (n <
|
|
867
|
-
throw new RangeError(`Int below min i128: ${
|
|
888
|
+
if (n > MAX_I1283)
|
|
889
|
+
throw new RangeError(`Int exceeds max i128: ${MAX_I1283}`);
|
|
890
|
+
if (n < MIN_I1283)
|
|
891
|
+
throw new RangeError(`Int below min i128: ${MIN_I1283}`);
|
|
868
892
|
return { type: "int", value: n };
|
|
869
893
|
}
|
|
870
894
|
function uintCV(value) {
|
|
871
895
|
const n = intToBigInt(value);
|
|
872
896
|
if (n < 0n)
|
|
873
897
|
throw new RangeError("Cannot construct unsigned int from negative value");
|
|
874
|
-
if (n >
|
|
875
|
-
throw new RangeError(`UInt exceeds max u128: ${
|
|
898
|
+
if (n > MAX_U1283)
|
|
899
|
+
throw new RangeError(`UInt exceeds max u128: ${MAX_U1283}`);
|
|
876
900
|
return { type: "uint", value: n };
|
|
877
901
|
}
|
|
878
902
|
var trueCV = () => ({ type: "true" });
|
|
@@ -921,6 +945,10 @@ function tupleCV(data) {
|
|
|
921
945
|
return { type: "tuple", value: data };
|
|
922
946
|
}
|
|
923
947
|
function stringAsciiCV(value) {
|
|
948
|
+
if (!isAscii(value))
|
|
949
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
950
|
+
if (value.length > MAX_STRING_BYTES)
|
|
951
|
+
throw new Error(`string-ascii exceeds max size of ${MAX_STRING_BYTES} bytes`);
|
|
924
952
|
return { type: "ascii", value };
|
|
925
953
|
}
|
|
926
954
|
function stringUtf8CV(value) {
|
|
@@ -3190,6 +3218,13 @@ function assertNoFeeTierForProvider(fee) {
|
|
|
3190
3218
|
throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
|
|
3191
3219
|
}
|
|
3192
3220
|
}
|
|
3221
|
+
function resolveCallArgs(params) {
|
|
3222
|
+
const { args, functionArgs } = params;
|
|
3223
|
+
if (args !== undefined && functionArgs !== undefined) {
|
|
3224
|
+
throw new Error("Pass args or functionArgs, not both (functionArgs is deprecated)");
|
|
3225
|
+
}
|
|
3226
|
+
return args ?? functionArgs ?? [];
|
|
3227
|
+
}
|
|
3193
3228
|
|
|
3194
3229
|
// src/actions/wallet/callContract.ts
|
|
3195
3230
|
async function callContract(client, params) {
|
|
@@ -3197,12 +3232,13 @@ async function callContract(client, params) {
|
|
|
3197
3232
|
if (!account)
|
|
3198
3233
|
throw new Error("Account required");
|
|
3199
3234
|
const [contractAddress, contractName] = parseContractId(params.contract);
|
|
3235
|
+
const args = resolveCallArgs(params);
|
|
3200
3236
|
if (isProviderAccount(account)) {
|
|
3201
3237
|
assertNoFeeTierForProvider(params.fee);
|
|
3202
3238
|
const result = await account.provider.request("stx_callContract", {
|
|
3203
3239
|
contract: params.contract,
|
|
3204
3240
|
functionName: params.functionName,
|
|
3205
|
-
functionArgs:
|
|
3241
|
+
functionArgs: args
|
|
3206
3242
|
});
|
|
3207
3243
|
return result.txid;
|
|
3208
3244
|
}
|
|
@@ -3214,7 +3250,7 @@ async function callContract(client, params) {
|
|
|
3214
3250
|
contractAddress,
|
|
3215
3251
|
contractName,
|
|
3216
3252
|
functionName: params.functionName,
|
|
3217
|
-
functionArgs:
|
|
3253
|
+
functionArgs: args,
|
|
3218
3254
|
fee: needsFeeResolution ? 0n : params.fee,
|
|
3219
3255
|
nonce,
|
|
3220
3256
|
publicKey: account.publicKey,
|
|
@@ -3296,7 +3332,7 @@ function getContract(params) {
|
|
|
3296
3332
|
return callContract(client, {
|
|
3297
3333
|
contract: contractId,
|
|
3298
3334
|
functionName: fn.name,
|
|
3299
|
-
|
|
3335
|
+
args: clarityArgs,
|
|
3300
3336
|
...options
|
|
3301
3337
|
});
|
|
3302
3338
|
};
|
|
@@ -4122,5 +4158,5 @@ function sbtc() {
|
|
|
4122
4158
|
});
|
|
4123
4159
|
}
|
|
4124
4160
|
|
|
4125
|
-
//# debugId=
|
|
4161
|
+
//# debugId=F4BE3E06E660EE3D64756E2164756E21
|
|
4126
4162
|
//# sourceMappingURL=index.cjs.map
|