@secondlayer/shared 6.23.0 → 6.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/src/db/index.d.ts +730 -1
  2. package/dist/src/db/index.js +251 -1
  3. package/dist/src/db/index.js.map +4 -4
  4. package/dist/src/db/queries/chain-reorgs.d.ts +2 -0
  5. package/dist/src/db/queries/chain-reorgs.js +249 -1
  6. package/dist/src/db/queries/chain-reorgs.js.map +4 -4
  7. package/dist/src/db/queries/contracts.d.ts +2 -0
  8. package/dist/src/db/queries/integrity.d.ts +2 -0
  9. package/dist/src/db/queries/subgraph-gaps.d.ts +2 -0
  10. package/dist/src/db/queries/subgraph-operations.d.ts +2 -0
  11. package/dist/src/db/queries/subgraphs.d.ts +2 -0
  12. package/dist/src/db/queries/subgraphs.js +249 -1
  13. package/dist/src/db/queries/subgraphs.js.map +4 -4
  14. package/dist/src/db/queries/subscriptions.d.ts +2 -0
  15. package/dist/src/db/schema.d.ts +2 -0
  16. package/dist/src/errors.d.ts +5 -2
  17. package/dist/src/errors.js +8 -5
  18. package/dist/src/errors.js.map +3 -3
  19. package/dist/src/index.d.ts +772 -3
  20. package/dist/src/index.js +258 -5
  21. package/dist/src/index.js.map +6 -6
  22. package/dist/src/node/client.d.ts +52 -0
  23. package/dist/src/node/client.js +188 -1
  24. package/dist/src/node/client.js.map +5 -4
  25. package/dist/src/node/consensus.d.ts +38 -0
  26. package/dist/src/node/consensus.js +67 -0
  27. package/dist/src/node/consensus.js.map +10 -0
  28. package/dist/src/node/local-client.d.ts +2 -0
  29. package/dist/src/node/nakamoto.d.ts +90 -0
  30. package/dist/src/node/nakamoto.js +177 -0
  31. package/dist/src/node/nakamoto.js.map +10 -0
  32. package/dist/src/schemas/index.js.map +2 -2
  33. package/dist/src/schemas/subscriptions.d.ts +10 -1
  34. package/dist/src/schemas/subscriptions.js.map +2 -2
  35. package/dist/src/types.d.ts +2 -0
  36. package/migrations/0089_blocks_index_block_hash.ts +25 -0
  37. package/package.json +9 -1
package/dist/src/index.js CHANGED
@@ -377,6 +377,254 @@ var SOURCE_READ_COLUMNS = {
377
377
  events: ["block_height", "data", "event_index", "tx_id", "type"],
378
378
  chain_reorgs: ["detected_at"]
379
379
  };
380
+ var SOURCE_READ_TYPES = {
381
+ blocks: {
382
+ burn_block_hash: { type: "text", nullable: true },
383
+ burn_block_height: { type: "int" },
384
+ canonical: { type: "boolean" },
385
+ hash: { type: "text" },
386
+ height: { type: "int" },
387
+ parent_hash: { type: "text" },
388
+ timestamp: { type: "int" }
389
+ },
390
+ decoded_events: {
391
+ amount: { type: "text", nullable: true },
392
+ asset_identifier: { type: "text", nullable: true },
393
+ block_height: { type: "int" },
394
+ canonical: { type: "boolean" },
395
+ contract_id: { type: "text", nullable: true },
396
+ cursor: { type: "text" },
397
+ event_index: { type: "int" },
398
+ event_type: { type: "text" },
399
+ memo: { type: "text", nullable: true },
400
+ payload: { type: "jsonb", nullable: true },
401
+ recipient: { type: "text", nullable: true },
402
+ sender: { type: "text", nullable: true },
403
+ tx_id: { type: "text" },
404
+ tx_index: { type: "int" },
405
+ value: { type: "text", nullable: true }
406
+ },
407
+ transactions: {
408
+ block_height: { type: "int" },
409
+ contract_id: { type: "text", nullable: true },
410
+ function_args: { type: "jsonb", nullable: true },
411
+ function_name: { type: "text", nullable: true },
412
+ raw_result: { type: "text", nullable: true },
413
+ raw_tx: { type: "text" },
414
+ sender: { type: "text" },
415
+ status: { type: "text" },
416
+ tx_id: { type: "text" },
417
+ tx_index: { type: "int" },
418
+ type: { type: "text" }
419
+ },
420
+ mempool_transactions: {
421
+ contract_id: { type: "text", nullable: true },
422
+ function_args: { type: "jsonb", nullable: true },
423
+ function_name: { type: "text", nullable: true },
424
+ raw_tx: { type: "text" },
425
+ received_at: { type: "timestamp" },
426
+ sender: { type: "text" },
427
+ seq: { type: "text" },
428
+ tx_id: { type: "text" },
429
+ type: { type: "text" }
430
+ },
431
+ pox4_calls: {
432
+ aggregated_amount_ustx: { type: "text", nullable: true },
433
+ aggregated_signer_index: { type: "int", nullable: true },
434
+ amount_ustx: { type: "text", nullable: true },
435
+ auth_allowed: { type: "boolean", nullable: true },
436
+ auth_id: { type: "text", nullable: true },
437
+ auth_period: { type: "int", nullable: true },
438
+ auth_topic: { type: "text", nullable: true },
439
+ block_height: { type: "int" },
440
+ block_time: { type: "timestamp" },
441
+ burn_block_height: { type: "int" },
442
+ caller: { type: "text" },
443
+ canonical: { type: "boolean" },
444
+ cursor: { type: "text" },
445
+ delegate_to: { type: "text", nullable: true },
446
+ end_cycle: { type: "int", nullable: true },
447
+ function_name: { type: "text" },
448
+ lock_period: { type: "int", nullable: true },
449
+ max_amount: { type: "text", nullable: true },
450
+ pox_addr_btc: { type: "text", nullable: true },
451
+ pox_addr_hashbytes: { type: "text", nullable: true },
452
+ pox_addr_version: { type: "int", nullable: true },
453
+ result_ok: { type: "boolean" },
454
+ reward_cycle: { type: "int", nullable: true },
455
+ signer_key: { type: "text", nullable: true },
456
+ signer_signature: { type: "text", nullable: true },
457
+ source_cursor: { type: "text" },
458
+ stacker: { type: "text", nullable: true },
459
+ start_cycle: { type: "int", nullable: true },
460
+ tx_id: { type: "text" },
461
+ tx_index: { type: "int" }
462
+ },
463
+ sbtc_events: {
464
+ amount: { type: "text", nullable: true },
465
+ bitcoin_txid: { type: "text", nullable: true },
466
+ block_height: { type: "int" },
467
+ block_time: { type: "timestamp" },
468
+ burn_hash: { type: "text", nullable: true },
469
+ burn_height: { type: "int", nullable: true },
470
+ canonical: { type: "boolean" },
471
+ cursor: { type: "text" },
472
+ event_index: { type: "int" },
473
+ fee: { type: "text", nullable: true },
474
+ governance_contract_type: { type: "int", nullable: true },
475
+ governance_new_contract: { type: "text", nullable: true },
476
+ max_fee: { type: "text", nullable: true },
477
+ output_index: { type: "int", nullable: true },
478
+ recipient_btc_hashbytes: { type: "text", nullable: true },
479
+ recipient_btc_version: { type: "int", nullable: true },
480
+ request_id: { type: "int", nullable: true },
481
+ sender: { type: "text", nullable: true },
482
+ signer_address: { type: "text", nullable: true },
483
+ signer_aggregate_pubkey: { type: "text", nullable: true },
484
+ signer_bitmap: { type: "text", nullable: true },
485
+ signer_keys_count: { type: "int", nullable: true },
486
+ signer_threshold: { type: "int", nullable: true },
487
+ sweep_txid: { type: "text", nullable: true },
488
+ topic: { type: "text" },
489
+ tx_id: { type: "text" },
490
+ tx_index: { type: "int" }
491
+ },
492
+ sbtc_token_events: {
493
+ amount: { type: "text" },
494
+ block_height: { type: "int" },
495
+ block_time: { type: "timestamp" },
496
+ canonical: { type: "boolean" },
497
+ cursor: { type: "text" },
498
+ event_index: { type: "int" },
499
+ event_type: { type: "text" },
500
+ memo: { type: "text", nullable: true },
501
+ recipient: { type: "text", nullable: true },
502
+ sender: { type: "text", nullable: true },
503
+ tx_id: { type: "text" },
504
+ tx_index: { type: "int" }
505
+ },
506
+ bns_name_events: {
507
+ block_height: { type: "int" },
508
+ block_time: { type: "timestamp" },
509
+ bns_id: { type: "text" },
510
+ canonical: { type: "boolean" },
511
+ cursor: { type: "text" },
512
+ event_index: { type: "int" },
513
+ fqn: { type: "text" },
514
+ hashed_salted_fqn_preorder: { type: "text", nullable: true },
515
+ imported_at: { type: "int", nullable: true },
516
+ name: { type: "text" },
517
+ namespace: { type: "text" },
518
+ owner: { type: "text", nullable: true },
519
+ preordered_by: { type: "text", nullable: true },
520
+ registered_at: { type: "int", nullable: true },
521
+ renewal_height: { type: "int", nullable: true },
522
+ stx_burn: { type: "text", nullable: true },
523
+ topic: { type: "text" },
524
+ tx_id: { type: "text" },
525
+ tx_index: { type: "int" }
526
+ },
527
+ bns_namespace_events: {
528
+ block_height: { type: "int" },
529
+ block_time: { type: "timestamp" },
530
+ canonical: { type: "boolean" },
531
+ cursor: { type: "text" },
532
+ event_index: { type: "int" },
533
+ launched_at: { type: "int", nullable: true },
534
+ lifetime: { type: "int", nullable: true },
535
+ manager: { type: "text", nullable: true },
536
+ manager_frozen: { type: "boolean", nullable: true },
537
+ manager_transfers_disabled: { type: "boolean", nullable: true },
538
+ namespace: { type: "text" },
539
+ price_frozen: { type: "boolean", nullable: true },
540
+ price_function: { type: "text", nullable: true },
541
+ revealed_at: { type: "int", nullable: true },
542
+ status: { type: "text" },
543
+ tx_id: { type: "text" },
544
+ tx_index: { type: "int" }
545
+ },
546
+ bns_marketplace_events: {
547
+ action: { type: "text" },
548
+ block_height: { type: "int" },
549
+ block_time: { type: "timestamp" },
550
+ bns_id: { type: "text" },
551
+ canonical: { type: "boolean" },
552
+ commission: { type: "text", nullable: true },
553
+ cursor: { type: "text" },
554
+ event_index: { type: "int" },
555
+ price_ustx: { type: "text", nullable: true },
556
+ tx_id: { type: "text" },
557
+ tx_index: { type: "int" }
558
+ },
559
+ bns_names: {
560
+ bns_id: { type: "text" },
561
+ fqn: { type: "text" },
562
+ last_event_at: { type: "timestamp" },
563
+ last_event_cursor: { type: "text" },
564
+ name: { type: "text" },
565
+ namespace: { type: "text" },
566
+ owner: { type: "text" },
567
+ registered_at: { type: "int", nullable: true },
568
+ renewal_height: { type: "int", nullable: true }
569
+ },
570
+ bns_namespaces: {
571
+ last_event_at: { type: "timestamp" },
572
+ last_event_cursor: { type: "text" },
573
+ launched_at: { type: "int", nullable: true },
574
+ lifetime: { type: "int", nullable: true },
575
+ manager: { type: "text", nullable: true },
576
+ manager_frozen: { type: "boolean" },
577
+ name_count: { type: "int" },
578
+ namespace: { type: "text" },
579
+ price_frozen: { type: "boolean" }
580
+ },
581
+ burn_block_rewards: {
582
+ amount_sats: { type: "text" },
583
+ burn_amount: { type: "text" },
584
+ burn_block_hash: { type: "text" },
585
+ burn_block_height: { type: "int" },
586
+ canonical: { type: "boolean" },
587
+ cursor: { type: "text" },
588
+ recipient_btc: { type: "text" },
589
+ reward_index: { type: "int" }
590
+ },
591
+ burn_block_reward_slots: {
592
+ burn_block_hash: { type: "text" },
593
+ burn_block_height: { type: "int" },
594
+ canonical: { type: "boolean" },
595
+ cursor: { type: "text" },
596
+ holder_btc: { type: "text" },
597
+ slot_index: { type: "int" }
598
+ },
599
+ events: {
600
+ block_height: { type: "int" },
601
+ data: { type: "jsonb" },
602
+ event_index: { type: "int" },
603
+ tx_id: { type: "text" },
604
+ type: { type: "text" }
605
+ },
606
+ chain_reorgs: {
607
+ detected_at: { type: "timestamp" }
608
+ }
609
+ };
610
+ var SOURCE_READ_PKS = {
611
+ blocks: ["height"],
612
+ decoded_events: ["cursor"],
613
+ transactions: ["tx_id"],
614
+ mempool_transactions: ["seq"],
615
+ pox4_calls: ["cursor"],
616
+ sbtc_events: ["cursor"],
617
+ sbtc_token_events: ["cursor"],
618
+ bns_name_events: ["cursor"],
619
+ bns_namespace_events: ["cursor"],
620
+ bns_marketplace_events: ["cursor"],
621
+ bns_names: ["fqn"],
622
+ bns_namespaces: ["namespace"],
623
+ burn_block_rewards: ["cursor"],
624
+ burn_block_reward_slots: ["cursor"],
625
+ events: ["tx_id", "event_index"],
626
+ chain_reorgs: null
627
+ };
380
628
  // src/db/migration-role.ts
381
629
  var currentRole = "both";
382
630
  function setMigrationRole(role) {
@@ -628,10 +876,12 @@ var ErrorCodes = {
628
876
  class SecondLayerError extends Error {
629
877
  code;
630
878
  cause;
631
- constructor(code, message, cause) {
879
+ details;
880
+ constructor(code, message, cause, details) {
632
881
  super(message);
633
882
  this.code = code;
634
883
  this.cause = cause;
884
+ this.details = details;
635
885
  this.name = this.constructor.name;
636
886
  Error.captureStackTrace?.(this, this.constructor);
637
887
  }
@@ -641,7 +891,8 @@ class SecondLayerError extends Error {
641
891
  code: this.code,
642
892
  message: this.message,
643
893
  stack: this.stack,
644
- cause: this.cause
894
+ cause: this.cause,
895
+ details: this.details
645
896
  };
646
897
  }
647
898
  }
@@ -671,8 +922,8 @@ class AuthenticationError extends SecondLayerError {
671
922
  }
672
923
 
673
924
  class AuthorizationError extends SecondLayerError {
674
- constructor(message) {
675
- super("AUTHORIZATION_ERROR", message);
925
+ constructor(message, details) {
926
+ super("AUTHORIZATION_ERROR", message, undefined, details);
676
927
  }
677
928
  }
678
929
 
@@ -1744,6 +1995,8 @@ export {
1744
1995
  STREAMS_TO_DB_EVENT_TYPES,
1745
1996
  STREAMS_EVENT_TYPES,
1746
1997
  STREAMS_DB_EVENT_TYPES,
1998
+ SOURCE_READ_TYPES,
1999
+ SOURCE_READ_PKS,
1747
2000
  SOURCE_READ_COLUMNS,
1748
2001
  ReplaySubscriptionRequestSchema,
1749
2002
  RateLimitError,
@@ -1774,5 +2027,5 @@ export {
1774
2027
  AuthenticationError
1775
2028
  };
1776
2029
 
1777
- //# debugId=E26BA28FDF632B7E64756E2164756E21
2030
+ //# debugId=875BC4F6587D522D64756E2164756E21
1778
2031
  //# sourceMappingURL=index.js.map