diff --git a/gnosis/eth/clients/etherscan_client.py b/gnosis/eth/clients/etherscan_client.py index d7f2596da..a99eeb3a6 100644 --- a/gnosis/eth/clients/etherscan_client.py +++ b/gnosis/eth/clients/etherscan_client.py @@ -30,6 +30,7 @@ class EtherscanClient: EthereumNetwork.KOVAN: "https://kovan.etherscan.io", EthereumNetwork.BINANCE_SMART_CHAIN_MAINNET: "https://bscscan.com", EthereumNetwork.POLYGON: "https://polygonscan.com", + EthereumNetwork.POLYGON_ZKEVM: "https://zkevm.polygonscan.com", EthereumNetwork.OPTIMISM: "https://optimistic.etherscan.io", EthereumNetwork.ARBITRUM_ONE: "https://arbiscan.io", EthereumNetwork.ARBITRUM_NOVA: "https://nova.arbiscan.io", @@ -53,6 +54,7 @@ class EtherscanClient: EthereumNetwork.KOVAN: "https://api-kovan.etherscan.io", EthereumNetwork.BINANCE_SMART_CHAIN_MAINNET: "https://api.bscscan.com", EthereumNetwork.POLYGON: "https://api.polygonscan.com", + EthereumNetwork.POLYGON_ZKEVM: "https://api-zkevm.polygonscan.com", EthereumNetwork.OPTIMISM: "https://api-optimistic.etherscan.io", EthereumNetwork.ARBITRUM_ONE: "https://api.arbiscan.io", EthereumNetwork.ARBITRUM_NOVA: "https://api-nova.arbiscan.io", diff --git a/gnosis/eth/ethereum_network.py b/gnosis/eth/ethereum_network.py index ec49986da..a1de10398 100644 --- a/gnosis/eth/ethereum_network.py +++ b/gnosis/eth/ethereum_network.py @@ -268,6 +268,7 @@ class EthereumNetwork(Enum): BRONOS_MAINNET = 1039 METIS_ANDROMEDA_MAINNET = 1088 MOAC_MAINNET = 1099 + POLYGON_ZKEVM = 1101 WEMIX3_0_MAINNET = 1111 WEMIX3_0_TESTNET = 1112 CORE_BLOCKCHAIN_MAINNET = 1116 diff --git a/gnosis/eth/multicall.py b/gnosis/eth/multicall.py index 60d0dd636..e3a7f84ac 100644 --- a/gnosis/eth/multicall.py +++ b/gnosis/eth/multicall.py @@ -52,6 +52,7 @@ class Multicall: EthereumNetwork.GNOSIS: "0x08612d3C4A5Dfe2FaaFaFe6a4ff712C2dC675bF7", EthereumNetwork.KCC_MAINNET: "0x7C1C85C39d3D6b6ecB811dfe949B9C23f6E818B0", EthereumNetwork.KCC_TESTNET: "0x665683D9bd41C09cF38c3956c926D9924F1ADa97", + EthereumNetwork.POLYGON_ZKEVM: "0xcA11bde05977b3631167028862bE2a173976CA11", } def __init__( diff --git a/gnosis/eth/tests/utils.py b/gnosis/eth/tests/utils.py index 6cb0547e3..d52c55344 100644 --- a/gnosis/eth/tests/utils.py +++ b/gnosis/eth/tests/utils.py @@ -62,7 +62,7 @@ def just_test_if_polygon_node() -> str: "id": 1, }, ).ok: - pytest.skip("Cannot connect to poylgon node", allow_module_level=True) + pytest.skip("Cannot connect to polygon node", allow_module_level=True) except IOError: pytest.skip( "Problem connecting to the polygon node", allow_module_level=True diff --git a/gnosis/protocol/gnosis_protocol_api.py b/gnosis/protocol/gnosis_protocol_api.py index 30a01738f..de2ce3d3b 100644 --- a/gnosis/protocol/gnosis_protocol_api.py +++ b/gnosis/protocol/gnosis_protocol_api.py @@ -71,12 +71,13 @@ def weth_address(self) -> ChecksumAddress: """ :return: Wrapped ether checksummed address """ - if self.network == EthereumNetwork.MAINNET: - return ChecksumAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") - elif self.network == EthereumNetwork.RINKEBY: - return ChecksumAddress("0xc778417E063141139Fce010982780140Aa0cD5Ab") - else: # XDAI - return ChecksumAddress("0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1") + if self.network == EthereumNetwork.GNOSIS: # WXDAI + return ChecksumAddress("0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d") + if self.network == EthereumNetwork.GOERLI: # Goerli WETH9 + return ChecksumAddress("0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6") + + # Mainnet WETH9 + return ChecksumAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") def get_quote( self, order: Order, from_address: ChecksumAddress @@ -129,9 +130,10 @@ def place_order( from_address = Account.from_key(private_key).address if not order.feeAmount: fee_amount = self.get_fee(order, from_address) - if "errorType" in fee_amount: # ErrorResponse + if isinstance(fee_amount, int): + order.feeAmount = fee_amount + elif "errorType" in fee_amount: # ErrorResponse return fee_amount - order.feeAmount = fee_amount signable_hash = eip712_encode_hash( order.get_eip712_structured_data( diff --git a/gnosis/protocol/tests/test_gnosis_protocol_api.py b/gnosis/protocol/tests/test_gnosis_protocol_api.py index 78626938d..beb6e67b6 100644 --- a/gnosis/protocol/tests/test_gnosis_protocol_api.py +++ b/gnosis/protocol/tests/test_gnosis_protocol_api.py @@ -151,8 +151,7 @@ def test_place_order(self): ) if type(order_id) is dict: - if order_id["errorType"] == "NoLiquidity": - pytest.xfail("NoLiquidity Error") - - self.assertEqual(order_id[:2], "0x") - self.assertEqual(len(order_id), 114) + pytest.xfail(order_id["errorType"]) + else: + self.assertEqual(order_id[:2], "0x") + self.assertEqual(len(order_id), 114) diff --git a/gnosis/safe/addresses.py b/gnosis/safe/addresses.py index e505d463e..0bc16b3a2 100644 --- a/gnosis/safe/addresses.py +++ b/gnosis/safe/addresses.py @@ -70,6 +70,10 @@ ("0x3E5c63644E683549055b9Be8653de26E0B4CD36E", 14306478, "1.3.0+L2"), ("0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552", 14306478, "1.3.0"), ], + EthereumNetwork.POLYGON_ZKEVM: [ + ("0x3E5c63644E683549055b9Be8653de26E0B4CD36E", 79000, "1.3.0+L2"), + ("0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552", 79000, "1.3.0"), + ], EthereumNetwork.MUMBAI: [ ("0x3E5c63644E683549055b9Be8653de26E0B4CD36E", 13736914, "1.3.0+L2"), ("0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552", 13736914, "1.3.0"), @@ -268,6 +272,18 @@ ("0xfb1bffC9d739B8D520DaF37dF666da4C687191EA", 22172521, "1.3.0+L2"), ("0x69f4D1788e39c87893C980c06EdF4b7f686e2938", 22172524, "1.3.0"), ], + EthereumNetwork.VELAS_EVM_MAINNET: [ + ("0xfb1bffC9d739B8D520DaF37dF666da4C687191EA", 27572492, "1.3.0+L2"), + ("0x69f4D1788e39c87893C980c06EdF4b7f686e2938", 27572642, "1.3.0"), + ], + EthereumNetwork.WEMIX3_0_MAINNET: [ + ("0xfb1bffC9d739B8D520DaF37dF666da4C687191EA", 12651754, "1.3.0+L2"), + ("0x69f4D1788e39c87893C980c06EdF4b7f686e2938", 12651757, "1.3.0"), + ], + EthereumNetwork.WEMIX3_0_TESTNET: [ + ("0xfb1bffC9d739B8D520DaF37dF666da4C687191EA", 20834033, "1.3.0+L2"), + ("0x69f4D1788e39c87893C980c06EdF4b7f686e2938", 20834039, "1.3.0"), + ], } PROXY_FACTORIES: Dict[EthereumNetwork, List[Tuple[str, int]]] = { @@ -314,6 +330,9 @@ EthereumNetwork.MUMBAI: [ ("0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2", 13736914), # v1.3.0 ], + EthereumNetwork.POLYGON_ZKEVM: [ + ("0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2", 79000), # v1.3.0 + ], EthereumNetwork.ARBITRUM_ONE: [ ("0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2", 1140), # v1.3.0 ], @@ -464,4 +483,13 @@ EthereumNetwork.IOTEX_NETWORK_MAINNET: [ ("0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC", 22172504), # v1.3.0 ], + EthereumNetwork.VELAS_EVM_MAINNET: [ + ("0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC", 27571962), # v1.3.0 + ], + EthereumNetwork.WEMIX3_0_MAINNET: [ + ("0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC", 12651730), # v1.3.0 + ], + EthereumNetwork.WEMIX3_0_TESTNET: [ + ("0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC", 20833988), # v1.3.0 + ], } diff --git a/gnosis/safe/safe_signature.py b/gnosis/safe/safe_signature.py index 966ecce2b..c09e31500 100644 --- a/gnosis/safe/safe_signature.py +++ b/gnosis/safe/safe_signature.py @@ -250,7 +250,8 @@ def is_valid(self, ethereum_client: EthereumClient, safe_address: str) -> bool: ).call(block_identifier=block_identifier) == 1 ) - except BadFunctionCallOutput as e: # Error using `pending` block identifier + except (ValueError, BadFunctionCallOutput, DecodingError) as e: + # Error using `pending` block identifier exception = e raise exception # This should never happen diff --git a/requirements-test.txt b/requirements-test.txt index 40f64d985..cb68c6f9e 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ -r requirements.txt coverage==7.2.3 -faker==18.3.2 -pytest==7.3.0 +faker==18.4.0 +pytest==7.3.1 pytest-django==4.5.2 pytest-env==0.8.1 pytest-rerunfailures==11.1.2 diff --git a/requirements.txt b/requirements.txt index 1cf251cb2..c0894ebc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ django-filter==23.1 djangorestframework==3.14.0 hexbytes==0.2.3 packaging -psycopg2-binary==2.9.5 +psycopg2-binary==2.9.6 py-evm==0.5.0a3 pysha3>=1.0.2 requests==2.28.2 diff --git a/setup.cfg b/setup.cfg index 323e26817..c0e4b6ca5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = safe-eth-py -version = 5.1.0 +version = 5.2.1 description = Safe Ecosystem Foundation utilities for Ethereum projects long_description = file: README.rst long_description_content_type = text/x-rst; charset=UTF-8