@@ -591,39 +591,17 @@ def _process_safe_creation_events(
591591 # Find events by type (each Safe should have at most one of each)
592592 setup_event : EventData | None = None
593593 proxy_creation_event : EventData | None = None
594+ proxy_creation_event_l2 : EventData | None = None
595+ chain_specific_proxy_creation_event_l2 : EventData | None = None
594596 for event in events :
595597 if event ["event" ] == "SafeSetup" :
596598 setup_event = event
597599 elif event ["event" ] == "ProxyCreation" :
598600 proxy_creation_event = event
599- # Generate InternalTx for ProxyCreation
600- internal_tx = self ._get_internal_tx_from_decoded_element (
601- proxy_creation_event ,
602- contract_address = proxy_creation_event ["args" ].get ("proxy" ),
603- tx_type = InternalTxType .CREATE .value ,
604- call_type = None ,
605- )
606- internal_txs .append (internal_tx )
607601 elif event ["event" ] == "ProxyCreationL2" :
608602 proxy_creation_event_l2 = event
609- internal_tx = self ._get_internal_tx_from_decoded_element (
610- proxy_creation_event_l2 ,
611- contract_address = proxy_creation_event_l2 ["args" ].get ("proxy" ),
612- tx_type = InternalTxType .CREATE .value ,
613- call_type = None ,
614- )
615- internal_txs .append (internal_tx )
616603 elif event ["event" ] == "ChainSpecificProxyCreationL2" :
617604 chain_specific_proxy_creation_event_l2 = event
618- internal_tx = self ._get_internal_tx_from_decoded_element (
619- chain_specific_proxy_creation_event_l2 ,
620- contract_address = chain_specific_proxy_creation_event_l2 [
621- "args"
622- ].get ("proxy" ),
623- tx_type = InternalTxType .CREATE .value ,
624- call_type = None ,
625- )
626- internal_txs .append (internal_tx )
627605 else :
628606 logger .error ("Unexpected event type: %s" , event ["event" ])
629607
@@ -636,11 +614,32 @@ def _process_safe_creation_events(
636614 call_type = None ,
637615 )
638616 internal_txs .append (internal_tx )
617+ if proxy_creation_event_l2 :
618+ internal_tx = self ._get_internal_tx_from_decoded_element (
619+ proxy_creation_event_l2 ,
620+ contract_address = proxy_creation_event_l2 ["args" ].get ("proxy" ),
621+ tx_type = InternalTxType .CREATE .value ,
622+ call_type = None ,
623+ )
624+ internal_txs .append (internal_tx )
625+ if chain_specific_proxy_creation_event_l2 :
626+ internal_tx = self ._get_internal_tx_from_decoded_element (
627+ chain_specific_proxy_creation_event_l2 ,
628+ contract_address = chain_specific_proxy_creation_event_l2 ["args" ].get (
629+ "proxy"
630+ ),
631+ tx_type = InternalTxType .CREATE .value ,
632+ call_type = None ,
633+ )
634+ internal_txs .append (internal_tx )
639635
640636 # Process SafeSetup - initializes the Safe
641637 if setup_event :
642638 if not proxy_creation_event :
643639 # SafeSetup without ProxyCreation means proxy was created in a previous block
640+ # ProxyCreationL2 or ChainSpecificProxyCreationL2 (only available v1.5.0 onwards) are not considered here because tracking ProxyCreation is enough.
641+ # ProxyCreation is also emmited when ProxyCreationL2 or ChainSpecificProxyCreationL2 are emmited.
642+ # See: https://github.com/safe-fndn/safe-smart-account/blob/release/v1.5.0/contracts/proxies/SafeProxyFactory.sol
644643 logger .debug (
645644 "[%s] Proxy was created in previous blocks, deleting the old InternalTx" ,
646645 safe_address ,
0 commit comments