Skip to content

Commit

Permalink
Add zksync etherscan api
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Aug 31, 2023
1 parent 6a36fd8 commit 1ef36e8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gnosis/eth/clients/etherscan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class EtherscanClient:
EthereumNetwork.NEON_EVM_DEVNET: "https://devnet.neonscan.org",
EthereumNetwork.NEON_EVM_MAINNET: "https://neonscan.org",
EthereumNetwork.SEPOLIA: "https://sepolia.etherscan.io",
EthereumNetwork.ZKSYNC_V2: "https://explorer.zksync.io/",
}

NETWORK_WITH_API_URL = {
Expand Down Expand Up @@ -74,6 +75,7 @@ class EtherscanClient:
EthereumNetwork.NEON_EVM_DEVNET: "https://devnet-api.neonscan.org",
EthereumNetwork.NEON_EVM_MAINNET: "https://api.neonscan.org",
EthereumNetwork.SEPOLIA: "https://api-sepolia.etherscan.io",
EthereumNetwork.ZKSYNC_V2: "https://block-explorer-api.mainnet.zksync.io/",
}
HTTP_HEADERS = {
"User-Agent": "curl/7.77.0",
Expand Down
11 changes: 11 additions & 0 deletions gnosis/eth/tests/clients/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,17 @@
"version": 1,
}

etherscan_multisend_abi = [
{"inputs": [], "stateMutability": "nonpayable", "type": "constructor"},
{
"inputs": [{"internalType": "bytes", "name": "transactions", "type": "bytes"}],
"name": "multiSend",
"outputs": [],
"stateMutability": "payable",
"type": "function",
},
]


etherscan_source_code_mock = [
{
Expand Down
13 changes: 12 additions & 1 deletion gnosis/eth/tests/clients/test_etherscan_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.test import TestCase

import pytest

from ... import EthereumNetwork
from ...clients import EtherscanClient, EtherscanRateLimitError
from .mocks import sourcify_safe_metadata
from .mocks import etherscan_multisend_abi, sourcify_safe_metadata


class TestEtherscanClient(TestCase):
Expand All @@ -27,3 +29,12 @@ def test_etherscan_get_abi(self):
self.assertIsNone(etherscan_api.get_contract_metadata(random_address))
except EtherscanRateLimitError:
self.skipTest("Etherscan rate limit reached")

@pytest.mark.xfail(reason="Test might fail due to third-party service issues")
def test_etherscan_get_abi_zksync(self):
multisend_address = "0x0dFcccB95225ffB03c6FBB2559B530C2B7C8A912"
etherscan_api = EtherscanClient(EthereumNetwork(324))
self.assertEqual(
etherscan_api.get_contract_abi(multisend_address),
etherscan_multisend_abi,
)

0 comments on commit 1ef36e8

Please sign in to comment.