1616
1717use crate :: types:: {
1818 createAccountCall, depositToCall, getSenderAddressCall, getUserOpHashCall, handleOpsCall,
19- simulateHandleOpsCall, simulateValidationCall, ExecutionResult , SenderAddressResult ,
19+ simulateHandleOpsCall, simulateValidationCall, ExecutionResult , OwnerType , SenderAddressResult ,
2020 ValidationResult ,
2121} ;
2222use crate :: utils:: {
@@ -511,10 +511,18 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
511511 factory_address : Address ,
512512 account_implementation : Address ,
513513 oa : FixedBytes < 32 > ,
514+ oa_type : OwnerType ,
514515 client_id : & [ u8 ] ,
515516 root : Address ,
516517 ) -> Address {
517- calculate_omni_account_address ( factory_address, account_implementation, oa, client_id, root)
518+ calculate_omni_account_address (
519+ factory_address,
520+ account_implementation,
521+ oa,
522+ oa_type,
523+ client_id,
524+ root,
525+ )
518526 }
519527
520528 pub async fn deposit_to ( & self , account : Address , amount : U256 ) -> Result < String , ( ) > {
@@ -542,14 +550,15 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
542550 & self ,
543551 factory_address : Address ,
544552 oa : [ u8 ; 32 ] ,
553+ oa_type : OwnerType ,
545554 client_id : & [ u8 ] ,
546555 root_address : Address ,
547556 call_data : Bytes ,
548557 paymaster_address : Option < Address > ,
549558 ) -> Result < PackedUserOperation , ( ) > {
550559 // Create init code using existing helper
551560 let init_code_bytes =
552- prepare_factory_init_code ( factory_address, oa, client_id, root_address) ;
561+ prepare_factory_init_code ( factory_address, oa, oa_type , client_id, root_address) ;
553562 let init_code = Bytes :: from ( init_code_bytes) ;
554563
555564 // Get sender address from EntryPoint
@@ -560,6 +569,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
560569 sender,
561570 factory_address,
562571 oa,
572+ oa_type,
563573 client_id,
564574 root_address,
565575 call_data,
@@ -576,6 +586,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
576586 factory_address : Address ,
577587 account_implementation : Address ,
578588 oa : [ u8 ; 32 ] ,
589+ oa_type : OwnerType ,
579590 client_id : & [ u8 ] ,
580591 root_address : Address ,
581592 call_data : Bytes ,
@@ -588,6 +599,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
588599 factory_address,
589600 account_implementation,
590601 oa_fixed,
602+ oa_type,
591603 client_id,
592604 root_address,
593605 ) ;
@@ -597,6 +609,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
597609 sender,
598610 factory_address,
599611 oa,
612+ oa_type,
600613 client_id,
601614 root_address,
602615 call_data,
@@ -612,6 +625,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
612625 sender : Address ,
613626 factory_address : Address ,
614627 oa : [ u8 ; 32 ] ,
628+ oa_type : OwnerType ,
615629 client_id : & [ u8 ] ,
616630 root_address : Address ,
617631 call_data : Bytes ,
@@ -633,7 +647,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
633647 let init_code_to_use = if code. is_empty ( ) {
634648 // No code at address, include init code
635649 let init_code_bytes =
636- prepare_factory_init_code ( factory_address, oa, client_id, root_address) ;
650+ prepare_factory_init_code ( factory_address, oa, oa_type , client_id, root_address) ;
637651 Bytes :: from ( init_code_bytes)
638652 } else {
639653 // Code already exists, no init code needed
@@ -675,6 +689,7 @@ impl<P: RpcProvider<Transaction = TransactionRequest, Addr = Address>> EntryPoin
675689pub fn prepare_factory_init_code (
676690 factory_address : Address ,
677691 oa : [ u8 ; 32 ] ,
692+ oa_type : OwnerType ,
678693 client_id : & [ u8 ] ,
679694 root : Address ,
680695) -> Vec < u8 > {
@@ -683,6 +698,7 @@ pub fn prepare_factory_init_code(
683698 let mut call = createAccountCall {
684699 //safe to unwrap
685700 oa : oa. into ( ) ,
701+ oaType : oa_type,
686702 //safe to unwrap
687703 clientId : client_id. to_owned ( ) . into ( ) ,
688704 root,
@@ -729,7 +745,7 @@ pub fn create_gas_fees(max_fee_per_gas: U256, max_priority_fee_per_gas: U256) ->
729745
730746#[ cfg( test) ]
731747pub mod test {
732- use crate :: types:: depositCall;
748+ use crate :: types:: { depositCall, OwnerType } ;
733749 use crate :: utils:: build_payable_transaction;
734750 use crate :: { prepare_factory_init_code, EntryPointClient , GasPriceConfig } ;
735751 use alloy:: hex;
@@ -772,6 +788,7 @@ pub mod test {
772788 let init_code_bytes = prepare_factory_init_code (
773789 factory_address,
774790 oa_bytes. 0 ,
791+ OwnerType :: Evm ,
775792 client_id_fixed_bytes. as_ref ( ) ,
776793 root_address,
777794 ) ;
@@ -784,7 +801,7 @@ pub mod test {
784801
785802 #[ test( test) ]
786803 pub fn test_prepare_init_code ( ) {
787- let expected = "e7f1725e7734ce288f8367e1bb143e90bb3f05120db21afe6d659c2361df3754aa7d46d9f0c993ec0335e60508128c6e3843f7dd962113910000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000 " ;
804+ let expected = "e7f1725e7734ce288f8367e1bb143e90bb3f0512158b8ca56d659c2361df3754aa7d46d9f0c993ec0335e60508128c6e3843f7dd9621139100000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000 " ;
788805
789806 let factory_address = address ! ( "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" ) ;
790807 let oa: [ u8 ; 32 ] =
@@ -797,7 +814,13 @@ pub mod test {
797814 . unwrap ( ) ;
798815 let root_address = address ! ( "0x0000000000000000000000000000000000000001" ) ;
799816
800- let init_code = prepare_factory_init_code ( factory_address, oa, & client_id, root_address) ;
817+ let init_code = prepare_factory_init_code (
818+ factory_address,
819+ oa,
820+ OwnerType :: Evm ,
821+ & client_id,
822+ root_address,
823+ ) ;
801824
802825 assert_eq ! ( expected, hex:: encode( init_code) ) ;
803826 }
@@ -822,6 +845,7 @@ pub mod test {
822845 let init_code_bytes = prepare_factory_init_code (
823846 factory_address,
824847 oa_bytes. 0 ,
848+ OwnerType :: Evm ,
825849 & client_id_fixed_bytes,
826850 root_address,
827851 ) ;
@@ -861,6 +885,7 @@ pub mod test {
861885 . create_packed_user_operation (
862886 factory_address,
863887 oa_bytes. 0 ,
888+ OwnerType :: Evm ,
864889 client_id_bytes,
865890 root_address,
866891 call_data1,
@@ -875,6 +900,7 @@ pub mod test {
875900 . create_packed_user_operation (
876901 factory_address,
877902 oa_bytes. 0 ,
903+ OwnerType :: Evm ,
878904 client_id_bytes,
879905 root_address,
880906 call_data2,
@@ -914,6 +940,7 @@ pub mod test {
914940 #[ test( tokio:: test) ]
915941 #[ ignore = "manual" ]
916942 pub async fn try_full_flow ( ) {
943+ let oa_type = OwnerType :: Evm ;
917944 let user_signer = PrivateKeySigner :: from_str (
918945 "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6" ,
919946 )
@@ -945,6 +972,7 @@ pub mod test {
945972 let init_code_bytes = prepare_factory_init_code (
946973 factory_address,
947974 oa_bytes. 0 ,
975+ oa_type,
948976 & client_id_fixed_bytes,
949977 root_address,
950978 ) ;
@@ -956,6 +984,7 @@ pub mod test {
956984 . create_packed_user_operation (
957985 factory_address,
958986 oa_bytes. 0 ,
987+ oa_type,
959988 & client_id_fixed_bytes,
960989 root_address,
961990 call_data. clone ( ) ,
@@ -1010,6 +1039,7 @@ pub mod test {
10101039 #[ ignore = "manual" ]
10111040 pub async fn test_local_vs_entrypoint_address_calculation ( ) {
10121041 let client_id = "test_client" ;
1042+ let oa_type = OwnerType :: Evm ;
10131043 let user_address = address ! ( "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720" ) ;
10141044 let entrypoint_address = address ! ( "0x5FbDB2315678afecb367f032d93F642f64180aa3" ) ;
10151045 let factory_address = address ! ( "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" ) ;
@@ -1026,8 +1056,13 @@ pub mod test {
10261056 let oa_bytes: FixedBytes < 32 > = FixedBytes :: from_slice ( oa. as_ref ( ) ) ;
10271057
10281058 // Calculate address using EntryPoint.getSenderAddress
1029- let init_code_bytes =
1030- prepare_factory_init_code ( factory_address, oa_bytes. 0 , client_id_bytes, root_address) ;
1059+ let init_code_bytes = prepare_factory_init_code (
1060+ factory_address,
1061+ oa_bytes. 0 ,
1062+ oa_type,
1063+ client_id_bytes,
1064+ root_address,
1065+ ) ;
10311066 let init_code = Bytes :: from ( init_code_bytes) ;
10321067 let entrypoint_address_result = entrypoint_client
10331068 . get_sender_address ( init_code)
@@ -1039,6 +1074,7 @@ pub mod test {
10391074 factory_address,
10401075 account_implementation,
10411076 oa_bytes,
1077+ oa_type,
10421078 client_id_bytes,
10431079 root_address,
10441080 ) ;
0 commit comments