@secretkeylabs/stacks-tools 0.6.0-6e4e19c → 0.6.0-9c72bfd
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/README.md +2 -2
- package/dist/index.cjs +88 -85
- package/dist/index.d.cts +22 -487
- package/dist/index.d.ts +22 -487
- package/dist/index.js +85 -82
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -660,6 +660,80 @@ var stackingPool = {
|
|
|
660
660
|
members
|
|
661
661
|
};
|
|
662
662
|
|
|
663
|
+
// src/stacks-api/transactions/address-transactions.ts
|
|
664
|
+
async function addressTransactions(args) {
|
|
665
|
+
const search = new URLSearchParams();
|
|
666
|
+
if (args.limit) search.append("limit", args.limit.toString());
|
|
667
|
+
if (args.offset) search.append("offset", args.offset.toString());
|
|
668
|
+
const init = {};
|
|
669
|
+
if (args.apiKeyConfig) {
|
|
670
|
+
init.headers = {
|
|
671
|
+
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
const res = await fetch(
|
|
675
|
+
`${args.baseUrl}/extended/v2/addresses/${args.address}/transactions?${search}`,
|
|
676
|
+
init
|
|
677
|
+
);
|
|
678
|
+
if (!res.ok) {
|
|
679
|
+
return error({
|
|
680
|
+
name: "FetchAddressTransactionsError",
|
|
681
|
+
message: "Failed to fetch address transactions.",
|
|
682
|
+
data: {
|
|
683
|
+
status: res.status,
|
|
684
|
+
statusText: res.statusText,
|
|
685
|
+
bodyText: await safePromise(res.text())
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
const [jsonParseError, data] = await safePromise(res.json());
|
|
690
|
+
if (jsonParseError) {
|
|
691
|
+
return error({
|
|
692
|
+
name: "ParseBodyError",
|
|
693
|
+
message: "Failed to parse response body as JSON.",
|
|
694
|
+
data: jsonParseError
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
return success(data);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/stacks-api/transactions/events-for-an-address-transaction.ts
|
|
701
|
+
async function eventsForAnAddressTransaction(args) {
|
|
702
|
+
const search = new URLSearchParams();
|
|
703
|
+
if (args.limit) search.append("limit", args.limit.toString());
|
|
704
|
+
if (args.offset) search.append("offset", args.offset.toString());
|
|
705
|
+
const init = {};
|
|
706
|
+
if (args.apiKeyConfig) {
|
|
707
|
+
init.headers = {
|
|
708
|
+
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
const endpoint = `${args.baseUrl}/extended/v2/addresses/${args.address}/transactions/${args.transactionId}/events?${search}`;
|
|
712
|
+
const res = await fetch(endpoint, init);
|
|
713
|
+
if (!res.ok) {
|
|
714
|
+
return error({
|
|
715
|
+
name: "FetchEventsForAnAddressTransactionError",
|
|
716
|
+
message: `Failed to fetch address transaction events.`,
|
|
717
|
+
data: {
|
|
718
|
+
address: args.address,
|
|
719
|
+
transactionId: args.transactionId,
|
|
720
|
+
status: res.status,
|
|
721
|
+
statusText: res.statusText,
|
|
722
|
+
bodyText: await safePromise(res.text())
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
const [jsonParseError, data] = await safePromise(res.json());
|
|
727
|
+
if (jsonParseError) {
|
|
728
|
+
return error({
|
|
729
|
+
name: "ParseBodyError",
|
|
730
|
+
message: "Failed to parse response body as JSON.",
|
|
731
|
+
error: jsonParseError
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
return success(data);
|
|
735
|
+
}
|
|
736
|
+
|
|
663
737
|
// src/stacks-api/transactions/schemas.ts
|
|
664
738
|
import * as v11 from "valibot";
|
|
665
739
|
var baseTransactionSchema = v11.object({
|
|
@@ -749,81 +823,8 @@ var transactionSchema = v11.variant("tx_type", [
|
|
|
749
823
|
tokenTransferSchema
|
|
750
824
|
]);
|
|
751
825
|
|
|
752
|
-
// src/stacks-api/transactions/address-transactions.ts
|
|
753
|
-
import * as v12 from "valibot";
|
|
754
|
-
var resultSchema = v12.object({
|
|
755
|
-
tx: transactionSchema,
|
|
756
|
-
stx_sent: v12.string(),
|
|
757
|
-
stx_received: v12.string(),
|
|
758
|
-
events: v12.object({
|
|
759
|
-
stx: v12.object({
|
|
760
|
-
transfer: v12.number(),
|
|
761
|
-
mint: v12.number(),
|
|
762
|
-
burn: v12.number()
|
|
763
|
-
}),
|
|
764
|
-
ft: v12.object({
|
|
765
|
-
transfer: v12.number(),
|
|
766
|
-
mint: v12.number(),
|
|
767
|
-
burn: v12.number()
|
|
768
|
-
}),
|
|
769
|
-
nft: v12.object({
|
|
770
|
-
transfer: v12.number(),
|
|
771
|
-
mint: v12.number(),
|
|
772
|
-
burn: v12.number()
|
|
773
|
-
})
|
|
774
|
-
})
|
|
775
|
-
});
|
|
776
|
-
var resultsSchema4 = v12.array(resultSchema);
|
|
777
|
-
var addressTransactionsResponseSchema = v12.object({
|
|
778
|
-
...baseListResponseSchema.entries,
|
|
779
|
-
results: resultsSchema4
|
|
780
|
-
});
|
|
781
|
-
async function addressTransactions(args) {
|
|
782
|
-
const search = new URLSearchParams();
|
|
783
|
-
if (args.limit) search.append("limit", args.limit.toString());
|
|
784
|
-
if (args.offset) search.append("offset", args.offset.toString());
|
|
785
|
-
const init = {};
|
|
786
|
-
if (args.apiKeyConfig) {
|
|
787
|
-
init.headers = {
|
|
788
|
-
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
const res = await fetch(
|
|
792
|
-
`${args.baseUrl}/extended/v2/addresses/${args.address}/transactions?${search}`,
|
|
793
|
-
init
|
|
794
|
-
);
|
|
795
|
-
if (!res.ok) {
|
|
796
|
-
return error({
|
|
797
|
-
name: "FetchAddressTransactionsError",
|
|
798
|
-
message: "Failed to fetch address transactions.",
|
|
799
|
-
data: {
|
|
800
|
-
status: res.status,
|
|
801
|
-
statusText: res.statusText,
|
|
802
|
-
bodyText: await safePromise(res.text())
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
const [jsonParseError, data] = await safePromise(res.json());
|
|
807
|
-
if (jsonParseError) {
|
|
808
|
-
return error({
|
|
809
|
-
name: "ParseBodyError",
|
|
810
|
-
message: "Failed to parse response body as JSON.",
|
|
811
|
-
data: jsonParseError
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
const validationResult = v12.safeParse(addressTransactionsResponseSchema, data);
|
|
815
|
-
if (!validationResult.success) {
|
|
816
|
-
return error({
|
|
817
|
-
name: "ValidateDataError",
|
|
818
|
-
message: "Failed to validate data.",
|
|
819
|
-
data: validationResult
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
return success(validationResult.output);
|
|
823
|
-
}
|
|
824
|
-
|
|
825
826
|
// src/stacks-api/transactions/get-transaction.ts
|
|
826
|
-
import * as
|
|
827
|
+
import * as v12 from "valibot";
|
|
827
828
|
async function getTransaction(args) {
|
|
828
829
|
const init = {};
|
|
829
830
|
if (args.apiKeyConfig) {
|
|
@@ -836,8 +837,9 @@ async function getTransaction(args) {
|
|
|
836
837
|
if (!res.ok) {
|
|
837
838
|
return error({
|
|
838
839
|
name: "FetchTransactionError",
|
|
839
|
-
message: `Failed to fetch transaction
|
|
840
|
-
|
|
840
|
+
message: `Failed to fetch transaction.`,
|
|
841
|
+
data: {
|
|
842
|
+
transactionId: args.transactionId,
|
|
841
843
|
status: res.status,
|
|
842
844
|
statusText: res.statusText,
|
|
843
845
|
bodyText: await safePromise(res.text())
|
|
@@ -852,7 +854,7 @@ async function getTransaction(args) {
|
|
|
852
854
|
error: jsonParseError
|
|
853
855
|
});
|
|
854
856
|
}
|
|
855
|
-
const validationResult =
|
|
857
|
+
const validationResult = v12.safeParse(transactionSchema, data);
|
|
856
858
|
if (!validationResult.success) {
|
|
857
859
|
return error({
|
|
858
860
|
name: "ValidateDataError",
|
|
@@ -909,6 +911,7 @@ async function mempoolTransactions(args) {
|
|
|
909
911
|
// src/stacks-api/transactions/index.ts
|
|
910
912
|
var transactions = {
|
|
911
913
|
addressTransactions,
|
|
914
|
+
eventsForAnAddressTransaction,
|
|
912
915
|
getTransaction,
|
|
913
916
|
mempoolTransactions
|
|
914
917
|
};
|
|
@@ -963,16 +966,16 @@ var stacksApi = {
|
|
|
963
966
|
};
|
|
964
967
|
|
|
965
968
|
// src/stacks-rpc-api/smart-contracts/map-entry.ts
|
|
966
|
-
import * as
|
|
967
|
-
var mapEntryResponseSchema =
|
|
969
|
+
import * as v13 from "valibot";
|
|
970
|
+
var mapEntryResponseSchema = v13.object({
|
|
968
971
|
/**
|
|
969
972
|
* Hex-encoded string of clarity value. It is always an optional tuple.
|
|
970
973
|
*/
|
|
971
|
-
data:
|
|
974
|
+
data: v13.string(),
|
|
972
975
|
/**
|
|
973
976
|
* Hex-encoded string of the MARF proof for the data
|
|
974
977
|
*/
|
|
975
|
-
proof:
|
|
978
|
+
proof: v13.optional(v13.string())
|
|
976
979
|
});
|
|
977
980
|
async function mapEntry(args) {
|
|
978
981
|
const search = new URLSearchParams();
|
|
@@ -1012,7 +1015,7 @@ async function mapEntry(args) {
|
|
|
1012
1015
|
data: jsonError
|
|
1013
1016
|
});
|
|
1014
1017
|
}
|
|
1015
|
-
const validationResult =
|
|
1018
|
+
const validationResult = v13.safeParse(mapEntryResponseSchema, data);
|
|
1016
1019
|
if (!validationResult.success) {
|
|
1017
1020
|
return error({
|
|
1018
1021
|
name: "ValidateDataError",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secretkeylabs/stacks-tools",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-9c72bfd",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@arethetypeswrong/cli": "0.15.4",
|
|
26
26
|
"@types/bun": "latest",
|
|
27
|
-
"prettier": "
|
|
28
|
-
"tsup": "
|
|
29
|
-
"typescript": "
|
|
27
|
+
"prettier": "3.5.3",
|
|
28
|
+
"tsup": "8.5.0",
|
|
29
|
+
"typescript": "5.8.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@stacks/blockchain-api-client": "
|
|
32
|
+
"@stacks/blockchain-api-client": "8.11.1",
|
|
33
33
|
"@stacks/transactions": "^7.0.0",
|
|
34
|
-
"valibot": "^
|
|
34
|
+
"valibot": "^1.1.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"exponential-backoff": "3.1.1"
|