eth-prototype 1.3.4__tar.gz → 1.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/PKG-INFO +1 -1
  2. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/PKG-INFO +1 -1
  3. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/build_artifacts.py +4 -0
  4. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/wrappers.py +14 -6
  5. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_aa_bundler.py +13 -4
  6. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_build_artifacts.py +8 -0
  7. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.coveragerc +0 -0
  8. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.github/workflows/publish.yaml +0 -0
  9. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.github/workflows/test.yaml +0 -0
  10. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.gitignore +0 -0
  11. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.isort.cfg +0 -0
  12. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.pre-commit-config.yaml +0 -0
  13. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/.readthedocs.yml +0 -0
  14. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/AUTHORS.rst +0 -0
  15. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/CHANGELOG.rst +0 -0
  16. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/LICENSE.txt +0 -0
  17. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/README.md +0 -0
  18. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/Makefile +0 -0
  19. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/_static/.gitignore +0 -0
  20. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/authors.rst +0 -0
  21. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/changelog.rst +0 -0
  22. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/conf.py +0 -0
  23. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/index.rst +0 -0
  24. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/license.rst +0 -0
  25. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/readme.rst +0 -0
  26. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/docs/requirements.txt +0 -0
  27. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/pyproject.toml +0 -0
  28. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/setup.cfg +0 -0
  29. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/setup.py +0 -0
  30. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/SOURCES.txt +0 -0
  31. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/dependency_links.txt +0 -0
  32. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/not-zip-safe +0 -0
  33. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/requires.txt +0 -0
  34. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/eth_prototype.egg-info/top_level.txt +0 -0
  35. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/__init__.py +0 -0
  36. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/aa_bundler.py +0 -0
  37. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/contracts.py +0 -0
  38. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/defender_relay.py +0 -0
  39. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/test_utils/__init__.py +0 -0
  40. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/test_utils/factories.py +0 -0
  41. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/test_utils/hardhat.py +0 -0
  42. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/test_utils/vcr_utils.py +0 -0
  43. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/w3wrappers.py +0 -0
  44. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/src/ethproto/wadray.py +0 -0
  45. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/__init__.py +0 -0
  46. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/cassettes/test_aa_bundler/test_build_user_operation.yaml +0 -0
  47. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/conftest.py +0 -0
  48. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/README.md +0 -0
  49. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/artifacts2/TestCurrency.sol/TestCurrency.json +0 -0
  50. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/Count.sol +0 -0
  51. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/Counter.sol +0 -0
  52. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/CounterUpgradeable.sol +0 -0
  53. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/CounterUpgradeableWithLibrary.sol +0 -0
  54. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/CounterWithLibrary.sol +0 -0
  55. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/Datatypes.sol +0 -0
  56. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/EventLauncher.sol +0 -0
  57. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/TestCurrency.sol +0 -0
  58. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/TestCurrencyUUPS.sol +0 -0
  59. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/contracts/TestNFT.sol +0 -0
  60. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/hardhat.config.js +0 -0
  61. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/package-lock.json +0 -0
  62. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/package.json +0 -0
  63. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/verifiable-binaries/@anotherOrg/aPkg/1.0.2/build/contracts/TestCurrency.sol/TestCurrency.json +0 -0
  64. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/verifiable-binaries/@org/pkg/0.2.1/build/contracts/TestCurrency.json +0 -0
  65. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/hardhat-project/verifiable-binaries/@org/pkg/0.3.0/build/contracts/TestCurrency.json +0 -0
  66. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_contracts.py +0 -0
  67. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_defender.py +0 -0
  68. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_time_control.py +0 -0
  69. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_w3.py +0 -0
  70. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tests/test_wadray.py +0 -0
  71. {eth_prototype-1.3.4 → eth_prototype-1.3.6}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eth-prototype
3
- Version: 1.3.4
3
+ Version: 1.3.6
4
4
  Summary: Prototype Ethereum Smart Contracts in Python
5
5
  Home-page: https://github.com/gnarvaja/eth-prototype
6
6
  Author: Guillermo M. Narvaja
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eth-prototype
3
- Version: 1.3.4
3
+ Version: 1.3.6
4
4
  Summary: Prototype Ethereum Smart Contracts in Python
5
5
  Home-page: https://github.com/gnarvaja/eth-prototype
6
6
  Author: Guillermo M. Narvaja
@@ -250,6 +250,10 @@ class ArtifactLibrary:
250
250
  Calling with contract_ref <ContractClass>@local is the same as calling get_artifact_by_name(<ContractClass>).
251
251
  """
252
252
  ref = self._find_ref(contract_ref)
253
+ if ref is None:
254
+ by_name = self.get_artifact_by_name(contract_ref)
255
+ if by_name is not None:
256
+ return by_name
253
257
 
254
258
  if ref is None:
255
259
  raise FileNotFoundError(f"Could not find artifact for {contract_ref} on {self.lookup_paths}")
@@ -18,6 +18,8 @@ DEFAULT_PROVIDER = env.str("DEFAULT_PROVIDER", None)
18
18
  ETHERSCAN_TOKEN = env.str("ETHERSCAN_TOKEN", None)
19
19
  ETHERSCAN_DOMAIN = env.str("ETHERSCAN_DOMAIN", "api.etherscan.io")
20
20
  ETHERSCAN_URL = env.str("ETHERSCAN_URL", "https://{domain}/v2/api?apikey={token}&chainid={chainid}&")
21
+ ETHERSCAN_CHAIN_ID = env.int("ETHERSCAN_CHAIN_ID", None)
22
+
21
23
  AMOUNT_DECIMALS = env.int("AMOUNT_DECIMALS", 18)
22
24
  AMOUNT_CLASSNAME = env.str("AMOUNT_CLASSNAME", None)
23
25
 
@@ -31,6 +33,10 @@ MAXUINT256 = 2**256 - 1
31
33
  _providers = {}
32
34
 
33
35
 
36
+ class EtherscanError(Exception):
37
+ ...
38
+
39
+
34
40
  def get_provider(provider_key=None):
35
41
  global DEFAULT_PROVIDER
36
42
  provider_key = provider_key or DEFAULT_PROVIDER
@@ -266,9 +272,8 @@ class BaseProvider(ABC):
266
272
  def get_etherscan_url(self):
267
273
  if ETHERSCAN_TOKEN is None:
268
274
  return None
269
- return ETHERSCAN_URL.format(
270
- token=ETHERSCAN_TOKEN, domain=ETHERSCAN_DOMAIN, chainid=self.w3.eth.chain_id
271
- )
275
+ chain_id = ETHERSCAN_CHAIN_ID or self.w3.eth.chain_id
276
+ return ETHERSCAN_URL.format(token=ETHERSCAN_TOKEN, domain=ETHERSCAN_DOMAIN, chainid=chain_id)
272
277
 
273
278
  def get_first_block(self, eth_wrapper):
274
279
  etherscan_url = self.get_etherscan_url()
@@ -283,9 +288,12 @@ class BaseProvider(ABC):
283
288
  resp = requests.get(url)
284
289
  resp.raise_for_status()
285
290
  resp = resp.json()
286
- if not resp["result"]:
287
- return -1
288
- return int(resp["result"][0]["blockNumber"])
291
+ if resp.get("status") != "1":
292
+ raise EtherscanError(f"Failed to get first block from {etherscan_url}: {resp}")
293
+ try:
294
+ return int(resp["result"][0]["blockNumber"])
295
+ except (KeyError, TypeError):
296
+ raise EtherscanError(f"Failed to parse first block for {address}: {resp}")
289
297
 
290
298
  def get_contract_address(self, eth_wrapper):
291
299
  return eth_wrapper.contract.address
@@ -5,13 +5,21 @@ from unittest.mock import MagicMock, patch
5
5
 
6
6
  import pytest
7
7
  from hexbytes import HexBytes
8
- from web3.auto import w3
8
+ from web3 import HTTPProvider, Web3
9
9
  from web3.constants import HASH_ZERO
10
+ from web3.middleware import ExtraDataToPOAMiddleware
10
11
 
11
12
  from ethproto import aa_bundler
12
13
  from ethproto.test_utils import factories
13
14
 
14
15
 
16
+ @pytest.fixture
17
+ def w3():
18
+ w3 = Web3(HTTPProvider("http://example.org"))
19
+ w3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
20
+ return w3
21
+
22
+
15
23
  def test_pack_two():
16
24
  assert aa_bundler.pack_two(0, 0) == HASH_ZERO
17
25
  assert aa_bundler.pack_two(1, 2) == "0x0000000000000000000000000000000100000000000000000000000000000002"
@@ -166,8 +174,8 @@ def test_get_nonce_with_local_cache(fetch_nonce_mock, randint_mock):
166
174
  fetch_nonce_mock.assert_not_called()
167
175
 
168
176
 
169
- def test_send_transaction():
170
- w3 = MagicMock()
177
+ def test_send_transaction(w3):
178
+ w3.eth = MagicMock()
171
179
  w3.eth.chain_id = CHAIN_ID
172
180
 
173
181
  tx = aa_bundler.Tx(
@@ -275,7 +283,8 @@ def test_random_key_nonces_are_thread_safe():
275
283
 
276
284
 
277
285
  @pytest.mark.vcr
278
- def test_build_user_operation():
286
+ def test_build_user_operation(w3):
287
+
279
288
  tx = aa_bundler.Tx(
280
289
  value=0,
281
290
  chain_id=137,
@@ -125,6 +125,14 @@ def test_artifact_libraries_generator():
125
125
  assert libraries == []
126
126
 
127
127
 
128
+ def test_artifact_library_ref_lookup_fallback():
129
+ library = ArtifactLibrary(
130
+ os.path.join(HARDHAT_PROJECT, "artifacts", "contracts", "Counter.sol"),
131
+ )
132
+
133
+ assert library.get_artifact_by_ref("Counter") == library.get_artifact_by_name("Counter")
134
+
135
+
128
136
  def test_artifact_library_ref_lookup():
129
137
  library = ArtifactLibrary(
130
138
  os.path.join(HARDHAT_PROJECT, "artifacts"),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes