@@ -86,55 +86,33 @@ impl RegistrationChain {
8686 } )
8787 }
8888
89- /// Attempts to update an existing RBAC registration chain
90- /// with a new CIP-509 registration, validating address and key usage consistency.
91- ///
92- /// # Returns
93- /// - `Ok((new_chain, validation_result))` if the chain was successfully updated and
94- /// validated.
89+ /// Creates or updates an RBAC registration chain from a CIP-509 registration.
9590 ///
96- /// # Errors
97- /// - Returns [`RbacValidationError::UnknownCatalystId`] if no Catalyst chain is found
98- /// for `previous_txn`.
99- /// - Returns [`RbacValidationError::InvalidRegistration`] if address/key duplication
100- /// or validation inconsistencies are detected.
101- #[ must_use]
102- pub async fn update_from_previous_txn < Provider > (
103- & self ,
104- reg : Cip509 ,
105- previous_txn : TransactionId ,
106- provider : & Provider ,
107- ) -> Result < RegistrationChain , RbacValidationError >
108- where
109- Provider : RbacRegistrationProvider ,
110- {
111- self . inner
112- . update_from_previous_txn ( reg, previous_txn, provider)
113- . await
114- }
115-
116- /// Attempts to initialize a new RBAC registration chain
117- /// from a given CIP-509 registration, ensuring uniqueness of Catalyst ID, stake
118- /// addresses, and associated public keys.
91+ /// If the given registration references a previous transaction, it attempts
92+ /// to update the existing chain using that previous transaction.
93+ /// Otherwise, it starts a new chain from the provided registration.
11994 ///
12095 /// # Returns
121- /// - `Ok((new_chain, validation_result))` if the chain was successfully initialized
122- /// and validated.
96+ /// - `Ok(Self)` if the chain was successfully initialized or updated and validated.
12397 ///
12498 /// # Errors
125- /// - [`RbacValidationError::UnknownCatalystId`]: if `reg` lacks a valid Catalyst ID.
126- /// - [`RbacValidationError::InvalidRegistration`]: if any functional validation,
127- /// stake address conflict, or public key duplication occurs.
99+ /// - [`RbacValidationError::UnknownCatalystId`] if no Catalyst chain can be found or
100+ /// inferred.
101+ /// - [`RbacValidationError::InvalidRegistration`] if any validation, address, or key
102+ /// duplication inconsistencies are detected.
128103 #[ must_use]
129- pub async fn start_from_provider < Provider > (
130- & self ,
104+ pub async fn update_from_previous_txn < Provider > (
131105 reg : Cip509 ,
132106 provider : & Provider ,
133- ) -> Result < RegistrationChain , RbacValidationError >
107+ ) -> Result < Self , RbacValidationError >
134108 where
135109 Provider : RbacRegistrationProvider ,
136110 {
137- self . inner . start_from_provider ( reg, provider) . await
111+ if let Some ( previous_txn) = reg. previous_transaction ( ) {
112+ RegistrationChainInner :: update_from_previous_txn ( reg, previous_txn, provider) . await
113+ } else {
114+ RegistrationChainInner :: start_from_provider ( reg, provider) . await
115+ }
138116 }
139117
140118 /// Validates that none of the signing keys in a given RBAC registration chain
@@ -633,7 +611,6 @@ impl RegistrationChainInner {
633611 /// or validation inconsistencies are detected.
634612 #[ must_use]
635613 pub async fn update_from_previous_txn < Provider > (
636- & self ,
637614 reg : Cip509 ,
638615 previous_txn : TransactionId ,
639616 provider : & Provider ,
@@ -709,7 +686,6 @@ impl RegistrationChainInner {
709686 /// stake address conflict, or public key duplication occurs.
710687 #[ must_use]
711688 pub async fn start_from_provider < Provider > (
712- & self ,
713689 reg : Cip509 ,
714690 provider : & Provider ,
715691 ) -> Result < RegistrationChain , RbacValidationError >
0 commit comments