@@ -489,67 +489,6 @@ impl RegistrationChainInner {
489489 Some ( new_inner)
490490 }
491491
492- /// Attempts to update an existing RBAC registration chain
493- /// with a new CIP-509 registration, validating address and key usage consistency.
494- pub async fn update < Provider > (
495- & self ,
496- reg : Cip509 ,
497- provider : & Provider ,
498- ) -> Option < Self >
499- where
500- Provider : RbacRegistrationProvider ,
501- {
502- let previous_txn = reg. previous_transaction ( ) ?;
503- let report = reg. report ( ) . to_owned ( ) ;
504-
505- // Find a chain this registration belongs to.
506- let Some ( catalyst_id) = provider. catalyst_id_from_txn_id ( previous_txn) . await . ok ( ) ? else {
507- // We are unable to determine a Catalyst ID, so there is no sense to update the problem
508- // report because we would be unable to store this registration anyway.
509- return None ;
510- } ;
511- let chain = provider. chain ( catalyst_id. clone ( ) ) . await . ok ( ) ??;
512-
513- // Check that addresses from the new registration aren't used in other chains.
514- let previous_addresses = chain. stake_addresses ( ) ;
515- let reg_addresses = reg. stake_addresses ( ) ;
516- let new_addresses: Vec < _ > = reg_addresses. difference ( & previous_addresses) . collect ( ) ;
517- for address in & new_addresses {
518- match provider
519- . catalyst_id_from_stake_address ( address)
520- . await
521- . ok ( ) ?
522- {
523- None => {
524- // All good: the address wasn't used before.
525- } ,
526- Some ( _) => {
527- report. functional_validation (
528- & format ! ( "{address} stake addresses is already used" ) ,
529- "It isn't allowed to use same stake address in multiple registration chains" ,
530- ) ;
531- } ,
532- }
533- }
534-
535- // Try to add a new registration to the chain.
536- let ( signing_pk, _) = self . get_latest_signing_pk_for_role ( RoleId :: Role0 ) ?;
537- let new_chain = chain. inner . update_stateless ( reg. clone ( ) , signing_pk) ?;
538-
539- // Check that new public keys aren't used by other chains.
540- let valid_pks = new_chain
541- . validate_public_keys ( & report, provider)
542- . await
543- . ok ( ) ?;
544-
545- // Return an error if any issues were recorded in the report.
546- if report. is_problematic ( ) || !valid_pks {
547- return None ;
548- }
549-
550- Some ( new_chain)
551- }
552-
553492 /// Attempts to initialize a new RBAC registration chain
554493 /// from a given CIP-509 registration, ensuring uniqueness of Catalyst ID, stake
555494 /// addresses, and associated public keys.
@@ -621,6 +560,67 @@ impl RegistrationChainInner {
621560 Some ( new_chain)
622561 }
623562
563+ /// Attempts to update an existing RBAC registration chain
564+ /// with a new CIP-509 registration, validating address and key usage consistency.
565+ pub async fn update < Provider > (
566+ & self ,
567+ reg : Cip509 ,
568+ provider : & Provider ,
569+ ) -> Option < Self >
570+ where
571+ Provider : RbacRegistrationProvider ,
572+ {
573+ let previous_txn = reg. previous_transaction ( ) ?;
574+ let report = reg. report ( ) . to_owned ( ) ;
575+
576+ // Find a chain this registration belongs to.
577+ let Some ( catalyst_id) = provider. catalyst_id_from_txn_id ( previous_txn) . await . ok ( ) ? else {
578+ // We are unable to determine a Catalyst ID, so there is no sense to update the problem
579+ // report because we would be unable to store this registration anyway.
580+ return None ;
581+ } ;
582+ let chain = provider. chain ( catalyst_id. clone ( ) ) . await . ok ( ) ??;
583+
584+ // Check that addresses from the new registration aren't used in other chains.
585+ let previous_addresses = chain. stake_addresses ( ) ;
586+ let reg_addresses = reg. stake_addresses ( ) ;
587+ let new_addresses: Vec < _ > = reg_addresses. difference ( & previous_addresses) . collect ( ) ;
588+ for address in & new_addresses {
589+ match provider
590+ . catalyst_id_from_stake_address ( address)
591+ . await
592+ . ok ( ) ?
593+ {
594+ None => {
595+ // All good: the address wasn't used before.
596+ } ,
597+ Some ( _) => {
598+ report. functional_validation (
599+ & format ! ( "{address} stake addresses is already used" ) ,
600+ "It isn't allowed to use same stake address in multiple registration chains" ,
601+ ) ;
602+ } ,
603+ }
604+ }
605+
606+ // Try to add a new registration to the chain.
607+ let ( signing_pk, _) = self . get_latest_signing_pk_for_role ( RoleId :: Role0 ) ?;
608+ let new_chain = chain. inner . update_stateless ( reg. clone ( ) , signing_pk) ?;
609+
610+ // Check that new public keys aren't used by other chains.
611+ let valid_pks = new_chain
612+ . validate_public_keys ( & report, provider)
613+ . await
614+ . ok ( ) ?;
615+
616+ // Return an error if any issues were recorded in the report.
617+ if report. is_problematic ( ) || !valid_pks {
618+ return None ;
619+ }
620+
621+ Some ( new_chain)
622+ }
623+
624624 /// Validates that none of the signing keys in a given RBAC registration chain
625625 /// have been used by any other existing chain, ensuring global key uniqueness
626626 /// across all Catalyst registrations.
0 commit comments