@stacks/codec 1.8.0-pox5.1 → 2.0.0-pox5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -10
- package/index.d.ts +332 -27
- package/index.js +55 -17
- package/index.mjs +33 -16
- package/loader.d.ts +22 -13
- package/native/darwin-arm64.node +0 -0
- package/native/linux-arm64-glibc.node +0 -0
- package/native/linux-arm64-musl.node +0 -0
- package/native/linux-x64-glibc.node +0 -0
- package/native/linux-x64-musl.node +0 -0
- package/native/win32-x64.node +0 -0
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -236,7 +236,7 @@ import { decodeClarityValueToPrincipal } from '@stacks/codec';
|
|
|
236
236
|
|
|
237
237
|
// Serialized hex string of an example Clarity value (0x-prefix optional, Buffer / Uint8Array also accepted)
|
|
238
238
|
const standardPrincipal = decodeClarityValueToPrincipal('0x0516a13dce8114be0f707f94470a2e5e86eb402f2923');
|
|
239
|
-
assert.strictEqual(
|
|
239
|
+
assert.strictEqual(standardPrincipal, 'SP2GKVKM12JZ0YW3ZJH3GMBJYGVNM0BS94ERA45AM');
|
|
240
240
|
|
|
241
241
|
const contractPrincipal = decodeClarityValueToPrincipal('0x0616a6a7a70f41adbe8eae708ed7ec2cbf41a272182014626974636f696e2d6d6f6e6b6579732d6c616273');
|
|
242
242
|
assert.strictEqual(contractPrincipal, 'SP2KAF9RF86PVX3NEE27DFV1CQX0T4WGR41X3S45C.bitcoin-monkeys-labs');
|
|
@@ -415,17 +415,22 @@ The directory structure of this project is:
|
|
|
415
415
|
/
|
|
416
416
|
├── Cargo.toml # The Cargo <a href="https://doc.rust-lang.org/cargo/reference/manifest.html">manifest file</a>
|
|
417
417
|
├── package.json # The npm <a href="https://docs.npmjs.com/cli/v7/configuring-npm/package-json">manifest file</a>
|
|
418
|
-
├──
|
|
419
|
-
├──
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
├──
|
|
425
|
-
|
|
418
|
+
├── build.js # Script to build the native Node addon for the executing host platform
|
|
419
|
+
├── index.ts # Typescript definitions for the JS interface exposed by the Node addon
|
|
420
|
+
├── loader.js # Script to determine which addon file to load based on the executing target platform
|
|
421
|
+
├── loader.d.ts # Type definitions for the functions exported by the Node addon
|
|
422
|
+
├── native/ # The <a href="https://nodejs.org/api/addons.html">Node addon</a> binaries built by this project (one per supported target)
|
|
423
|
+
├── src/ # Rust source code
|
|
424
|
+
│ ├── upstream/ # Thin layer over stacks-network/stacks-core types (address, clarity_value, post_condition, stacks_block, stacks_tx)
|
|
425
|
+
│ ├── derived/ # Local decoders that produce Stacks-API-shaped output (memo, pox_events)
|
|
426
|
+
│ ├── util/ # Crate-internal helpers (hex, neon bindings, DeserializeError)
|
|
427
|
+
│ └── lib.rs # Neon entry point — exports the JS-facing functions
|
|
428
|
+
├── tests/ # Jest end-to-end tests + fixtures
|
|
429
|
+
├── scripts/ # update-stacks-core.sh — bump the upstream git pin
|
|
430
|
+
└── docs/ # Migration / upgrade documentation
|
|
426
431
|
</pre>
|
|
427
432
|
|
|
428
|
-
|
|
433
|
+
All consensus wire-format parsing is delegated to upstream `stacks-network/stacks-core` crates (`stackslib`, `clarity`, `stacks-common`, `stacks-codec`) — see [`docs/upstream-migration.md`](docs/upstream-migration.md) for the rationale and pin-bump workflow.
|
|
429
434
|
|
|
430
435
|
## NPM Library Bundling
|
|
431
436
|
|
package/index.d.ts
CHANGED
|
@@ -524,7 +524,7 @@ export interface StacksWorkScore {
|
|
|
524
524
|
/** String-quoted unsigned integer - work score */
|
|
525
525
|
work: string;
|
|
526
526
|
}
|
|
527
|
-
export declare enum
|
|
527
|
+
export declare enum Pox4EventName {
|
|
528
528
|
HandleUnlock = "handle-unlock",
|
|
529
529
|
StackStx = "stack-stx",
|
|
530
530
|
StackIncrease = "stack-increase",
|
|
@@ -538,7 +538,13 @@ export declare enum PoxEventName {
|
|
|
538
538
|
StackAggregationIncrease = "stack-aggregation-increase",
|
|
539
539
|
RevokeDelegateStx = "revoke-delegate-stx"
|
|
540
540
|
}
|
|
541
|
-
export interface
|
|
541
|
+
export interface Pox4EventBase {
|
|
542
|
+
/**
|
|
543
|
+
* Discriminant identifying the source PoX contract version. For events
|
|
544
|
+
* decoded from pox-2 / pox-3 / pox-4 this is always `'pox4'` — pox-5
|
|
545
|
+
* events come back as {@link Pox5Event} instead.
|
|
546
|
+
*/
|
|
547
|
+
pox_version: 'pox4';
|
|
542
548
|
stacker: string;
|
|
543
549
|
/** String-quoted unsigned integer */
|
|
544
550
|
locked: string;
|
|
@@ -549,8 +555,8 @@ export interface PoxEventBase {
|
|
|
549
555
|
pox_addr: string | null;
|
|
550
556
|
pox_addr_raw: string | null;
|
|
551
557
|
}
|
|
552
|
-
export interface
|
|
553
|
-
name:
|
|
558
|
+
export interface Pox4EventHandleUnlock extends Pox4EventBase {
|
|
559
|
+
name: Pox4EventName.HandleUnlock;
|
|
554
560
|
data: {
|
|
555
561
|
/** String-quoted unsigned integer */
|
|
556
562
|
first_cycle_locked: string;
|
|
@@ -558,8 +564,8 @@ export interface PoxEventHandleUnlock extends PoxEventBase {
|
|
|
558
564
|
first_unlocked_cycle: string;
|
|
559
565
|
};
|
|
560
566
|
}
|
|
561
|
-
export interface
|
|
562
|
-
name:
|
|
567
|
+
export interface Pox4EventStackStx extends Pox4EventBase {
|
|
568
|
+
name: Pox4EventName.StackStx;
|
|
563
569
|
data: {
|
|
564
570
|
/** String-quoted unsigned integer */
|
|
565
571
|
lock_amount: string;
|
|
@@ -577,8 +583,8 @@ export interface PoxEventStackStx extends PoxEventBase {
|
|
|
577
583
|
start_cycle_id: string | null;
|
|
578
584
|
};
|
|
579
585
|
}
|
|
580
|
-
export interface
|
|
581
|
-
name:
|
|
586
|
+
export interface Pox4EventStackIncrease extends Pox4EventBase {
|
|
587
|
+
name: Pox4EventName.StackIncrease;
|
|
582
588
|
data: {
|
|
583
589
|
/** String-quoted unsigned integer */
|
|
584
590
|
increase_by: string;
|
|
@@ -592,8 +598,8 @@ export interface PoxEventStackIncrease extends PoxEventBase {
|
|
|
592
598
|
start_cycle_id: string | null;
|
|
593
599
|
};
|
|
594
600
|
}
|
|
595
|
-
export interface
|
|
596
|
-
name:
|
|
601
|
+
export interface Pox4EventStackExtend extends Pox4EventBase {
|
|
602
|
+
name: Pox4EventName.StackExtend;
|
|
597
603
|
data: {
|
|
598
604
|
/** String-quoted unsigned integer */
|
|
599
605
|
extend_count: string;
|
|
@@ -607,8 +613,8 @@ export interface PoxEventStackExtend extends PoxEventBase {
|
|
|
607
613
|
start_cycle_id: string | null;
|
|
608
614
|
};
|
|
609
615
|
}
|
|
610
|
-
export interface
|
|
611
|
-
name:
|
|
616
|
+
export interface Pox4EventDelegateStx extends Pox4EventBase {
|
|
617
|
+
name: Pox4EventName.DelegateStx;
|
|
612
618
|
data: {
|
|
613
619
|
/** String-quoted unsigned integer */
|
|
614
620
|
amount_ustx: string;
|
|
@@ -621,8 +627,8 @@ export interface PoxEventDelegateStx extends PoxEventBase {
|
|
|
621
627
|
start_cycle_id: string | null;
|
|
622
628
|
};
|
|
623
629
|
}
|
|
624
|
-
export interface
|
|
625
|
-
name:
|
|
630
|
+
export interface Pox4EventDelegateStackStx extends Pox4EventBase {
|
|
631
|
+
name: Pox4EventName.DelegateStackStx;
|
|
626
632
|
data: {
|
|
627
633
|
/** String-quoted unsigned integer */
|
|
628
634
|
lock_amount: string;
|
|
@@ -639,8 +645,8 @@ export interface PoxEventDelegateStackStx extends PoxEventBase {
|
|
|
639
645
|
start_cycle_id: string | null;
|
|
640
646
|
};
|
|
641
647
|
}
|
|
642
|
-
export interface
|
|
643
|
-
name:
|
|
648
|
+
export interface Pox4EventDelegateStackIncrease extends Pox4EventBase {
|
|
649
|
+
name: Pox4EventName.DelegateStackIncrease;
|
|
644
650
|
data: {
|
|
645
651
|
/** String-quoted unsigned integer */
|
|
646
652
|
increase_by: string;
|
|
@@ -653,8 +659,8 @@ export interface PoxEventDelegateStackIncrease extends PoxEventBase {
|
|
|
653
659
|
start_cycle_id: string | null;
|
|
654
660
|
};
|
|
655
661
|
}
|
|
656
|
-
export interface
|
|
657
|
-
name:
|
|
662
|
+
export interface Pox4EventDelegateStackExtend extends Pox4EventBase {
|
|
663
|
+
name: Pox4EventName.DelegateStackExtend;
|
|
658
664
|
data: {
|
|
659
665
|
/** String-quoted unsigned integer */
|
|
660
666
|
unlock_burn_height: string;
|
|
@@ -667,8 +673,8 @@ export interface PoxEventDelegateStackExtend extends PoxEventBase {
|
|
|
667
673
|
start_cycle_id: string | null;
|
|
668
674
|
};
|
|
669
675
|
}
|
|
670
|
-
export interface
|
|
671
|
-
name:
|
|
676
|
+
export interface Pox4EventStackAggregationCommit extends Pox4EventBase {
|
|
677
|
+
name: Pox4EventName.StackAggregationCommit;
|
|
672
678
|
data: {
|
|
673
679
|
/** String-quoted unsigned integer */
|
|
674
680
|
reward_cycle: string;
|
|
@@ -682,8 +688,8 @@ export interface PoxEventStackAggregationCommit extends PoxEventBase {
|
|
|
682
688
|
start_cycle_id: string | null;
|
|
683
689
|
};
|
|
684
690
|
}
|
|
685
|
-
export interface
|
|
686
|
-
name:
|
|
691
|
+
export interface Pox4EventStackAggregationCommitIndexed extends Pox4EventBase {
|
|
692
|
+
name: Pox4EventName.StackAggregationCommitIndexed;
|
|
687
693
|
data: {
|
|
688
694
|
/** String-quoted unsigned integer */
|
|
689
695
|
reward_cycle: string;
|
|
@@ -697,8 +703,8 @@ export interface PoxEventStackAggregationCommitIndexed extends PoxEventBase {
|
|
|
697
703
|
start_cycle_id: string | null;
|
|
698
704
|
};
|
|
699
705
|
}
|
|
700
|
-
export interface
|
|
701
|
-
name:
|
|
706
|
+
export interface Pox4EventStackAggregationIncrease extends Pox4EventBase {
|
|
707
|
+
name: Pox4EventName.StackAggregationIncrease;
|
|
702
708
|
data: {
|
|
703
709
|
/** String-quoted unsigned integer */
|
|
704
710
|
reward_cycle: string;
|
|
@@ -710,8 +716,8 @@ export interface PoxEventStackAggregationIncrease extends PoxEventBase {
|
|
|
710
716
|
start_cycle_id: string | null;
|
|
711
717
|
};
|
|
712
718
|
}
|
|
713
|
-
export interface
|
|
714
|
-
name:
|
|
719
|
+
export interface Pox4EventRevokeDelegateStx extends Pox4EventBase {
|
|
720
|
+
name: Pox4EventName.RevokeDelegateStx;
|
|
715
721
|
data: {
|
|
716
722
|
delegate_to: string;
|
|
717
723
|
/** String-quoted unsigned integer or null */
|
|
@@ -720,4 +726,303 @@ export interface PoxEventRevokeDelegateStx extends PoxEventBase {
|
|
|
720
726
|
start_cycle_id: string | null;
|
|
721
727
|
};
|
|
722
728
|
}
|
|
723
|
-
export type
|
|
729
|
+
export type Pox4Event = Pox4EventHandleUnlock | Pox4EventStackStx | Pox4EventStackIncrease | Pox4EventStackExtend | Pox4EventDelegateStx | Pox4EventDelegateStackStx | Pox4EventDelegateStackIncrease | Pox4EventDelegateStackExtend | Pox4EventStackAggregationCommit | Pox4EventStackAggregationCommitIndexed | Pox4EventStackAggregationIncrease | Pox4EventRevokeDelegateStx;
|
|
730
|
+
export declare enum Pox5EventName {
|
|
731
|
+
SetupBond = "setup-bond",
|
|
732
|
+
AddToAllowlist = "add-to-allowlist",
|
|
733
|
+
RegisterForBond = "register-for-bond",
|
|
734
|
+
UpdateBondRegistration = "update-bond-registration",
|
|
735
|
+
RegisterSigner = "register-signer",
|
|
736
|
+
Stake = "stake",
|
|
737
|
+
StakeUpdate = "stake-update",
|
|
738
|
+
AnnounceL1EarlyExit = "announce-l1-early-exit",
|
|
739
|
+
UnstakeSbtc = "unstake-sbtc",
|
|
740
|
+
Unstake = "unstake",
|
|
741
|
+
CalculateRewards = "calculate-rewards",
|
|
742
|
+
BondDistribution = "bond-distribution",
|
|
743
|
+
ClaimRewards = "claim-rewards"
|
|
744
|
+
}
|
|
745
|
+
export interface Pox5EventBase {
|
|
746
|
+
/**
|
|
747
|
+
* Discriminant identifying the source PoX contract version. For events
|
|
748
|
+
* decoded from pox-5 this is always `'pox5'` — earlier-contract events
|
|
749
|
+
* come back as {@link Pox4Event} instead.
|
|
750
|
+
*/
|
|
751
|
+
pox_version: 'pox5';
|
|
752
|
+
}
|
|
753
|
+
export interface Pox5EventSetupBond extends Pox5EventBase {
|
|
754
|
+
name: Pox5EventName.SetupBond;
|
|
755
|
+
data: {
|
|
756
|
+
/** String-quoted unsigned integer */
|
|
757
|
+
bond_index: string;
|
|
758
|
+
/** String-quoted unsigned integer (basis points) */
|
|
759
|
+
target_rate: string;
|
|
760
|
+
/** String-quoted unsigned integer */
|
|
761
|
+
stx_value_ratio: string;
|
|
762
|
+
/** String-quoted unsigned integer */
|
|
763
|
+
min_ustx_ratio: string;
|
|
764
|
+
/**
|
|
765
|
+
* `(buff 683)` hex string. Opaque early-unlock authorization script
|
|
766
|
+
* (e.g. `<pubkey> OP_CHECKSIGVERIFY`, or an M-of-N multisig template).
|
|
767
|
+
*/
|
|
768
|
+
early_unlock_bytes: string;
|
|
769
|
+
/** c32 principal allowed to call `announce-l1-early-exit` for stakers in this bond. */
|
|
770
|
+
early_unlock_admin: string;
|
|
771
|
+
/** String-quoted unsigned integer */
|
|
772
|
+
first_reward_cycle: string;
|
|
773
|
+
/** String-quoted unsigned integer */
|
|
774
|
+
bond_start_height: string;
|
|
775
|
+
/** String-quoted unsigned integer */
|
|
776
|
+
unlock_cycle: string;
|
|
777
|
+
/** String-quoted unsigned integer */
|
|
778
|
+
unlock_burn_height: string;
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
export interface Pox5EventAddToAllowlist extends Pox5EventBase {
|
|
782
|
+
name: Pox5EventName.AddToAllowlist;
|
|
783
|
+
data: {
|
|
784
|
+
/** c32 principal of the staker being added to a bond's allowlist. */
|
|
785
|
+
staker: string;
|
|
786
|
+
/** String-quoted unsigned integer */
|
|
787
|
+
max_sats: string;
|
|
788
|
+
/** String-quoted unsigned integer */
|
|
789
|
+
bond_index: string;
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
export interface Pox5EventRegisterForBond extends Pox5EventBase {
|
|
793
|
+
name: Pox5EventName.RegisterForBond;
|
|
794
|
+
data: {
|
|
795
|
+
/** c32 principal */
|
|
796
|
+
signer: string;
|
|
797
|
+
/** c32 principal */
|
|
798
|
+
staker: string;
|
|
799
|
+
/** String-quoted unsigned integer */
|
|
800
|
+
amount_ustx: string;
|
|
801
|
+
/** String-quoted unsigned integer */
|
|
802
|
+
sats_total: string;
|
|
803
|
+
/** String-quoted unsigned integer */
|
|
804
|
+
bond_index: string;
|
|
805
|
+
/** String-quoted unsigned integer */
|
|
806
|
+
first_reward_cycle: string;
|
|
807
|
+
/** String-quoted unsigned integer */
|
|
808
|
+
unlock_burn_height: string;
|
|
809
|
+
/** String-quoted unsigned integer */
|
|
810
|
+
unlock_cycle: string;
|
|
811
|
+
/** True if the participant proved an L1 BTC lockup; false if they locked sBTC. */
|
|
812
|
+
is_l1_lock: boolean;
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
export interface Pox5EventUpdateBondRegistration extends Pox5EventBase {
|
|
816
|
+
name: Pox5EventName.UpdateBondRegistration;
|
|
817
|
+
data: {
|
|
818
|
+
/** c32 principal */
|
|
819
|
+
staker: string;
|
|
820
|
+
/** c32 principal of the new signer */
|
|
821
|
+
signer: string;
|
|
822
|
+
/** c32 principal of the previous signer */
|
|
823
|
+
old_signer: string;
|
|
824
|
+
/** String-quoted unsigned integer */
|
|
825
|
+
bond_index: string;
|
|
826
|
+
/** String-quoted unsigned integer */
|
|
827
|
+
amount_ustx: string;
|
|
828
|
+
/** String-quoted unsigned integer */
|
|
829
|
+
amount_sats: string;
|
|
830
|
+
/** String-quoted unsigned integer */
|
|
831
|
+
first_reward_cycle: string;
|
|
832
|
+
/** String-quoted unsigned integer */
|
|
833
|
+
num_cycles: string;
|
|
834
|
+
/** True if the participant's stake is an L1 BTC lockup. */
|
|
835
|
+
is_l1_lock: boolean;
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
export interface Pox5EventRegisterSigner extends Pox5EventBase {
|
|
839
|
+
name: Pox5EventName.RegisterSigner;
|
|
840
|
+
data: {
|
|
841
|
+
/** c32 principal */
|
|
842
|
+
signer: string;
|
|
843
|
+
/** `(buff 33)` hex string — compressed secp256k1 public key. */
|
|
844
|
+
signer_key: string;
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
export interface Pox5EventStake extends Pox5EventBase {
|
|
848
|
+
name: Pox5EventName.Stake;
|
|
849
|
+
data: {
|
|
850
|
+
/** c32 principal */
|
|
851
|
+
signer: string;
|
|
852
|
+
/** c32 principal */
|
|
853
|
+
staker: string;
|
|
854
|
+
/** String-quoted unsigned integer */
|
|
855
|
+
amount_ustx: string;
|
|
856
|
+
/** String-quoted unsigned integer */
|
|
857
|
+
num_cycles: string;
|
|
858
|
+
/** String-quoted unsigned integer */
|
|
859
|
+
first_reward_cycle: string;
|
|
860
|
+
/** String-quoted unsigned integer */
|
|
861
|
+
unlock_burn_height: string;
|
|
862
|
+
/** String-quoted unsigned integer */
|
|
863
|
+
unlock_cycle: string;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
export interface Pox5EventStakeUpdate extends Pox5EventBase {
|
|
867
|
+
name: Pox5EventName.StakeUpdate;
|
|
868
|
+
data: {
|
|
869
|
+
/** String-quoted unsigned integer */
|
|
870
|
+
unlock_burn_height: string;
|
|
871
|
+
/** c32 principal */
|
|
872
|
+
staker: string;
|
|
873
|
+
/** c32 principal of the new signer */
|
|
874
|
+
signer: string;
|
|
875
|
+
/** c32 principal of the previous signer */
|
|
876
|
+
old_signer: string;
|
|
877
|
+
/** String-quoted unsigned integer (the previous unlock cycle before extension) */
|
|
878
|
+
prev_unlock_height: string;
|
|
879
|
+
/** String-quoted unsigned integer */
|
|
880
|
+
unlock_cycle: string;
|
|
881
|
+
/** String-quoted unsigned integer */
|
|
882
|
+
num_cycles: string;
|
|
883
|
+
/** String-quoted unsigned integer — total locked amount after this update */
|
|
884
|
+
amount_ustx: string;
|
|
885
|
+
/** String-quoted unsigned integer */
|
|
886
|
+
amount_increase: string;
|
|
887
|
+
/** String-quoted unsigned integer */
|
|
888
|
+
cycles_to_extend: string;
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
export interface Pox5EventAnnounceL1EarlyExit extends Pox5EventBase {
|
|
892
|
+
name: Pox5EventName.AnnounceL1EarlyExit;
|
|
893
|
+
data: {
|
|
894
|
+
/** c32 principal */
|
|
895
|
+
staker: string;
|
|
896
|
+
/** c32 principal */
|
|
897
|
+
signer: string;
|
|
898
|
+
/** String-quoted unsigned integer */
|
|
899
|
+
bond_index: string;
|
|
900
|
+
/** String-quoted unsigned integer */
|
|
901
|
+
amount_sats_released: string;
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
export interface Pox5EventUnstakeSbtc extends Pox5EventBase {
|
|
905
|
+
name: Pox5EventName.UnstakeSbtc;
|
|
906
|
+
data: {
|
|
907
|
+
/** c32 principal */
|
|
908
|
+
staker: string;
|
|
909
|
+
/** c32 principal */
|
|
910
|
+
signer: string;
|
|
911
|
+
/** String-quoted unsigned integer */
|
|
912
|
+
bond_index: string;
|
|
913
|
+
/** String-quoted unsigned integer */
|
|
914
|
+
amount_withdrawn_sats: string;
|
|
915
|
+
/** String-quoted unsigned integer — sBTC shares remaining after withdrawal */
|
|
916
|
+
new_amount_sats: string;
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
export interface Pox5EventUnstake extends Pox5EventBase {
|
|
920
|
+
name: Pox5EventName.Unstake;
|
|
921
|
+
data: {
|
|
922
|
+
/** c32 principal */
|
|
923
|
+
staker: string;
|
|
924
|
+
/** c32 principal */
|
|
925
|
+
signer: string;
|
|
926
|
+
/** String-quoted unsigned integer */
|
|
927
|
+
amount_ustx: string;
|
|
928
|
+
/** String-quoted unsigned integer */
|
|
929
|
+
first_reward_cycle: string;
|
|
930
|
+
/** String-quoted unsigned integer */
|
|
931
|
+
unlock_cycle: string;
|
|
932
|
+
/** String-quoted unsigned integer */
|
|
933
|
+
unlock_burn_height: string;
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Logged by `calculate-rewards`. The contract emits this topic **twice** per
|
|
938
|
+
* call: a phase-1 (pre-distribution) print carrying `stranded_staker_cut`,
|
|
939
|
+
* and a phase-2 (post-distribution) print carrying `new_reserve`. Exactly
|
|
940
|
+
* one of those two fields is populated per event; the other is `null`.
|
|
941
|
+
*
|
|
942
|
+
* Phase-1 fires before reserve and accounting state are updated; useful for
|
|
943
|
+
* inspecting whether the staker cut was folded into the reserve because no
|
|
944
|
+
* STX was staked.
|
|
945
|
+
*
|
|
946
|
+
* Phase-2 fires after state is committed and matches the value returned to
|
|
947
|
+
* the caller.
|
|
948
|
+
*/
|
|
949
|
+
export interface Pox5EventCalculateRewards extends Pox5EventBase {
|
|
950
|
+
name: Pox5EventName.CalculateRewards;
|
|
951
|
+
data: {
|
|
952
|
+
/** Array of string-quoted unsigned integers (bond indices being settled) */
|
|
953
|
+
bond_periods: string[];
|
|
954
|
+
/** String-quoted unsigned integer */
|
|
955
|
+
calculation_height: string;
|
|
956
|
+
/** String-quoted unsigned integer */
|
|
957
|
+
remaining_rewards: string;
|
|
958
|
+
/** String-quoted unsigned integer */
|
|
959
|
+
accrued_rewards: string;
|
|
960
|
+
/**
|
|
961
|
+
* Phase-2 only. String-quoted unsigned integer — portion of accrued
|
|
962
|
+
* rewards retained in the reserve. `null` on the phase-1 event.
|
|
963
|
+
*/
|
|
964
|
+
new_reserve: string | null;
|
|
965
|
+
/**
|
|
966
|
+
* Phase-1 only. String-quoted unsigned integer — the would-be STX
|
|
967
|
+
* staker cut that gets folded into the reserve when no STX is staked
|
|
968
|
+
* for the cycle. `null` on the phase-2 event.
|
|
969
|
+
*/
|
|
970
|
+
stranded_staker_cut: string | null;
|
|
971
|
+
/** String-quoted unsigned integer */
|
|
972
|
+
stx_staker_rewards: string;
|
|
973
|
+
/** String-quoted unsigned integer */
|
|
974
|
+
stx_cycle: string;
|
|
975
|
+
/** String-quoted unsigned integer */
|
|
976
|
+
cycle_staked_ustx: string;
|
|
977
|
+
/** String-quoted unsigned integer */
|
|
978
|
+
next_rewards_per_ustx: string;
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
export interface Pox5EventBondDistribution extends Pox5EventBase {
|
|
982
|
+
name: Pox5EventName.BondDistribution;
|
|
983
|
+
data: {
|
|
984
|
+
/** String-quoted unsigned integer */
|
|
985
|
+
bond_index: string;
|
|
986
|
+
/** String-quoted unsigned integer */
|
|
987
|
+
target_yield: string;
|
|
988
|
+
/** String-quoted unsigned integer */
|
|
989
|
+
earned: string;
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
/** Sub-tuple emitted under `stx_rewards` in `claim-rewards` events. */
|
|
993
|
+
export interface Pox5ClaimRewardsInfo {
|
|
994
|
+
/** String-quoted unsigned integer */
|
|
995
|
+
earned: string;
|
|
996
|
+
/** String-quoted unsigned integer */
|
|
997
|
+
rewards_per_token: string;
|
|
998
|
+
}
|
|
999
|
+
/** One entry in the `bond_rewards` list of a `claim-rewards` event. */
|
|
1000
|
+
export interface Pox5BondRewardsInfo extends Pox5ClaimRewardsInfo {
|
|
1001
|
+
/** String-quoted unsigned integer */
|
|
1002
|
+
bond_index: string;
|
|
1003
|
+
}
|
|
1004
|
+
export interface Pox5EventClaimRewards extends Pox5EventBase {
|
|
1005
|
+
name: Pox5EventName.ClaimRewards;
|
|
1006
|
+
data: {
|
|
1007
|
+
stx_rewards: Pox5ClaimRewardsInfo;
|
|
1008
|
+
bond_rewards: Pox5BondRewardsInfo[];
|
|
1009
|
+
/** String-quoted unsigned integer */
|
|
1010
|
+
bond_totals: string;
|
|
1011
|
+
/** String-quoted unsigned integer */
|
|
1012
|
+
total_rewards: string;
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
export type Pox5Event = Pox5EventSetupBond | Pox5EventAddToAllowlist | Pox5EventRegisterForBond | Pox5EventUpdateBondRegistration | Pox5EventRegisterSigner | Pox5EventStake | Pox5EventStakeUpdate | Pox5EventAnnounceL1EarlyExit | Pox5EventUnstakeSbtc | Pox5EventUnstake | Pox5EventCalculateRewards | Pox5EventBondDistribution | Pox5EventClaimRewards;
|
|
1016
|
+
/**
|
|
1017
|
+
* Any decoded PoX synthetic event, regardless of the source contract version.
|
|
1018
|
+
*
|
|
1019
|
+
* Two discriminants are available; use whichever fits the call site:
|
|
1020
|
+
*
|
|
1021
|
+
* - `event.pox_version` — `'pox4'` or `'pox5'`. Use this when you only care
|
|
1022
|
+
* which contract family the event came from (e.g. routing to a per-version
|
|
1023
|
+
* handler).
|
|
1024
|
+
* - `event.name` — the specific event-name string literal. The pox-4 and
|
|
1025
|
+
* pox-5 name sets don't overlap, so a single switch on `name` narrows
|
|
1026
|
+
* all the way down to the per-event interface.
|
|
1027
|
+
*/
|
|
1028
|
+
export type PoxEvent = Pox4Event | Pox5Event;
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.Pox5EventName = exports.Pox4EventName = exports.ClarityTypeID = exports.PostConditionModeID = exports.AnchorModeID = exports.TransactionVersion = exports.TxPublicKeyEncoding = exports.TxAuthFieldTypeID = exports.ClarityVersion = exports.TxSpendingConditionMultiSigHashMode = exports.TxSpendingConditionSingleSigHashMode = exports.PostConditionAuthFlag = exports.TxPayloadTypeID = exports.TenureChangeCause = exports.PrincipalTypeID = exports.PostConditionPrincipalTypeID = exports.PostConditionFungibleConditionCodeName = exports.PostConditionFungibleConditionCodeID = exports.PostConditionNonFungibleConditionName = exports.PostConditionNonfungibleConditionCodeID = exports.PostConditionAssetInfoID = exports.StacksNativeEncodingBindings = void 0;
|
|
40
40
|
const bindings = __importStar(require("./loader.js"));
|
|
41
41
|
__exportStar(require("./loader.js"), exports);
|
|
42
42
|
exports.StacksNativeEncodingBindings = bindings;
|
|
@@ -208,20 +208,58 @@ var ClarityTypeID;
|
|
|
208
208
|
ClarityTypeID[ClarityTypeID["StringUtf8"] = 14] = "StringUtf8";
|
|
209
209
|
})(ClarityTypeID || (exports.ClarityTypeID = ClarityTypeID = {}));
|
|
210
210
|
// ============================================================================
|
|
211
|
-
// PoX Synthetic Event Types
|
|
211
|
+
// PoX Synthetic Event Types — pox-2 / pox-3 / pox-4
|
|
212
|
+
//
|
|
213
|
+
// These describe synthetic events the Stacks node emits for the older PoX
|
|
214
|
+
// contracts (pox-2 through pox-4). The wire shape is always
|
|
215
|
+
// `Response(Ok({ stacker, locked, ..., name, data }))` — the node
|
|
216
|
+
// synthesizes the wrapper from contract-call return values.
|
|
217
|
+
//
|
|
218
|
+
// PoX-5 changed the model: events are produced by `(print { topic, ... })`
|
|
219
|
+
// calls inside the contract itself, so they have a different shape. Those
|
|
220
|
+
// types live in the next section below.
|
|
212
221
|
// ============================================================================
|
|
213
|
-
var
|
|
214
|
-
(function (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
})(
|
|
222
|
+
var Pox4EventName;
|
|
223
|
+
(function (Pox4EventName) {
|
|
224
|
+
Pox4EventName["HandleUnlock"] = "handle-unlock";
|
|
225
|
+
Pox4EventName["StackStx"] = "stack-stx";
|
|
226
|
+
Pox4EventName["StackIncrease"] = "stack-increase";
|
|
227
|
+
Pox4EventName["StackExtend"] = "stack-extend";
|
|
228
|
+
Pox4EventName["DelegateStx"] = "delegate-stx";
|
|
229
|
+
Pox4EventName["DelegateStackStx"] = "delegate-stack-stx";
|
|
230
|
+
Pox4EventName["DelegateStackIncrease"] = "delegate-stack-increase";
|
|
231
|
+
Pox4EventName["DelegateStackExtend"] = "delegate-stack-extend";
|
|
232
|
+
Pox4EventName["StackAggregationCommit"] = "stack-aggregation-commit";
|
|
233
|
+
Pox4EventName["StackAggregationCommitIndexed"] = "stack-aggregation-commit-indexed";
|
|
234
|
+
Pox4EventName["StackAggregationIncrease"] = "stack-aggregation-increase";
|
|
235
|
+
Pox4EventName["RevokeDelegateStx"] = "revoke-delegate-stx";
|
|
236
|
+
})(Pox4EventName || (exports.Pox4EventName = Pox4EventName = {}));
|
|
237
|
+
// ============================================================================
|
|
238
|
+
// PoX Synthetic Event Types — pox-5
|
|
239
|
+
//
|
|
240
|
+
// PoX-5 events are emitted by explicit `(print { topic: "...", ... })` calls
|
|
241
|
+
// in the contract source, so each event arrives as a flat Clarity tuple with
|
|
242
|
+
// a `topic` ASCII string plus event-specific data. This is structurally
|
|
243
|
+
// different from pox-2/3/4, where the Stacks node synthesizes a
|
|
244
|
+
// `Response(Ok({ stacker, locked, ..., name, data }))` per stacking call.
|
|
245
|
+
//
|
|
246
|
+
// On the JS side every pox-5 event has the same outer shape
|
|
247
|
+
// `{ name: string, data: { ... } }`; the per-event `data` payloads are
|
|
248
|
+
// modeled below.
|
|
249
|
+
// ============================================================================
|
|
250
|
+
var Pox5EventName;
|
|
251
|
+
(function (Pox5EventName) {
|
|
252
|
+
Pox5EventName["SetupBond"] = "setup-bond";
|
|
253
|
+
Pox5EventName["AddToAllowlist"] = "add-to-allowlist";
|
|
254
|
+
Pox5EventName["RegisterForBond"] = "register-for-bond";
|
|
255
|
+
Pox5EventName["UpdateBondRegistration"] = "update-bond-registration";
|
|
256
|
+
Pox5EventName["RegisterSigner"] = "register-signer";
|
|
257
|
+
Pox5EventName["Stake"] = "stake";
|
|
258
|
+
Pox5EventName["StakeUpdate"] = "stake-update";
|
|
259
|
+
Pox5EventName["AnnounceL1EarlyExit"] = "announce-l1-early-exit";
|
|
260
|
+
Pox5EventName["UnstakeSbtc"] = "unstake-sbtc";
|
|
261
|
+
Pox5EventName["Unstake"] = "unstake";
|
|
262
|
+
Pox5EventName["CalculateRewards"] = "calculate-rewards";
|
|
263
|
+
Pox5EventName["BondDistribution"] = "bond-distribution";
|
|
264
|
+
Pox5EventName["ClaimRewards"] = "claim-rewards";
|
|
265
|
+
})(Pox5EventName || (exports.Pox5EventName = Pox5EventName = {}));
|
package/index.mjs
CHANGED
|
@@ -142,21 +142,37 @@ var ClarityTypeID = /* @__PURE__ */ ((ClarityTypeID2) => {
|
|
|
142
142
|
ClarityTypeID2[ClarityTypeID2["StringUtf8"] = 14] = "StringUtf8";
|
|
143
143
|
return ClarityTypeID2;
|
|
144
144
|
})(ClarityTypeID || {});
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return
|
|
159
|
-
})(
|
|
145
|
+
var Pox4EventName = /* @__PURE__ */ ((Pox4EventName2) => {
|
|
146
|
+
Pox4EventName2["HandleUnlock"] = "handle-unlock";
|
|
147
|
+
Pox4EventName2["StackStx"] = "stack-stx";
|
|
148
|
+
Pox4EventName2["StackIncrease"] = "stack-increase";
|
|
149
|
+
Pox4EventName2["StackExtend"] = "stack-extend";
|
|
150
|
+
Pox4EventName2["DelegateStx"] = "delegate-stx";
|
|
151
|
+
Pox4EventName2["DelegateStackStx"] = "delegate-stack-stx";
|
|
152
|
+
Pox4EventName2["DelegateStackIncrease"] = "delegate-stack-increase";
|
|
153
|
+
Pox4EventName2["DelegateStackExtend"] = "delegate-stack-extend";
|
|
154
|
+
Pox4EventName2["StackAggregationCommit"] = "stack-aggregation-commit";
|
|
155
|
+
Pox4EventName2["StackAggregationCommitIndexed"] = "stack-aggregation-commit-indexed";
|
|
156
|
+
Pox4EventName2["StackAggregationIncrease"] = "stack-aggregation-increase";
|
|
157
|
+
Pox4EventName2["RevokeDelegateStx"] = "revoke-delegate-stx";
|
|
158
|
+
return Pox4EventName2;
|
|
159
|
+
})(Pox4EventName || {});
|
|
160
|
+
var Pox5EventName = /* @__PURE__ */ ((Pox5EventName2) => {
|
|
161
|
+
Pox5EventName2["SetupBond"] = "setup-bond";
|
|
162
|
+
Pox5EventName2["AddToAllowlist"] = "add-to-allowlist";
|
|
163
|
+
Pox5EventName2["RegisterForBond"] = "register-for-bond";
|
|
164
|
+
Pox5EventName2["UpdateBondRegistration"] = "update-bond-registration";
|
|
165
|
+
Pox5EventName2["RegisterSigner"] = "register-signer";
|
|
166
|
+
Pox5EventName2["Stake"] = "stake";
|
|
167
|
+
Pox5EventName2["StakeUpdate"] = "stake-update";
|
|
168
|
+
Pox5EventName2["AnnounceL1EarlyExit"] = "announce-l1-early-exit";
|
|
169
|
+
Pox5EventName2["UnstakeSbtc"] = "unstake-sbtc";
|
|
170
|
+
Pox5EventName2["Unstake"] = "unstake";
|
|
171
|
+
Pox5EventName2["CalculateRewards"] = "calculate-rewards";
|
|
172
|
+
Pox5EventName2["BondDistribution"] = "bond-distribution";
|
|
173
|
+
Pox5EventName2["ClaimRewards"] = "claim-rewards";
|
|
174
|
+
return Pox5EventName2;
|
|
175
|
+
})(Pox5EventName || {});
|
|
160
176
|
export {
|
|
161
177
|
AnchorModeID,
|
|
162
178
|
ClarityTypeID,
|
|
@@ -169,7 +185,8 @@ export {
|
|
|
169
185
|
PostConditionNonFungibleConditionName,
|
|
170
186
|
PostConditionNonfungibleConditionCodeID,
|
|
171
187
|
PostConditionPrincipalTypeID,
|
|
172
|
-
|
|
188
|
+
Pox4EventName,
|
|
189
|
+
Pox5EventName,
|
|
173
190
|
PrincipalTypeID,
|
|
174
191
|
StacksNativeEncodingBindings,
|
|
175
192
|
TenureChangeCause,
|
package/loader.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
DecodedStacksBlockResult,
|
|
6
6
|
ClarityValue,
|
|
7
7
|
ClarityValueAbstract,
|
|
8
|
-
|
|
8
|
+
PoxEvent,
|
|
9
9
|
} from './index.js';
|
|
10
10
|
|
|
11
11
|
export function getVersion(): string;
|
|
@@ -72,20 +72,29 @@ export function stacksAddressFromParts(version: number, hash160: string | Buffer
|
|
|
72
72
|
export function memoToString(memo: string | Buffer): string;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* Decode a serialized Clarity value representing a PoX synthetic
|
|
75
|
+
* Decode a serialized Clarity value representing a PoX synthetic event.
|
|
76
|
+
*
|
|
77
|
+
* The native runtime sniffs the Clarity value's shape and routes it to the
|
|
78
|
+
* appropriate per-version decoder:
|
|
79
|
+
*
|
|
80
|
+
* - A flat tuple with a `topic` ASCII field → pox-5 event (returns a
|
|
81
|
+
* {@link Pox5Event}).
|
|
82
|
+
* - A `Response(Ok({ stacker, locked, ..., name, data }))` tuple →
|
|
83
|
+
* pox-2 / pox-3 / pox-4 event (returns a {@link Pox4Event}).
|
|
84
|
+
* - Anything else → `null`. This includes pox-2/3/4 `Response(Err _)`
|
|
85
|
+
* payloads from failed stacking calls.
|
|
86
|
+
*
|
|
87
|
+
* Narrow the result on `event.name` (a string-literal field present on every
|
|
88
|
+
* variant). The pox-4 and pox-5 name sets don't overlap, so a single switch
|
|
89
|
+
* over `name` is enough to discriminate.
|
|
90
|
+
*
|
|
76
91
|
* @param arg - Hex string or Buffer containing the serialized Clarity value
|
|
77
|
-
* @param network - The Stacks network type
|
|
78
|
-
*
|
|
92
|
+
* @param network - The Stacks network type (used only by the pox-4 decoder
|
|
93
|
+
* when encoding pox-addr bytes into a BTC address; ignored by pox-5).
|
|
94
|
+
* @returns The decoded PoX event, or `null` if the Clarity value isn't a
|
|
95
|
+
* recognized event shape.
|
|
79
96
|
*/
|
|
80
97
|
export function decodePoxSyntheticEvent(
|
|
81
98
|
arg: string | Buffer,
|
|
82
99
|
network: 'mainnet' | 'testnet' | 'devnet' | 'mocknet'
|
|
83
|
-
):
|
|
84
|
-
|
|
85
|
-
export function startProfiler(): string;
|
|
86
|
-
|
|
87
|
-
export function stopProfiler(): Buffer;
|
|
88
|
-
|
|
89
|
-
export function createProfiler(): () => Buffer;
|
|
90
|
-
|
|
91
|
-
export function perfTestC32Encode(): Buffer;
|
|
100
|
+
): PoxEvent | null;
|
package/native/darwin-arm64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/native/win32-x64.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/codec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-pox5.1",
|
|
4
|
+
"author": "Stacks Labs",
|
|
5
|
+
"license": "GPL-3.0",
|
|
4
6
|
"description": "Encoding & decoding functions for the Stacks blockchain exposed as a fast native Node.js addon",
|
|
5
7
|
"main": "./index.js",
|
|
6
8
|
"module": "./index.mjs",
|
|
@@ -23,14 +25,8 @@
|
|
|
23
25
|
"lint": "npm run lint:cargo",
|
|
24
26
|
"lint:cargo": "cargo fmt --all -- --check",
|
|
25
27
|
"lint:fix": "cargo fmt --all",
|
|
26
|
-
"perf-test:contract-call-args": "node --expose-gc perf-tests/decode-contract-call-args/test.js",
|
|
27
|
-
"perf-test:decode-post-conditions": "node --expose-gc perf-tests/decode-post-conditions/test.js",
|
|
28
|
-
"perf-test:encode-stx-address": "node perf-tests/encode-stx-address/test.js",
|
|
29
|
-
"perf-test:decode-stx-address": "node perf-tests/decode-stx-address/test.js",
|
|
30
28
|
"prepublishOnly": "npm run build"
|
|
31
29
|
},
|
|
32
|
-
"author": "Stacks Labs",
|
|
33
|
-
"license": "GPL-3.0",
|
|
34
30
|
"repository": {
|
|
35
31
|
"type": "git",
|
|
36
32
|
"url": "git+https://github.com/stx-labs/stacks-codec-js.git"
|
|
@@ -49,7 +45,7 @@
|
|
|
49
45
|
"typescript": "^5.7.0"
|
|
50
46
|
},
|
|
51
47
|
"dependencies": {
|
|
52
|
-
"@types/node": "^
|
|
48
|
+
"@types/node": "^24.0.0",
|
|
53
49
|
"detect-libc": "^2.0.1"
|
|
54
50
|
},
|
|
55
51
|
"files": [
|