@secondlayer/stacks 6.0.0 → 6.1.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-0pc6tmf0.js +50 -0
- package/dist/shared/{stacks-qex691bh.js.map → stacks-esm-0pc6tmf0.js.map} +2 -2
- package/dist/shared/{stacks-qt8ehebn.js → stacks-esm-16d82wyc.js} +10 -10
- package/dist/shared/{stacks-qt8ehebn.js.map → stacks-esm-16d82wyc.js.map} +2 -2
- package/dist/shared/{stacks-qs5fzts5.js → stacks-esm-7a0ehykf.js} +43 -43
- package/dist/shared/{stacks-qs5fzts5.js.map → stacks-esm-7a0ehykf.js.map} +2 -2
- package/dist/shared/{stacks-4hs8r4q2.js → stacks-esm-7v18h5dk.js} +4 -4
- package/dist/shared/{stacks-xjkn3en1.cjs.map → stacks-esm-7v18h5dk.js.map} +2 -2
- package/dist/shared/{stacks-71k0vmct.js → stacks-esm-8f5catbf.js} +126 -126
- package/dist/shared/{stacks-71k0vmct.js.map → stacks-esm-8f5catbf.js.map} +2 -2
- package/dist/shared/{stacks-wxfd6r4b.js → stacks-esm-8jt6k8p3.js} +13 -13
- package/dist/shared/{stacks-wxfd6r4b.js.map → stacks-esm-8jt6k8p3.js.map} +2 -2
- package/dist/shared/{stacks-x0qqwrev.js → stacks-esm-a20wyky3.js} +92 -92
- package/dist/shared/{stacks-agk106zs.cjs.map → stacks-esm-a20wyky3.js.map} +2 -2
- package/dist/shared/{stacks-gjz26k6b.js → stacks-esm-b54n1jdx.js} +102 -58
- package/dist/shared/stacks-esm-b54n1jdx.js.map +12 -0
- package/dist/shared/{stacks-9c1yam8b.js → stacks-esm-cmtj5vky.js} +162 -162
- package/dist/shared/{stacks-9c1yam8b.js.map → stacks-esm-cmtj5vky.js.map} +2 -2
- package/dist/shared/{stacks-z90xdr1x.js → stacks-esm-e2qhfgke.js} +36 -36
- package/dist/shared/{stacks-z90xdr1x.js.map → stacks-esm-e2qhfgke.js.map} +2 -2
- package/dist/shared/{stacks-v03zef3g.js → stacks-esm-ea4m4bk7.js} +117 -117
- package/dist/shared/{stacks-v03zef3g.js.map → stacks-esm-ea4m4bk7.js.map} +2 -2
- package/dist/shared/{stacks-69nq48jp.js → stacks-esm-hkw1kvd4.js} +140 -140
- package/dist/shared/{stacks-69nq48jp.js.map → stacks-esm-hkw1kvd4.js.map} +2 -2
- package/dist/shared/{stacks-qcae5852.js → stacks-esm-k108pemv.js} +4 -4
- package/dist/shared/{stacks-qcae5852.js.map → stacks-esm-k108pemv.js.map} +2 -2
- package/dist/shared/stacks-esm-kbz5s6v8.js +84 -0
- package/dist/shared/{stacks-4d7c3x27.js.map → stacks-esm-kbz5s6v8.js.map} +2 -2
- package/dist/shared/{stacks-kg1npstf.js → stacks-esm-mt1thm7k.js} +9 -9
- package/dist/shared/{stacks-kg1npstf.js.map → stacks-esm-mt1thm7k.js.map} +2 -2
- package/dist/shared/{stacks-yvb7rvwk.js → stacks-esm-n1mekwnb.js} +9 -9
- package/dist/shared/{stacks-8vzxax5e.cjs.map → stacks-esm-n1mekwnb.js.map} +2 -2
- package/dist/shared/{stacks-mftyrc60.js → stacks-esm-nt5hf8ht.js} +34 -34
- package/dist/shared/{stacks-mftyrc60.js.map → stacks-esm-nt5hf8ht.js.map} +2 -2
- package/dist/shared/{stacks-51ybf135.js → stacks-esm-phgy8yqf.js} +210 -210
- package/dist/shared/{stacks-51ybf135.js.map → stacks-esm-phgy8yqf.js.map} +2 -2
- package/dist/shared/{stacks-mbt36bzt.js → stacks-esm-pxv6ny92.js} +116 -116
- package/dist/shared/{stacks-mbt36bzt.js.map → stacks-esm-pxv6ny92.js.map} +2 -2
- package/dist/shared/{stacks-8brgfvqx.js → stacks-esm-qfzxhdqz.js} +19 -19
- package/dist/shared/{stacks-8brgfvqx.js.map → stacks-esm-qfzxhdqz.js.map} +2 -2
- package/dist/shared/{stacks-fd4rx56e.js → stacks-esm-snj9s2q8.js} +43 -43
- package/dist/shared/{stacks-fd4rx56e.js.map → stacks-esm-snj9s2q8.js.map} +2 -2
- package/dist/shared/{stacks-yajyej2y.js → stacks-esm-ss9ap75h.js} +28 -28
- package/dist/shared/{stacks-yajyej2y.js.map → stacks-esm-ss9ap75h.js.map} +2 -2
- package/dist/shared/{stacks-1m3m1agc.js → stacks-esm-t88hc019.js} +18 -18
- package/dist/shared/{stacks-1m3m1agc.js.map → stacks-esm-t88hc019.js.map} +2 -2
- package/dist/shared/stacks-esm-tdrdye4y.js +48 -0
- package/dist/shared/{stacks-enpj9krt.cjs.map → stacks-esm-tdrdye4y.js.map} +2 -2
- package/dist/src/accounts/index.cjs +565 -9
- package/dist/src/accounts/index.cjs.map +10 -4
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/accounts/index.js +26 -26
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +3860 -44
- package/dist/src/actions/index.cjs.map +65 -3
- package/dist/src/actions/index.d.cts +1 -1
- package/dist/src/actions/index.d.ts +1 -1
- package/dist/src/actions/index.js +102 -103
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +2506 -31
- package/dist/src/bitcoin/index.cjs.map +31 -3
- package/dist/src/bitcoin/index.d.cts +92 -92
- package/dist/src/bitcoin/index.d.ts +92 -92
- package/dist/src/bitcoin/index.js +88 -90
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +4435 -10
- package/dist/src/bns/index.cjs.map +50 -3
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +39 -41
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.cjs +141 -5
- package/dist/src/chains/index.cjs.map +5 -3
- package/dist/src/chains/index.d.cts +1 -1
- package/dist/src/chains/index.d.ts +1 -1
- package/dist/src/chains/index.js +12 -12
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +2021 -1
- package/dist/src/clarity/index.cjs.map +24 -3
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/clarity/index.js +170 -171
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +19 -19
- package/dist/src/connect/index.cjs.map +2 -2
- package/dist/src/connect/index.d.cts +1 -1
- package/dist/src/connect/index.d.ts +1 -1
- package/dist/src/connect/index.js +19 -19
- package/dist/src/connect/index.js.map +2 -2
- package/dist/src/connect/walletconnect/index.cjs +6 -46
- package/dist/src/connect/walletconnect/index.cjs.map +3 -4
- package/dist/src/connect/walletconnect/index.d.cts +1 -1
- package/dist/src/connect/walletconnect/index.d.ts +1 -1
- package/dist/src/connect/walletconnect/index.js +6 -46
- package/dist/src/connect/walletconnect/index.js.map +3 -4
- package/dist/src/filters/index.cjs +727 -1
- package/dist/src/filters/index.cjs.map +11 -3
- package/dist/src/filters/index.d.cts +76 -13
- package/dist/src/filters/index.d.ts +76 -13
- package/dist/src/filters/index.js +30 -26
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/index.cjs +4000 -126
- package/dist/src/index.cjs.map +69 -4
- package/dist/src/index.d.cts +658 -607
- package/dist/src/index.d.ts +658 -607
- package/dist/src/index.js +219 -219
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.cjs +1728 -1
- package/dist/src/postconditions/index.cjs.map +20 -3
- package/dist/src/postconditions/index.d.cts +1 -1
- package/dist/src/postconditions/index.d.ts +1 -1
- package/dist/src/postconditions/index.js +16 -17
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +3866 -11
- package/dist/src/pox/index.cjs.map +48 -3
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +40 -41
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +4124 -95
- package/dist/src/pox5/index.cjs.map +55 -4
- package/dist/src/pox5/index.d.cts +9 -1
- package/dist/src/pox5/index.d.ts +9 -1
- package/dist/src/pox5/index.js +210 -209
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +3719 -16
- package/dist/src/sbtc/index.cjs.map +47 -3
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +39 -40
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/simnet/index.cjs +16 -16
- package/dist/src/simnet/index.cjs.map +2 -2
- package/dist/src/simnet/index.d.cts +1 -1
- package/dist/src/simnet/index.d.ts +1 -1
- package/dist/src/simnet/index.js +16 -16
- package/dist/src/simnet/index.js.map +2 -2
- package/dist/src/stackingdao/index.cjs +3747 -3
- package/dist/src/stackingdao/index.cjs.map +45 -3
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +26 -27
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.cjs +160 -6
- package/dist/src/subscriptions/index.cjs.map +6 -3
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/subscriptions/index.js +14 -15
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.cjs +2189 -49
- package/dist/src/transactions/index.cjs.map +23 -3
- package/dist/src/transactions/index.d.cts +1 -1
- package/dist/src/transactions/index.d.ts +1 -1
- package/dist/src/transactions/index.js +104 -105
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +503 -69
- package/dist/src/utils/index.cjs.map +9 -3
- package/dist/src/utils/index.d.cts +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +131 -131
- package/dist/src/utils/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-02actsrx.cjs +0 -17
- package/dist/shared/stacks-02actsrx.cjs.map +0 -10
- package/dist/shared/stacks-03vfm21t.cjs +0 -222
- package/dist/shared/stacks-03vfm21t.cjs.map +0 -12
- package/dist/shared/stacks-24h5k94q.cjs +0 -74
- package/dist/shared/stacks-24h5k94q.cjs.map +0 -11
- package/dist/shared/stacks-37kz5t9f.cjs +0 -764
- package/dist/shared/stacks-37kz5t9f.cjs.map +0 -23
- package/dist/shared/stacks-3mt2q2na.cjs +0 -65
- package/dist/shared/stacks-3mt2q2na.cjs.map +0 -9
- package/dist/shared/stacks-4d7c3x27.js +0 -84
- package/dist/shared/stacks-4hs8r4q2.js.map +0 -10
- package/dist/shared/stacks-8vzxax5e.cjs +0 -45
- package/dist/shared/stacks-agk106zs.cjs +0 -267
- package/dist/shared/stacks-bdgh9n83.cjs +0 -212
- package/dist/shared/stacks-bdgh9n83.cjs.map +0 -11
- package/dist/shared/stacks-dpxnxhqb.cjs +0 -51
- package/dist/shared/stacks-dpxnxhqb.cjs.map +0 -11
- package/dist/shared/stacks-ee53k9j2.cjs +0 -651
- package/dist/shared/stacks-ee53k9j2.cjs.map +0 -13
- package/dist/shared/stacks-enpj9krt.cjs +0 -38
- package/dist/shared/stacks-f35mnrmg.cjs +0 -164
- package/dist/shared/stacks-f35mnrmg.cjs.map +0 -10
- package/dist/shared/stacks-fhzwsn5d.cjs +0 -261
- package/dist/shared/stacks-fhzwsn5d.cjs.map +0 -12
- package/dist/shared/stacks-gjz26k6b.js.map +0 -12
- package/dist/shared/stacks-gza2n1zs.cjs +0 -73
- package/dist/shared/stacks-gza2n1zs.cjs.map +0 -11
- package/dist/shared/stacks-kem68d80.cjs +0 -156
- package/dist/shared/stacks-kem68d80.cjs.map +0 -10
- package/dist/shared/stacks-n98w7g57.cjs +0 -234
- package/dist/shared/stacks-n98w7g57.cjs.map +0 -10
- package/dist/shared/stacks-p337hp6m.cjs +0 -336
- package/dist/shared/stacks-p337hp6m.cjs.map +0 -25
- package/dist/shared/stacks-q34k4vnc.cjs +0 -286
- package/dist/shared/stacks-q34k4vnc.cjs.map +0 -12
- package/dist/shared/stacks-qex691bh.js +0 -50
- package/dist/shared/stacks-rryme9bv.cjs +0 -569
- package/dist/shared/stacks-rryme9bv.cjs.map +0 -13
- package/dist/shared/stacks-s5vej5z6.cjs +0 -410
- package/dist/shared/stacks-s5vej5z6.cjs.map +0 -15
- package/dist/shared/stacks-sdqkapct.cjs +0 -67
- package/dist/shared/stacks-sdqkapct.cjs.map +0 -12
- package/dist/shared/stacks-v2rfr46a.js +0 -48
- package/dist/shared/stacks-v2rfr46a.js.map +0 -10
- package/dist/shared/stacks-vea7nde7.cjs +0 -731
- package/dist/shared/stacks-vea7nde7.cjs.map +0 -13
- package/dist/shared/stacks-wk8yp13j.cjs +0 -33
- package/dist/shared/stacks-wk8yp13j.cjs.map +0 -11
- package/dist/shared/stacks-x0qqwrev.js.map +0 -12
- package/dist/shared/stacks-xjkn3en1.cjs +0 -42
- package/dist/shared/stacks-xnrywjf1.cjs +0 -131
- package/dist/shared/stacks-xnrywjf1.cjs.map +0 -11
- package/dist/shared/stacks-yvb7rvwk.js.map +0 -10
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
bytesToHex2,
|
|
3
|
+
with0x2,
|
|
4
|
+
intToBigInt2
|
|
5
|
+
} from "./stacks-esm-7a0ehykf.js";
|
|
4
6
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
serializeCVBytes2,
|
|
8
|
+
BroadcastError2,
|
|
9
|
+
TransactionAbortedError2,
|
|
10
|
+
TransactionDroppedError2,
|
|
11
|
+
WaitForTransactionTimeoutError2,
|
|
12
|
+
deserializeCVBytes2
|
|
13
|
+
} from "./stacks-esm-hkw1kvd4.js";
|
|
9
14
|
import {
|
|
10
|
-
clearTxCache,
|
|
11
15
|
serializePayload,
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
clearTxCache,
|
|
17
|
+
serializeTransaction2
|
|
18
|
+
} from "./stacks-esm-phgy8yqf.js";
|
|
14
19
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
TransactionDroppedError,
|
|
18
|
-
WaitForTransactionTimeoutError,
|
|
19
|
-
deserializeCVBytes,
|
|
20
|
-
serializeCVBytes
|
|
21
|
-
} from "./stacks-69nq48jp.js";
|
|
20
|
+
parseContractId2
|
|
21
|
+
} from "./stacks-esm-kbz5s6v8.js";
|
|
22
22
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
buildContractCall2,
|
|
24
|
+
signTransactionWithAccount2,
|
|
25
|
+
getTransactionId2
|
|
26
|
+
} from "./stacks-esm-cmtj5vky.js";
|
|
25
27
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./stacks-
|
|
28
|
+
MalformedResponseError2
|
|
29
|
+
} from "./stacks-esm-0pc6tmf0.js";
|
|
28
30
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
with0x
|
|
32
|
-
} from "./stacks-qs5fzts5.js";
|
|
31
|
+
BaseError2
|
|
32
|
+
} from "./stacks-esm-7v18h5dk.js";
|
|
33
33
|
|
|
34
34
|
// src/actions/public/estimateFee.ts
|
|
35
35
|
function isValidEstimation(e) {
|
|
36
36
|
return typeof e === "object" && e !== null && "fee_rate" in e && "fee" in e && (typeof e.fee_rate === "number" || typeof e.fee_rate === "string") && (typeof e.fee === "number" || typeof e.fee === "string");
|
|
37
37
|
}
|
|
38
|
-
async function
|
|
39
|
-
const payloadHex =
|
|
40
|
-
const txHex =
|
|
38
|
+
async function estimateFee2(client, params) {
|
|
39
|
+
const payloadHex = bytesToHex2(serializePayload(params.transaction.payload));
|
|
40
|
+
const txHex = bytesToHex2(serializeTransaction2(params.transaction));
|
|
41
41
|
const data = await client.request("/v2/fees/transaction", {
|
|
42
42
|
method: "POST",
|
|
43
43
|
body: {
|
|
@@ -48,7 +48,7 @@ async function estimateFee(client, params) {
|
|
|
48
48
|
const raw = data?.estimations ?? [];
|
|
49
49
|
return raw.map((e) => {
|
|
50
50
|
if (!isValidEstimation(e)) {
|
|
51
|
-
throw new
|
|
51
|
+
throw new MalformedResponseError2("estimateFee: node response contains invalid fee estimation entry");
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
54
|
feeRate: Number(e.fee_rate),
|
|
@@ -58,16 +58,16 @@ async function estimateFee(client, params) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// src/actions/public/getBlockHeight.ts
|
|
61
|
-
async function
|
|
61
|
+
async function getBlockHeight2(client) {
|
|
62
62
|
const data = await client.request("/v2/info", { method: "GET" });
|
|
63
63
|
if (typeof data?.stacks_tip_height !== "number") {
|
|
64
|
-
throw new
|
|
64
|
+
throw new MalformedResponseError2('getBlockHeight: /v2/info response is missing "stacks_tip_height"');
|
|
65
65
|
}
|
|
66
66
|
return data.stacks_tip_height;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// src/errors/http.ts
|
|
70
|
-
class
|
|
70
|
+
class HttpRequestError2 extends BaseError2 {
|
|
71
71
|
name = "HttpRequestError";
|
|
72
72
|
status;
|
|
73
73
|
url;
|
|
@@ -82,31 +82,31 @@ class HttpRequestError extends BaseError {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// src/actions/public/getMapEntry.ts
|
|
85
|
-
async function
|
|
86
|
-
const [address, name] =
|
|
87
|
-
const serializedKey =
|
|
85
|
+
async function getMapEntry2(client, params) {
|
|
86
|
+
const [address, name] = parseContractId2(params.contract);
|
|
87
|
+
const serializedKey = with0x2(bytesToHex2(serializeCVBytes2(params.key)));
|
|
88
88
|
const data = await client.request(`/v2/map_entry/${address}/${name}/${params.mapName}`, {
|
|
89
89
|
method: "POST",
|
|
90
90
|
body: serializedKey
|
|
91
91
|
});
|
|
92
92
|
if (typeof data?.data !== "string") {
|
|
93
|
-
throw new
|
|
93
|
+
throw new MalformedResponseError2(`getMapEntry: /v2/map_entry/${address}/${name}/${params.mapName} response is missing "data"`);
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return deserializeCVBytes2(data.data);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// src/actions/public/getNonce.ts
|
|
99
|
-
async function
|
|
99
|
+
async function getNonce2(client, params) {
|
|
100
100
|
const data = await client.request(`/v2/accounts/${encodeURIComponent(params.address)}`, { method: "GET" });
|
|
101
101
|
const nonce = data?.nonce;
|
|
102
102
|
if (typeof nonce !== "number" && typeof nonce !== "string") {
|
|
103
|
-
throw new
|
|
103
|
+
throw new MalformedResponseError2(`getNonce: /v2/accounts/${params.address} response is missing "nonce"`);
|
|
104
104
|
}
|
|
105
105
|
return BigInt(nonce);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// src/errors/transport.ts
|
|
109
|
-
class
|
|
109
|
+
class TimeoutError2 extends BaseError2 {
|
|
110
110
|
name = "TimeoutError";
|
|
111
111
|
method;
|
|
112
112
|
url;
|
|
@@ -187,7 +187,7 @@ async function fetchWithRetry(url, options, retryCount, retryDelay, timeout, ext
|
|
|
187
187
|
let timedOut = false;
|
|
188
188
|
const timeoutId = setTimeout(() => {
|
|
189
189
|
timedOut = true;
|
|
190
|
-
controller.abort(new
|
|
190
|
+
controller.abort(new TimeoutError2({ method, url, timeout, attempt }));
|
|
191
191
|
}, timeout);
|
|
192
192
|
const onCallerAbort = () => controller.abort(abortReason(signal));
|
|
193
193
|
signal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
@@ -206,7 +206,7 @@ async function fetchWithRetry(url, options, retryCount, retryDelay, timeout, ext
|
|
|
206
206
|
} catch (error) {
|
|
207
207
|
if (signal?.aborted)
|
|
208
208
|
throw abortReason(signal);
|
|
209
|
-
lastError = timedOut ? new
|
|
209
|
+
lastError = timedOut ? new TimeoutError2({ method, url, timeout, attempt }) : error instanceof Error ? error : new Error(String(error));
|
|
210
210
|
if (attempt < retryCount) {
|
|
211
211
|
clearTimeout(timeoutId);
|
|
212
212
|
await sleep(retryDelay * (attempt + 1), signal);
|
|
@@ -223,7 +223,7 @@ async function fetchWithRetry(url, options, retryCount, retryDelay, timeout, ext
|
|
|
223
223
|
throw abortReason(signal);
|
|
224
224
|
if (!timedOut)
|
|
225
225
|
throw error;
|
|
226
|
-
lastError = new
|
|
226
|
+
lastError = new TimeoutError2({ method, url, timeout, attempt });
|
|
227
227
|
if (attempt < retryCount) {
|
|
228
228
|
clearTimeout(timeoutId);
|
|
229
229
|
await sleep(retryDelay * (attempt + 1), signal);
|
|
@@ -242,13 +242,13 @@ async function fetchWithRetry(url, options, retryCount, retryDelay, timeout, ext
|
|
|
242
242
|
return;
|
|
243
243
|
})
|
|
244
244
|
]);
|
|
245
|
-
throw new
|
|
245
|
+
throw new HttpRequestError2(response.status, {
|
|
246
246
|
details: capDetails(body),
|
|
247
247
|
url,
|
|
248
248
|
method
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
lastError = new
|
|
251
|
+
lastError = new HttpRequestError2(response.status, { url, method });
|
|
252
252
|
const delay = retryAfterMs(response) ?? retryDelay * (attempt + 1);
|
|
253
253
|
response.body?.cancel().catch(() => {});
|
|
254
254
|
clearTimeout(timeoutId);
|
|
@@ -298,7 +298,7 @@ function buildRequestFn(baseUrl, config) {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
// src/actions/public/txSources.ts
|
|
301
|
-
class
|
|
301
|
+
class IndexSourceConfigError2 extends Error {
|
|
302
302
|
name = "IndexSourceConfigError";
|
|
303
303
|
}
|
|
304
304
|
function isHiroHost(url, client) {
|
|
@@ -323,10 +323,10 @@ function indexRequestFn(client, baseUrl, sourceName) {
|
|
|
323
323
|
const transportUrl = client.transport.config.url?.replace(/\/$/, "");
|
|
324
324
|
if (baseUrl === undefined) {
|
|
325
325
|
if (!transportUrl) {
|
|
326
|
-
throw new
|
|
326
|
+
throw new IndexSourceConfigError2(`${sourceName} needs the URL of your Secondlayer instance: pass baseUrl, or use an http() transport pointed at the instance`);
|
|
327
327
|
}
|
|
328
328
|
if (isHiroHost(transportUrl, client)) {
|
|
329
|
-
throw new
|
|
329
|
+
throw new IndexSourceConfigError2(`${sourceName} reads /v1/index on a Secondlayer instance, and ${transportUrl} is a Hiro host: pass baseUrl with the URL of your instance`);
|
|
330
330
|
}
|
|
331
331
|
return client.request;
|
|
332
332
|
}
|
|
@@ -337,7 +337,7 @@ function indexRequestFn(client, baseUrl, sourceName) {
|
|
|
337
337
|
return buildRequestFn(target, { timeout, retryCount, retryDelay });
|
|
338
338
|
}
|
|
339
339
|
function indexNotFound(error, sourceName) {
|
|
340
|
-
if (!(error instanceof
|
|
340
|
+
if (!(error instanceof HttpRequestError2) || error.status !== 404) {
|
|
341
341
|
return false;
|
|
342
342
|
}
|
|
343
343
|
const body = error.details;
|
|
@@ -345,7 +345,7 @@ function indexNotFound(error, sourceName) {
|
|
|
345
345
|
try {
|
|
346
346
|
JSON.parse(body);
|
|
347
347
|
} catch {
|
|
348
|
-
throw new
|
|
348
|
+
throw new IndexSourceConfigError2(`${sourceName} got a non-JSON 404 from ${error.url ?? "the transport host"}: it does not serve /v1/index, pass baseUrl with the URL of your Secondlayer instance`, { cause: error });
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
return true;
|
|
@@ -357,7 +357,7 @@ function decodeResultHex(hex) {
|
|
|
357
357
|
if (!hex)
|
|
358
358
|
return {};
|
|
359
359
|
try {
|
|
360
|
-
return { result:
|
|
360
|
+
return { result: deserializeCVBytes2(hex), resultHex: hex };
|
|
361
361
|
} catch {
|
|
362
362
|
return { resultHex: hex };
|
|
363
363
|
}
|
|
@@ -373,14 +373,14 @@ function normalizeStatus(txStatus) {
|
|
|
373
373
|
return txStatus.startsWith("dropped") ? "dropped" : undefined;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function extendedApiSource2() {
|
|
377
377
|
return {
|
|
378
378
|
async get({ client, txid }) {
|
|
379
379
|
let data;
|
|
380
380
|
try {
|
|
381
381
|
data = await client.request(`/extended/v1/tx/${encodeURIComponent(normalizeTxid(txid))}`, { method: "GET" });
|
|
382
382
|
} catch (error) {
|
|
383
|
-
if (error instanceof
|
|
383
|
+
if (error instanceof HttpRequestError2 && error.status === 404) {
|
|
384
384
|
return { receipt: null };
|
|
385
385
|
}
|
|
386
386
|
throw error;
|
|
@@ -405,7 +405,7 @@ function extendedApiSource() {
|
|
|
405
405
|
}
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function indexTxSource2(params = {}) {
|
|
409
409
|
const headers = params.apiKey ? { authorization: `Bearer ${params.apiKey}` } : undefined;
|
|
410
410
|
return {
|
|
411
411
|
canonicalOnly: true,
|
|
@@ -443,22 +443,22 @@ function indexTxSource(params = {}) {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
// src/actions/public/getTransaction.ts
|
|
446
|
-
async function
|
|
447
|
-
const source = params.source ??
|
|
446
|
+
async function getTransaction2(client, params) {
|
|
447
|
+
const source = params.source ?? extendedApiSource2();
|
|
448
448
|
const { receipt } = await source.get({ client, txid: params.txid });
|
|
449
449
|
return receipt;
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
// src/actions/public/waitForTransactionReceipt.ts
|
|
453
453
|
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
454
|
-
async function
|
|
454
|
+
async function waitForTransactionReceipt2(client, params) {
|
|
455
455
|
const {
|
|
456
456
|
txid,
|
|
457
457
|
confirmations = 1,
|
|
458
458
|
timeout = 180000,
|
|
459
459
|
pollingInterval = 3000
|
|
460
460
|
} = params;
|
|
461
|
-
const source = params.source ??
|
|
461
|
+
const source = params.source ?? extendedApiSource2();
|
|
462
462
|
const droppedGracePeriod = params.droppedGracePeriod ?? (source.canonicalOnly ? timeout : 30000);
|
|
463
463
|
const startedAt = Date.now();
|
|
464
464
|
let unknownSince = null;
|
|
@@ -469,16 +469,16 @@ async function waitForTransactionReceipt(client, params) {
|
|
|
469
469
|
if (receipt === null) {
|
|
470
470
|
unknownSince ??= Date.now();
|
|
471
471
|
if (Date.now() - unknownSince >= droppedGracePeriod) {
|
|
472
|
-
throw new
|
|
472
|
+
throw new TransactionDroppedError2(everPending ? `Transaction ${txid} left the mempool without being mined` : `Transaction ${txid} was never observed by the status source`, { txid });
|
|
473
473
|
}
|
|
474
474
|
} else {
|
|
475
475
|
unknownSince = null;
|
|
476
476
|
switch (receipt.status) {
|
|
477
477
|
case "dropped":
|
|
478
|
-
throw new
|
|
478
|
+
throw new TransactionDroppedError2(`Transaction ${txid} was dropped from the mempool`, { txid });
|
|
479
479
|
case "abort_by_response":
|
|
480
480
|
case "abort_by_post_condition":
|
|
481
|
-
throw new
|
|
481
|
+
throw new TransactionAbortedError2(`Transaction ${txid} aborted (${receipt.status})`, { receipt });
|
|
482
482
|
case "pending":
|
|
483
483
|
everPending = true;
|
|
484
484
|
break;
|
|
@@ -486,7 +486,7 @@ async function waitForTransactionReceipt(client, params) {
|
|
|
486
486
|
if (confirmations <= 1)
|
|
487
487
|
return receipt;
|
|
488
488
|
if (receipt.blockHeight !== undefined) {
|
|
489
|
-
const tip = snapshot.tip ?? await
|
|
489
|
+
const tip = snapshot.tip ?? await getBlockHeight2(client);
|
|
490
490
|
if (tip - receipt.blockHeight + 1 >= confirmations)
|
|
491
491
|
return receipt;
|
|
492
492
|
}
|
|
@@ -495,18 +495,18 @@ async function waitForTransactionReceipt(client, params) {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
if (Date.now() - startedAt >= timeout) {
|
|
498
|
-
throw new
|
|
498
|
+
throw new WaitForTransactionTimeoutError2(`Timed out after ${timeout}ms waiting for transaction ${txid}`, { txid });
|
|
499
499
|
}
|
|
500
500
|
await sleep2(pollingInterval);
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
// src/actions/wallet/sendTransaction.ts
|
|
505
|
-
async function
|
|
506
|
-
const hex =
|
|
505
|
+
async function sendTransaction2(client, params) {
|
|
506
|
+
const hex = bytesToHex2(serializeTransaction2(params.transaction));
|
|
507
507
|
const body = { tx: hex };
|
|
508
508
|
if (params.attachment) {
|
|
509
|
-
body.attachment = typeof params.attachment === "string" ? params.attachment :
|
|
509
|
+
body.attachment = typeof params.attachment === "string" ? params.attachment : bytesToHex2(params.attachment);
|
|
510
510
|
}
|
|
511
511
|
let data;
|
|
512
512
|
try {
|
|
@@ -516,33 +516,33 @@ async function sendTransaction(client, params) {
|
|
|
516
516
|
retryCount: 0
|
|
517
517
|
});
|
|
518
518
|
} catch (error) {
|
|
519
|
-
if (error instanceof
|
|
519
|
+
if (error instanceof HttpRequestError2 && error.details) {
|
|
520
520
|
try {
|
|
521
521
|
data = JSON.parse(error.details);
|
|
522
522
|
} catch {
|
|
523
523
|
throw error;
|
|
524
524
|
}
|
|
525
|
-
} else if (error instanceof
|
|
526
|
-
const
|
|
527
|
-
const receipt = await
|
|
525
|
+
} else if (error instanceof TimeoutError2) {
|
|
526
|
+
const txid = getTransactionId2(params.transaction);
|
|
527
|
+
const receipt = await getTransaction2(client, { txid }).catch(() => null);
|
|
528
528
|
if (receipt === null)
|
|
529
529
|
throw error;
|
|
530
|
-
data = { txid
|
|
530
|
+
data = { txid };
|
|
531
531
|
} else {
|
|
532
532
|
throw error;
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
if (data.error) {
|
|
536
|
-
throw new
|
|
536
|
+
throw new BroadcastError2(data.reason ?? data.error, {
|
|
537
537
|
reason: data.reason,
|
|
538
538
|
reasonData: data.reason_data,
|
|
539
|
-
txid: data.txid ??
|
|
539
|
+
txid: data.txid ?? getTransactionId2(params.transaction)
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
|
-
const txid = typeof data === "string" ? data.replace(/"/g, "") : data.txid ??
|
|
542
|
+
const txid = typeof data === "string" ? data.replace(/"/g, "") : data.txid ?? getTransactionId2(params.transaction);
|
|
543
543
|
if (params.wait) {
|
|
544
544
|
const confirmations = params.wait === true ? 1 : params.wait;
|
|
545
|
-
const receipt = await
|
|
545
|
+
const receipt = await waitForTransactionReceipt2(client, {
|
|
546
546
|
txid,
|
|
547
547
|
confirmations
|
|
548
548
|
});
|
|
@@ -552,12 +552,12 @@ async function sendTransaction(client, params) {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
// src/actions/wallet/nonceManager.ts
|
|
555
|
-
function
|
|
555
|
+
function jsonRpcSource2() {
|
|
556
556
|
return {
|
|
557
|
-
get: ({ client, address }) =>
|
|
557
|
+
get: ({ client, address }) => getNonce2(client, { address })
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function memoryStore2() {
|
|
561
561
|
const next = new Map;
|
|
562
562
|
const locks = new Map;
|
|
563
563
|
function withLock(key, fn) {
|
|
@@ -593,9 +593,9 @@ function memoryStore() {
|
|
|
593
593
|
function nonceKey(client, address) {
|
|
594
594
|
return `${client.chain?.id ?? "stacks"}:${address}`;
|
|
595
595
|
}
|
|
596
|
-
function
|
|
597
|
-
const source = params.source ??
|
|
598
|
-
const store = params.store ??
|
|
596
|
+
function createNonceManager2(params = {}) {
|
|
597
|
+
const source = params.source ?? jsonRpcSource2();
|
|
598
|
+
const store = params.store ?? memoryStore2();
|
|
599
599
|
return {
|
|
600
600
|
consume({ client, address }) {
|
|
601
601
|
return store.reserve(nonceKey(client, address), () => source.get({ client, address }));
|
|
@@ -611,10 +611,10 @@ function createNonceManager(params = {}) {
|
|
|
611
611
|
}
|
|
612
612
|
};
|
|
613
613
|
}
|
|
614
|
-
async function
|
|
614
|
+
async function resolveNonce2(client, address) {
|
|
615
615
|
if (client.nonceManager)
|
|
616
616
|
return client.nonceManager.consume({ client, address });
|
|
617
|
-
return
|
|
617
|
+
return getNonce2(client, { address });
|
|
618
618
|
}
|
|
619
619
|
async function releaseNonce(client, address, nonce) {
|
|
620
620
|
if (!client.nonceManager)
|
|
@@ -623,7 +623,7 @@ async function releaseNonce(client, address, nonce) {
|
|
|
623
623
|
await client.nonceManager.release({ client, address, nonce });
|
|
624
624
|
} catch {}
|
|
625
625
|
}
|
|
626
|
-
async function
|
|
626
|
+
async function reconcileNonce2(manager, params) {
|
|
627
627
|
const { client, address, source } = params;
|
|
628
628
|
const downward = params.downward ?? true;
|
|
629
629
|
const authoritative = await source.get({ client, address });
|
|
@@ -637,7 +637,7 @@ async function reconcileNonce(manager, params) {
|
|
|
637
637
|
await manager.reset({ client, address });
|
|
638
638
|
return { reset: true, authoritative, tracked };
|
|
639
639
|
}
|
|
640
|
-
function
|
|
640
|
+
function startNonceReconciler2(manager, params) {
|
|
641
641
|
const { client, addresses, source, clock } = params;
|
|
642
642
|
const intervalMs = params.intervalMs ?? 60000;
|
|
643
643
|
let running = true;
|
|
@@ -646,7 +646,7 @@ function startNonceReconciler(manager, params) {
|
|
|
646
646
|
return;
|
|
647
647
|
for (const address of addresses) {
|
|
648
648
|
try {
|
|
649
|
-
const result = await
|
|
649
|
+
const result = await reconcileNonce2(manager, {
|
|
650
650
|
client,
|
|
651
651
|
address,
|
|
652
652
|
source,
|
|
@@ -678,8 +678,8 @@ function startNonceReconciler(manager, params) {
|
|
|
678
678
|
stop: () => clearInterval(timer)
|
|
679
679
|
};
|
|
680
680
|
}
|
|
681
|
-
function
|
|
682
|
-
if (!(error instanceof
|
|
681
|
+
function isNonceConflictError2(error) {
|
|
682
|
+
if (!(error instanceof BroadcastError2))
|
|
683
683
|
return false;
|
|
684
684
|
if (error.reason === "ConflictingNonceInMempool" || error.reason === "BadNonce") {
|
|
685
685
|
return true;
|
|
@@ -688,14 +688,14 @@ function isNonceConflictError(error) {
|
|
|
688
688
|
return false;
|
|
689
689
|
return error.message.toLowerCase().includes("nonce");
|
|
690
690
|
}
|
|
691
|
-
async function
|
|
691
|
+
async function broadcastWithNonceReset2(client, params) {
|
|
692
692
|
try {
|
|
693
|
-
const result = await
|
|
693
|
+
const result = await sendTransaction2(client, {
|
|
694
694
|
transaction: params.transaction
|
|
695
695
|
});
|
|
696
696
|
return result.txid;
|
|
697
697
|
} catch (error) {
|
|
698
|
-
if (client.nonceManager &&
|
|
698
|
+
if (client.nonceManager && isNonceConflictError2(error)) {
|
|
699
699
|
await client.nonceManager.reset({ client, address: params.address });
|
|
700
700
|
}
|
|
701
701
|
throw error;
|
|
@@ -703,56 +703,56 @@ async function broadcastWithNonceReset(client, params) {
|
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
// src/actions/wallet/utils.ts
|
|
706
|
-
function
|
|
706
|
+
function isProviderAccount2(account) {
|
|
707
707
|
return account.type === "provider";
|
|
708
708
|
}
|
|
709
709
|
var FEE_TIERS = ["min", "low", "mid", "high"];
|
|
710
710
|
var TIER_INDEX = { low: 0, mid: 1, high: 2 };
|
|
711
|
-
function
|
|
711
|
+
function isFeeTier2(fee) {
|
|
712
712
|
return typeof fee === "string" && FEE_TIERS.includes(fee);
|
|
713
713
|
}
|
|
714
|
-
function
|
|
715
|
-
return BigInt(
|
|
714
|
+
function minimumFee2(transaction) {
|
|
715
|
+
return BigInt(serializeTransaction2(transaction).length);
|
|
716
716
|
}
|
|
717
|
-
function
|
|
718
|
-
return error instanceof
|
|
717
|
+
function isNoEstimateAvailable2(error) {
|
|
718
|
+
return error instanceof HttpRequestError2 && error.status === 400 && (error.details?.includes("NoEstimateAvailable") ?? false);
|
|
719
719
|
}
|
|
720
|
-
async function
|
|
721
|
-
if (fee !== undefined && !
|
|
722
|
-
return { fee:
|
|
720
|
+
async function resolveFee2(client, transaction, fee) {
|
|
721
|
+
if (fee !== undefined && !isFeeTier2(fee))
|
|
722
|
+
return { fee: intToBigInt2(fee) };
|
|
723
723
|
const tier = fee ?? "mid";
|
|
724
724
|
if (tier === "min")
|
|
725
|
-
return { fee:
|
|
725
|
+
return { fee: minimumFee2(transaction), tier };
|
|
726
726
|
let estimates;
|
|
727
727
|
try {
|
|
728
|
-
estimates = await
|
|
728
|
+
estimates = await estimateFee2(client, { transaction });
|
|
729
729
|
} catch (error) {
|
|
730
|
-
if (!
|
|
730
|
+
if (!isNoEstimateAvailable2(error))
|
|
731
731
|
throw error;
|
|
732
|
-
return { fee:
|
|
732
|
+
return { fee: minimumFee2(transaction), tier: "min" };
|
|
733
733
|
}
|
|
734
734
|
const pick = estimates[TIER_INDEX[tier]] ?? estimates[estimates.length - 1];
|
|
735
735
|
if (pick)
|
|
736
736
|
return { fee: BigInt(pick.fee), tier };
|
|
737
|
-
return { fee:
|
|
737
|
+
return { fee: minimumFee2(transaction), tier: "min" };
|
|
738
738
|
}
|
|
739
739
|
function setUnsignedFee(transaction, fee) {
|
|
740
740
|
transaction.auth.spendingCondition.fee = fee;
|
|
741
741
|
clearTxCache(transaction);
|
|
742
742
|
}
|
|
743
743
|
function assertNoFeeTierForProvider(fee) {
|
|
744
|
-
if (
|
|
744
|
+
if (isFeeTier2(fee)) {
|
|
745
745
|
throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
// src/actions/wallet/callContract.ts
|
|
750
|
-
async function
|
|
750
|
+
async function callContract2(client, params) {
|
|
751
751
|
const account = client.account;
|
|
752
752
|
if (!account)
|
|
753
753
|
throw new Error("Account required");
|
|
754
|
-
const [contractAddress, contractName] =
|
|
755
|
-
if (
|
|
754
|
+
const [contractAddress, contractName] = parseContractId2(params.contract);
|
|
755
|
+
if (isProviderAccount2(account)) {
|
|
756
756
|
assertNoFeeTierForProvider(params.fee);
|
|
757
757
|
const result = await account.provider.request("stx_callContract", {
|
|
758
758
|
contract: params.contract,
|
|
@@ -762,10 +762,10 @@ async function callContract(client, params) {
|
|
|
762
762
|
return result.txid;
|
|
763
763
|
}
|
|
764
764
|
const managed = params.nonce === undefined && client.nonceManager !== undefined;
|
|
765
|
-
const nonce = params.nonce ?? await
|
|
765
|
+
const nonce = params.nonce ?? await resolveNonce2(client, account.address);
|
|
766
766
|
try {
|
|
767
|
-
const needsFeeResolution = params.fee === undefined ||
|
|
768
|
-
const unsigned =
|
|
767
|
+
const needsFeeResolution = params.fee === undefined || isFeeTier2(params.fee);
|
|
768
|
+
const unsigned = buildContractCall2({
|
|
769
769
|
contractAddress,
|
|
770
770
|
contractName,
|
|
771
771
|
functionName: params.functionName,
|
|
@@ -778,11 +778,11 @@ async function callContract(client, params) {
|
|
|
778
778
|
postConditions: params.postConditions
|
|
779
779
|
});
|
|
780
780
|
if (needsFeeResolution) {
|
|
781
|
-
const { fee } = await
|
|
781
|
+
const { fee } = await resolveFee2(client, unsigned, params.fee);
|
|
782
782
|
setUnsignedFee(unsigned, fee);
|
|
783
783
|
}
|
|
784
|
-
const signed = await
|
|
785
|
-
return await
|
|
784
|
+
const signed = await signTransactionWithAccount2(unsigned, account);
|
|
785
|
+
return await broadcastWithNonceReset2(client, {
|
|
786
786
|
transaction: signed,
|
|
787
787
|
address: account.address
|
|
788
788
|
});
|
|
@@ -793,7 +793,7 @@ async function callContract(client, params) {
|
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
|
|
796
|
-
export {
|
|
796
|
+
export { estimateFee2, getBlockHeight2, HttpRequestError2, getMapEntry2, getNonce2, TimeoutError2, createTransport, buildRequestFn, IndexSourceConfigError2, indexRequestFn, indexNotFound, extendedApiSource2, indexTxSource2, getTransaction2, waitForTransactionReceipt2, sendTransaction2, jsonRpcSource2, memoryStore2, createNonceManager2, resolveNonce2, releaseNonce, reconcileNonce2, startNonceReconciler2, isNonceConflictError2, broadcastWithNonceReset2, isProviderAccount2, isFeeTier2, minimumFee2, isNoEstimateAvailable2, resolveFee2, setUnsignedFee, assertNoFeeTierForProvider, callContract2 };
|
|
797
797
|
|
|
798
|
-
//# debugId=
|
|
799
|
-
//# sourceMappingURL=stacks-
|
|
798
|
+
//# debugId=863F4AC28F71513464756E2164756E21
|
|
799
|
+
//# sourceMappingURL=stacks-esm-ea4m4bk7.js.map
|