@@ -505,7 +505,7 @@ impl StakeDelegation {
505
505
. map ( |addr| Address :: from ( & ExplorerAddress :: New ( addr) ) )
506
506
}
507
507
508
- pub fn pool ( & self , context : & Context ) -> Vec < Pool > {
508
+ pub fn pools ( & self , context : & Context ) -> Vec < Pool > {
509
509
use chain_impl_mockchain:: account:: DelegationType ;
510
510
use std:: iter:: FromIterator as _;
511
511
@@ -666,7 +666,7 @@ impl From<certificate::OwnerStakeDelegation> for OwnerStakeDelegation {
666
666
Context = Context ,
667
667
) ]
668
668
impl OwnerStakeDelegation {
669
- fn pool ( & self ) -> Vec < Pool > {
669
+ fn pools ( & self ) -> Vec < Pool > {
670
670
use chain_impl_mockchain:: account:: DelegationType ;
671
671
use std:: iter:: FromIterator as _;
672
672
@@ -684,12 +684,63 @@ impl OwnerStakeDelegation {
684
684
}
685
685
}
686
686
687
+ /// Retirement info for a pool
688
+ struct PoolRetirement {
689
+ pool_retirement : certificate:: PoolRetirement ,
690
+ }
691
+
692
+ impl From < certificate:: PoolRetirement > for PoolRetirement {
693
+ fn from ( pool_retirement : certificate:: PoolRetirement ) -> PoolRetirement {
694
+ PoolRetirement { pool_retirement }
695
+ }
696
+ }
697
+
698
+ #[ juniper:: object(
699
+ Context = Context ,
700
+ ) ]
701
+ impl PoolRetirement {
702
+ pub fn pool_id ( & self ) -> PoolId {
703
+ PoolId ( format ! ( "{}" , self . pool_retirement. pool_id) )
704
+ }
705
+
706
+ pub fn retirement_time ( & self ) -> TimeOffsetSeconds {
707
+ self . pool_retirement . retirement_time . into ( )
708
+ }
709
+ }
710
+
711
+ struct PoolUpdate {
712
+ pool_update : certificate:: PoolUpdate ,
713
+ }
714
+
715
+ impl From < certificate:: PoolUpdate > for PoolUpdate {
716
+ fn from ( pool_update : certificate:: PoolUpdate ) -> PoolUpdate {
717
+ PoolUpdate { pool_update }
718
+ }
719
+ }
720
+
721
+ #[ juniper:: object(
722
+ Context = Context ,
723
+ ) ]
724
+ impl PoolUpdate {
725
+ pub fn pool_id ( & self ) -> PoolId {
726
+ PoolId ( format ! ( "{}" , self . pool_update. pool_id) )
727
+ }
728
+
729
+ pub fn start_validity ( & self ) -> TimeOffsetSeconds {
730
+ self . pool_update . start_validity . into ( )
731
+ }
732
+
733
+ // TODO: Previous keys?
734
+ // TODO: Updated keys?
735
+ }
736
+
687
737
// TODO can we use jormungandr-lib Certificate ?
688
738
enum Certificate {
689
739
StakeDelegation ( StakeDelegation ) ,
690
740
OwnerStakeDelegation ( OwnerStakeDelegation ) ,
691
741
PoolRegistration ( PoolRegistration ) ,
692
- // TODO: PoolManagement
742
+ PoolRetirement ( PoolRetirement ) ,
743
+ PoolUpdate ( PoolUpdate ) ,
693
744
}
694
745
695
746
impl TryFrom < chain_impl_mockchain:: certificate:: Certificate > for Certificate {
@@ -707,8 +758,12 @@ impl TryFrom<chain_impl_mockchain::certificate::Certificate> for Certificate {
707
758
certificate:: Certificate :: PoolRegistration ( c) => {
708
759
Ok ( Certificate :: PoolRegistration ( PoolRegistration :: from ( c) ) )
709
760
}
710
- certificate:: Certificate :: PoolRetirement ( _) => Err ( ErrorKind :: Unimplemented . into ( ) ) ,
711
- certificate:: Certificate :: PoolUpdate ( _) => Err ( ErrorKind :: Unimplemented . into ( ) ) ,
761
+ certificate:: Certificate :: PoolRetirement ( c) => {
762
+ Ok ( Certificate :: PoolRetirement ( PoolRetirement :: from ( c) ) )
763
+ }
764
+ certificate:: Certificate :: PoolUpdate ( c) => {
765
+ Ok ( Certificate :: PoolUpdate ( PoolUpdate :: from ( c) ) )
766
+ }
712
767
}
713
768
}
714
769
}
@@ -720,6 +775,8 @@ graphql_union!(Certificate: Context |&self| {
720
775
& StakeDelegation => match * self { Certificate :: StakeDelegation ( ref c) => Some ( c) , _ => None } ,
721
776
& OwnerStakeDelegation => match * self { Certificate :: OwnerStakeDelegation ( ref c) => Some ( c) , _ => None } ,
722
777
& PoolRegistration => match * self { Certificate :: PoolRegistration ( ref c) => Some ( c) , _ => None } ,
778
+ & PoolUpdate => match * self { Certificate :: PoolUpdate ( ref c) => Some ( c) , _ => None } ,
779
+ & PoolRetirement => match * self { Certificate :: PoolRetirement ( ref c) => Some ( c) , _ => None }
723
780
}
724
781
} ) ;
725
782
0 commit comments