-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathcommon.ts
1556 lines (1372 loc) · 39.1 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { ClarityAbi } from '@stacks/transactions';
import { Block } from '@stacks/stacks-blockchain-api-types';
import { SyntheticPoxEventName } from '../pox-helpers';
import { PgBytea, PgJsonb, PgNumeric } from '@hirosystems/api-toolkit';
export interface DbBlock {
block_hash: string;
burn_block_time: number;
burn_block_hash: string;
burn_block_height: number;
miner_txid: string;
index_block_hash: string;
parent_index_block_hash: string;
parent_block_hash: string;
parent_microblock_hash: string;
parent_microblock_sequence: number;
block_height: number;
/** Set to `true` if entry corresponds to the canonical chain tip */
canonical: boolean;
/** Sum of the execution costs for each tx included in the block */
execution_cost_read_count: number;
execution_cost_read_length: number;
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
}
/** An interface representing the microblock data that can be constructed _only_ from the /new_microblocks payload */
export interface DbMicroblockPartial {
microblock_hash: string;
microblock_sequence: number;
microblock_parent_hash: string;
parent_index_block_hash: string;
parent_burn_block_time: number;
parent_burn_block_hash: string;
parent_burn_block_height: number;
}
export interface DbMicroblock extends DbMicroblockPartial {
canonical: boolean;
microblock_canonical: boolean;
block_height: number;
parent_block_height: number;
parent_block_hash: string;
index_block_hash: string;
block_hash: string;
}
export interface DbBurnBlock {
block_hash: string;
burn_block_time: number;
burn_block_hash: string;
burn_block_height: number;
stacks_blocks: string[];
}
export interface DbBurnchainReward {
canonical: boolean;
burn_block_hash: string;
burn_block_height: number;
burn_amount: bigint;
reward_recipient: string;
reward_amount: bigint;
reward_index: number;
}
export interface DbRewardSlotHolder {
canonical: boolean;
burn_block_hash: string;
burn_block_height: number;
address: string;
slot_index: number;
}
export interface DbMinerReward {
block_hash: string;
index_block_hash: string;
from_index_block_hash: string;
mature_block_height: number;
/** Set to `true` if entry corresponds to the canonical chain tip */
canonical: boolean;
/** STX principal */
recipient: string;
/** STX principal */
miner_address: string | null;
coinbase_amount: bigint;
tx_fees_anchored: bigint;
tx_fees_streamed_confirmed: bigint;
tx_fees_streamed_produced: bigint;
}
export enum DbTxTypeId {
TokenTransfer = 0x00,
SmartContract = 0x01,
ContractCall = 0x02,
PoisonMicroblock = 0x03,
Coinbase = 0x04,
CoinbaseToAltRecipient = 0x05,
VersionedSmartContract = 0x06,
TenureChange = 0x07,
NakamotoCoinbase = 0x08,
}
export enum DbTxStatus {
Pending = 0,
Success = 1,
AbortByResponse = -1,
AbortByPostCondition = -2,
/** Replaced by a transaction with the same nonce, but a higher fee. */
DroppedReplaceByFee = -10,
/** Replaced by a transaction with the same nonce but in the canonical fork. */
DroppedReplaceAcrossFork = -11,
/** The transaction is too expensive to include in a block. */
DroppedTooExpensive = -12,
/** Transaction was dropped because it became stale. */
DroppedStaleGarbageCollect = -13,
/** Dropped by the API (even though the Stacks node hadn't dropped it) because it exceeded maximum mempool age */
DroppedApiGarbageCollect = -14,
}
export enum DbTxAnchorMode {
OnChainOnly = 0x01,
OffChainOnly = 0x02,
Any = 0x03,
}
export interface BaseTx {
/** u64 */
fee_rate: bigint;
sender_address: string;
sponsored: boolean;
sponsor_address?: string;
sponsor_nonce?: number;
nonce: number;
tx_id: string;
anchor_mode: DbTxAnchorMode;
/** Only valid for `token_transfer` tx types. */
token_transfer_recipient_address?: string;
/** 64-bit unsigned integer. */
token_transfer_amount?: bigint;
/** Hex encoded arbitrary message, up to 34 bytes length (should try decoding to an ASCII string). */
token_transfer_memo?: string;
status: DbTxStatus;
type_id: DbTxTypeId;
/** Only valid for `contract_call` tx types */
contract_call_contract_id?: string;
contract_call_function_name?: string;
/** Hex encoded Clarity values. Undefined if function defines no args. */
contract_call_function_args?: string;
abi?: string;
/** Only valid for `tenure-change` tx types. */
tenure_change_tenure_consensus_hash?: string;
tenure_change_prev_tenure_consensus_hash?: string;
tenure_change_burn_view_consensus_hash?: string;
tenure_change_previous_tenure_end?: string;
tenure_change_previous_tenure_blocks?: number;
tenure_change_cause?: number;
tenure_change_pubkey_hash?: string;
tenure_change_signature?: string;
tenure_change_signers?: string;
}
export interface DbTx extends BaseTx {
index_block_hash: string;
parent_index_block_hash: string;
block_hash: string;
parent_block_hash: string;
block_height: number;
burn_block_time: number;
parent_burn_block_time: number;
tx_index: number;
/** Hex encoded Clarity values. */
raw_result: string;
/** Set to `true` if entry corresponds to the canonical chain tip */
canonical: boolean;
microblock_canonical: boolean;
// TODO(mb): should probably be (number | null) rather than -1 for batched tx
microblock_sequence: number;
// TODO(mb): should probably be (string | null) rather than empty string for batched tx
microblock_hash: string;
post_conditions: string;
/** u8 */
origin_hash_mode: number;
/** Only valid for `versioned_smart_contract` tx types */
smart_contract_clarity_version?: number;
/** Only valid for `smart_contract` tx types. */
smart_contract_contract_id?: string;
smart_contract_source_code?: string;
/** Only valid for `poison_microblock` tx types. */
poison_microblock_header_1?: string;
poison_microblock_header_2?: string;
/** Only valid for `coinbase` tx types. Hex encoded 32-bytes. */
coinbase_payload?: string;
/** Only valid for `coinbase-to-alt-recipient` tx types. Either a standard principal or contract principal. */
coinbase_alt_recipient?: string;
/** Only valid for `nakamoto-coinbase` tx types. Hex encoded 80-bytes. */
coinbase_vrf_proof?: string;
event_count: number;
execution_cost_read_count: number;
execution_cost_read_length: number;
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
}
export interface DbTxRaw extends DbTx {
raw_tx: string;
}
export interface DbTxGlobalStatus {
status: DbTxStatus;
index_block_hash?: string;
microblock_hash?: string;
}
export interface DbMempoolStats {
tx_type_counts: Record<string, number>;
tx_simple_fee_averages: Record<
string,
{
p25: number | null;
p50: number | null;
p75: number | null;
p95: number | null;
}
>;
tx_ages: Record<
string,
{
p25: number | null;
p50: number | null;
p75: number | null;
p95: number | null;
}
>;
tx_byte_sizes: Record<
string,
{
p25: number | null;
p50: number | null;
p75: number | null;
p95: number | null;
}
>;
}
export interface DbMempoolTx extends BaseTx {
pruned: boolean;
receipt_time: number;
post_conditions: string;
/** u8 */
origin_hash_mode: number;
/** Only valid for `versioned_smart_contract` tx types */
smart_contract_clarity_version?: number;
/** Only valid for `smart_contract` tx types. */
smart_contract_contract_id?: string;
smart_contract_source_code?: string;
/** Only valid for `poison_microblock` tx types. */
poison_microblock_header_1?: string;
poison_microblock_header_2?: string;
/** Only valid for `coinbase` tx types. Hex encoded 32-bytes. */
coinbase_payload?: string;
/** Only valid for `coinbase-to-alt-recipient` tx types. Either a standard principal or contract principal. */
coinbase_alt_recipient?: string;
/** Only valid for `nakamoto-coinbase` tx types. Hex encoded 80-bytes. */
coinbase_vrf_proof?: string;
}
export interface DbMempoolTxRaw extends DbMempoolTx {
raw_tx: string;
}
export interface DbSmartContract {
tx_id: string;
canonical: boolean;
contract_id: string;
block_height: number;
clarity_version: number | null;
source_code: string;
abi: string | null;
}
export enum DbFaucetRequestCurrency {
BTC = 'btc',
STX = 'stx',
}
export interface DbFaucetRequest {
currency: DbFaucetRequestCurrency;
address: string;
ip: string;
occurred_at: number;
}
export enum DbEventTypeId {
SmartContractLog = 1,
StxAsset = 2,
FungibleTokenAsset = 3,
NonFungibleTokenAsset = 4,
StxLock = 5,
}
export interface DbEventBase {
event_index: number;
tx_id: string;
tx_index: number;
block_height: number;
/** Set to `true` if entry corresponds to the canonical chain tip */
canonical: boolean;
}
export type PoxSyntheticEventTable = 'pox2_events' | 'pox3_events' | 'pox4_events';
export interface DbPoxSyntheticBaseEventData {
stacker: string;
locked: bigint;
balance: bigint;
burnchain_unlock_height: bigint;
pox_addr: string | null;
pox_addr_raw: string | null;
}
export interface DbPoxSyntheticHandleUnlockEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.HandleUnlock;
data: {
first_cycle_locked: bigint;
first_unlocked_cycle: bigint;
};
}
export interface DbPoxSyntheticStackStxEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackStx;
data: {
lock_amount: bigint;
lock_period: bigint;
start_burn_height: bigint;
unlock_burn_height: bigint;
};
}
export interface DbPoxSyntheticStackIncreaseEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackIncrease;
data: {
increase_by: bigint;
total_locked: bigint;
};
}
export interface DbPoxSyntheticStackExtendEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackExtend;
data: {
extend_count: bigint;
unlock_burn_height: bigint;
};
}
export interface DbPoxSyntheticDelegateStxEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.DelegateStx;
data: {
amount_ustx: bigint;
delegate_to: string;
unlock_burn_height: bigint | null;
};
}
export interface DbPoxSyntheticDelegateStackStxEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.DelegateStackStx;
data: {
lock_amount: bigint;
unlock_burn_height: bigint;
start_burn_height: bigint;
lock_period: bigint;
delegator: string;
};
}
export interface DbPoxSyntheticDelegateStackIncreaseEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.DelegateStackIncrease;
data: {
increase_by: bigint;
total_locked: bigint;
delegator: string;
};
}
export interface DbPoxSyntheticDelegateStackExtendEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.DelegateStackExtend;
data: {
unlock_burn_height: bigint;
extend_count: bigint;
delegator: string;
};
}
export interface DbPoxSyntheticStackAggregationCommitEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackAggregationCommit;
data: {
reward_cycle: bigint;
amount_ustx: bigint;
};
}
export interface DbPoxSyntheticStackAggregationCommitIndexedEvent
extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackAggregationCommitIndexed;
data: {
reward_cycle: bigint;
amount_ustx: bigint;
};
}
export interface DbPoxSyntheticStackAggregationIncreaseEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.StackAggregationIncrease;
data: {
reward_cycle: bigint;
amount_ustx: bigint;
};
}
export interface DbPoxSyntheticRevokeDelegateStxEvent extends DbPoxSyntheticBaseEventData {
name: SyntheticPoxEventName.RevokeDelegateStx;
data: {
// TODO: determine what data is available for this event type
amount_ustx: bigint;
delegate_to: string;
};
}
export type DbPoxSyntheticEventData =
| DbPoxSyntheticHandleUnlockEvent
| DbPoxSyntheticStackStxEvent
| DbPoxSyntheticStackIncreaseEvent
| DbPoxSyntheticStackExtendEvent
| DbPoxSyntheticDelegateStxEvent
| DbPoxSyntheticDelegateStackStxEvent
| DbPoxSyntheticDelegateStackIncreaseEvent
| DbPoxSyntheticDelegateStackExtendEvent
| DbPoxSyntheticStackAggregationCommitEvent
| DbPoxSyntheticStackAggregationCommitIndexedEvent
| DbPoxSyntheticStackAggregationIncreaseEvent
| DbPoxSyntheticRevokeDelegateStxEvent;
export type DbPoxSyntheticEvent = DbEventBase & DbPoxSyntheticEventData;
export interface DbPoxStacker {
stacker: string;
pox_addr?: string;
amount_ustx: string;
burn_block_unlock_height?: number;
block_height: number;
tx_id: string;
}
export interface DbSmartContractEvent extends DbEventBase {
event_type: DbEventTypeId.SmartContractLog;
contract_identifier: string;
topic: string;
value: string;
}
export interface DbStxLockEvent extends DbEventBase {
event_type: DbEventTypeId.StxLock;
locked_amount: bigint;
unlock_height: number;
locked_address: string;
contract_name: string;
}
export enum DbAssetEventTypeId {
Transfer = 1,
Mint = 2,
Burn = 3,
}
interface DbAssetEvent extends DbEventBase {
asset_event_type_id: DbAssetEventTypeId;
sender?: string;
recipient?: string;
}
export interface DbStxEvent extends DbAssetEvent {
event_type: DbEventTypeId.StxAsset;
amount: bigint;
memo?: string;
}
interface DbContractAssetEvent extends DbAssetEvent {
asset_identifier: string;
}
export interface DbFtEvent extends DbContractAssetEvent {
event_type: DbEventTypeId.FungibleTokenAsset;
/** unsigned 128-bit integer */
amount: bigint;
}
export interface DbNftEvent extends DbContractAssetEvent {
event_type: DbEventTypeId.NonFungibleTokenAsset;
value: string;
}
export interface StxUnlockEvent {
tx_id: string;
stacker_address: string;
unlocked_amount: string;
}
export type DbEvent = DbSmartContractEvent | DbStxEvent | DbStxLockEvent | DbFtEvent | DbNftEvent;
export interface DbTxWithAssetTransfers {
tx: DbTx;
stx_sent: bigint;
stx_received: bigint;
stx_transfers: {
amount: bigint;
sender?: string;
recipient?: string;
}[];
ft_transfers: {
asset_identifier: string;
amount: bigint;
sender?: string;
recipient?: string;
}[];
nft_transfers: {
asset_identifier: string;
value: string;
sender?: string;
recipient?: string;
}[];
}
export interface NftHoldingInfo {
asset_identifier: string;
value: string;
recipient: string;
tx_id: string;
block_height: number;
}
export interface NftHoldingInfoWithTxMetadata {
nft_holding_info: NftHoldingInfo;
tx?: DbTx;
}
export interface NftEventWithTxMetadata {
nft_event: DbNftEvent;
tx?: DbTx;
}
export interface AddressNftEventIdentifier {
sender: string;
recipient: string;
asset_identifier: string;
value: string;
block_height: number;
tx_id: string;
event_index: number;
tx_index: number;
asset_event_type_id: number;
}
export interface DataStoreBlockUpdateData {
block: DbBlock;
microblocks: DbMicroblock[];
minerRewards: DbMinerReward[];
txs: DataStoreTxEventData[];
pox_v1_unlock_height?: number;
pox_v2_unlock_height?: number;
pox_v3_unlock_height?: number;
}
export interface DataStoreMicroblockUpdateData {
microblocks: DbMicroblockPartial[];
txs: DataStoreTxEventData[];
}
export interface DataStoreTxEventData {
tx: DbTxRaw;
stxEvents: DbStxEvent[];
stxLockEvents: DbStxLockEvent[];
ftEvents: DbFtEvent[];
nftEvents: DbNftEvent[];
contractLogEvents: DbSmartContractEvent[];
smartContracts: DbSmartContract[];
names: DbBnsName[];
namespaces: DbBnsNamespace[];
pox2Events: DbPoxSyntheticEvent[];
pox3Events: DbPoxSyntheticEvent[];
pox4Events: DbPoxSyntheticEvent[];
}
export interface DataStoreAttachmentData {
op: string;
name: string;
namespace: string;
zonefile: string;
zonefileHash: string;
txId: string;
indexBlockHash: string;
blockHeight: number;
}
export interface DataStoreBnsBlockData {
index_block_hash: string;
parent_index_block_hash: string;
microblock_hash: string;
microblock_sequence: number;
microblock_canonical: boolean;
}
export interface DataStoreAttachmentSubdomainData {
attachment?: DataStoreAttachmentData;
blockData?: DataStoreBnsBlockData;
subdomains?: DbBnsSubdomain[];
}
export interface DbSearchResult {
entity_type: 'standard_address' | 'contract_address' | 'block_hash' | 'tx_id' | 'mempool_tx_id';
entity_id: string;
entity_data?: DbBlock | DbMempoolTx | DbTx;
}
export interface DbSearchResultWithMetadata {
entity_type: 'standard_address' | 'contract_address' | 'block_hash' | 'tx_id' | 'mempool_tx_id';
entity_id: string;
entity_data?: Block | DbMempoolTx | DbTx;
}
export interface DbFtBalance {
balance: bigint;
totalSent: bigint;
totalReceived: bigint;
}
export interface DbStxBalance {
balance: bigint;
totalSent: bigint;
totalReceived: bigint;
totalFeesSent: bigint;
totalMinerRewardsReceived: bigint;
lockTxId: string;
locked: bigint;
lockHeight: number;
burnchainLockHeight: number;
burnchainUnlockHeight: number;
}
export interface DbInboundStxTransfer {
sender: string;
amount: bigint;
memo: string;
block_height: number;
tx_id: string;
transfer_type: string;
tx_index: number;
}
export interface DbBnsZoneFile {
zonefile: string;
}
export interface DbBnsNamespace {
id?: number;
namespace_id: string;
address: string;
launched_at?: number;
reveal_block: number;
ready_block: number;
buckets: string;
base: bigint;
coeff: bigint;
nonalpha_discount: bigint;
no_vowel_discount: bigint;
lifetime: number;
status?: string;
tx_id: string;
tx_index: number;
canonical: boolean;
}
export interface DbBnsName {
id?: number;
name: string;
address: string;
namespace_id: string;
registered_at: number;
expire_block: number;
grace_period?: number;
renewal_deadline?: number;
resolver?: string;
zonefile: string;
zonefile_hash: string;
tx_id: string;
tx_index: number;
event_index?: number;
status?: string;
canonical: boolean;
}
export interface DbBnsSubdomain {
id?: number;
name: string;
namespace_id: string;
fully_qualified_subdomain: string;
owner: string;
zonefile: string;
zonefile_hash: string;
parent_zonefile_hash: string;
parent_zonefile_index: number;
block_height: number;
zonefile_offset: number;
resolver: string;
tx_id: string;
tx_index: number;
canonical: boolean;
index_block_hash?: string;
}
export interface DbConfigState {
bns_names_onchain_imported: boolean;
bns_subdomains_imported: boolean;
token_offering_imported: boolean;
}
export interface DbTokenOfferingLocked {
address: string;
value: bigint;
block: number;
}
export interface DbGetBlockWithMetadataOpts<
TWithTxs extends boolean,
TWithMicroblocks extends boolean
> {
txs?: TWithTxs;
microblocks?: TWithMicroblocks;
}
export interface DbGetBlockWithMetadataResponse<
TWithTxs extends boolean,
TWithMicroblocks extends boolean
> {
block: DbBlock;
txs: TWithTxs extends true ? DbTx[] : null;
microblocks: TWithMicroblocks extends true
? { accepted: DbMicroblock[]; streamed: DbMicroblock[] }
: null;
microblock_tx_count: Record<string, number>;
}
export interface DbRawEventRequest {
event_path: string;
payload: string;
}
export type BlockIdentifier =
| { hash: string }
| { height: number }
| { burnBlockHash: string }
| { burnBlockHeight: number };
export interface BlockQueryResult {
block_hash: string;
index_block_hash: string;
parent_index_block_hash: string;
parent_block_hash: string;
parent_microblock_hash: string;
parent_microblock_sequence: number;
block_height: number;
burn_block_time: number;
burn_block_hash: string;
burn_block_height: number;
miner_txid: string;
canonical: boolean;
execution_cost_read_count: string;
execution_cost_read_length: string;
execution_cost_runtime: string;
execution_cost_write_count: string;
execution_cost_write_length: string;
}
export interface MicroblockQueryResult {
canonical: boolean;
microblock_canonical: boolean;
microblock_hash: string;
microblock_sequence: number;
microblock_parent_hash: string;
parent_index_block_hash: string;
block_height: number;
parent_block_height: number;
parent_block_hash: string;
index_block_hash: string;
block_hash: string;
parent_burn_block_height: number;
parent_burn_block_hash: string;
parent_burn_block_time: number;
}
export interface MempoolTxQueryResult {
pruned: boolean;
tx_id: string;
nonce: number;
sponsor_nonce?: number;
type_id: number;
anchor_mode: number;
status: number;
receipt_time: number;
receipt_block_height: number;
canonical: boolean;
post_conditions: string;
fee_rate: string;
sponsored: boolean;
sponsor_address: string | null;
sender_address: string;
origin_hash_mode: number;
// `token_transfer` tx types
token_transfer_recipient_address?: string;
token_transfer_amount?: string;
token_transfer_memo?: string;
// `versioned_smart_contract` tx types
smart_contract_clarity_version?: number;
// `smart_contract` tx types
smart_contract_contract_id?: string;
smart_contract_source_code?: string;
// `contract_call` tx types
contract_call_contract_id?: string;
contract_call_function_name?: string;
contract_call_function_args?: string;
// `poison_microblock` tx types
poison_microblock_header_1?: string;
poison_microblock_header_2?: string;
// `coinbase` tx types
coinbase_payload?: string;
/** Only valid for `coinbase-to-alt-recipient` tx types. Either a standard principal or contract principal. */
coinbase_alt_recipient?: string;
/** Only valid for `nakamoto-coinbase` tx types. Hex encoded 80-bytes. */
coinbase_vrf_proof?: string;
// `tenure-change` tx types
tenure_change_tenure_consensus_hash?: string;
tenure_change_prev_tenure_consensus_hash?: string;
tenure_change_burn_view_consensus_hash?: string;
tenure_change_previous_tenure_end?: string;
tenure_change_previous_tenure_blocks?: number;
tenure_change_cause?: number;
tenure_change_pubkey_hash: string;
tenure_change_signature?: string;
tenure_change_signers?: string;
// sending abi in case tx is contract call
abi: unknown | null;
}
export interface TxQueryResult {
tx_id: string;
tx_index: number;
index_block_hash: string;
parent_index_block_hash: string;
block_hash: string;
parent_block_hash: string;
block_height: number;
burn_block_time: number;
parent_burn_block_time: number;
nonce: number;
sponsor_nonce?: number;
type_id: number;
anchor_mode: number;
status: number;
raw_result: string;
canonical: boolean;
microblock_canonical: boolean;
microblock_sequence: number;
microblock_hash: string;
post_conditions: string;
fee_rate: string;
sponsored: boolean;
sponsor_address: string | null;
sender_address: string;
origin_hash_mode: number;
// `token_transfer` tx types
token_transfer_recipient_address?: string;
token_transfer_amount?: string;
token_transfer_memo?: string;
// `versioned_smart_contract` tx types
smart_contract_clarity_version?: number;
// `smart_contract` tx types
smart_contract_contract_id?: string;
smart_contract_source_code?: string;
// `contract_call` tx types
contract_call_contract_id?: string;
contract_call_function_name?: string;
contract_call_function_args?: string;
// `poison_microblock` tx types
poison_microblock_header_1?: string;
poison_microblock_header_2?: string;
// `coinbase` tx types
coinbase_payload?: string;
// `coinbase-to-alt-recipient` tx types
coinbase_alt_recipient?: string;
// `nakamoto-coinbase` tx types. Hex encoded 80-bytes.
coinbase_vrf_proof?: string;
// `tenure-change` tx types
tenure_change_tenure_consensus_hash?: string;
tenure_change_prev_tenure_consensus_hash?: string;
tenure_change_burn_view_consensus_hash?: string;
tenure_change_previous_tenure_end?: string;
tenure_change_previous_tenure_blocks?: number;
tenure_change_cause?: number;
tenure_change_pubkey_hash: string;
tenure_change_signature?: string;
tenure_change_signers?: string;
// events count
event_count: number;
execution_cost_read_count: string;
execution_cost_read_length: string;
execution_cost_runtime: string;
execution_cost_write_count: string;
execution_cost_write_length: string;
}
export interface ContractTxQueryResult extends TxQueryResult {
abi?: unknown | null;
}
export interface FaucetRequestQueryResult {
currency: string;
ip: string;
address: string;
occurred_at: string;
}
export interface UpdatedEntities {
markedCanonical: {
blocks: number;
microblocks: number;
minerRewards: number;
txs: number;
stxLockEvents: number;
stxEvents: number;
ftEvents: number;
nftEvents: number;
pox2Events: number;
pox3Events: number;
pox4Events: number;
contractLogs: number;
smartContracts: number;
names: number;
namespaces: number;
subdomains: number;
};
markedNonCanonical: {
blocks: number;
microblocks: number;