55use std:: fmt:: { Display , Formatter } ;
66
77use anyhow:: { anyhow, Context } ;
8+ use catalyst_types:: hashes:: Blake2b224Hash ;
89use pallas:: {
910 crypto:: hash:: Hash ,
1011 ledger:: {
@@ -26,8 +27,9 @@ impl StakeAddress {
2627 /// Creates a new instance from the given parameters.
2728 #[ allow( clippy:: expect_used, clippy:: missing_panics_doc) ]
2829 #[ must_use]
29- pub fn new ( network : Network , is_script : bool , hash : Hash < 28 > ) -> Self {
30+ pub fn new ( network : Network , is_script : bool , stake_pk_hash : Blake2b224Hash ) -> Self {
3031 let network = network. into ( ) ;
32+ let hash = stake_pk_hash. into ( ) ;
3133 // `pallas::StakeAddress` can only be constructed from `ShelleyAddress`, so we are forced
3234 // to create a dummy shelley address. The input hash parameter is used to construct both
3335 // payment and delegation parts, but the payment part isn't used in the stake address
@@ -49,8 +51,8 @@ impl StakeAddress {
4951 #[ must_use]
5052 pub fn from_stake_cred ( network : Network , cred : & conway:: StakeCredential ) -> Self {
5153 match cred {
52- conway:: StakeCredential :: Scripthash ( h) => Self :: new ( network, true , * h ) ,
53- conway:: StakeCredential :: AddrKeyhash ( h) => Self :: new ( network, false , * h ) ,
54+ conway:: StakeCredential :: Scripthash ( h) => Self :: new ( network, true , ( * h ) . into ( ) ) ,
55+ conway:: StakeCredential :: AddrKeyhash ( h) => Self :: new ( network, false , ( * h ) . into ( ) ) ,
5456 }
5557 }
5658
@@ -111,7 +113,7 @@ impl TryFrom<&[u8]> for StakeAddress {
111113 v => return Err ( anyhow ! ( "Unexpected type value: {v}, header = {header}" ) ) ,
112114 } ;
113115
114- Ok ( Self :: new ( network, is_script, hash) )
116+ Ok ( Self :: new ( network, is_script, hash. into ( ) ) )
115117 }
116118}
117119
@@ -155,7 +157,7 @@ mod tests {
155157 ] ;
156158
157159 for ( network, is_script, hash, expected_header) in test_data {
158- let stake_address = StakeAddress :: new ( network, is_script, hash) ;
160+ let stake_address = StakeAddress :: new ( network, is_script, hash. into ( ) ) ;
159161 assert_eq ! ( stake_address. is_script( ) , is_script) ;
160162
161163 // Check that conversion to bytes includes the expected header value.
@@ -227,7 +229,7 @@ mod tests {
227229 // cSpell:enable
228230
229231 for ( network, is_script, hash, expected) in test_data {
230- let address = StakeAddress :: new ( network, is_script, hash) ;
232+ let address = StakeAddress :: new ( network, is_script, hash. into ( ) ) ;
231233 assert_eq ! ( expected, format!( "{address}" ) ) ;
232234 }
233235 }
0 commit comments