@@ -14,7 +14,7 @@ use registration_witness::Cip36RegistrationWitness;
1414use validation:: { validate_payment_address_network, validate_signature, validate_voting_keys} ;
1515use voting_pk:: VotingPubKey ;
1616
17- use crate :: { MetadatumLabel , MetadatumValue , Network , Slot , TransactionAuxData } ;
17+ use crate :: { MetadatumLabel , MetadatumValue , MultiEraBlock , Network , TxnIndex } ;
1818
1919/// CIP-36 Catalyst registration
2020#[ derive( Clone , Default , Debug ) ]
@@ -48,37 +48,40 @@ impl Cip36 {
4848 ///
4949 /// # Parameters
5050 ///
51- /// * `aux_data` - The transaction auxiliary data.
51+ /// * `block` - The block containing the auxiliary data.
52+ /// * `txn_idx` - The transaction index that contain the auxiliary data.
5253 /// * `is_catalyst_strict` - Is this a Catalyst strict registration?
53- /// * `slot` - The slot number of the auxiliary data.
5454 ///
5555 /// # Errors
5656 ///
5757 /// If the CIP-36 key registration or registration witness metadata is not found.
5858 /// or if the CIP-36 key registration or registration witness metadata cannot be
5959 /// decoded.
6060 pub fn new (
61- aux_data : & TransactionAuxData , is_catalyst_strict : bool , slot : Slot , network : Network ,
61+ block : & MultiEraBlock , txn_idx : TxnIndex , is_catalyst_strict : bool ,
6262 ) -> anyhow:: Result < Self > {
63- let Some ( k61284) = aux_data . metadata ( MetadatumLabel :: CIP036_REGISTRATION ) else {
63+ let Some ( k61284) = block . txn_metadata ( txn_idx , MetadatumLabel :: CIP036_REGISTRATION ) else {
6464 bail ! ( "CIP-36 key registration metadata not found" )
6565 } ;
66- let Some ( k61285) = aux_data . metadata ( MetadatumLabel :: CIP036_WITNESS ) else {
66+ let Some ( k61285) = block . txn_metadata ( txn_idx , MetadatumLabel :: CIP036_WITNESS ) else {
6767 bail ! ( "CIP-36 registration witness metadata not found" )
6868 } ;
6969
70+ let slot = block. decode ( ) . slot ( ) ;
71+ let network = block. network ( ) ;
72+
7073 let mut key_registration = Decoder :: new ( k61284. as_ref ( ) ) ;
7174 let mut registration_witness = Decoder :: new ( k61285. as_ref ( ) ) ;
7275
7376 let key_registration = match Cip36KeyRegistration :: decode ( & mut key_registration, & mut ( ) ) {
7477 Ok ( mut metadata) => {
75- let nonce = if is_catalyst_strict && metadata. raw_nonce > slot. into ( ) {
78+ let nonce = if is_catalyst_strict && metadata. raw_nonce > slot {
7679 slot
7780 } else {
78- metadata. raw_nonce . into ( )
81+ metadata. raw_nonce
7982 } ;
8083
81- metadata. nonce = nonce. into ( ) ;
84+ metadata. nonce = nonce;
8285 metadata
8386 } ,
8487 Err ( e) => {
0 commit comments