1414from eth_account import Account
1515from factory .fuzzy import FuzzyText
1616from hexbytes import HexBytes
17+ from packaging .version import Version
1718from requests import ReadTimeout
1819from rest_framework import status
1920from rest_framework .exceptions import ErrorDetail
3132from safe_transaction_service .contracts .models import ContractQuerySet
3233from safe_transaction_service .contracts .tests .factories import ContractFactory
3334from safe_transaction_service .contracts .tx_decoder import DbTxDecoder
34- from safe_transaction_service .safe_messages .utils import (
35- select_safe_encoded_message_hash_by_safe_version ,
36- )
3735from safe_transaction_service .tokens .models import Token
3836from safe_transaction_service .tokens .tests .factories import TokenFactory
3937from safe_transaction_service .utils .utils import datetime_to_str
@@ -1773,12 +1771,14 @@ def test_post_multisig_transaction_with_1271_signature(self):
17731771 )
17741772 safe_tx_hash = safe_tx .safe_tx_hash
17751773 safe_tx_hash_preimage = safe_tx .safe_tx_hash_preimage
1776-
1777- selected_hash = select_safe_encoded_message_hash_by_safe_version (
1778- safe .get_version (), safe_tx_hash , safe_tx_hash_preimage
1774+ # >= v1.3.0: supports isValidSignature(bytes32, bytes) and isValidSignature(bytes, bytes)
1775+ # < v1.3.0: only isValidSignature(bytes, bytes) with the preimage
1776+ # < v1.5.0: test isValidSignature(bytes, bytes) for backward compatibility
1777+ safe_owner_message_hash = safe_owner .get_message_hash (
1778+ safe_tx_hash
1779+ if Version (safe .get_version ()) >= Version ("1.5.0" )
1780+ else safe_tx_hash_preimage
17791781 )
1780-
1781- safe_owner_message_hash = safe_owner .get_message_hash (selected_hash )
17821782 safe_owner_signature = account .unsafe_sign_hash (safe_owner_message_hash )[
17831783 "signature"
17841784 ]
@@ -5013,7 +5013,7 @@ def test_export_view_standalone_transfer_priority(self):
50135013
50145014class TestViewsV141 (TestViewsV150 ):
50155015 """
5016- Test views v2 with Safe v1.4.1 contracts.
5016+ Test views with Safe v1.4.1 contracts.
50175017 """
50185018
50195019 def deploy_test_safe (self , * args , ** kwargs ) -> Safe :
@@ -5023,3 +5023,31 @@ def deploy_test_safe(self, *args, **kwargs) -> Safe:
50235023 :return: Deploy last available Safe
50245024 """
50255025 return self .deploy_test_safe_v1_4_1 (* args , ** kwargs )
5026+
5027+
5028+ class TestViewsV130 (TestViewsV150 ):
5029+ """
5030+ Test views with Safe v1.3.0 contracts.
5031+ """
5032+
5033+ def deploy_test_safe (self , * args , ** kwargs ) -> Safe :
5034+ """
5035+ :param args:
5036+ :param kwargs:
5037+ :return: Deploy last available Safe
5038+ """
5039+ return self .deploy_test_safe_v1_3_0 (* args , ** kwargs )
5040+
5041+
5042+ class TestViewsV111 (TestViewsV150 ):
5043+ """
5044+ Test views with Safe v1.1.1 contracts.
5045+ """
5046+
5047+ def deploy_test_safe (self , * args , ** kwargs ) -> Safe :
5048+ """
5049+ :param args:
5050+ :param kwargs:
5051+ :return: Deploy last available Safe
5052+ """
5053+ return self .deploy_test_safe_v1_1_1 (* args , ** kwargs )
0 commit comments