diff --git a/safe_transaction_service/history/filters.py b/safe_transaction_service/history/filters.py index 01193fbfb..51438d022 100644 --- a/safe_transaction_service/history/filters.py +++ b/safe_transaction_service/history/filters.py @@ -85,10 +85,10 @@ class Meta: class ModuleTransactionFilter(filters.FilterSet): - block_number = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number') - block_number__gt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number', + block_number = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id') + block_number__gt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id', lookup_expr='gt') - block_number__lt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number', + block_number__lt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id', lookup_expr='lt') transaction_hash = django_filters.CharFilter(field_name='internal_tx__ethereum_tx_id') diff --git a/safe_transaction_service/history/tests/test_views.py b/safe_transaction_service/history/tests/test_views.py index 5e1de1fdc..ad677edd8 100644 --- a/safe_transaction_service/history/tests/test_views.py +++ b/safe_transaction_service/history/tests/test_views.py @@ -137,6 +137,9 @@ def test_get_module_transactions(self): self.assertEqual(response.data['results'][0]['safe'], module_transaction.safe) self.assertEqual(response.data['results'][0]['module'], module_transaction.module) + # Add another ModuleTransaction to check filters + ModuleTransactionFactory(safe=safe_address) + url = reverse('v1:module-transactions', args=(safe_address,)) + f'?transaction_hash={module_transaction.internal_tx.ethereum_tx_id}' response = self.client.get(url, format='json') @@ -149,6 +152,12 @@ def test_get_module_transactions(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['count'], 0) + url = reverse('v1:module-transactions', + args=(safe_address,)) + f'?block_number={module_transaction.internal_tx.ethereum_tx.block_id}' + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data['count'], 1) + def test_get_multisig_transaction(self): safe_tx_hash = Web3.keccak(text='gnosis').hex() response = self.client.get(reverse('v1:multisig-transaction', args=(safe_tx_hash,)), format='json')