@secondlayer/stacks 6.2.2 → 6.4.0
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-8f5catbf.js → stacks-esm-1mybf3yt.js} +2 -2
- package/dist/shared/{stacks-esm-tdrdye4y.js → stacks-esm-4ja7b0px.js} +2 -2
- package/dist/shared/{stacks-esm-t88hc019.js → stacks-esm-5qdnx2q9.js} +3 -3
- package/dist/shared/{stacks-esm-b54n1jdx.js → stacks-esm-6qv8gjes.js} +6 -6
- package/dist/shared/stacks-esm-6qv8gjes.js.map +12 -0
- package/dist/shared/{stacks-esm-a20wyky3.js → stacks-esm-896kv9yv.js} +2 -2
- package/dist/shared/{stacks-esm-exgw8j2j.js → stacks-esm-bragecm9.js} +7 -7
- package/dist/shared/{stacks-esm-hkw1kvd4.js → stacks-esm-gs60rd15.js} +7 -4
- package/dist/shared/{stacks-esm-hkw1kvd4.js.map → stacks-esm-gs60rd15.js.map} +3 -3
- package/dist/shared/{stacks-esm-xcd4sv1h.js → stacks-esm-hcjqgrtm.js} +5 -5
- package/dist/shared/{stacks-esm-pq0e379d.js → stacks-esm-hv11fdgy.js} +3 -3
- package/dist/shared/{stacks-esm-1b2rhv6y.js → stacks-esm-w36fvdxx.js} +2 -2
- package/dist/shared/{stacks-esm-7n5wd5md.js → stacks-esm-w8kswk0r.js} +5 -5
- package/dist/shared/{stacks-esm-0pc6tmf0.js → stacks-esm-x8gjr2v6.js} +2 -2
- package/dist/shared/{stacks-esm-nt5hf8ht.js → stacks-esm-z0rq3ejt.js} +44 -21
- package/dist/shared/stacks-esm-z0rq3ejt.js.map +12 -0
- package/dist/shared/{stacks-esm-p3zypwsw.js → stacks-esm-zwbhghxb.js} +2 -2
- package/dist/src/actions/index.cjs +6 -3
- package/dist/src/actions/index.cjs.map +3 -3
- package/dist/src/actions/index.js +10 -10
- package/dist/src/bitcoin/index.cjs +48 -21
- package/dist/src/bitcoin/index.cjs.map +4 -4
- package/dist/src/bitcoin/index.d.cts +13 -1
- package/dist/src/bitcoin/index.d.ts +13 -1
- package/dist/src/bitcoin/index.js +9 -7
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +6 -3
- package/dist/src/bns/index.cjs.map +3 -3
- package/dist/src/bns/index.js +10 -10
- package/dist/src/clarity/index.cjs +6 -3
- package/dist/src/clarity/index.cjs.map +3 -3
- package/dist/src/clarity/index.js +4 -4
- package/dist/src/filters/index.cjs +5 -5
- package/dist/src/filters/index.cjs.map +3 -3
- package/dist/src/filters/index.d.cts +6 -0
- package/dist/src/filters/index.d.ts +6 -0
- package/dist/src/filters/index.js +1 -1
- package/dist/src/index.cjs +10 -7
- package/dist/src/index.cjs.map +4 -4
- package/dist/src/index.d.cts +6 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +9 -9
- package/dist/src/postconditions/index.cjs +6 -3
- package/dist/src/postconditions/index.cjs.map +3 -3
- package/dist/src/postconditions/index.js +3 -3
- package/dist/src/pox/index.cjs +6 -3
- package/dist/src/pox/index.cjs.map +3 -3
- package/dist/src/pox/index.js +8 -8
- package/dist/src/pox5/index.cjs +47 -21
- package/dist/src/pox5/index.cjs.map +4 -4
- package/dist/src/pox5/index.js +10 -10
- package/dist/src/sbtc/index.cjs +6 -3
- package/dist/src/sbtc/index.cjs.map +3 -3
- package/dist/src/sbtc/index.js +7 -7
- package/dist/src/simnet/index.cjs +6 -16
- package/dist/src/simnet/index.cjs.map +3 -3
- package/dist/src/simnet/index.js +6 -16
- package/dist/src/simnet/index.js.map +3 -3
- package/dist/src/stackingdao/index.cjs +6 -3
- package/dist/src/stackingdao/index.cjs.map +3 -3
- package/dist/src/stackingdao/index.js +8 -8
- package/dist/src/transactions/index.cjs +6 -3
- package/dist/src/transactions/index.cjs.map +3 -3
- package/dist/src/transactions/index.js +3 -3
- package/package.json +1 -1
- package/dist/shared/stacks-esm-b54n1jdx.js.map +0 -12
- package/dist/shared/stacks-esm-nt5hf8ht.js.map +0 -12
- /package/dist/shared/{stacks-esm-8f5catbf.js.map → stacks-esm-1mybf3yt.js.map} +0 -0
- /package/dist/shared/{stacks-esm-tdrdye4y.js.map → stacks-esm-4ja7b0px.js.map} +0 -0
- /package/dist/shared/{stacks-esm-t88hc019.js.map → stacks-esm-5qdnx2q9.js.map} +0 -0
- /package/dist/shared/{stacks-esm-a20wyky3.js.map → stacks-esm-896kv9yv.js.map} +0 -0
- /package/dist/shared/{stacks-esm-exgw8j2j.js.map → stacks-esm-bragecm9.js.map} +0 -0
- /package/dist/shared/{stacks-esm-xcd4sv1h.js.map → stacks-esm-hcjqgrtm.js.map} +0 -0
- /package/dist/shared/{stacks-esm-pq0e379d.js.map → stacks-esm-hv11fdgy.js.map} +0 -0
- /package/dist/shared/{stacks-esm-1b2rhv6y.js.map → stacks-esm-w36fvdxx.js.map} +0 -0
- /package/dist/shared/{stacks-esm-7n5wd5md.js.map → stacks-esm-w8kswk0r.js.map} +0 -0
- /package/dist/shared/{stacks-esm-0pc6tmf0.js.map → stacks-esm-x8gjr2v6.js.map} +0 -0
- /package/dist/shared/{stacks-esm-p3zypwsw.js.map → stacks-esm-zwbhghxb.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import"../../shared/stacks-esm-7a0ehykf.js";
|
|
2
|
-
import"../../shared/stacks-esm-
|
|
2
|
+
import"../../shared/stacks-esm-gs60rd15.js";
|
|
3
3
|
import"../../shared/stacks-esm-kbz5s6v8.js";
|
|
4
|
-
import"../../shared/stacks-esm-
|
|
5
|
-
import"../../shared/stacks-esm-
|
|
6
|
-
import"../../shared/stacks-esm-
|
|
4
|
+
import"../../shared/stacks-esm-zwbhghxb.js";
|
|
5
|
+
import"../../shared/stacks-esm-hv11fdgy.js";
|
|
6
|
+
import"../../shared/stacks-esm-4ja7b0px.js";
|
|
7
7
|
import {
|
|
8
8
|
getAccountHistory2,
|
|
9
9
|
getAccountInfo2,
|
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
signTransactionAction2,
|
|
21
21
|
sponsorTransaction2,
|
|
22
22
|
transferStx2
|
|
23
|
-
} from "../../shared/stacks-esm-
|
|
24
|
-
import"../../shared/stacks-esm-
|
|
23
|
+
} from "../../shared/stacks-esm-bragecm9.js";
|
|
24
|
+
import"../../shared/stacks-esm-896kv9yv.js";
|
|
25
25
|
import {
|
|
26
26
|
getContract2,
|
|
27
27
|
buildFunctionArgs2,
|
|
28
28
|
isResponseOutput2,
|
|
29
29
|
ContractResponseError2
|
|
30
|
-
} from "../../shared/stacks-esm-
|
|
30
|
+
} from "../../shared/stacks-esm-w8kswk0r.js";
|
|
31
31
|
import {
|
|
32
32
|
getBalance2,
|
|
33
33
|
getDataVar2,
|
|
34
34
|
multicall2
|
|
35
|
-
} from "../../shared/stacks-esm-
|
|
35
|
+
} from "../../shared/stacks-esm-5qdnx2q9.js";
|
|
36
36
|
import {
|
|
37
37
|
estimateFee2,
|
|
38
38
|
getBlockHeight2,
|
|
@@ -49,10 +49,10 @@ import {
|
|
|
49
49
|
isNoEstimateAvailable2,
|
|
50
50
|
resolveFee2,
|
|
51
51
|
callContract2
|
|
52
|
-
} from "../../shared/stacks-esm-
|
|
52
|
+
} from "../../shared/stacks-esm-hcjqgrtm.js";
|
|
53
53
|
import {
|
|
54
54
|
readContract2
|
|
55
|
-
} from "../../shared/stacks-esm-
|
|
55
|
+
} from "../../shared/stacks-esm-x8gjr2v6.js";
|
|
56
56
|
import {
|
|
57
57
|
watchBlocks2,
|
|
58
58
|
watchMempool2,
|
|
@@ -66,6 +66,7 @@ var __export = (target, all) => {
|
|
|
66
66
|
// src/bitcoin/index.ts
|
|
67
67
|
var exports_bitcoin = {};
|
|
68
68
|
__export(exports_bitcoin, {
|
|
69
|
+
BitcoinSourceError: () => BitcoinSourceError,
|
|
69
70
|
BtcReader: () => BtcReader,
|
|
70
71
|
EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET: () => EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET,
|
|
71
72
|
SPV_ADAPTER_ABI: () => SPV_ADAPTER_ABI,
|
|
@@ -452,6 +453,14 @@ function rootFromProof(leafInternal, proof) {
|
|
|
452
453
|
}
|
|
453
454
|
|
|
454
455
|
// src/bitcoin/proof.ts
|
|
456
|
+
class BitcoinSourceError extends Error {
|
|
457
|
+
code;
|
|
458
|
+
name = "BitcoinSourceError";
|
|
459
|
+
constructor(code, message) {
|
|
460
|
+
super(message);
|
|
461
|
+
this.code = code;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
455
464
|
function normalizeTxid(txid) {
|
|
456
465
|
return without0x(txid).toLowerCase();
|
|
457
466
|
}
|
|
@@ -528,22 +537,32 @@ function bitcoinRpcSource(config) {
|
|
|
528
537
|
const basic = typeof config.auth === "string" ? config.auth : btoa(`${config.auth.username}:${config.auth.password}`);
|
|
529
538
|
headers.authorization = `Basic ${basic}`;
|
|
530
539
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
540
|
+
let res;
|
|
541
|
+
try {
|
|
542
|
+
res = await doFetch(config.url, {
|
|
543
|
+
method: "POST",
|
|
544
|
+
headers,
|
|
545
|
+
body: JSON.stringify({
|
|
546
|
+
jsonrpc: "1.0",
|
|
547
|
+
id: "secondlayer",
|
|
548
|
+
method,
|
|
549
|
+
params: rpcParams
|
|
550
|
+
})
|
|
551
|
+
});
|
|
552
|
+
} catch (error) {
|
|
553
|
+
throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: ${error instanceof Error ? error.message : "network error"}`);
|
|
554
|
+
}
|
|
555
|
+
let json;
|
|
556
|
+
try {
|
|
557
|
+
json = await res.json();
|
|
558
|
+
} catch {
|
|
559
|
+
throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: HTTP ${res.status}`);
|
|
543
560
|
}
|
|
544
|
-
const json = await res.json();
|
|
545
561
|
if (json.error) {
|
|
546
|
-
throw new
|
|
562
|
+
throw new BitcoinSourceError(json.error.code === -5 ? "not-found" : "unavailable", `bitcoin rpc ${method} error: ${json.error.message}`);
|
|
563
|
+
}
|
|
564
|
+
if (!res.ok) {
|
|
565
|
+
throw new BitcoinSourceError("unavailable", `bitcoin rpc ${method} failed: HTTP ${res.status}`);
|
|
547
566
|
}
|
|
548
567
|
return json.result;
|
|
549
568
|
}
|
|
@@ -557,7 +576,7 @@ function bitcoinRpcSource(config) {
|
|
|
557
576
|
true
|
|
558
577
|
]);
|
|
559
578
|
if (!tx.blockhash) {
|
|
560
|
-
throw new
|
|
579
|
+
throw new BitcoinSourceError("unconfirmed", `tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`);
|
|
561
580
|
}
|
|
562
581
|
const block = await rpc("getblock", [
|
|
563
582
|
tx.blockhash,
|
|
@@ -578,9 +597,14 @@ function esploraSource(config) {
|
|
|
578
597
|
const doFetch = config.fetch ?? fetch;
|
|
579
598
|
const base = config.url.replace(/\/+$/, "");
|
|
580
599
|
async function get(path) {
|
|
581
|
-
|
|
600
|
+
let res;
|
|
601
|
+
try {
|
|
602
|
+
res = await doFetch(`${base}${path}`);
|
|
603
|
+
} catch (error) {
|
|
604
|
+
throw new BitcoinSourceError("unavailable", `esplora GET ${path} failed: ${error instanceof Error ? error.message : "network error"}`);
|
|
605
|
+
}
|
|
582
606
|
if (!res.ok) {
|
|
583
|
-
throw new
|
|
607
|
+
throw new BitcoinSourceError(res.status === 404 ? "not-found" : "unavailable", `esplora GET ${path} failed: HTTP ${res.status}`);
|
|
584
608
|
}
|
|
585
609
|
return res;
|
|
586
610
|
}
|
|
@@ -591,7 +615,7 @@ function esploraSource(config) {
|
|
|
591
615
|
async getBlockForTx(txid) {
|
|
592
616
|
const status = await (await get(`/tx/${txid}`)).json();
|
|
593
617
|
if (!status.status.confirmed) {
|
|
594
|
-
throw new
|
|
618
|
+
throw new BitcoinSourceError("unconfirmed", `tx ${txid} is unconfirmed`);
|
|
595
619
|
}
|
|
596
620
|
const blockHashHex = status.status.block_hash;
|
|
597
621
|
const header = (await (await get(`/block/${blockHashHex}/header`)).text()).trim();
|
|
@@ -1087,11 +1111,14 @@ function readCV(reader, depth = 0) {
|
|
|
1087
1111
|
case "err":
|
|
1088
1112
|
return responseErrorCV(readCV(reader, depth + 1));
|
|
1089
1113
|
case "address":
|
|
1090
|
-
return
|
|
1114
|
+
return { type: "address", value: readAddress(reader) };
|
|
1091
1115
|
case "contract": {
|
|
1092
1116
|
const addr = readAddress(reader);
|
|
1093
1117
|
const name = readLPString(reader);
|
|
1094
|
-
|
|
1118
|
+
if (new TextEncoder().encode(name).byteLength >= 128) {
|
|
1119
|
+
throw new Error("Contract name must be less than 128 bytes");
|
|
1120
|
+
}
|
|
1121
|
+
return { type: "contract", value: `${addr}.${name}` };
|
|
1095
1122
|
}
|
|
1096
1123
|
case "list": {
|
|
1097
1124
|
const len = reader.readUInt32BE();
|
|
@@ -2798,5 +2825,5 @@ async function verifyBitcoinPayment(client, params) {
|
|
|
2798
2825
|
return { verified, mined, output, proof };
|
|
2799
2826
|
}
|
|
2800
2827
|
|
|
2801
|
-
//# debugId=
|
|
2828
|
+
//# debugId=1D0CF391F783188564756E2164756E21
|
|
2802
2829
|
//# sourceMappingURL=index.cjs.map
|