@secretkeylabs/stacks-tools 0.2.0 → 0.3.0-05c5288
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/index.cjs +1090 -0
- package/dist/index.d.cts +661 -0
- package/dist/index.d.ts +661 -2
- package/dist/index.js +1052 -3
- package/package.json +13 -5
- package/dist/index.js.map +0 -1
- package/dist/pox4-api/burn-height-to-reward-cycle.d.ts +0 -7
- package/dist/pox4-api/burn-height-to-reward-cycle.js +0 -6
- package/dist/pox4-api/burn-height-to-reward-cycle.js.map +0 -1
- package/dist/pox4-api/current-pox-reward-cycle.d.ts +0 -1
- package/dist/pox4-api/current-pox-reward-cycle.js +0 -3
- package/dist/pox4-api/current-pox-reward-cycle.js.map +0 -1
- package/dist/pox4-api/get-stacker-info.d.ts +0 -1
- package/dist/pox4-api/get-stacker-info.js +0 -3
- package/dist/pox4-api/get-stacker-info.js.map +0 -1
- package/dist/pox4-api/reward-cycle-to-burn-height.d.ts +0 -1
- package/dist/pox4-api/reward-cycle-to-burn-height.js +0 -3
- package/dist/pox4-api/reward-cycle-to-burn-height.js.map +0 -1
- package/dist/queries/get-signer-total-locked.d.ts +0 -18
- package/dist/queries/get-signer-total-locked.js +0 -59
- package/dist/queries/get-signer-total-locked.js.map +0 -1
- package/dist/queries/index.d.ts +0 -4
- package/dist/queries/index.js +0 -5
- package/dist/queries/index.js.map +0 -1
- package/dist/stacks-api/accounts/balances.d.ts +0 -34
- package/dist/stacks-api/accounts/balances.js +0 -70
- package/dist/stacks-api/accounts/balances.js.map +0 -1
- package/dist/stacks-api/accounts/index.d.ts +0 -4
- package/dist/stacks-api/accounts/index.js +0 -5
- package/dist/stacks-api/accounts/index.js.map +0 -1
- package/dist/stacks-api/blocks/get-block.d.ts +0 -29
- package/dist/stacks-api/blocks/get-block.js +0 -62
- package/dist/stacks-api/blocks/get-block.js.map +0 -1
- package/dist/stacks-api/blocks/index.d.ts +0 -4
- package/dist/stacks-api/blocks/index.js +0 -5
- package/dist/stacks-api/blocks/index.js.map +0 -1
- package/dist/stacks-api/index.d.ts +0 -28
- package/dist/stacks-api/index.js +0 -17
- package/dist/stacks-api/index.js.map +0 -1
- package/dist/stacks-api/info/core-api.d.ts +0 -21
- package/dist/stacks-api/info/core-api.js +0 -55
- package/dist/stacks-api/info/core-api.js.map +0 -1
- package/dist/stacks-api/info/index.d.ts +0 -6
- package/dist/stacks-api/info/index.js +0 -7
- package/dist/stacks-api/info/index.js.map +0 -1
- package/dist/stacks-api/info/pox-details.d.ts +0 -59
- package/dist/stacks-api/info/pox-details.js +0 -92
- package/dist/stacks-api/info/pox-details.js.map +0 -1
- package/dist/stacks-api/proof-of-transfer/cycle.d.ts +0 -16
- package/dist/stacks-api/proof-of-transfer/cycle.js +0 -50
- package/dist/stacks-api/proof-of-transfer/cycle.js.map +0 -1
- package/dist/stacks-api/proof-of-transfer/cycles.d.ts +0 -37
- package/dist/stacks-api/proof-of-transfer/cycles.js +0 -61
- package/dist/stacks-api/proof-of-transfer/cycles.js.map +0 -1
- package/dist/stacks-api/proof-of-transfer/index.d.ts +0 -10
- package/dist/stacks-api/proof-of-transfer/index.js +0 -11
- package/dist/stacks-api/proof-of-transfer/index.js.map +0 -1
- package/dist/stacks-api/proof-of-transfer/signers-in-cycle.d.ts +0 -45
- package/dist/stacks-api/proof-of-transfer/signers-in-cycle.js +0 -66
- package/dist/stacks-api/proof-of-transfer/signers-in-cycle.js.map +0 -1
- package/dist/stacks-api/proof-of-transfer/stackers-for-signer-in-cycle.d.ts +0 -34
- package/dist/stacks-api/proof-of-transfer/stackers-for-signer-in-cycle.js +0 -59
- package/dist/stacks-api/proof-of-transfer/stackers-for-signer-in-cycle.js.map +0 -1
- package/dist/stacks-api/smart-contracts/index.d.ts +0 -4
- package/dist/stacks-api/smart-contracts/index.js +0 -5
- package/dist/stacks-api/smart-contracts/index.js.map +0 -1
- package/dist/stacks-api/smart-contracts/read-only.d.ts +0 -19
- package/dist/stacks-api/smart-contracts/read-only.js +0 -50
- package/dist/stacks-api/smart-contracts/read-only.js.map +0 -1
- package/dist/stacks-api/stacking-pool/index.d.ts +0 -4
- package/dist/stacks-api/stacking-pool/index.js +0 -5
- package/dist/stacks-api/stacking-pool/index.js.map +0 -1
- package/dist/stacks-api/stacking-pool/members.d.ts +0 -34
- package/dist/stacks-api/stacking-pool/members.js +0 -64
- package/dist/stacks-api/stacking-pool/members.js.map +0 -1
- package/dist/stacks-api/transactions/address-transactions.d.ts +0 -487
- package/dist/stacks-api/transactions/address-transactions.js +0 -75
- package/dist/stacks-api/transactions/address-transactions.js.map +0 -1
- package/dist/stacks-api/transactions/get-transaction.d.ts +0 -8
- package/dist/stacks-api/transactions/get-transaction.js +0 -42
- package/dist/stacks-api/transactions/get-transaction.js.map +0 -1
- package/dist/stacks-api/transactions/index.d.ts +0 -6
- package/dist/stacks-api/transactions/index.js +0 -7
- package/dist/stacks-api/transactions/index.js.map +0 -1
- package/dist/stacks-api/transactions/schemas.d.ts +0 -327
- package/dist/stacks-api/transactions/schemas.js +0 -85
- package/dist/stacks-api/transactions/schemas.js.map +0 -1
- package/dist/stacks-api/types.d.ts +0 -26
- package/dist/stacks-api/types.js +0 -8
- package/dist/stacks-api/types.js.map +0 -1
- package/dist/utils/call-rate-limited-api.d.ts +0 -8
- package/dist/utils/call-rate-limited-api.js +0 -28
- package/dist/utils/call-rate-limited-api.js.map +0 -1
- package/dist/utils/safe.d.ts +0 -10
- package/dist/utils/safe.js +0 -31
- package/dist/utils/safe.js.map +0 -1
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const baseTransactionSchema: v.ObjectSchema<{
|
|
3
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
4
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
5
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
6
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
7
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
8
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
9
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
10
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
11
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
12
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
13
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
14
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
15
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
16
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
17
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
18
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
19
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
20
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
21
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
22
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
23
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
24
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
25
|
-
readonly tx_result: v.ObjectSchema<{
|
|
26
|
-
readonly hex: v.StringSchema<undefined>;
|
|
27
|
-
readonly repr: v.StringSchema<undefined>;
|
|
28
|
-
}, undefined>;
|
|
29
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
30
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
31
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
32
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
33
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
34
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
35
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
36
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
37
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
38
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
39
|
-
}, undefined>;
|
|
40
|
-
export declare const contractCallTransactionSchema: v.ObjectSchema<{
|
|
41
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
42
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
43
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
44
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
45
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
46
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
47
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
48
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
49
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
50
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
51
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
52
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
53
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
54
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
55
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
56
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
57
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
58
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
59
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
60
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
61
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
62
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
63
|
-
readonly tx_result: v.ObjectSchema<{
|
|
64
|
-
readonly hex: v.StringSchema<undefined>;
|
|
65
|
-
readonly repr: v.StringSchema<undefined>;
|
|
66
|
-
}, undefined>;
|
|
67
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
68
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
69
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
70
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
71
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
72
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
73
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
74
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
75
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
76
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
77
|
-
readonly tx_type: v.LiteralSchema<"contract_call", undefined>;
|
|
78
|
-
readonly contract_call: v.ObjectSchema<{
|
|
79
|
-
readonly contract_id: v.StringSchema<undefined>;
|
|
80
|
-
readonly function_name: v.StringSchema<undefined>;
|
|
81
|
-
readonly function_signature: v.StringSchema<undefined>;
|
|
82
|
-
readonly function_args: v.ArraySchema<v.ObjectSchema<{
|
|
83
|
-
readonly hex: v.StringSchema<undefined>;
|
|
84
|
-
readonly repr: v.StringSchema<undefined>;
|
|
85
|
-
readonly name: v.StringSchema<undefined>;
|
|
86
|
-
readonly type: v.StringSchema<undefined>;
|
|
87
|
-
}, undefined>, undefined>;
|
|
88
|
-
}, undefined>;
|
|
89
|
-
}, undefined>;
|
|
90
|
-
export type ContractCallTransaction = v.InferOutput<typeof contractCallTransactionSchema>;
|
|
91
|
-
export declare const smartContractTransactionSchema: v.ObjectSchema<{
|
|
92
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
93
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
94
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
95
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
96
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
97
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
98
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
99
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
100
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
101
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
102
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
103
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
104
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
105
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
106
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
107
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
108
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
109
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
110
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
111
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
112
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
113
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
114
|
-
readonly tx_result: v.ObjectSchema<{
|
|
115
|
-
readonly hex: v.StringSchema<undefined>;
|
|
116
|
-
readonly repr: v.StringSchema<undefined>;
|
|
117
|
-
}, undefined>;
|
|
118
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
119
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
120
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
121
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
122
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
123
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
124
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
125
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
126
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
127
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
128
|
-
readonly tx_type: v.LiteralSchema<"smart_contract", undefined>;
|
|
129
|
-
readonly smart_contract: v.ObjectSchema<{
|
|
130
|
-
/**
|
|
131
|
-
* NOTE: The types may be wrong, not sure what type of value is used when
|
|
132
|
-
* the version is not `null`.
|
|
133
|
-
*/
|
|
134
|
-
readonly clarity_version: v.UnionSchema<[v.NullSchema<undefined>, v.NumberSchema<undefined>], undefined>;
|
|
135
|
-
readonly contract_id: v.StringSchema<undefined>;
|
|
136
|
-
readonly source_code: v.StringSchema<undefined>;
|
|
137
|
-
}, undefined>;
|
|
138
|
-
}, undefined>;
|
|
139
|
-
export type SmartContractTransaction = v.InferOutput<typeof smartContractTransactionSchema>;
|
|
140
|
-
export declare const tokenTransferSchema: v.ObjectSchema<{
|
|
141
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
142
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
143
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
144
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
145
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
146
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
147
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
148
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
149
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
150
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
151
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
152
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
153
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
154
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
155
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
156
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
157
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
158
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
159
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
160
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
161
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
162
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
163
|
-
readonly tx_result: v.ObjectSchema<{
|
|
164
|
-
readonly hex: v.StringSchema<undefined>;
|
|
165
|
-
readonly repr: v.StringSchema<undefined>;
|
|
166
|
-
}, undefined>;
|
|
167
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
168
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
169
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
170
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
171
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
172
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
173
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
174
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
175
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
176
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
177
|
-
readonly tx_type: v.LiteralSchema<"token_transfer", undefined>;
|
|
178
|
-
readonly token_transfer: v.ObjectSchema<{
|
|
179
|
-
readonly recipient_address: v.StringSchema<undefined>;
|
|
180
|
-
readonly amount: v.StringSchema<undefined>;
|
|
181
|
-
readonly memo: v.StringSchema<undefined>;
|
|
182
|
-
}, undefined>;
|
|
183
|
-
}, undefined>;
|
|
184
|
-
/**
|
|
185
|
-
* Incomplete schema of some transaction types.
|
|
186
|
-
*/
|
|
187
|
-
export declare const transactionSchema: v.VariantSchema<"tx_type", [v.ObjectSchema<{
|
|
188
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
189
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
190
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
191
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
192
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
193
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
194
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
195
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
196
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
197
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
198
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
199
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
200
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
201
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
202
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
203
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
204
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
205
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
206
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
207
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
208
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
209
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
210
|
-
readonly tx_result: v.ObjectSchema<{
|
|
211
|
-
readonly hex: v.StringSchema<undefined>;
|
|
212
|
-
readonly repr: v.StringSchema<undefined>;
|
|
213
|
-
}, undefined>;
|
|
214
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
215
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
216
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
217
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
218
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
219
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
220
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
221
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
222
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
223
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
224
|
-
readonly tx_type: v.LiteralSchema<"contract_call", undefined>;
|
|
225
|
-
readonly contract_call: v.ObjectSchema<{
|
|
226
|
-
readonly contract_id: v.StringSchema<undefined>;
|
|
227
|
-
readonly function_name: v.StringSchema<undefined>;
|
|
228
|
-
readonly function_signature: v.StringSchema<undefined>;
|
|
229
|
-
readonly function_args: v.ArraySchema<v.ObjectSchema<{
|
|
230
|
-
readonly hex: v.StringSchema<undefined>;
|
|
231
|
-
readonly repr: v.StringSchema<undefined>;
|
|
232
|
-
readonly name: v.StringSchema<undefined>;
|
|
233
|
-
readonly type: v.StringSchema<undefined>;
|
|
234
|
-
}, undefined>, undefined>;
|
|
235
|
-
}, undefined>;
|
|
236
|
-
}, undefined>, v.ObjectSchema<{
|
|
237
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
238
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
239
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
240
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
241
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
242
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
243
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
244
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
245
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
246
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
247
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
248
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
249
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
250
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
251
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
252
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
253
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
254
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
255
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
256
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
257
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
258
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
259
|
-
readonly tx_result: v.ObjectSchema<{
|
|
260
|
-
readonly hex: v.StringSchema<undefined>;
|
|
261
|
-
readonly repr: v.StringSchema<undefined>;
|
|
262
|
-
}, undefined>;
|
|
263
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
264
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
265
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
266
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
267
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
268
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
269
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
270
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
271
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
272
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
273
|
-
readonly tx_type: v.LiteralSchema<"smart_contract", undefined>;
|
|
274
|
-
readonly smart_contract: v.ObjectSchema<{
|
|
275
|
-
/**
|
|
276
|
-
* NOTE: The types may be wrong, not sure what type of value is used when
|
|
277
|
-
* the version is not `null`.
|
|
278
|
-
*/
|
|
279
|
-
readonly clarity_version: v.UnionSchema<[v.NullSchema<undefined>, v.NumberSchema<undefined>], undefined>;
|
|
280
|
-
readonly contract_id: v.StringSchema<undefined>;
|
|
281
|
-
readonly source_code: v.StringSchema<undefined>;
|
|
282
|
-
}, undefined>;
|
|
283
|
-
}, undefined>, v.ObjectSchema<{
|
|
284
|
-
readonly tx_id: v.StringSchema<undefined>;
|
|
285
|
-
readonly nonce: v.NumberSchema<undefined>;
|
|
286
|
-
readonly fee_rate: v.StringSchema<undefined>;
|
|
287
|
-
readonly sender_address: v.StringSchema<undefined>;
|
|
288
|
-
readonly sponsored: v.BooleanSchema<undefined>;
|
|
289
|
-
readonly post_condition_mode: v.StringSchema<undefined>;
|
|
290
|
-
readonly post_conditions: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
291
|
-
readonly anchor_mode: v.StringSchema<undefined>;
|
|
292
|
-
readonly is_unanchored: v.BooleanSchema<undefined>;
|
|
293
|
-
readonly block_hash: v.StringSchema<undefined>;
|
|
294
|
-
readonly parent_block_hash: v.StringSchema<undefined>;
|
|
295
|
-
readonly block_height: v.NumberSchema<undefined>;
|
|
296
|
-
readonly block_time: v.NumberSchema<undefined>;
|
|
297
|
-
readonly block_time_iso: v.StringSchema<undefined>;
|
|
298
|
-
readonly burn_block_height: v.NumberSchema<undefined>;
|
|
299
|
-
readonly burn_block_time: v.NumberSchema<undefined>;
|
|
300
|
-
readonly burn_block_time_iso: v.StringSchema<undefined>;
|
|
301
|
-
readonly parent_burn_block_time: v.NumberSchema<undefined>;
|
|
302
|
-
readonly parent_burn_block_time_iso: v.StringSchema<undefined>;
|
|
303
|
-
readonly canonical: v.BooleanSchema<undefined>;
|
|
304
|
-
readonly tx_index: v.NumberSchema<undefined>;
|
|
305
|
-
readonly tx_status: v.StringSchema<undefined>;
|
|
306
|
-
readonly tx_result: v.ObjectSchema<{
|
|
307
|
-
readonly hex: v.StringSchema<undefined>;
|
|
308
|
-
readonly repr: v.StringSchema<undefined>;
|
|
309
|
-
}, undefined>;
|
|
310
|
-
readonly microblock_hash: v.StringSchema<undefined>;
|
|
311
|
-
readonly microblock_sequence: v.NumberSchema<undefined>;
|
|
312
|
-
readonly microblock_canonical: v.BooleanSchema<undefined>;
|
|
313
|
-
readonly event_count: v.NumberSchema<undefined>;
|
|
314
|
-
readonly events: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
315
|
-
readonly execution_cost_read_count: v.NumberSchema<undefined>;
|
|
316
|
-
readonly execution_cost_read_length: v.NumberSchema<undefined>;
|
|
317
|
-
readonly execution_cost_runtime: v.NumberSchema<undefined>;
|
|
318
|
-
readonly execution_cost_write_count: v.NumberSchema<undefined>;
|
|
319
|
-
readonly execution_cost_write_length: v.NumberSchema<undefined>;
|
|
320
|
-
readonly tx_type: v.LiteralSchema<"token_transfer", undefined>;
|
|
321
|
-
readonly token_transfer: v.ObjectSchema<{
|
|
322
|
-
readonly recipient_address: v.StringSchema<undefined>;
|
|
323
|
-
readonly amount: v.StringSchema<undefined>;
|
|
324
|
-
readonly memo: v.StringSchema<undefined>;
|
|
325
|
-
}, undefined>;
|
|
326
|
-
}, undefined>], undefined>;
|
|
327
|
-
export type Transaction = v.InferOutput<typeof transactionSchema>;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const baseTransactionSchema = v.object({
|
|
3
|
-
tx_id: v.string(),
|
|
4
|
-
nonce: v.number(),
|
|
5
|
-
fee_rate: v.string(),
|
|
6
|
-
sender_address: v.string(),
|
|
7
|
-
sponsored: v.boolean(),
|
|
8
|
-
post_condition_mode: v.string(),
|
|
9
|
-
post_conditions: v.array(v.unknown()),
|
|
10
|
-
anchor_mode: v.string(),
|
|
11
|
-
is_unanchored: v.boolean(),
|
|
12
|
-
block_hash: v.string(),
|
|
13
|
-
parent_block_hash: v.string(),
|
|
14
|
-
block_height: v.number(),
|
|
15
|
-
block_time: v.number(),
|
|
16
|
-
block_time_iso: v.string(),
|
|
17
|
-
burn_block_height: v.number(),
|
|
18
|
-
burn_block_time: v.number(),
|
|
19
|
-
burn_block_time_iso: v.string(),
|
|
20
|
-
parent_burn_block_time: v.number(),
|
|
21
|
-
parent_burn_block_time_iso: v.string(),
|
|
22
|
-
canonical: v.boolean(),
|
|
23
|
-
tx_index: v.number(),
|
|
24
|
-
tx_status: v.string(),
|
|
25
|
-
tx_result: v.object({
|
|
26
|
-
hex: v.string(),
|
|
27
|
-
repr: v.string(),
|
|
28
|
-
}),
|
|
29
|
-
microblock_hash: v.string(),
|
|
30
|
-
microblock_sequence: v.number(),
|
|
31
|
-
microblock_canonical: v.boolean(),
|
|
32
|
-
event_count: v.number(),
|
|
33
|
-
events: v.array(v.unknown()),
|
|
34
|
-
execution_cost_read_count: v.number(),
|
|
35
|
-
execution_cost_read_length: v.number(),
|
|
36
|
-
execution_cost_runtime: v.number(),
|
|
37
|
-
execution_cost_write_count: v.number(),
|
|
38
|
-
execution_cost_write_length: v.number(),
|
|
39
|
-
});
|
|
40
|
-
export const contractCallTransactionSchema = v.object({
|
|
41
|
-
tx_type: v.literal("contract_call"),
|
|
42
|
-
contract_call: v.object({
|
|
43
|
-
contract_id: v.string(),
|
|
44
|
-
function_name: v.string(),
|
|
45
|
-
function_signature: v.string(),
|
|
46
|
-
function_args: v.array(v.object({
|
|
47
|
-
hex: v.string(),
|
|
48
|
-
repr: v.string(),
|
|
49
|
-
name: v.string(),
|
|
50
|
-
type: v.string(),
|
|
51
|
-
})),
|
|
52
|
-
}),
|
|
53
|
-
...baseTransactionSchema.entries,
|
|
54
|
-
});
|
|
55
|
-
export const smartContractTransactionSchema = v.object({
|
|
56
|
-
tx_type: v.literal("smart_contract"),
|
|
57
|
-
smart_contract: v.object({
|
|
58
|
-
/**
|
|
59
|
-
* NOTE: The types may be wrong, not sure what type of value is used when
|
|
60
|
-
* the version is not `null`.
|
|
61
|
-
*/
|
|
62
|
-
clarity_version: v.union([v.null(), v.number()]),
|
|
63
|
-
contract_id: v.string(),
|
|
64
|
-
source_code: v.string(),
|
|
65
|
-
}),
|
|
66
|
-
...baseTransactionSchema.entries,
|
|
67
|
-
});
|
|
68
|
-
export const tokenTransferSchema = v.object({
|
|
69
|
-
tx_type: v.literal("token_transfer"),
|
|
70
|
-
token_transfer: v.object({
|
|
71
|
-
recipient_address: v.string(),
|
|
72
|
-
amount: v.string(),
|
|
73
|
-
memo: v.string(),
|
|
74
|
-
}),
|
|
75
|
-
...baseTransactionSchema.entries,
|
|
76
|
-
});
|
|
77
|
-
/**
|
|
78
|
-
* Incomplete schema of some transaction types.
|
|
79
|
-
*/
|
|
80
|
-
export const transactionSchema = v.variant("tx_type", [
|
|
81
|
-
contractCallTransactionSchema,
|
|
82
|
-
smartContractTransactionSchema,
|
|
83
|
-
tokenTransferSchema,
|
|
84
|
-
]);
|
|
85
|
-
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/stacks-api/transactions/schemas.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export type ApiKeyConfig = {
|
|
3
|
-
key: string;
|
|
4
|
-
header: string;
|
|
5
|
-
};
|
|
6
|
-
export type ApiRequestOptions = {
|
|
7
|
-
baseUrl: string;
|
|
8
|
-
apiKeyConfig?: ApiKeyConfig;
|
|
9
|
-
};
|
|
10
|
-
export type ApiPaginationOptions = {
|
|
11
|
-
/**
|
|
12
|
-
* The number of items to return. Each endpoint has its own maximum allowed
|
|
13
|
-
* limit, although many support at least 50 items. The [Hiro
|
|
14
|
-
* docs](https://docs.hiro.so/stacks/api) include the allowed maximum for each
|
|
15
|
-
* endpoint.
|
|
16
|
-
*/
|
|
17
|
-
limit?: number;
|
|
18
|
-
offset?: number;
|
|
19
|
-
};
|
|
20
|
-
export type ApiClientOptions = Partial<ApiRequestOptions>;
|
|
21
|
-
export declare const baseListResponseSchema: v.ObjectSchema<{
|
|
22
|
-
readonly limit: v.NumberSchema<undefined>;
|
|
23
|
-
readonly offset: v.NumberSchema<undefined>;
|
|
24
|
-
readonly total: v.NumberSchema<undefined>;
|
|
25
|
-
readonly results: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
26
|
-
}, undefined>;
|
package/dist/stacks-api/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stacks-api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAyB7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Result, type SafeError } from "./safe.js";
|
|
2
|
-
type Options = {
|
|
3
|
-
startingDelay?: number;
|
|
4
|
-
numOfAttempts?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function callRateLimitedApi<T>(fn: () => Promise<T>, options?: Options): Promise<T>;
|
|
7
|
-
export declare function safeCallRateLimitedApi<T>(fn: () => Promise<Result<T>>, options?: Options): Promise<Result<T, SafeError<"MaxRetriesExceeded" | string>>>;
|
|
8
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { error as safeError } from "./safe.js";
|
|
2
|
-
import { backOff } from "exponential-backoff";
|
|
3
|
-
const defaultStartingDelay = 15_000;
|
|
4
|
-
const defaultNumOfAttempts = 5;
|
|
5
|
-
export function callRateLimitedApi(fn, options) {
|
|
6
|
-
return backOff(fn, {
|
|
7
|
-
startingDelay: options?.startingDelay ?? defaultStartingDelay,
|
|
8
|
-
numOfAttempts: options?.numOfAttempts ?? defaultNumOfAttempts,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
export async function safeCallRateLimitedApi(fn, options) {
|
|
12
|
-
try {
|
|
13
|
-
return await backOff(() => fn(), {
|
|
14
|
-
startingDelay: options?.startingDelay ?? 15_000,
|
|
15
|
-
numOfAttempts: options?.numOfAttempts ?? 5,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
return safeError({
|
|
20
|
-
name: "MaxRetriesExceeded",
|
|
21
|
-
message: "Failed to call rate limited API.",
|
|
22
|
-
data: {
|
|
23
|
-
error,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=call-rate-limited-api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"call-rate-limited-api.js","sourceRoot":"","sources":["../../src/utils/call-rate-limited-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAA+B,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO9C,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,UAAU,kBAAkB,CAChC,EAAoB,EACpB,OAAiB;IAEjB,OAAO,OAAO,CAAC,EAAE,EAAE;QACjB,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,oBAAoB;QAC7D,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,oBAAoB;KAC9D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,EAA4B,EAC5B,OAAiB;IAEjB,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;YAC/B,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,MAAM;YAC/C,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,CAAC;SAC3C,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;YACf,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,kCAAkC;YAC3C,IAAI,EAAE;gBACJ,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/utils/safe.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type SafeError<TName extends string = string, TData = unknown> = {
|
|
2
|
-
readonly name: TName;
|
|
3
|
-
readonly message: string;
|
|
4
|
-
readonly data?: TData;
|
|
5
|
-
};
|
|
6
|
-
export type Result<TData = unknown, E extends SafeError = SafeError> = [E, null] | [null, TData];
|
|
7
|
-
export declare function success<D>(data: D): Result<D, never>;
|
|
8
|
-
export declare function error<const E extends SafeError>(error: E): Result<never, E>;
|
|
9
|
-
export declare function safePromise<TData>(promise: Promise<TData>): Promise<Result<TData, SafeError<"SafePromiseError">>>;
|
|
10
|
-
export declare function safeCall<Return>(fn: () => Return): Result<Return, SafeError<"SafeCallError">>;
|
package/dist/utils/safe.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export function success(data) {
|
|
2
|
-
return [null, data];
|
|
3
|
-
}
|
|
4
|
-
export function error(error) {
|
|
5
|
-
return [error, null];
|
|
6
|
-
}
|
|
7
|
-
export async function safePromise(promise) {
|
|
8
|
-
try {
|
|
9
|
-
return success(await promise);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
return error({
|
|
13
|
-
name: "SafePromiseError",
|
|
14
|
-
message: "Safe promise rejected.",
|
|
15
|
-
data: e,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function safeCall(fn) {
|
|
20
|
-
try {
|
|
21
|
-
return success(fn());
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
return error({
|
|
25
|
-
name: "SafeCallError",
|
|
26
|
-
message: "Safe call failed.",
|
|
27
|
-
data: e,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=safe.js.map
|
package/dist/utils/safe.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../../src/utils/safe.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,OAAO,CAAI,IAAO;IAChC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,KAAK,CAA4B,KAAQ;IACvD,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAuB;IAEvB,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;YACX,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,wBAAwB;YACjC,IAAI,EAAE,CAAC;SACR,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,EAAgB;IAEhB,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;YACX,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,mBAAmB;YAC5B,IAAI,EAAE,CAAC;SACR,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|