@@ -768,6 +768,39 @@ impl GetCurrentValidatorsResult {
768
768
}
769
769
}
770
770
771
+ /// ref. <https://docs.avax.network/apis/avalanchego/apis/p-chain#platformgetpendingvalidators>
772
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Clone ) ]
773
+ pub struct GetPendingValidatorsResponse {
774
+ pub jsonrpc : String ,
775
+ pub id : u32 ,
776
+
777
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
778
+ pub result : Option < GetPendingValidatorsResult > ,
779
+
780
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
781
+ pub error : Option < jsonrpc:: ResponseError > ,
782
+ }
783
+
784
+ impl Default for GetPendingValidatorsResponse {
785
+ fn default ( ) -> Self {
786
+ Self {
787
+ jsonrpc : "2.0" . to_string ( ) ,
788
+ id : 1 ,
789
+ result : Some ( GetPendingValidatorsResult :: default ( ) ) ,
790
+ error : None ,
791
+ }
792
+ }
793
+ }
794
+
795
+ /// ref. <https://docs.avax.network/apis/avalanchego/apis/p-chain#platformgetpendingvalidators>
796
+ /// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#ClientPermissionlessValidator>
797
+ /// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#ClientStaker>
798
+ #[ derive( Default , Debug , Serialize , Deserialize , PartialEq , Clone ) ]
799
+ pub struct GetPendingValidatorsResult {
800
+ pub validators : Vec < ApiPrimaryValidator > ,
801
+ pub delegators : Vec < ApiPrimaryDelegator > ,
802
+ }
803
+
771
804
/// ref. <https://docs.avax.network/apis/avalanchego/apis/p-chain#platformgetcurrentvalidators>
772
805
/// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#ClientPermissionlessValidator>
773
806
/// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#ClientStaker>
@@ -783,52 +816,54 @@ pub struct ApiPrimaryValidator {
783
816
#[ serde_as( as = "DisplayFromStr" ) ]
784
817
pub end_time : u64 ,
785
818
786
- /// None for subnet validator.
819
+ /// None for elastic Subnet validator
787
820
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
788
821
#[ serde( skip_serializing_if = "Option::is_none" ) ]
789
822
pub weight : Option < u64 > ,
790
823
791
- /// None for subnet validator.
824
+ /// None for permissioned Subnet validator
792
825
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
826
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
793
827
pub stake_amount : Option < u64 > ,
794
828
795
829
#[ serde( rename = "nodeID" ) ]
796
830
pub node_id : node:: Id ,
797
831
798
- /// None for subnet validator.
832
+ /// None for permissioned Subnet validator
799
833
#[ serde( skip_serializing_if = "Option::is_none" ) ]
800
834
pub validation_reward_owner : Option < ApiOwner > ,
801
- /// None for subnet validator.
835
+ /// None for permissioned Subnet validator
802
836
#[ serde( skip_serializing_if = "Option::is_none" ) ]
803
837
pub delegation_reward_owner : Option < ApiOwner > ,
804
838
805
- /// None for subnet validator.
839
+ /// None for permissioned Subnet validator
806
840
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
807
841
pub potential_reward : Option < u64 > ,
808
- /// None for subnet validator.
842
+ /// None for permissioned Subnet validator
809
843
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
810
844
#[ serde( skip_serializing_if = "Option::is_none" ) ]
811
845
pub delegation_fee : Option < f32 > ,
812
846
847
+ /// None for permissioned Subnet validator
813
848
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
814
849
#[ serde( skip_serializing_if = "Option::is_none" ) ]
815
850
pub uptime : Option < f32 > ,
816
851
pub connected : bool ,
817
852
818
- /// None if the validator doesn't have a BLS public key.
853
+ /// None for permissioned Subnet validator
819
854
#[ serde( skip_serializing_if = "Option::is_none" ) ]
820
855
pub signer : Option < bls:: ProofOfPossession > ,
821
856
822
- /// None for subnet validator.
857
+ /// None for permissioned Subnet validator
823
858
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
824
859
#[ serde( skip_serializing_if = "Option::is_none" ) ]
825
860
pub delegator_count : Option < u64 > ,
826
- /// None for subnet validator.
861
+ /// None for permissioned Subnet validator
827
862
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
828
863
#[ serde( skip_serializing_if = "Option::is_none" ) ]
829
864
pub delegator_weight : Option < u64 > ,
830
865
831
- /// None for subnet validator.
866
+ /// None for permissioned Subnet validator
832
867
#[ serde( skip_serializing_if = "Option::is_none" ) ]
833
868
pub delegators : Option < Vec < ApiPrimaryDelegator > > ,
834
869
}
@@ -852,7 +887,7 @@ impl ApiPrimaryValidator {
852
887
delegation_reward_owner : None ,
853
888
potential_reward : None ,
854
889
delegation_fee : None ,
855
- uptime : Some ( 0_f32 ) ,
890
+ uptime : None ,
856
891
connected : false ,
857
892
signer : None ,
858
893
delegator_count : None ,
@@ -910,12 +945,11 @@ pub struct ApiPrimaryDelegator {
910
945
#[ serde( rename = "nodeID" ) ]
911
946
pub node_id : node:: Id ,
912
947
913
- /// None for subnet validator.
914
948
#[ serde( skip_serializing_if = "Option::is_none" ) ]
915
949
pub reward_owner : Option < ApiOwner > ,
916
950
917
951
#[ serde_as( as = "Option<DisplayFromStr>" ) ]
918
- #[ serde( rename = "potentialReward" ) ]
952
+ #[ serde( rename = "potentialReward" , skip_serializing_if = "Option::is_none" ) ]
919
953
pub potential_reward : Option < u64 > ,
920
954
}
921
955
@@ -1089,6 +1123,75 @@ fn test_get_current_validators() {
1089
1123
assert_eq ! ( resp, expected) ;
1090
1124
}
1091
1125
1126
+ /// RUST_LOG=debug cargo test --package avalanche-types --lib -- jsonrpc::platformvm::test_get_pending_validators --exact --show-output
1127
+ #[ test]
1128
+
1129
+ fn test_get_pending_validators ( ) {
1130
+ use std:: str:: FromStr ;
1131
+
1132
+ // ref. <https://docs.avax.network/apis/avalanchego/apis/p-chain#platformgetcurrentvalidators>
1133
+ let resp: GetPendingValidatorsResponse = serde_json:: from_str (
1134
+ r#"
1135
+ {
1136
+ "jsonrpc": "2.0",
1137
+ "result": {
1138
+ "validators": [
1139
+ {
1140
+ "txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm",
1141
+ "startTime": "1600368632",
1142
+ "endTime": "1602960455",
1143
+ "stakeAmount": "200000000000",
1144
+ "nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
1145
+ "delegationFee": "10.0000",
1146
+ "connected": false
1147
+ }
1148
+ ],
1149
+ "delegators": [
1150
+ {
1151
+ "txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV",
1152
+ "startTime": "1600368523",
1153
+ "endTime": "1602960342",
1154
+ "stakeAmount": "20000000000",
1155
+ "nodeID": "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg"
1156
+ }
1157
+ ]
1158
+ },
1159
+ "id": 1
1160
+ }
1161
+ "# ,
1162
+ )
1163
+ . unwrap ( ) ;
1164
+
1165
+ let expected = GetPendingValidatorsResponse {
1166
+ jsonrpc : "2.0" . to_string ( ) ,
1167
+ id : 1 ,
1168
+ result : Some ( GetPendingValidatorsResult {
1169
+ validators : <Vec < ApiPrimaryValidator > >:: from ( [ ApiPrimaryValidator {
1170
+ tx_id : ids:: Id :: from_str ( "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm" )
1171
+ . unwrap ( ) ,
1172
+ start_time : 1600368632 ,
1173
+ end_time : 1602960455 ,
1174
+ stake_amount : Some ( 200000000000 ) ,
1175
+ node_id : node:: Id :: from_str ( "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD" ) . unwrap ( ) ,
1176
+ delegation_fee : Some ( 10.0 ) ,
1177
+ connected : false ,
1178
+ ..ApiPrimaryValidator :: default ( )
1179
+ } ] ) ,
1180
+ delegators : <Vec < ApiPrimaryDelegator > >:: from ( [ ApiPrimaryDelegator {
1181
+ tx_id : ids:: Id :: from_str ( "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV" )
1182
+ . unwrap ( ) ,
1183
+ start_time : 1600368523 ,
1184
+ end_time : 1602960342 ,
1185
+ stake_amount : 20000000000 ,
1186
+ node_id : node:: Id :: from_str ( "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg" ) . unwrap ( ) ,
1187
+ ..ApiPrimaryDelegator :: default ( )
1188
+ } ] ) ,
1189
+ } ) ,
1190
+ error : None ,
1191
+ } ;
1192
+ assert_eq ! ( resp, expected) ;
1193
+ }
1194
+
1092
1195
/// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#APIUTXO>
1093
1196
#[ serde_as]
1094
1197
#[ derive( Debug , Serialize , Deserialize , Eq , PartialEq , Clone ) ]
0 commit comments