@@ -27,7 +27,7 @@ use crate::cardano::{
2727 CertKeyHash , CertOrPk , Cip0134UriSet , Cip509 , PaymentHistory , PointData , PointTxnIdx ,
2828 RoleData , RoleDataRecord , ValidationSignature ,
2929 } ,
30- state :: RbacChainsState ,
30+ provider :: RbacChainsProvider ,
3131} ;
3232
3333/// Registration chains.
@@ -50,12 +50,10 @@ impl RegistrationChain {
5050 /// # Errors
5151 /// - Propagates any I/O or provider-level errors encountered while checking key
5252 /// ownership (e.g., database lookup failures).
53- pub async fn new < State > (
53+ pub async fn new (
5454 cip509 : & Cip509 ,
55- state : & mut State ,
55+ provider : & impl RbacChainsProvider ,
5656 ) -> anyhow:: Result < Option < Self > >
57- where
58- State : RbacChainsState ,
5957 {
6058 let Some ( new_chain) = Self :: new_stateless ( cip509) else {
6159 return Ok ( None ) ;
@@ -64,24 +62,20 @@ impl RegistrationChain {
6462 // Verify that a Catalyst ID of this chain is unique.
6563 {
6664 let cat_id = new_chain. catalyst_id ( ) ;
67- if state . is_chain_known ( cat_id) . await ? {
65+ if provider . is_chain_known ( cat_id) . await ? {
6866 cip509. report ( ) . functional_validation (
6967 & format ! ( "{} is already used" , cat_id. as_short_id( ) ) ,
7068 "It isn't allowed to use same Catalyst ID (certificate subject public key) in multiple registration chains" ,
7169 ) ;
7270 }
7371
74- check_signing_public_key ( cat_id, cip509, state ) . await ?;
72+ check_signing_public_key ( cat_id, cip509, provider ) . await ?;
7573 }
7674
7775 if cip509. report ( ) . is_problematic ( ) {
7876 return Ok ( None ) ;
7977 }
8078
81- state
82- . take_stake_address_from_chains ( cip509. stake_addresses ( ) )
83- . await ?;
84-
8579 Ok ( Some ( new_chain) )
8680 }
8781
@@ -108,13 +102,11 @@ impl RegistrationChain {
108102 /// # Errors
109103 /// - Propagates any I/O or provider-level errors encountered while checking key
110104 /// ownership (e.g., database lookup failures).
111- pub async fn update < State > (
105+ pub async fn update (
112106 & self ,
113107 cip509 : & Cip509 ,
114- state : & State ,
108+ provider : & impl RbacChainsProvider ,
115109 ) -> anyhow:: Result < Option < Self > >
116- where
117- State : RbacChainsState ,
118110 {
119111 let Some ( new_chain) = self . update_stateless ( cip509) else {
120112 return Ok ( None ) ;
@@ -123,17 +115,19 @@ impl RegistrationChain {
123115 // Check that addresses from the new registration aren't used in other chains.
124116 let previous_stake_addresses = self . stake_addresses ( ) ;
125117 let reg_stake_addresses = cip509. stake_addresses ( ) ;
126- let new_stake_addresses: Vec < _ > = reg_stake_addresses. difference ( & previous_stake_addresses) . collect ( ) ;
118+ let new_stake_addresses: Vec < _ > = reg_stake_addresses
119+ . difference ( & previous_stake_addresses)
120+ . collect ( ) ;
127121 for address in & new_stake_addresses {
128- if state . is_stake_address_used ( address) . await ? {
122+ if provider . is_stake_address_used ( address) . await ? {
129123 cip509. report ( ) . functional_validation (
130124 & format ! ( "{address} stake address is already used" ) ,
131125 "It isn't allowed to use same stake address in multiple registration chains, if its not a new chain" ,
132126 ) ;
133127 }
134128 }
135129
136- check_signing_public_key ( self . catalyst_id ( ) , cip509, state ) . await ?;
130+ check_signing_public_key ( self . catalyst_id ( ) , cip509, provider ) . await ?;
137131
138132 if cip509. report ( ) . is_problematic ( ) {
139133 Ok ( None )
@@ -737,7 +731,7 @@ async fn check_signing_public_key<State>(
737731 state : & State ,
738732) -> anyhow:: Result < ( ) >
739733where
740- State : RbacChainsState ,
734+ State : RbacChainsProvider ,
741735{
742736 for role in cip509. all_roles ( ) {
743737 if let Some ( key) = cip509. signing_public_key_for_role ( role)
0 commit comments