@@ -16,10 +16,7 @@ use tempo_contracts::precompiles::{
1616 NATIVE_MULTISIG_ADDRESS , NativeMultisigError , NativeMultisigEvent ,
1717} ;
1818use tempo_precompiles_macros:: contract;
19- use tempo_primitives:: transaction:: {
20- MULTISIG_ACCOUNT_DOMAIN , MULTISIG_CONFIG_DOMAIN , MultisigConfig , MultisigConfigError ,
21- MultisigOwner ,
22- } ;
19+ use tempo_primitives:: transaction:: { MultisigConfig , MultisigConfigError } ;
2320
2421use crate :: is_valid_multisig_account;
2522
@@ -145,9 +142,10 @@ impl NativeMultisig {
145142
146143 fn derive_account_from_config ( & self , config : & MultisigConfig ) -> Result < Address > {
147144 config. validate ( ) . map_err ( map_multisig_config_error) ?;
148- let hash = self
149- . storage
150- . keccak256 ( & account_derivation_preimage ( config) ) ?;
145+ let preimage = config
146+ . account_derivation_preimage ( )
147+ . map_err ( map_multisig_config_error) ?;
148+ let hash = self . storage . keccak256 ( & preimage) ?;
151149 let account = Address :: from_slice ( & hash[ 12 ..] ) ;
152150 if config. owner_weight ( account) . is_some ( ) {
153151 return Err ( NativeMultisigError :: invalid_multisig_owner ( ) . into ( ) ) ;
@@ -159,35 +157,10 @@ impl NativeMultisig {
159157 }
160158
161159 fn hash_config_commitment ( & self , config : & MultisigConfig ) -> Result < B256 > {
162- self . storage . keccak256 ( & config_commitment_preimage ( config) )
163- }
164- }
165-
166- fn account_derivation_preimage ( config : & MultisigConfig ) -> Vec < u8 > {
167- let mut input = Vec :: new ( ) ;
168- input. extend_from_slice ( MULTISIG_ACCOUNT_DOMAIN ) ;
169- input. extend_from_slice ( config. salt . as_slice ( ) ) ;
170- input. push ( config. threshold ) ;
171- input. push ( config. owners . len ( ) as u8 ) ;
172- append_owners ( & mut input, & config. owners ) ;
173- input
174- }
175-
176- fn config_commitment_preimage ( config : & MultisigConfig ) -> Vec < u8 > {
177- let mut input = Vec :: new ( ) ;
178- input. extend_from_slice ( MULTISIG_CONFIG_DOMAIN ) ;
179- input. extend_from_slice ( config. salt . as_slice ( ) ) ;
180- input. extend_from_slice ( & config. version . to_be_bytes ( ) ) ;
181- input. push ( config. threshold ) ;
182- input. push ( config. owners . len ( ) as u8 ) ;
183- append_owners ( & mut input, & config. owners ) ;
184- input
185- }
186-
187- fn append_owners ( input : & mut Vec < u8 > , owners : & [ MultisigOwner ] ) {
188- for owner in owners {
189- input. extend_from_slice ( owner. owner . as_slice ( ) ) ;
190- input. push ( owner. weight ) ;
160+ let preimage = config
161+ . commitment_preimage ( )
162+ . map_err ( map_multisig_config_error) ?;
163+ self . storage . keccak256 ( & preimage)
191164 }
192165}
193166
@@ -222,6 +195,7 @@ mod tests {
222195 } ;
223196 use alloy:: primitives:: address;
224197 use tempo_chainspec:: hardfork:: TempoHardfork ;
198+ use tempo_primitives:: transaction:: MultisigOwner ;
225199
226200 fn initial_config ( ) -> MultisigConfig {
227201 MultisigConfig {
0 commit comments