@secondlayer/stacks 1.0.1 → 2.0.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-0nfexv24.cjs → stacks-0jk7vd8r.cjs} +9 -8
- package/dist/shared/{stacks-0nfexv24.cjs.map → stacks-0jk7vd8r.cjs.map} +5 -5
- package/dist/shared/{stacks-wjem3xw9.js → stacks-0zysn74p.js} +11 -10
- package/dist/shared/{stacks-wjem3xw9.js.map → stacks-0zysn74p.js.map} +5 -5
- package/dist/shared/stacks-14pgpkrr.cjs.map +6 -6
- package/dist/shared/{stacks-s7z5q8be.js → stacks-2h8d2y27.js} +29 -28
- package/dist/shared/stacks-2h8d2y27.js.map +11 -0
- package/dist/shared/{stacks-96d6m1zy.js → stacks-3erxq8wh.js} +6 -6
- package/dist/shared/{stacks-96d6m1zy.js.map → stacks-3erxq8wh.js.map} +4 -4
- package/dist/shared/{stacks-ra02bpny.cjs → stacks-3y058qda.cjs} +29 -28
- package/dist/shared/stacks-3y058qda.cjs.map +11 -0
- package/dist/shared/{stacks-s10yb9gz.js → stacks-6xmk24yw.js} +2 -2
- package/dist/shared/{stacks-70p84bgg.js → stacks-7tn3zsbe.js} +3 -3
- package/dist/shared/stacks-7tn3zsbe.js.map +10 -0
- package/dist/shared/{stacks-y5262j0z.cjs → stacks-8e4k5qnm.cjs} +4 -4
- package/dist/shared/{stacks-y5262j0z.cjs.map → stacks-8e4k5qnm.cjs.map} +4 -4
- package/dist/shared/{stacks-5tprhns9.cjs → stacks-dpxnxhqb.cjs} +2 -5
- package/dist/shared/{stacks-5tprhns9.cjs.map → stacks-dpxnxhqb.cjs.map} +3 -3
- package/dist/shared/{stacks-4x2bcc2k.js → stacks-fy5h5qyx.js} +7 -7
- package/dist/shared/{stacks-4x2bcc2k.js.map → stacks-fy5h5qyx.js.map} +6 -6
- package/dist/shared/{stacks-zf7rbpzp.js → stacks-g7ffp8aj.js} +3 -3
- package/dist/shared/{stacks-zf7rbpzp.js.map → stacks-g7ffp8aj.js.map} +2 -2
- package/dist/shared/{stacks-1s5w4ncf.js → stacks-g7ys594x.js} +7 -7
- package/dist/shared/{stacks-1s5w4ncf.js.map → stacks-g7ys594x.js.map} +4 -4
- package/dist/shared/{stacks-09wa7ewe.js → stacks-kmnthgj7.js} +12 -12
- package/dist/shared/stacks-kmnthgj7.js.map +15 -0
- package/dist/shared/{stacks-je937aas.js → stacks-kmshch4q.js} +3 -3
- package/dist/shared/{stacks-y3dh7hv1.js → stacks-tjjnkt3r.js} +2 -5
- package/dist/shared/{stacks-y3dh7hv1.js.map → stacks-tjjnkt3r.js.map} +3 -3
- package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
- package/dist/shared/stacks-wyxj879g.cjs.map +2 -2
- package/dist/shared/{stacks-rwfgts3s.js → stacks-xxn5ma6g.js} +2 -2
- package/dist/shared/{stacks-17sdtaxg.cjs → stacks-xxvz1x0f.cjs} +8 -8
- package/dist/shared/stacks-xxvz1x0f.cjs.map +15 -0
- package/dist/shared/{stacks-s30kkvm8.js → stacks-y2p4h5ks.js} +4 -4
- package/dist/shared/{stacks-znrb59ce.cjs → stacks-y3nbm8bw.cjs} +3 -3
- package/dist/shared/{stacks-znrb59ce.cjs.map → stacks-y3nbm8bw.cjs.map} +4 -4
- package/dist/src/accounts/index.cjs +3 -2
- package/dist/src/accounts/index.cjs.map +3 -3
- package/dist/src/accounts/index.js +5 -4
- package/dist/src/accounts/index.js.map +3 -3
- package/dist/src/actions/index.js +11 -11
- package/dist/src/bns/index.cjs +2 -4
- package/dist/src/bns/index.cjs.map +4 -4
- package/dist/src/bns/index.js +12 -14
- package/dist/src/bns/index.js.map +4 -4
- package/dist/src/clarity/index.js +5 -5
- package/dist/src/connect/index.cjs +17 -17
- package/dist/src/connect/index.cjs.map +7 -7
- package/dist/src/connect/index.js +17 -17
- package/dist/src/connect/index.js.map +7 -7
- package/dist/src/connect/walletconnect/index.cjs +16 -13
- package/dist/src/connect/walletconnect/index.cjs.map +9 -9
- package/dist/src/connect/walletconnect/index.js +16 -13
- package/dist/src/connect/walletconnect/index.js.map +9 -9
- package/dist/src/index.cjs +4 -4
- package/dist/src/index.cjs.map +8 -8
- package/dist/src/index.d.cts +0 -4
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +13 -13
- package/dist/src/index.js.map +8 -8
- package/dist/src/postconditions/index.js +3 -3
- package/dist/src/pox/index.cjs +2 -2
- package/dist/src/pox/index.cjs.map +3 -3
- package/dist/src/pox/index.js +11 -11
- package/dist/src/pox/index.js.map +3 -3
- package/dist/src/stackingdao/index.cjs +7 -7
- package/dist/src/stackingdao/index.cjs.map +3 -3
- package/dist/src/stackingdao/index.js +16 -16
- package/dist/src/stackingdao/index.js.map +3 -3
- package/dist/src/subscriptions/index.js +1 -1
- package/dist/src/tools/btc/index.cjs.map +2 -2
- package/dist/src/tools/btc/index.js.map +2 -2
- package/dist/src/tools/index.cjs +42 -43
- package/dist/src/tools/index.cjs.map +23 -23
- package/dist/src/tools/index.js +42 -43
- package/dist/src/tools/index.js.map +23 -23
- package/dist/src/transactions/index.js +6 -6
- package/dist/src/utils/index.js +3 -3
- package/package.json +1 -7
- package/dist/shared/stacks-09wa7ewe.js.map +0 -15
- package/dist/shared/stacks-17sdtaxg.cjs.map +0 -15
- package/dist/shared/stacks-70p84bgg.js.map +0 -10
- package/dist/shared/stacks-ra02bpny.cjs.map +0 -11
- package/dist/shared/stacks-s7z5q8be.js.map +0 -11
- package/dist/src/triggers/index.cjs +0 -66
- package/dist/src/triggers/index.cjs.map +0 -10
- package/dist/src/triggers/index.d.cts +0 -120
- package/dist/src/triggers/index.d.ts +0 -120
- package/dist/src/triggers/index.js +0 -25
- package/dist/src/triggers/index.js.map +0 -10
- /package/dist/shared/{stacks-s10yb9gz.js.map → stacks-6xmk24yw.js.map} +0 -0
- /package/dist/shared/{stacks-je937aas.js.map → stacks-kmshch4q.js.map} +0 -0
- /package/dist/shared/{stacks-rwfgts3s.js.map → stacks-xxn5ma6g.js.map} +0 -0
- /package/dist/shared/{stacks-s30kkvm8.js.map → stacks-y2p4h5ks.js.map} +0 -0
package/dist/src/tools/index.js
CHANGED
|
@@ -18,13 +18,13 @@ function bytesToHex(bytes) {
|
|
|
18
18
|
return hex;
|
|
19
19
|
}
|
|
20
20
|
function hexToBytes(hex) {
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
const array = new Uint8Array(
|
|
21
|
+
let h = without0x(hex);
|
|
22
|
+
if (h.length % 2)
|
|
23
|
+
h = `0${h}`;
|
|
24
|
+
const array = new Uint8Array(h.length / 2);
|
|
25
25
|
for (let i = 0;i < array.length; i++) {
|
|
26
26
|
const j = i * 2;
|
|
27
|
-
const byte = Number.parseInt(
|
|
27
|
+
const byte = Number.parseInt(h.slice(j, j + 2), 16);
|
|
28
28
|
if (Number.isNaN(byte) || byte < 0)
|
|
29
29
|
throw new Error("Invalid byte sequence");
|
|
30
30
|
array[i] = byte;
|
|
@@ -140,15 +140,16 @@ function c32normalize(input) {
|
|
|
140
140
|
return input.toUpperCase().replace(/O/g, "0").replace(/L|I/g, "1");
|
|
141
141
|
}
|
|
142
142
|
function c32encode(inputHex) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
let hex = inputHex;
|
|
144
|
+
if (hex.length % 2 !== 0)
|
|
145
|
+
hex = `0${hex}`;
|
|
146
|
+
hex = hex.toLowerCase();
|
|
146
147
|
const res = [];
|
|
147
148
|
let carry = 0;
|
|
148
|
-
for (let i =
|
|
149
|
+
for (let i = hex.length - 1;i >= 0; i--) {
|
|
149
150
|
if (carry < 4) {
|
|
150
|
-
const currentCode = HEX.indexOf(
|
|
151
|
-
const nextCode = i !== 0 ? HEX.indexOf(
|
|
151
|
+
const currentCode = HEX.indexOf(hex[i]) >> carry;
|
|
152
|
+
const nextCode = i !== 0 ? HEX.indexOf(hex[i - 1]) : 0;
|
|
152
153
|
const nextBits = 1 + carry;
|
|
153
154
|
const nextLowBits = nextCode % (1 << nextBits) << 5 - nextBits;
|
|
154
155
|
res.unshift(C32[currentCode + nextLowBits]);
|
|
@@ -161,7 +162,7 @@ function c32encode(inputHex) {
|
|
|
161
162
|
while (leadingZeros < res.length && res[leadingZeros] === "0")
|
|
162
163
|
leadingZeros++;
|
|
163
164
|
const stripped = res.slice(leadingZeros);
|
|
164
|
-
const bytes = hexToBytes(
|
|
165
|
+
const bytes = hexToBytes(hex);
|
|
165
166
|
let zeroBytesCount = 0;
|
|
166
167
|
while (zeroBytesCount < bytes.length && bytes[zeroBytesCount] === 0)
|
|
167
168
|
zeroBytesCount++;
|
|
@@ -169,21 +170,21 @@ function c32encode(inputHex) {
|
|
|
169
170
|
return [...prefix, ...stripped].join("");
|
|
170
171
|
}
|
|
171
172
|
function c32decode(c32input) {
|
|
172
|
-
|
|
173
|
-
if (!
|
|
173
|
+
const input = c32normalize(c32input);
|
|
174
|
+
if (!input.match(`^[${C32}]*$`))
|
|
174
175
|
throw new Error("Not a c32-encoded string");
|
|
175
|
-
const zeroPrefix =
|
|
176
|
-
const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]
|
|
176
|
+
const zeroPrefix = input.match(`^${C32[0]}*`);
|
|
177
|
+
const numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]?.length : 0;
|
|
177
178
|
const res = [];
|
|
178
179
|
let carry = 0;
|
|
179
180
|
let carryBits = 0;
|
|
180
|
-
for (let i =
|
|
181
|
+
for (let i = input.length - 1;i >= 0; i--) {
|
|
181
182
|
if (carryBits === 4) {
|
|
182
183
|
res.unshift(HEX[carry]);
|
|
183
184
|
carryBits = 0;
|
|
184
185
|
carry = 0;
|
|
185
186
|
}
|
|
186
|
-
const currentValue = (C32.indexOf(
|
|
187
|
+
const currentValue = (C32.indexOf(input[i]) << carryBits) + carry;
|
|
187
188
|
res.unshift(HEX[currentValue % 16]);
|
|
188
189
|
carryBits += 1;
|
|
189
190
|
carry = currentValue >> 4;
|
|
@@ -209,19 +210,19 @@ function c32checkEncode(version, data) {
|
|
|
209
210
|
throw new Error("Invalid version (must be between 0 and 31)");
|
|
210
211
|
if (!data.match(/^[0-9a-fA-F]*$/))
|
|
211
212
|
throw new Error("Invalid data (not a hex string)");
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
|
|
213
|
+
let d = data.toLowerCase();
|
|
214
|
+
if (d.length % 2 !== 0)
|
|
215
|
+
d = `0${d}`;
|
|
215
216
|
let versionHex = version.toString(16);
|
|
216
217
|
if (versionHex.length === 1)
|
|
217
218
|
versionHex = `0${versionHex}`;
|
|
218
|
-
const checksumHex = c32checksum(`${versionHex}${
|
|
219
|
-
return `${C32[version]}${c32encode(`${
|
|
219
|
+
const checksumHex = c32checksum(`${versionHex}${d}`);
|
|
220
|
+
return `${C32[version]}${c32encode(`${d}${checksumHex}`)}`;
|
|
220
221
|
}
|
|
221
222
|
function c32checkDecode(c32data) {
|
|
222
|
-
|
|
223
|
-
const dataHex = c32decode(
|
|
224
|
-
const version = C32.indexOf(
|
|
223
|
+
const normalized = c32normalize(c32data);
|
|
224
|
+
const dataHex = c32decode(normalized.slice(1));
|
|
225
|
+
const version = C32.indexOf(normalized[0]);
|
|
225
226
|
const checksum = dataHex.slice(-8);
|
|
226
227
|
let versionHex = version.toString(16);
|
|
227
228
|
if (versionHex.length === 1)
|
|
@@ -346,7 +347,7 @@ function serializeCVBytes(value) {
|
|
|
346
347
|
return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
|
|
347
348
|
}
|
|
348
349
|
default:
|
|
349
|
-
throw new Error(
|
|
350
|
+
throw new Error("Cannot serialize unknown clarity type");
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
353
|
|
|
@@ -453,12 +454,11 @@ function serializeSpendingCondition(condition) {
|
|
|
453
454
|
}
|
|
454
455
|
function serializeAuthField(field) {
|
|
455
456
|
if (field.type === "publicKey") {
|
|
456
|
-
const
|
|
457
|
-
return concatBytes(writeUInt8(
|
|
458
|
-
} else {
|
|
459
|
-
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
460
|
-
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
457
|
+
const typeId2 = field.pubKeyEncoding === 0 ? 0 : 1;
|
|
458
|
+
return concatBytes(writeUInt8(typeId2), hexToBytes(field.data));
|
|
461
459
|
}
|
|
460
|
+
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
461
|
+
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
462
462
|
}
|
|
463
463
|
function serializeAuthorization(auth) {
|
|
464
464
|
const parts = [writeUInt8(auth.authType)];
|
|
@@ -592,7 +592,7 @@ async function estimateFee(client, params) {
|
|
|
592
592
|
method: "POST",
|
|
593
593
|
body: {
|
|
594
594
|
estimated_len: Math.ceil(txHex.length / 2),
|
|
595
|
-
transaction_payload:
|
|
595
|
+
transaction_payload: `0x${payloadHex}`
|
|
596
596
|
}
|
|
597
597
|
});
|
|
598
598
|
return (data.estimations ?? []).map((e) => ({
|
|
@@ -694,12 +694,13 @@ var MAX_U128 = BigInt("0xffffffffffffffffffffffffffffffff");
|
|
|
694
694
|
var MIN_I128 = BigInt("-170141183460469231731687303715884105728");
|
|
695
695
|
var MAX_I128 = BigInt("0x7fffffffffffffffffffffffffffffff");
|
|
696
696
|
function intCV(value) {
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
let v = value;
|
|
698
|
+
if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
|
|
699
|
+
v = bytesToTwosBigInt(hexToBytes(v));
|
|
699
700
|
}
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
const n = intToBigInt(
|
|
701
|
+
if (v instanceof Uint8Array)
|
|
702
|
+
v = bytesToTwosBigInt(v);
|
|
703
|
+
const n = intToBigInt(v);
|
|
703
704
|
if (n > MAX_I128)
|
|
704
705
|
throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);
|
|
705
706
|
if (n < MIN_I128)
|
|
@@ -1081,7 +1082,8 @@ function hashP2PKH(input) {
|
|
|
1081
1082
|
// src/transactions/authorization.ts
|
|
1082
1083
|
etc.hmacSha256Sync = (key, ...msgs) => {
|
|
1083
1084
|
const h = hmac.create(sha2563, key);
|
|
1084
|
-
|
|
1085
|
+
for (const msg of msgs)
|
|
1086
|
+
h.update(msg);
|
|
1085
1087
|
return h.digest();
|
|
1086
1088
|
};
|
|
1087
1089
|
var EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));
|
|
@@ -2017,9 +2019,6 @@ async function simulateTransaction(client, params) {
|
|
|
2017
2019
|
// src/errors/websocket.ts
|
|
2018
2020
|
class WebSocketError extends BaseError {
|
|
2019
2021
|
name = "WebSocketError";
|
|
2020
|
-
constructor(message, options) {
|
|
2021
|
-
super(message, options);
|
|
2022
|
-
}
|
|
2023
2022
|
}
|
|
2024
2023
|
|
|
2025
2024
|
// src/subscriptions/actions.ts
|
|
@@ -2431,5 +2430,5 @@ export {
|
|
|
2431
2430
|
bnsResolve
|
|
2432
2431
|
};
|
|
2433
2432
|
|
|
2434
|
-
//# debugId=
|
|
2433
|
+
//# debugId=D11981BB65E0A0F464756E2164756E21
|
|
2435
2434
|
//# sourceMappingURL=index.js.map
|