@@ -6,9 +6,10 @@ use std::{collections::HashMap, sync::Arc};
66
77use anyhow:: bail;
88use c509_certificate:: c509:: C509 ;
9- use cardano_blockchain_types:: TransactionId ;
9+ use cardano_blockchain_types:: { Cip0134Uri , StakeAddress , TransactionId } ;
1010use catalyst_types:: { id_uri:: IdUri , uuid:: UuidV4 } ;
1111use ed25519_dalek:: VerifyingKey ;
12+ use pallas:: ledger:: addresses:: Address ;
1213use tracing:: error;
1314use update_rbac:: {
1415 revocations_list, update_c509_certs, update_public_keys, update_role_data, update_x509_certs,
@@ -204,6 +205,21 @@ impl RegistrationChain {
204205 . get ( role)
205206 . and_then ( |rdr| rdr. encryption_key_from_rotation ( rotation) )
206207 }
208+
209+ /// Returns a list of role 0 stake addresses.
210+ #[ must_use]
211+ pub fn role_0_stake_addresses ( & self ) -> Vec < StakeAddress > {
212+ let mut result = Vec :: new ( ) ;
213+
214+ if let Some ( uris) = self . inner . certificate_uris . x_uris ( ) . get ( & 0 ) {
215+ result. extend ( convert_stake_addresses ( uris) ) ;
216+ }
217+ if let Some ( uris) = self . inner . certificate_uris . c_uris ( ) . get ( & 0 ) {
218+ result. extend ( convert_stake_addresses ( uris) ) ;
219+ }
220+
221+ result
222+ }
207223}
208224
209225/// Inner structure of registration chain.
@@ -391,6 +407,18 @@ impl RegistrationChainInner {
391407 }
392408}
393409
410+ /// Converts a list of `Cip0134Uri` to a list of stake addresses.
411+ fn convert_stake_addresses ( uris : & [ Cip0134Uri ] ) -> Vec < StakeAddress > {
412+ uris. iter ( )
413+ . filter_map ( |uri| {
414+ match uri. address ( ) {
415+ Address :: Stake ( a) => Some ( a. clone ( ) . into ( ) ) ,
416+ _ => None ,
417+ }
418+ } )
419+ . collect ( )
420+ }
421+
394422#[ cfg( test) ]
395423mod test {
396424 use super :: * ;
0 commit comments