@secretkeylabs/stacks-tools 0.5.0 → 0.6.0-4cfe719
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 +480 -388
- package/dist/index.d.cts +457 -184
- package/dist/index.d.ts +457 -184
- package/dist/index.js +490 -388
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
callRateLimitedApi: () => callRateLimitedApi,
|
|
34
34
|
error: () => error,
|
|
35
|
+
pox4Api: () => pox4Api,
|
|
35
36
|
queries: () => queries,
|
|
36
37
|
safeCall: () => safeCall,
|
|
37
38
|
safeCallRateLimitedApi: () => safeCallRateLimitedApi,
|
|
@@ -73,37 +74,6 @@ function safeCall(fn) {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
// src/stacks-api/accounts/balances.ts
|
|
76
|
-
var v = __toESM(require("valibot"), 1);
|
|
77
|
-
var responseSchema = v.object({
|
|
78
|
-
stx: v.object({
|
|
79
|
-
balance: v.string(),
|
|
80
|
-
total_sent: v.string(),
|
|
81
|
-
total_received: v.string(),
|
|
82
|
-
total_fees_sent: v.string(),
|
|
83
|
-
total_miner_rewards_received: v.string(),
|
|
84
|
-
lock_tx_id: v.string(),
|
|
85
|
-
locked: v.string(),
|
|
86
|
-
lock_height: v.number(),
|
|
87
|
-
burnchain_lock_height: v.number(),
|
|
88
|
-
burnchain_unlock_height: v.number()
|
|
89
|
-
}),
|
|
90
|
-
fungible_tokens: v.record(
|
|
91
|
-
v.string(),
|
|
92
|
-
v.object({
|
|
93
|
-
balance: v.string(),
|
|
94
|
-
total_sent: v.string(),
|
|
95
|
-
total_received: v.string()
|
|
96
|
-
})
|
|
97
|
-
),
|
|
98
|
-
non_fungible_tokens: v.record(
|
|
99
|
-
v.string(),
|
|
100
|
-
v.object({
|
|
101
|
-
count: v.string(),
|
|
102
|
-
total_sent: v.string(),
|
|
103
|
-
total_received: v.string()
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
});
|
|
107
77
|
async function balances(opts) {
|
|
108
78
|
const search = new URLSearchParams();
|
|
109
79
|
if (opts.unanchored) search.append("unanchored", "true");
|
|
@@ -123,7 +93,7 @@ async function balances(opts) {
|
|
|
123
93
|
data: {
|
|
124
94
|
status: res.status,
|
|
125
95
|
statusText: res.statusText,
|
|
126
|
-
|
|
96
|
+
bodyText: await safePromise(res.text())
|
|
127
97
|
}
|
|
128
98
|
});
|
|
129
99
|
}
|
|
@@ -135,25 +105,17 @@ async function balances(opts) {
|
|
|
135
105
|
data: jsonError
|
|
136
106
|
});
|
|
137
107
|
}
|
|
138
|
-
|
|
139
|
-
if (!validationResult.success) {
|
|
140
|
-
return error({
|
|
141
|
-
name: "ValidateDataError",
|
|
142
|
-
message: "Failed to validate data.",
|
|
143
|
-
data: validationResult
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return success(validationResult.output);
|
|
108
|
+
return success(data);
|
|
147
109
|
}
|
|
148
110
|
|
|
149
111
|
// src/stacks-api/accounts/latest-nonce.ts
|
|
150
|
-
var
|
|
151
|
-
var
|
|
152
|
-
last_mempool_tx_nonce:
|
|
153
|
-
last_executed_tx_nonce:
|
|
154
|
-
possible_next_nonce:
|
|
155
|
-
detected_missing_nonces:
|
|
156
|
-
detected_mempool_nonces:
|
|
112
|
+
var v = __toESM(require("valibot"), 1);
|
|
113
|
+
var responseSchema = v.object({
|
|
114
|
+
last_mempool_tx_nonce: v.nullable(v.number()),
|
|
115
|
+
last_executed_tx_nonce: v.nullable(v.number()),
|
|
116
|
+
possible_next_nonce: v.number(),
|
|
117
|
+
detected_missing_nonces: v.array(v.number()),
|
|
118
|
+
detected_mempool_nonces: v.array(v.number())
|
|
157
119
|
});
|
|
158
120
|
async function latestNonce(opts) {
|
|
159
121
|
const init = {};
|
|
@@ -172,7 +134,7 @@ async function latestNonce(opts) {
|
|
|
172
134
|
endpoint,
|
|
173
135
|
status: res.status,
|
|
174
136
|
statusText: res.statusText,
|
|
175
|
-
|
|
137
|
+
bodyText: await safePromise(res.text())
|
|
176
138
|
}
|
|
177
139
|
});
|
|
178
140
|
}
|
|
@@ -184,7 +146,7 @@ async function latestNonce(opts) {
|
|
|
184
146
|
data: jsonError
|
|
185
147
|
});
|
|
186
148
|
}
|
|
187
|
-
const validationResult =
|
|
149
|
+
const validationResult = v.safeParse(responseSchema, data);
|
|
188
150
|
if (!validationResult.success) {
|
|
189
151
|
return error({
|
|
190
152
|
name: "ValidateDataError",
|
|
@@ -202,36 +164,36 @@ var accounts = {
|
|
|
202
164
|
};
|
|
203
165
|
|
|
204
166
|
// src/stacks-api/types.ts
|
|
205
|
-
var
|
|
206
|
-
var baseListResponseSchema =
|
|
207
|
-
limit:
|
|
208
|
-
offset:
|
|
209
|
-
total:
|
|
210
|
-
results:
|
|
167
|
+
var v2 = __toESM(require("valibot"), 1);
|
|
168
|
+
var baseListResponseSchema = v2.object({
|
|
169
|
+
limit: v2.number(),
|
|
170
|
+
offset: v2.number(),
|
|
171
|
+
total: v2.number(),
|
|
172
|
+
results: v2.array(v2.unknown())
|
|
211
173
|
});
|
|
212
174
|
|
|
213
175
|
// src/stacks-api/blocks/get-block.ts
|
|
214
|
-
var
|
|
215
|
-
var
|
|
216
|
-
canonical:
|
|
217
|
-
height:
|
|
218
|
-
hash:
|
|
219
|
-
block_time:
|
|
220
|
-
block_time_iso:
|
|
221
|
-
index_block_hash:
|
|
222
|
-
parent_block_hash:
|
|
223
|
-
parent_index_block_hash:
|
|
224
|
-
burn_block_time:
|
|
225
|
-
burn_block_time_iso:
|
|
226
|
-
burn_block_hash:
|
|
227
|
-
burn_block_height:
|
|
228
|
-
miner_txid:
|
|
229
|
-
tx_count:
|
|
230
|
-
execution_cost_read_count:
|
|
231
|
-
execution_cost_read_length:
|
|
232
|
-
execution_cost_runtime:
|
|
233
|
-
execution_cost_write_count:
|
|
234
|
-
execution_cost_write_length:
|
|
176
|
+
var v3 = __toESM(require("valibot"), 1);
|
|
177
|
+
var responseSchema2 = v3.object({
|
|
178
|
+
canonical: v3.boolean(),
|
|
179
|
+
height: v3.number(),
|
|
180
|
+
hash: v3.string(),
|
|
181
|
+
block_time: v3.number(),
|
|
182
|
+
block_time_iso: v3.string(),
|
|
183
|
+
index_block_hash: v3.string(),
|
|
184
|
+
parent_block_hash: v3.string(),
|
|
185
|
+
parent_index_block_hash: v3.string(),
|
|
186
|
+
burn_block_time: v3.number(),
|
|
187
|
+
burn_block_time_iso: v3.string(),
|
|
188
|
+
burn_block_hash: v3.string(),
|
|
189
|
+
burn_block_height: v3.number(),
|
|
190
|
+
miner_txid: v3.string(),
|
|
191
|
+
tx_count: v3.number(),
|
|
192
|
+
execution_cost_read_count: v3.number(),
|
|
193
|
+
execution_cost_read_length: v3.number(),
|
|
194
|
+
execution_cost_runtime: v3.number(),
|
|
195
|
+
execution_cost_write_count: v3.number(),
|
|
196
|
+
execution_cost_write_length: v3.number()
|
|
235
197
|
});
|
|
236
198
|
async function getBlock(opts) {
|
|
237
199
|
const init = {};
|
|
@@ -251,7 +213,7 @@ async function getBlock(opts) {
|
|
|
251
213
|
data: {
|
|
252
214
|
status: res.status,
|
|
253
215
|
statusText: res.statusText,
|
|
254
|
-
|
|
216
|
+
bodyText: await safePromise(res.text())
|
|
255
217
|
}
|
|
256
218
|
});
|
|
257
219
|
}
|
|
@@ -263,7 +225,7 @@ async function getBlock(opts) {
|
|
|
263
225
|
data: jsonError
|
|
264
226
|
});
|
|
265
227
|
}
|
|
266
|
-
const validationResult =
|
|
228
|
+
const validationResult = v3.safeParse(responseSchema2, data);
|
|
267
229
|
if (!validationResult.success) {
|
|
268
230
|
return error({
|
|
269
231
|
name: "ValidateDataError",
|
|
@@ -300,7 +262,7 @@ async function stx(opts) {
|
|
|
300
262
|
data: {
|
|
301
263
|
status: res.status,
|
|
302
264
|
statusText: res.statusText,
|
|
303
|
-
|
|
265
|
+
bodyText: await safePromise(res.text())
|
|
304
266
|
}
|
|
305
267
|
});
|
|
306
268
|
}
|
|
@@ -321,22 +283,22 @@ var faucets = {
|
|
|
321
283
|
};
|
|
322
284
|
|
|
323
285
|
// src/stacks-api/info/core-api.ts
|
|
324
|
-
var
|
|
325
|
-
var CoreApiResponseSchema =
|
|
326
|
-
peer_version:
|
|
327
|
-
pox_consensus:
|
|
328
|
-
burn_block_height:
|
|
329
|
-
stable_pox_consensus:
|
|
330
|
-
stable_burn_block_height:
|
|
331
|
-
server_version:
|
|
332
|
-
network_id:
|
|
333
|
-
parent_network_id:
|
|
334
|
-
stacks_tip_height:
|
|
335
|
-
stacks_tip:
|
|
336
|
-
stacks_tip_consensus_hash:
|
|
337
|
-
unanchored_tip:
|
|
338
|
-
unanchored_seq:
|
|
339
|
-
exit_at_block_height:
|
|
286
|
+
var v4 = __toESM(require("valibot"), 1);
|
|
287
|
+
var CoreApiResponseSchema = v4.object({
|
|
288
|
+
peer_version: v4.number(),
|
|
289
|
+
pox_consensus: v4.string(),
|
|
290
|
+
burn_block_height: v4.number(),
|
|
291
|
+
stable_pox_consensus: v4.string(),
|
|
292
|
+
stable_burn_block_height: v4.number(),
|
|
293
|
+
server_version: v4.string(),
|
|
294
|
+
network_id: v4.number(),
|
|
295
|
+
parent_network_id: v4.number(),
|
|
296
|
+
stacks_tip_height: v4.number(),
|
|
297
|
+
stacks_tip: v4.string(),
|
|
298
|
+
stacks_tip_consensus_hash: v4.string(),
|
|
299
|
+
unanchored_tip: v4.nullable(v4.string()),
|
|
300
|
+
unanchored_seq: v4.nullable(v4.string()),
|
|
301
|
+
exit_at_block_height: v4.nullable(v4.number())
|
|
340
302
|
});
|
|
341
303
|
async function coreApi(apiOpts) {
|
|
342
304
|
const init = {};
|
|
@@ -353,7 +315,7 @@ async function coreApi(apiOpts) {
|
|
|
353
315
|
data: {
|
|
354
316
|
status: res.status,
|
|
355
317
|
statusText: res.statusText,
|
|
356
|
-
|
|
318
|
+
bodyText: await safePromise(res.text())
|
|
357
319
|
}
|
|
358
320
|
});
|
|
359
321
|
}
|
|
@@ -365,7 +327,7 @@ async function coreApi(apiOpts) {
|
|
|
365
327
|
data: parseBodyError
|
|
366
328
|
});
|
|
367
329
|
}
|
|
368
|
-
const validationResult =
|
|
330
|
+
const validationResult = v4.safeParse(CoreApiResponseSchema, data);
|
|
369
331
|
if (!validationResult.success) {
|
|
370
332
|
return error({
|
|
371
333
|
name: "ValidateDataError",
|
|
@@ -376,117 +338,20 @@ async function coreApi(apiOpts) {
|
|
|
376
338
|
return success(validationResult.output);
|
|
377
339
|
}
|
|
378
340
|
|
|
379
|
-
// src/stacks-api/info/pox-details.ts
|
|
380
|
-
var v6 = __toESM(require("valibot"), 1);
|
|
381
|
-
var poxDetailsResponseSchema = v6.object({
|
|
382
|
-
contract_id: v6.string(),
|
|
383
|
-
pox_activation_threshold_ustx: v6.number(),
|
|
384
|
-
first_burnchain_block_height: v6.number(),
|
|
385
|
-
current_burnchain_block_height: v6.number(),
|
|
386
|
-
prepare_phase_block_length: v6.number(),
|
|
387
|
-
reward_phase_block_length: v6.number(),
|
|
388
|
-
reward_slots: v6.number(),
|
|
389
|
-
rejection_fraction: v6.null(),
|
|
390
|
-
total_liquid_supply_ustx: v6.number(),
|
|
391
|
-
current_cycle: v6.object({
|
|
392
|
-
id: v6.number(),
|
|
393
|
-
min_threshold_ustx: v6.number(),
|
|
394
|
-
stacked_ustx: v6.number(),
|
|
395
|
-
is_pox_active: v6.boolean()
|
|
396
|
-
}),
|
|
397
|
-
next_cycle: v6.object({
|
|
398
|
-
id: v6.number(),
|
|
399
|
-
min_threshold_ustx: v6.number(),
|
|
400
|
-
min_increment_ustx: v6.number(),
|
|
401
|
-
stacked_ustx: v6.number(),
|
|
402
|
-
prepare_phase_start_block_height: v6.number(),
|
|
403
|
-
blocks_until_prepare_phase: v6.number(),
|
|
404
|
-
reward_phase_start_block_height: v6.number(),
|
|
405
|
-
blocks_until_reward_phase: v6.number(),
|
|
406
|
-
ustx_until_pox_rejection: v6.null()
|
|
407
|
-
}),
|
|
408
|
-
epochs: v6.array(
|
|
409
|
-
v6.object({
|
|
410
|
-
epoch_id: v6.string(),
|
|
411
|
-
start_height: v6.number(),
|
|
412
|
-
end_height: v6.number(),
|
|
413
|
-
block_limit: v6.object({
|
|
414
|
-
write_length: v6.number(),
|
|
415
|
-
write_count: v6.number(),
|
|
416
|
-
read_length: v6.number(),
|
|
417
|
-
read_count: v6.number(),
|
|
418
|
-
runtime: v6.number()
|
|
419
|
-
}),
|
|
420
|
-
network_epoch: v6.number()
|
|
421
|
-
})
|
|
422
|
-
),
|
|
423
|
-
min_amount_ustx: v6.number(),
|
|
424
|
-
prepare_cycle_length: v6.number(),
|
|
425
|
-
reward_cycle_id: v6.number(),
|
|
426
|
-
reward_cycle_length: v6.number(),
|
|
427
|
-
rejection_votes_left_required: v6.null(),
|
|
428
|
-
next_reward_cycle_in: v6.number(),
|
|
429
|
-
contract_versions: v6.array(
|
|
430
|
-
v6.object({
|
|
431
|
-
contract_id: v6.string(),
|
|
432
|
-
activation_burnchain_block_height: v6.number(),
|
|
433
|
-
first_reward_cycle_id: v6.number()
|
|
434
|
-
})
|
|
435
|
-
)
|
|
436
|
-
});
|
|
437
|
-
async function poxDetails(args) {
|
|
438
|
-
const init = {};
|
|
439
|
-
if (args.apiKeyConfig) {
|
|
440
|
-
init.headers = {
|
|
441
|
-
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
const res = await fetch(`${args.baseUrl}/v2/pox`, init);
|
|
445
|
-
if (!res.ok) {
|
|
446
|
-
return error({
|
|
447
|
-
name: "FetchPoxDetailsError",
|
|
448
|
-
message: "Failed to fetch pox details.",
|
|
449
|
-
data: {
|
|
450
|
-
status: res.status,
|
|
451
|
-
statusText: res.statusText,
|
|
452
|
-
bodyParseResult: await safePromise(res.json())
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
const [jsonParseError, data] = await safePromise(res.json());
|
|
457
|
-
if (jsonParseError) {
|
|
458
|
-
return error({
|
|
459
|
-
name: "ParseBodyError",
|
|
460
|
-
message: "Failed to parse pox details response.",
|
|
461
|
-
data: jsonParseError
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
const validationResult = v6.safeParse(poxDetailsResponseSchema, data);
|
|
465
|
-
if (!validationResult.success) {
|
|
466
|
-
return error({
|
|
467
|
-
name: "ValidateDataError",
|
|
468
|
-
message: "Failed to parse pox details response.",
|
|
469
|
-
data: validationResult
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
return success(validationResult.output);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
341
|
// src/stacks-api/info/index.ts
|
|
476
342
|
var info = {
|
|
477
|
-
coreApi
|
|
478
|
-
poxDetails
|
|
343
|
+
coreApi
|
|
479
344
|
};
|
|
480
345
|
|
|
481
346
|
// src/stacks-api/proof-of-transfer/cycle.ts
|
|
482
|
-
var
|
|
483
|
-
var
|
|
484
|
-
block_height:
|
|
485
|
-
index_block_hash:
|
|
486
|
-
cycle_number:
|
|
487
|
-
total_weight:
|
|
488
|
-
total_stacked_amount:
|
|
489
|
-
total_signers:
|
|
347
|
+
var v5 = __toESM(require("valibot"), 1);
|
|
348
|
+
var responseSchema3 = v5.object({
|
|
349
|
+
block_height: v5.number(),
|
|
350
|
+
index_block_hash: v5.string(),
|
|
351
|
+
cycle_number: v5.number(),
|
|
352
|
+
total_weight: v5.number(),
|
|
353
|
+
total_stacked_amount: v5.string(),
|
|
354
|
+
total_signers: v5.number()
|
|
490
355
|
});
|
|
491
356
|
async function cycle(opts) {
|
|
492
357
|
const init = {};
|
|
@@ -505,7 +370,7 @@ async function cycle(opts) {
|
|
|
505
370
|
endpoint,
|
|
506
371
|
status: res.status,
|
|
507
372
|
statusText: res.statusText,
|
|
508
|
-
|
|
373
|
+
bodyText: await safePromise(res.text())
|
|
509
374
|
}
|
|
510
375
|
});
|
|
511
376
|
}
|
|
@@ -517,7 +382,7 @@ async function cycle(opts) {
|
|
|
517
382
|
data: jsonError
|
|
518
383
|
});
|
|
519
384
|
}
|
|
520
|
-
const validationResult =
|
|
385
|
+
const validationResult = v5.safeParse(responseSchema3, data);
|
|
521
386
|
if (!validationResult.success) {
|
|
522
387
|
return error({
|
|
523
388
|
name: "ValidateDataError",
|
|
@@ -529,17 +394,17 @@ async function cycle(opts) {
|
|
|
529
394
|
}
|
|
530
395
|
|
|
531
396
|
// src/stacks-api/proof-of-transfer/cycles.ts
|
|
532
|
-
var
|
|
533
|
-
var cycleInfoSchema =
|
|
534
|
-
block_height:
|
|
535
|
-
index_block_hash:
|
|
536
|
-
cycle_number:
|
|
537
|
-
total_weight:
|
|
538
|
-
total_stacked_amount:
|
|
539
|
-
total_signers:
|
|
397
|
+
var v6 = __toESM(require("valibot"), 1);
|
|
398
|
+
var cycleInfoSchema = v6.object({
|
|
399
|
+
block_height: v6.number(),
|
|
400
|
+
index_block_hash: v6.string(),
|
|
401
|
+
cycle_number: v6.number(),
|
|
402
|
+
total_weight: v6.number(),
|
|
403
|
+
total_stacked_amount: v6.string(),
|
|
404
|
+
total_signers: v6.number()
|
|
540
405
|
});
|
|
541
|
-
var resultsSchema =
|
|
542
|
-
var cyclesResponseSchema =
|
|
406
|
+
var resultsSchema = v6.array(cycleInfoSchema);
|
|
407
|
+
var cyclesResponseSchema = v6.object({
|
|
543
408
|
...baseListResponseSchema.entries,
|
|
544
409
|
results: resultsSchema
|
|
545
410
|
});
|
|
@@ -563,7 +428,7 @@ async function cycles(args) {
|
|
|
563
428
|
endpoint,
|
|
564
429
|
status: res.status,
|
|
565
430
|
statusText: res.statusText,
|
|
566
|
-
|
|
431
|
+
bodyText: await safePromise(res.text())
|
|
567
432
|
}
|
|
568
433
|
});
|
|
569
434
|
}
|
|
@@ -575,7 +440,7 @@ async function cycles(args) {
|
|
|
575
440
|
data: jsonError
|
|
576
441
|
});
|
|
577
442
|
}
|
|
578
|
-
const validationResult =
|
|
443
|
+
const validationResult = v6.safeParse(cyclesResponseSchema, data);
|
|
579
444
|
if (!validationResult.success) {
|
|
580
445
|
return error({
|
|
581
446
|
name: "ValidateDataError",
|
|
@@ -587,16 +452,16 @@ async function cycles(args) {
|
|
|
587
452
|
}
|
|
588
453
|
|
|
589
454
|
// src/stacks-api/proof-of-transfer/signer-in-cycle.ts
|
|
590
|
-
var
|
|
591
|
-
var signerInCycleResponseSchema =
|
|
592
|
-
signing_key:
|
|
593
|
-
signer_address:
|
|
594
|
-
weight:
|
|
595
|
-
stacked_amount:
|
|
596
|
-
weight_percent:
|
|
597
|
-
stacked_amount_percent:
|
|
598
|
-
solo_stacker_count:
|
|
599
|
-
pooled_stacker_count:
|
|
455
|
+
var v7 = __toESM(require("valibot"), 1);
|
|
456
|
+
var signerInCycleResponseSchema = v7.object({
|
|
457
|
+
signing_key: v7.string(),
|
|
458
|
+
signer_address: v7.string(),
|
|
459
|
+
weight: v7.number(),
|
|
460
|
+
stacked_amount: v7.string(),
|
|
461
|
+
weight_percent: v7.number(),
|
|
462
|
+
stacked_amount_percent: v7.number(),
|
|
463
|
+
solo_stacker_count: v7.number(),
|
|
464
|
+
pooled_stacker_count: v7.number()
|
|
600
465
|
});
|
|
601
466
|
async function signerInCycle(args) {
|
|
602
467
|
const init = {};
|
|
@@ -632,7 +497,7 @@ async function signerInCycle(args) {
|
|
|
632
497
|
}
|
|
633
498
|
});
|
|
634
499
|
}
|
|
635
|
-
const validationResult =
|
|
500
|
+
const validationResult = v7.safeParse(signerInCycleResponseSchema, data);
|
|
636
501
|
if (!validationResult.success) {
|
|
637
502
|
return error({
|
|
638
503
|
name: "ValidateDataError",
|
|
@@ -644,19 +509,19 @@ async function signerInCycle(args) {
|
|
|
644
509
|
}
|
|
645
510
|
|
|
646
511
|
// src/stacks-api/proof-of-transfer/signers-in-cycle.ts
|
|
647
|
-
var
|
|
648
|
-
var signerSchema =
|
|
649
|
-
signing_key:
|
|
650
|
-
signer_address:
|
|
651
|
-
weight:
|
|
652
|
-
stacked_amount:
|
|
653
|
-
weight_percent:
|
|
654
|
-
stacked_amount_percent:
|
|
655
|
-
pooled_stacker_count:
|
|
656
|
-
solo_stacker_count:
|
|
512
|
+
var v8 = __toESM(require("valibot"), 1);
|
|
513
|
+
var signerSchema = v8.object({
|
|
514
|
+
signing_key: v8.string(),
|
|
515
|
+
signer_address: v8.string(),
|
|
516
|
+
weight: v8.number(),
|
|
517
|
+
stacked_amount: v8.string(),
|
|
518
|
+
weight_percent: v8.number(),
|
|
519
|
+
stacked_amount_percent: v8.number(),
|
|
520
|
+
pooled_stacker_count: v8.number(),
|
|
521
|
+
solo_stacker_count: v8.number()
|
|
657
522
|
});
|
|
658
|
-
var resultsSchema2 =
|
|
659
|
-
var signersResponseSchema =
|
|
523
|
+
var resultsSchema2 = v8.array(signerSchema);
|
|
524
|
+
var signersResponseSchema = v8.object({
|
|
660
525
|
...baseListResponseSchema.entries,
|
|
661
526
|
results: resultsSchema2
|
|
662
527
|
});
|
|
@@ -680,7 +545,7 @@ async function signersInCycle(args) {
|
|
|
680
545
|
endpoint,
|
|
681
546
|
status: res.status,
|
|
682
547
|
statusText: res.statusText,
|
|
683
|
-
|
|
548
|
+
bodyText: await safePromise(res.text())
|
|
684
549
|
}
|
|
685
550
|
});
|
|
686
551
|
}
|
|
@@ -695,7 +560,7 @@ async function signersInCycle(args) {
|
|
|
695
560
|
}
|
|
696
561
|
});
|
|
697
562
|
}
|
|
698
|
-
const validationResult =
|
|
563
|
+
const validationResult = v8.safeParse(signersResponseSchema, data);
|
|
699
564
|
if (!validationResult.success) {
|
|
700
565
|
return error({
|
|
701
566
|
name: "ValidateDataError",
|
|
@@ -707,15 +572,15 @@ async function signersInCycle(args) {
|
|
|
707
572
|
}
|
|
708
573
|
|
|
709
574
|
// src/stacks-api/proof-of-transfer/stackers-for-signer-in-cycle.ts
|
|
710
|
-
var
|
|
711
|
-
var stackerInfoSchema =
|
|
712
|
-
stacker_address:
|
|
713
|
-
stacked_amount:
|
|
714
|
-
pox_address:
|
|
715
|
-
stacker_type:
|
|
575
|
+
var v9 = __toESM(require("valibot"), 1);
|
|
576
|
+
var stackerInfoSchema = v9.object({
|
|
577
|
+
stacker_address: v9.string(),
|
|
578
|
+
stacked_amount: v9.string(),
|
|
579
|
+
pox_address: v9.string(),
|
|
580
|
+
stacker_type: v9.union([v9.literal("pooled"), v9.literal("solo")])
|
|
716
581
|
});
|
|
717
|
-
var resultsSchema3 =
|
|
718
|
-
var stackersForSignerInCycleResponseSchema =
|
|
582
|
+
var resultsSchema3 = v9.array(stackerInfoSchema);
|
|
583
|
+
var stackersForSignerInCycleResponseSchema = v9.object({
|
|
719
584
|
...baseListResponseSchema.entries,
|
|
720
585
|
results: resultsSchema3
|
|
721
586
|
});
|
|
@@ -740,7 +605,7 @@ async function stackersForSignerInCycle(opts) {
|
|
|
740
605
|
endpoint,
|
|
741
606
|
status: res.status,
|
|
742
607
|
statusText: res.statusText,
|
|
743
|
-
|
|
608
|
+
bodyText: await safePromise(res.text())
|
|
744
609
|
}
|
|
745
610
|
});
|
|
746
611
|
}
|
|
@@ -752,7 +617,7 @@ async function stackersForSignerInCycle(opts) {
|
|
|
752
617
|
data: jsonError
|
|
753
618
|
});
|
|
754
619
|
}
|
|
755
|
-
const validationResult =
|
|
620
|
+
const validationResult = v9.safeParse(
|
|
756
621
|
stackersForSignerInCycleResponseSchema,
|
|
757
622
|
data
|
|
758
623
|
);
|
|
@@ -776,20 +641,20 @@ var proofOfTransfer = {
|
|
|
776
641
|
};
|
|
777
642
|
|
|
778
643
|
// src/stacks-api/stacking-pool/members.ts
|
|
779
|
-
var
|
|
780
|
-
var memberSchema =
|
|
781
|
-
stacker:
|
|
782
|
-
pox_addr:
|
|
783
|
-
amount_ustx:
|
|
784
|
-
burn_block_unlock_height:
|
|
785
|
-
block_height:
|
|
786
|
-
tx_id:
|
|
644
|
+
var v10 = __toESM(require("valibot"), 1);
|
|
645
|
+
var memberSchema = v10.object({
|
|
646
|
+
stacker: v10.string(),
|
|
647
|
+
pox_addr: v10.optional(v10.string()),
|
|
648
|
+
amount_ustx: v10.string(),
|
|
649
|
+
burn_block_unlock_height: v10.optional(v10.number()),
|
|
650
|
+
block_height: v10.number(),
|
|
651
|
+
tx_id: v10.string()
|
|
787
652
|
});
|
|
788
|
-
var membersResponseSchema =
|
|
789
|
-
limit:
|
|
790
|
-
offset:
|
|
791
|
-
total:
|
|
792
|
-
results:
|
|
653
|
+
var membersResponseSchema = v10.object({
|
|
654
|
+
limit: v10.number(),
|
|
655
|
+
offset: v10.number(),
|
|
656
|
+
total: v10.number(),
|
|
657
|
+
results: v10.array(memberSchema)
|
|
793
658
|
});
|
|
794
659
|
async function members(args) {
|
|
795
660
|
const search = new URLSearchParams();
|
|
@@ -812,7 +677,7 @@ async function members(args) {
|
|
|
812
677
|
data: {
|
|
813
678
|
status: res.status,
|
|
814
679
|
statusText: res.statusText,
|
|
815
|
-
|
|
680
|
+
bodyText: await safePromise(res.text())
|
|
816
681
|
}
|
|
817
682
|
});
|
|
818
683
|
}
|
|
@@ -824,7 +689,7 @@ async function members(args) {
|
|
|
824
689
|
data: jsonParseError
|
|
825
690
|
});
|
|
826
691
|
}
|
|
827
|
-
const validationResult =
|
|
692
|
+
const validationResult = v10.safeParse(membersResponseSchema, data);
|
|
828
693
|
if (!validationResult.success) {
|
|
829
694
|
return error({
|
|
830
695
|
name: "ValidateDataError",
|
|
@@ -841,120 +706,120 @@ var stackingPool = {
|
|
|
841
706
|
};
|
|
842
707
|
|
|
843
708
|
// src/stacks-api/transactions/schemas.ts
|
|
844
|
-
var
|
|
845
|
-
var baseTransactionSchema =
|
|
846
|
-
tx_id:
|
|
847
|
-
nonce:
|
|
848
|
-
fee_rate:
|
|
849
|
-
sender_address:
|
|
850
|
-
sponsored:
|
|
851
|
-
post_condition_mode:
|
|
852
|
-
post_conditions:
|
|
853
|
-
anchor_mode:
|
|
854
|
-
is_unanchored:
|
|
855
|
-
block_hash:
|
|
856
|
-
parent_block_hash:
|
|
857
|
-
block_height:
|
|
858
|
-
block_time:
|
|
859
|
-
block_time_iso:
|
|
860
|
-
burn_block_height:
|
|
861
|
-
burn_block_time:
|
|
862
|
-
burn_block_time_iso:
|
|
863
|
-
parent_burn_block_time:
|
|
864
|
-
parent_burn_block_time_iso:
|
|
865
|
-
canonical:
|
|
866
|
-
tx_index:
|
|
867
|
-
tx_status:
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
709
|
+
var v11 = __toESM(require("valibot"), 1);
|
|
710
|
+
var baseTransactionSchema = v11.object({
|
|
711
|
+
tx_id: v11.string(),
|
|
712
|
+
nonce: v11.number(),
|
|
713
|
+
fee_rate: v11.string(),
|
|
714
|
+
sender_address: v11.string(),
|
|
715
|
+
sponsored: v11.boolean(),
|
|
716
|
+
post_condition_mode: v11.string(),
|
|
717
|
+
post_conditions: v11.array(v11.unknown()),
|
|
718
|
+
anchor_mode: v11.string(),
|
|
719
|
+
is_unanchored: v11.boolean(),
|
|
720
|
+
block_hash: v11.string(),
|
|
721
|
+
parent_block_hash: v11.string(),
|
|
722
|
+
block_height: v11.number(),
|
|
723
|
+
block_time: v11.number(),
|
|
724
|
+
block_time_iso: v11.string(),
|
|
725
|
+
burn_block_height: v11.number(),
|
|
726
|
+
burn_block_time: v11.number(),
|
|
727
|
+
burn_block_time_iso: v11.string(),
|
|
728
|
+
parent_burn_block_time: v11.number(),
|
|
729
|
+
parent_burn_block_time_iso: v11.string(),
|
|
730
|
+
canonical: v11.boolean(),
|
|
731
|
+
tx_index: v11.number(),
|
|
732
|
+
tx_status: v11.union([
|
|
733
|
+
v11.literal("success"),
|
|
734
|
+
v11.literal("abort_by_response"),
|
|
735
|
+
v11.literal("abort_by_post_condition")
|
|
871
736
|
]),
|
|
872
|
-
tx_result:
|
|
873
|
-
hex:
|
|
874
|
-
repr:
|
|
737
|
+
tx_result: v11.object({
|
|
738
|
+
hex: v11.string(),
|
|
739
|
+
repr: v11.string()
|
|
875
740
|
}),
|
|
876
|
-
microblock_hash:
|
|
877
|
-
microblock_sequence:
|
|
878
|
-
microblock_canonical:
|
|
879
|
-
event_count:
|
|
880
|
-
events:
|
|
881
|
-
execution_cost_read_count:
|
|
882
|
-
execution_cost_read_length:
|
|
883
|
-
execution_cost_runtime:
|
|
884
|
-
execution_cost_write_count:
|
|
885
|
-
execution_cost_write_length:
|
|
741
|
+
microblock_hash: v11.string(),
|
|
742
|
+
microblock_sequence: v11.number(),
|
|
743
|
+
microblock_canonical: v11.boolean(),
|
|
744
|
+
event_count: v11.number(),
|
|
745
|
+
events: v11.array(v11.unknown()),
|
|
746
|
+
execution_cost_read_count: v11.number(),
|
|
747
|
+
execution_cost_read_length: v11.number(),
|
|
748
|
+
execution_cost_runtime: v11.number(),
|
|
749
|
+
execution_cost_write_count: v11.number(),
|
|
750
|
+
execution_cost_write_length: v11.number()
|
|
886
751
|
});
|
|
887
|
-
var contractCallTransactionSchema =
|
|
888
|
-
tx_type:
|
|
889
|
-
contract_call:
|
|
890
|
-
contract_id:
|
|
891
|
-
function_name:
|
|
892
|
-
function_signature:
|
|
893
|
-
function_args:
|
|
894
|
-
|
|
895
|
-
hex:
|
|
896
|
-
repr:
|
|
897
|
-
name:
|
|
898
|
-
type:
|
|
752
|
+
var contractCallTransactionSchema = v11.object({
|
|
753
|
+
tx_type: v11.literal("contract_call"),
|
|
754
|
+
contract_call: v11.object({
|
|
755
|
+
contract_id: v11.string(),
|
|
756
|
+
function_name: v11.string(),
|
|
757
|
+
function_signature: v11.string(),
|
|
758
|
+
function_args: v11.array(
|
|
759
|
+
v11.object({
|
|
760
|
+
hex: v11.string(),
|
|
761
|
+
repr: v11.string(),
|
|
762
|
+
name: v11.string(),
|
|
763
|
+
type: v11.string()
|
|
899
764
|
})
|
|
900
765
|
)
|
|
901
766
|
}),
|
|
902
767
|
...baseTransactionSchema.entries
|
|
903
768
|
});
|
|
904
|
-
var smartContractTransactionSchema =
|
|
905
|
-
tx_type:
|
|
906
|
-
smart_contract:
|
|
769
|
+
var smartContractTransactionSchema = v11.object({
|
|
770
|
+
tx_type: v11.literal("smart_contract"),
|
|
771
|
+
smart_contract: v11.object({
|
|
907
772
|
/**
|
|
908
773
|
* NOTE: The types may be wrong, not sure what type of value is used when
|
|
909
774
|
* the version is not `null`.
|
|
910
775
|
*/
|
|
911
|
-
clarity_version:
|
|
912
|
-
contract_id:
|
|
913
|
-
source_code:
|
|
776
|
+
clarity_version: v11.union([v11.null(), v11.number()]),
|
|
777
|
+
contract_id: v11.string(),
|
|
778
|
+
source_code: v11.string()
|
|
914
779
|
}),
|
|
915
780
|
...baseTransactionSchema.entries
|
|
916
781
|
});
|
|
917
|
-
var tokenTransferSchema =
|
|
918
|
-
tx_type:
|
|
919
|
-
token_transfer:
|
|
920
|
-
recipient_address:
|
|
921
|
-
amount:
|
|
922
|
-
memo:
|
|
782
|
+
var tokenTransferSchema = v11.object({
|
|
783
|
+
tx_type: v11.literal("token_transfer"),
|
|
784
|
+
token_transfer: v11.object({
|
|
785
|
+
recipient_address: v11.string(),
|
|
786
|
+
amount: v11.string(),
|
|
787
|
+
memo: v11.string()
|
|
923
788
|
}),
|
|
924
789
|
...baseTransactionSchema.entries
|
|
925
790
|
});
|
|
926
|
-
var transactionSchema =
|
|
791
|
+
var transactionSchema = v11.variant("tx_type", [
|
|
927
792
|
contractCallTransactionSchema,
|
|
928
793
|
smartContractTransactionSchema,
|
|
929
794
|
tokenTransferSchema
|
|
930
795
|
]);
|
|
931
796
|
|
|
932
797
|
// src/stacks-api/transactions/address-transactions.ts
|
|
933
|
-
var
|
|
934
|
-
var resultSchema =
|
|
798
|
+
var v12 = __toESM(require("valibot"), 1);
|
|
799
|
+
var resultSchema = v12.object({
|
|
935
800
|
tx: transactionSchema,
|
|
936
|
-
stx_sent:
|
|
937
|
-
stx_received:
|
|
938
|
-
events:
|
|
939
|
-
stx:
|
|
940
|
-
transfer:
|
|
941
|
-
mint:
|
|
942
|
-
burn:
|
|
801
|
+
stx_sent: v12.string(),
|
|
802
|
+
stx_received: v12.string(),
|
|
803
|
+
events: v12.object({
|
|
804
|
+
stx: v12.object({
|
|
805
|
+
transfer: v12.number(),
|
|
806
|
+
mint: v12.number(),
|
|
807
|
+
burn: v12.number()
|
|
943
808
|
}),
|
|
944
|
-
ft:
|
|
945
|
-
transfer:
|
|
946
|
-
mint:
|
|
947
|
-
burn:
|
|
809
|
+
ft: v12.object({
|
|
810
|
+
transfer: v12.number(),
|
|
811
|
+
mint: v12.number(),
|
|
812
|
+
burn: v12.number()
|
|
948
813
|
}),
|
|
949
|
-
nft:
|
|
950
|
-
transfer:
|
|
951
|
-
mint:
|
|
952
|
-
burn:
|
|
814
|
+
nft: v12.object({
|
|
815
|
+
transfer: v12.number(),
|
|
816
|
+
mint: v12.number(),
|
|
817
|
+
burn: v12.number()
|
|
953
818
|
})
|
|
954
819
|
})
|
|
955
820
|
});
|
|
956
|
-
var resultsSchema4 =
|
|
957
|
-
var addressTransactionsResponseSchema =
|
|
821
|
+
var resultsSchema4 = v12.array(resultSchema);
|
|
822
|
+
var addressTransactionsResponseSchema = v12.object({
|
|
958
823
|
...baseListResponseSchema.entries,
|
|
959
824
|
results: resultsSchema4
|
|
960
825
|
});
|
|
@@ -979,7 +844,7 @@ async function addressTransactions(args) {
|
|
|
979
844
|
data: {
|
|
980
845
|
status: res.status,
|
|
981
846
|
statusText: res.statusText,
|
|
982
|
-
|
|
847
|
+
bodyText: await safePromise(res.text())
|
|
983
848
|
}
|
|
984
849
|
});
|
|
985
850
|
}
|
|
@@ -991,7 +856,7 @@ async function addressTransactions(args) {
|
|
|
991
856
|
data: jsonParseError
|
|
992
857
|
});
|
|
993
858
|
}
|
|
994
|
-
const validationResult =
|
|
859
|
+
const validationResult = v12.safeParse(addressTransactionsResponseSchema, data);
|
|
995
860
|
if (!validationResult.success) {
|
|
996
861
|
return error({
|
|
997
862
|
name: "ValidateDataError",
|
|
@@ -1003,7 +868,7 @@ async function addressTransactions(args) {
|
|
|
1003
868
|
}
|
|
1004
869
|
|
|
1005
870
|
// src/stacks-api/transactions/get-transaction.ts
|
|
1006
|
-
var
|
|
871
|
+
var v13 = __toESM(require("valibot"), 1);
|
|
1007
872
|
async function getTransaction(args) {
|
|
1008
873
|
const init = {};
|
|
1009
874
|
if (args.apiKeyConfig) {
|
|
@@ -1020,7 +885,7 @@ async function getTransaction(args) {
|
|
|
1020
885
|
response: {
|
|
1021
886
|
status: res.status,
|
|
1022
887
|
statusText: res.statusText,
|
|
1023
|
-
|
|
888
|
+
bodyText: await safePromise(res.text())
|
|
1024
889
|
}
|
|
1025
890
|
});
|
|
1026
891
|
}
|
|
@@ -1032,7 +897,7 @@ async function getTransaction(args) {
|
|
|
1032
897
|
error: jsonParseError
|
|
1033
898
|
});
|
|
1034
899
|
}
|
|
1035
|
-
const validationResult =
|
|
900
|
+
const validationResult = v13.safeParse(transactionSchema, data);
|
|
1036
901
|
if (!validationResult.success) {
|
|
1037
902
|
return error({
|
|
1038
903
|
name: "ValidateDataError",
|
|
@@ -1043,10 +908,91 @@ async function getTransaction(args) {
|
|
|
1043
908
|
return success(validationResult.output);
|
|
1044
909
|
}
|
|
1045
910
|
|
|
911
|
+
// src/stacks-api/transactions/mempool-transactions.ts
|
|
912
|
+
async function mempoolTransactions(args) {
|
|
913
|
+
const search = new URLSearchParams();
|
|
914
|
+
if (args.limit) search.append("limit", args.limit.toString());
|
|
915
|
+
if (args.offset) search.append("offset", args.offset.toString());
|
|
916
|
+
if (args.senderAddress) search.append("sender_address", args.senderAddress);
|
|
917
|
+
if (args.recipientAddress)
|
|
918
|
+
search.append("recipient_address", args.recipientAddress);
|
|
919
|
+
if (args.address) search.append("address", args.address);
|
|
920
|
+
if (args.orderBy) search.append("order_by", args.orderBy);
|
|
921
|
+
if (args.order) search.append("order", args.order);
|
|
922
|
+
const init = {};
|
|
923
|
+
if (args.apiKeyConfig) {
|
|
924
|
+
init.headers = {
|
|
925
|
+
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
const res = await fetch(
|
|
929
|
+
`${args.baseUrl}/extended/v1/tx/mempool?${search}`,
|
|
930
|
+
init
|
|
931
|
+
);
|
|
932
|
+
if (!res.ok) {
|
|
933
|
+
return error({
|
|
934
|
+
name: "FetchMempoolTransactionsError",
|
|
935
|
+
message: "Failed to fetch mempool transactions.",
|
|
936
|
+
data: {
|
|
937
|
+
status: res.status,
|
|
938
|
+
statusText: res.statusText,
|
|
939
|
+
bodyText: await safePromise(res.text())
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
const [jsonParseError, data] = await safePromise(res.json());
|
|
944
|
+
if (jsonParseError) {
|
|
945
|
+
return error({
|
|
946
|
+
name: "ParseBodyError",
|
|
947
|
+
message: "Failed to parse response body.",
|
|
948
|
+
data: jsonParseError
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
return success(data);
|
|
952
|
+
}
|
|
953
|
+
|
|
1046
954
|
// src/stacks-api/transactions/index.ts
|
|
1047
955
|
var transactions = {
|
|
1048
956
|
addressTransactions,
|
|
1049
|
-
getTransaction
|
|
957
|
+
getTransaction,
|
|
958
|
+
mempoolTransactions
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
// src/stacks-api/mempool/transaction-fee-priorities.ts
|
|
962
|
+
async function transactionFeePriorities(opts) {
|
|
963
|
+
const init = {};
|
|
964
|
+
if (opts.apiKeyConfig) {
|
|
965
|
+
init.headers = {
|
|
966
|
+
[opts.apiKeyConfig.header]: opts.apiKeyConfig.key
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
const endpoint = `${opts.baseUrl}/extended/v2/mempool/fees`;
|
|
970
|
+
const res = await fetch(endpoint, init);
|
|
971
|
+
if (!res.ok) {
|
|
972
|
+
return error({
|
|
973
|
+
name: "FetchFeePrioritiesError",
|
|
974
|
+
message: "Failed to fetch transaction fee priorities.",
|
|
975
|
+
data: {
|
|
976
|
+
status: res.status,
|
|
977
|
+
statusText: res.statusText,
|
|
978
|
+
bodyParseResult: await safePromise(res.text())
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
const [jsonError, data] = await safePromise(res.json());
|
|
983
|
+
if (jsonError) {
|
|
984
|
+
return error({
|
|
985
|
+
name: "ParseBodyError",
|
|
986
|
+
message: "Failed to parse response body as JSON.",
|
|
987
|
+
data: jsonError
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
return success(data);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
// src/stacks-api/mempool/index.ts
|
|
994
|
+
var mempool = {
|
|
995
|
+
transactionFeePriorities
|
|
1050
996
|
};
|
|
1051
997
|
|
|
1052
998
|
// src/stacks-api/index.ts
|
|
@@ -1055,22 +1001,23 @@ var stacksApi = {
|
|
|
1055
1001
|
blocks,
|
|
1056
1002
|
faucets,
|
|
1057
1003
|
info,
|
|
1004
|
+
mempool,
|
|
1058
1005
|
proofOfTransfer,
|
|
1059
1006
|
stackingPool,
|
|
1060
1007
|
transactions
|
|
1061
1008
|
};
|
|
1062
1009
|
|
|
1063
1010
|
// src/stacks-rpc-api/smart-contracts/map-entry.ts
|
|
1064
|
-
var
|
|
1065
|
-
var mapEntryResponseSchema =
|
|
1011
|
+
var v14 = __toESM(require("valibot"), 1);
|
|
1012
|
+
var mapEntryResponseSchema = v14.object({
|
|
1066
1013
|
/**
|
|
1067
1014
|
* Hex-encoded string of clarity value. It is always an optional tuple.
|
|
1068
1015
|
*/
|
|
1069
|
-
data:
|
|
1016
|
+
data: v14.string(),
|
|
1070
1017
|
/**
|
|
1071
1018
|
* Hex-encoded string of the MARF proof for the data
|
|
1072
1019
|
*/
|
|
1073
|
-
proof:
|
|
1020
|
+
proof: v14.optional(v14.string())
|
|
1074
1021
|
});
|
|
1075
1022
|
async function mapEntry(args) {
|
|
1076
1023
|
const search = new URLSearchParams();
|
|
@@ -1098,7 +1045,7 @@ async function mapEntry(args) {
|
|
|
1098
1045
|
status: res.status,
|
|
1099
1046
|
statusText: res.statusText,
|
|
1100
1047
|
endpoint,
|
|
1101
|
-
|
|
1048
|
+
bodyText: await safePromise(res.text())
|
|
1102
1049
|
}
|
|
1103
1050
|
});
|
|
1104
1051
|
}
|
|
@@ -1110,7 +1057,7 @@ async function mapEntry(args) {
|
|
|
1110
1057
|
data: jsonError
|
|
1111
1058
|
});
|
|
1112
1059
|
}
|
|
1113
|
-
const validationResult =
|
|
1060
|
+
const validationResult = v14.safeParse(mapEntryResponseSchema, data);
|
|
1114
1061
|
if (!validationResult.success) {
|
|
1115
1062
|
return error({
|
|
1116
1063
|
name: "ValidateDataError",
|
|
@@ -1122,20 +1069,6 @@ async function mapEntry(args) {
|
|
|
1122
1069
|
}
|
|
1123
1070
|
|
|
1124
1071
|
// src/stacks-rpc-api/smart-contracts/read-only.ts
|
|
1125
|
-
var v17 = __toESM(require("valibot"), 1);
|
|
1126
|
-
var readOnlyResponseSchema = v17.variant("okay", [
|
|
1127
|
-
v17.object({
|
|
1128
|
-
okay: v17.literal(true),
|
|
1129
|
-
/**
|
|
1130
|
-
* A Clarity value as a hex-encoded string.
|
|
1131
|
-
*/
|
|
1132
|
-
result: v17.string()
|
|
1133
|
-
}),
|
|
1134
|
-
v17.object({
|
|
1135
|
-
okay: v17.literal(false),
|
|
1136
|
-
cause: v17.unknown()
|
|
1137
|
-
})
|
|
1138
|
-
]);
|
|
1139
1072
|
async function readOnly(args) {
|
|
1140
1073
|
const headers = {
|
|
1141
1074
|
"Content-Type": "application/json"
|
|
@@ -1160,7 +1093,7 @@ async function readOnly(args) {
|
|
|
1160
1093
|
data: {
|
|
1161
1094
|
status: res.status,
|
|
1162
1095
|
statusText: res.statusText,
|
|
1163
|
-
|
|
1096
|
+
bodyText: await safePromise(res.text())
|
|
1164
1097
|
}
|
|
1165
1098
|
});
|
|
1166
1099
|
}
|
|
@@ -1172,15 +1105,7 @@ async function readOnly(args) {
|
|
|
1172
1105
|
data: error
|
|
1173
1106
|
});
|
|
1174
1107
|
}
|
|
1175
|
-
|
|
1176
|
-
if (!validationResult.success) {
|
|
1177
|
-
return error({
|
|
1178
|
-
name: "ValidateDataError",
|
|
1179
|
-
message: "Failed to validate data.",
|
|
1180
|
-
data: validationResult
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
return success(validationResult.output);
|
|
1108
|
+
return success(data);
|
|
1184
1109
|
}
|
|
1185
1110
|
|
|
1186
1111
|
// src/stacks-rpc-api/smart-contracts/index.ts
|
|
@@ -1189,8 +1114,45 @@ var smartContracts = {
|
|
|
1189
1114
|
readOnly
|
|
1190
1115
|
};
|
|
1191
1116
|
|
|
1117
|
+
// src/stacks-rpc-api/pox/pox-details.ts
|
|
1118
|
+
async function poxDetails(args) {
|
|
1119
|
+
const init = {};
|
|
1120
|
+
if (args.apiKeyConfig) {
|
|
1121
|
+
init.headers = {
|
|
1122
|
+
[args.apiKeyConfig.header]: args.apiKeyConfig.key
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
const res = await fetch(`${args.baseUrl}/v2/pox`, init);
|
|
1126
|
+
if (!res.ok) {
|
|
1127
|
+
return error({
|
|
1128
|
+
name: "FetchPoxDetailsError",
|
|
1129
|
+
message: "Failed to fetch pox details.",
|
|
1130
|
+
data: {
|
|
1131
|
+
status: res.status,
|
|
1132
|
+
statusText: res.statusText,
|
|
1133
|
+
bodyText: await safePromise(res.text())
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
const [jsonParseError, data] = await safePromise(res.json());
|
|
1138
|
+
if (jsonParseError) {
|
|
1139
|
+
return error({
|
|
1140
|
+
name: "ParseBodyError",
|
|
1141
|
+
message: "Failed to parse pox details response.",
|
|
1142
|
+
data: jsonParseError
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
return success(data);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/stacks-rpc-api/pox/index.ts
|
|
1149
|
+
var pox = {
|
|
1150
|
+
poxDetails
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1192
1153
|
// src/stacks-rpc-api/index.ts
|
|
1193
1154
|
var stacksRpcApi = {
|
|
1155
|
+
pox,
|
|
1194
1156
|
smartContracts
|
|
1195
1157
|
};
|
|
1196
1158
|
|
|
@@ -1289,10 +1251,140 @@ async function getSignerStackedAmount(args) {
|
|
|
1289
1251
|
var queries = {
|
|
1290
1252
|
getSignerStackedAmount
|
|
1291
1253
|
};
|
|
1254
|
+
|
|
1255
|
+
// src/pox4-api/maps/stacking-state.ts
|
|
1256
|
+
var import_transactions2 = require("@stacks/transactions");
|
|
1257
|
+
|
|
1258
|
+
// src/pox4-api/constants.ts
|
|
1259
|
+
var netValueMap = {
|
|
1260
|
+
mainnet: {
|
|
1261
|
+
pox4ContractAddress: "SP000000000000000000002Q6VF78",
|
|
1262
|
+
pox4ContractName: "pox-4"
|
|
1263
|
+
},
|
|
1264
|
+
testnet: {
|
|
1265
|
+
pox4ContractAddress: "ST000000000000000000002AMW42H",
|
|
1266
|
+
pox4ContractName: "pox-4"
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
function networkDependentValues(network) {
|
|
1270
|
+
return netValueMap[network];
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// src/pox4-api/maps/stacking-state.ts
|
|
1274
|
+
async function stackingState({
|
|
1275
|
+
key,
|
|
1276
|
+
network,
|
|
1277
|
+
baseUrl,
|
|
1278
|
+
apiKeyConfig,
|
|
1279
|
+
proof,
|
|
1280
|
+
tip
|
|
1281
|
+
}) {
|
|
1282
|
+
const [mapEntryError, mapEntryData] = await mapEntry({
|
|
1283
|
+
contractAddress: networkDependentValues(network).pox4ContractAddress,
|
|
1284
|
+
contractName: networkDependentValues(network).pox4ContractName,
|
|
1285
|
+
mapKey: (0, import_transactions2.cvToHex)(key),
|
|
1286
|
+
mapName: "stacking-state",
|
|
1287
|
+
apiKeyConfig,
|
|
1288
|
+
proof,
|
|
1289
|
+
tip,
|
|
1290
|
+
baseUrl
|
|
1291
|
+
});
|
|
1292
|
+
if (mapEntryError)
|
|
1293
|
+
return error({
|
|
1294
|
+
name: "FetchStackingStateError",
|
|
1295
|
+
message: "Failed to fetch stacking state.",
|
|
1296
|
+
data: mapEntryError
|
|
1297
|
+
});
|
|
1298
|
+
return success({
|
|
1299
|
+
data: (0, import_transactions2.hexToCV)(mapEntryData.data),
|
|
1300
|
+
proof: mapEntryData.proof
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// src/pox4-api/maps/index.ts
|
|
1305
|
+
var maps = { stackingState };
|
|
1306
|
+
|
|
1307
|
+
// src/pox4-api/read-only/get-stacker-info.ts
|
|
1308
|
+
var import_transactions3 = require("@stacks/transactions");
|
|
1309
|
+
async function getStackerInfo({
|
|
1310
|
+
principal,
|
|
1311
|
+
network,
|
|
1312
|
+
baseUrl,
|
|
1313
|
+
apiKeyConfig
|
|
1314
|
+
}) {
|
|
1315
|
+
const [readOnlyError, readOnlyData] = await stacksRpcApi.smartContracts.readOnly({
|
|
1316
|
+
contractAddress: networkDependentValues(network).pox4ContractAddress,
|
|
1317
|
+
contractName: networkDependentValues(network).pox4ContractName,
|
|
1318
|
+
functionName: "get-stacker-info",
|
|
1319
|
+
arguments: [(0, import_transactions3.cvToHex)((0, import_transactions3.principalCV)(principal))],
|
|
1320
|
+
baseUrl,
|
|
1321
|
+
apiKeyConfig,
|
|
1322
|
+
sender: principal
|
|
1323
|
+
});
|
|
1324
|
+
if (readOnlyError) {
|
|
1325
|
+
return error({
|
|
1326
|
+
name: "GetStackerInfoError",
|
|
1327
|
+
message: "Failed to get stacker info.",
|
|
1328
|
+
data: readOnlyError
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
if (!readOnlyData.okay) {
|
|
1332
|
+
return error({
|
|
1333
|
+
name: "GetStackerInfoFunctionCallError",
|
|
1334
|
+
message: "Call to `get-stacker-info` failed.",
|
|
1335
|
+
data: readOnlyData
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
return success((0, import_transactions3.hexToCV)(readOnlyData.result));
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// src/pox4-api/read-only/get-check-delegation.ts
|
|
1342
|
+
var import_transactions4 = require("@stacks/transactions");
|
|
1343
|
+
async function getCheckDelegation({
|
|
1344
|
+
principal,
|
|
1345
|
+
network,
|
|
1346
|
+
baseUrl,
|
|
1347
|
+
apiKeyConfig
|
|
1348
|
+
}) {
|
|
1349
|
+
const [readOnlyError, readOnlyData] = await stacksRpcApi.smartContracts.readOnly({
|
|
1350
|
+
contractAddress: networkDependentValues(network).pox4ContractAddress,
|
|
1351
|
+
contractName: networkDependentValues(network).pox4ContractName,
|
|
1352
|
+
functionName: "get-check-delegation",
|
|
1353
|
+
arguments: [(0, import_transactions4.cvToHex)((0, import_transactions4.principalCV)(principal))],
|
|
1354
|
+
baseUrl,
|
|
1355
|
+
apiKeyConfig,
|
|
1356
|
+
sender: principal
|
|
1357
|
+
});
|
|
1358
|
+
if (readOnlyError) {
|
|
1359
|
+
return error({
|
|
1360
|
+
name: "GetCheckDelegationError",
|
|
1361
|
+
message: "Failed to get check delegation.",
|
|
1362
|
+
data: readOnlyError
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
if (!readOnlyData.okay) {
|
|
1366
|
+
return error({
|
|
1367
|
+
name: "GetCheckDelegationFunctionCallError",
|
|
1368
|
+
message: "Call to `get-check-delegation` failed.",
|
|
1369
|
+
data: readOnlyData
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
return success((0, import_transactions4.hexToCV)(readOnlyData.result));
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// src/pox4-api/read-only/index.ts
|
|
1376
|
+
var readOnly2 = {
|
|
1377
|
+
getStackerInfo,
|
|
1378
|
+
getCheckDelegation
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
// src/pox4-api/index.ts
|
|
1382
|
+
var pox4Api = { maps, readOnly: readOnly2 };
|
|
1292
1383
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1293
1384
|
0 && (module.exports = {
|
|
1294
1385
|
callRateLimitedApi,
|
|
1295
1386
|
error,
|
|
1387
|
+
pox4Api,
|
|
1296
1388
|
queries,
|
|
1297
1389
|
safeCall,
|
|
1298
1390
|
safeCallRateLimitedApi,
|