File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
safe_transaction_service/history Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11import datetime
2+ import json
23from collections .abc import Iterator , Sequence
34from decimal import Decimal
45from enum import Enum
@@ -407,10 +408,12 @@ def account_abstraction_txs(self) -> RawQuerySet:
407408 """
408409 :return: Transactions containing ERC4337 `UserOperation` event
409410 """
410- query = '{"topics": ["' + to_0x_hex_str (USER_OPERATION_EVENT_TOPIC ) + '"]}'
411+ # Use json.dumps to safely construct the JSON query string
412+ query_json = json .dumps ({"topics" : [to_0x_hex_str (USER_OPERATION_EVENT_TOPIC )]})
411413
412414 return self .raw (
413- f"SELECT * FROM history_ethereumtx WHERE '{ query } '::jsonb <@ ANY (logs)"
415+ "SELECT * FROM history_ethereumtx WHERE %s::jsonb <@ ANY (logs)" ,
416+ [query_json ],
414417 )
415418
416419
Original file line number Diff line number Diff line change @@ -350,20 +350,26 @@ def test_create_from_tx_dict(self):
350350 ethereum_tx .transaction_index , tx_receipt ["transactionIndex" ]
351351 )
352352
353- def test_account_abstraction_tx_hashes (self ):
353+ def test_account_abstraction_txs (self ):
354354 self .assertEqual (len (EthereumTx .objects .account_abstraction_txs ()), 0 )
355355
356356 # Insert random transaction
357357 EthereumTxFactory ()
358358 self .assertEqual (len (EthereumTx .objects .account_abstraction_txs ()), 0 )
359359
360+ # Insert a non 4337 transaction
361+ _ethereum_tx = EthereumTxFactory (
362+ logs = [clean_receipt_log (log ) for log in type_0_tx ["receipt" ]["logs" ]]
363+ )
364+ self .assertEqual (len (EthereumTx .objects .account_abstraction_txs ()), 0 )
365+
360366 # Insert a 4337 transaction
361- ethereum_tx = EthereumTxFactory (
367+ aa_ethereum_tx = EthereumTxFactory (
362368 logs = [clean_receipt_log (log ) for log in aa_tx_receipt_mock ["logs" ]]
363369 )
364370 ethereum_txs = EthereumTx .objects .account_abstraction_txs ()
365371 self .assertEqual (len (ethereum_txs ), 1 )
366- self .assertEqual (ethereum_txs [0 ], ethereum_tx )
372+ self .assertEqual (ethereum_txs [0 ], aa_ethereum_tx )
367373
368374 def test_get_deployed_proxies_from_logs (self ):
369375 ethereum_tx = EthereumTxFactory (
You can’t perform that action at this time.
0 commit comments