eth-prototype 1.3.0b1__tar.gz → 1.3.0b2__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 (68) hide show
  1. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/PKG-INFO +7 -6
  2. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/setup.cfg +6 -5
  3. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/PKG-INFO +7 -6
  4. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/requires.txt +6 -5
  5. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/aa_bundler.py +19 -0
  6. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/w3wrappers.py +4 -4
  7. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/wrappers.py +1 -1
  8. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/conftest.py +3 -3
  9. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_w3.py +48 -5
  10. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tox.ini +1 -4
  11. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.coveragerc +0 -0
  12. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.github/workflows/publish.yaml +0 -0
  13. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.github/workflows/test.yaml +0 -0
  14. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.gitignore +0 -0
  15. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.isort.cfg +0 -0
  16. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.pre-commit-config.yaml +0 -0
  17. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/.readthedocs.yml +0 -0
  18. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/AUTHORS.rst +0 -0
  19. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/CHANGELOG.rst +0 -0
  20. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/LICENSE.txt +0 -0
  21. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/README.md +0 -0
  22. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/Makefile +0 -0
  23. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/_static/.gitignore +0 -0
  24. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/authors.rst +0 -0
  25. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/changelog.rst +0 -0
  26. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/conf.py +0 -0
  27. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/index.rst +0 -0
  28. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/license.rst +0 -0
  29. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/readme.rst +0 -0
  30. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/docs/requirements.txt +0 -0
  31. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/pyproject.toml +0 -0
  32. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/setup.py +0 -0
  33. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/SOURCES.txt +0 -0
  34. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/dependency_links.txt +0 -0
  35. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/not-zip-safe +0 -0
  36. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/eth_prototype.egg-info/top_level.txt +0 -0
  37. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/__init__.py +0 -0
  38. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/build_artifacts.py +0 -0
  39. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/contracts.py +0 -0
  40. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/defender_relay.py +0 -0
  41. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/test_utils/__init__.py +0 -0
  42. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/test_utils/factories.py +0 -0
  43. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/test_utils/hardhat.py +0 -0
  44. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/test_utils/vcr_utils.py +0 -0
  45. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/src/ethproto/wadray.py +0 -0
  46. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/__init__.py +0 -0
  47. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/cassettes/test_aa_bundler/test_build_user_operation.yaml +0 -0
  48. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/README.md +0 -0
  49. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/artifacts2/TestCurrency.sol/TestCurrency.json +0 -0
  50. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/Count.sol +0 -0
  51. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/Counter.sol +0 -0
  52. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/CounterUpgradeable.sol +0 -0
  53. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/CounterUpgradeableWithLibrary.sol +0 -0
  54. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/CounterWithLibrary.sol +0 -0
  55. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/Datatypes.sol +0 -0
  56. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/EventLauncher.sol +0 -0
  57. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/TestCurrency.sol +0 -0
  58. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/TestCurrencyUUPS.sol +0 -0
  59. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/contracts/TestNFT.sol +0 -0
  60. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/hardhat.config.js +0 -0
  61. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/package-lock.json +0 -0
  62. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/hardhat-project/package.json +0 -0
  63. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_aa_bundler.py +0 -0
  64. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_build_artifacts.py +0 -0
  65. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_contracts.py +0 -0
  66. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_defender.py +0 -0
  67. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_time_control.py +0 -0
  68. {eth_prototype-1.3.0b1 → eth_prototype-1.3.0b2}/tests/test_wadray.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eth-prototype
3
- Version: 1.3.0b1
3
+ Version: 1.3.0b2
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
@@ -26,14 +26,15 @@ Requires-Dist: boto3; extra == "defender"
26
26
  Provides-Extra: gmpy2
27
27
  Requires-Dist: gmpy2; extra == "gmpy2"
28
28
  Provides-Extra: testing
29
- Requires-Dist: setuptools; extra == "testing"
30
- Requires-Dist: pytest; extra == "testing"
29
+ Requires-Dist: boto3; extra == "testing"
30
+ Requires-Dist: factory-boy; extra == "testing"
31
31
  Requires-Dist: gmpy2; extra == "testing"
32
+ Requires-Dist: pytest; extra == "testing"
32
33
  Requires-Dist: pytest-cov; extra == "testing"
33
- Requires-Dist: web3[tester]==7.*; extra == "testing"
34
- Requires-Dist: boto3; extra == "testing"
34
+ Requires-Dist: pytest-mock; extra == "testing"
35
35
  Requires-Dist: pytest-recording; extra == "testing"
36
- Requires-Dist: factory-boy; extra == "testing"
36
+ Requires-Dist: setuptools; extra == "testing"
37
+ Requires-Dist: web3[tester]==7.*; extra == "testing"
37
38
 
38
39
  # eth-prototype
39
40
 
@@ -41,14 +41,15 @@ defender =
41
41
  gmpy2 =
42
42
  gmpy2
43
43
  testing =
44
- setuptools
45
- pytest
44
+ boto3
45
+ factory-boy
46
46
  gmpy2
47
+ pytest
47
48
  pytest-cov
48
- web3[tester]==7.*
49
- boto3
49
+ pytest-mock
50
50
  pytest-recording
51
- factory-boy
51
+ setuptools
52
+ web3[tester]==7.*
52
53
 
53
54
  [options.entry_points]
54
55
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eth-prototype
3
- Version: 1.3.0b1
3
+ Version: 1.3.0b2
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
@@ -26,14 +26,15 @@ Requires-Dist: boto3; extra == "defender"
26
26
  Provides-Extra: gmpy2
27
27
  Requires-Dist: gmpy2; extra == "gmpy2"
28
28
  Provides-Extra: testing
29
- Requires-Dist: setuptools; extra == "testing"
30
- Requires-Dist: pytest; extra == "testing"
29
+ Requires-Dist: boto3; extra == "testing"
30
+ Requires-Dist: factory-boy; extra == "testing"
31
31
  Requires-Dist: gmpy2; extra == "testing"
32
+ Requires-Dist: pytest; extra == "testing"
32
33
  Requires-Dist: pytest-cov; extra == "testing"
33
- Requires-Dist: web3[tester]==7.*; extra == "testing"
34
- Requires-Dist: boto3; extra == "testing"
34
+ Requires-Dist: pytest-mock; extra == "testing"
35
35
  Requires-Dist: pytest-recording; extra == "testing"
36
- Requires-Dist: factory-boy; extra == "testing"
36
+ Requires-Dist: setuptools; extra == "testing"
37
+ Requires-Dist: web3[tester]==7.*; extra == "testing"
37
38
 
38
39
  # eth-prototype
39
40
 
@@ -13,14 +13,15 @@ boto3
13
13
  gmpy2
14
14
 
15
15
  [testing]
16
- setuptools
17
- pytest
16
+ boto3
17
+ factory-boy
18
18
  gmpy2
19
+ pytest
19
20
  pytest-cov
20
- web3[tester]==7.*
21
- boto3
21
+ pytest-mock
22
22
  pytest-recording
23
- factory-boy
23
+ setuptools
24
+ web3[tester]==7.*
24
25
 
25
26
  [web3]
26
27
  web3==7.*
@@ -14,6 +14,7 @@ from eth_utils import add_0x_prefix, function_signature_to_4byte_selector
14
14
  from hexbytes import HexBytes
15
15
  from web3 import Web3
16
16
  from web3.constants import ADDRESS_ZERO
17
+ from web3.types import TxParams
17
18
 
18
19
  from .contracts import RevertError
19
20
 
@@ -94,6 +95,16 @@ class Tx:
94
95
  from_: HexAddress = ADDRESS_ZERO
95
96
  chain_id: int = None
96
97
 
98
+ @classmethod
99
+ def from_tx_params(cls, params: TxParams) -> "Tx":
100
+ return cls(
101
+ target=params["to"],
102
+ data=HexBytes(params["data"]),
103
+ value=params["value"],
104
+ from_=params.get("from", ADDRESS_ZERO),
105
+ chain_id=params.get("chainId", None),
106
+ )
107
+
97
108
  def as_execute_args(self):
98
109
  return [self.target, self.value, self.data]
99
110
 
@@ -320,6 +331,14 @@ class Bundler:
320
331
  self.base_gas_price_factor = base_gas_price_factor
321
332
  self.executor_pk = executor_pk
322
333
 
334
+ def __str__(self):
335
+ return (
336
+ f"Bundler(type={self.bundler_type}, entrypoint={self.entrypoint}, nonce_mode={self.nonce_mode}"
337
+ f"fixed_nonce_key={self.fixed_nonce_key}, verification_gas_factor={self.verification_gas_factor},"
338
+ f"gas_limit_factor={self.gas_limit_factor}, priority_gas_price_factor={self.priority_gas_price_factor},"
339
+ f"base_gas_price_factor={self.base_gas_price_factor})"
340
+ )
341
+
323
342
  def get_nonce_and_key(self, tx: Tx, fetch=False):
324
343
  nonce_key = tx.nonce_key
325
344
  nonce = tx.nonce
@@ -111,7 +111,7 @@ def transact(provider, function, tx_kwargs):
111
111
  }
112
112
  )
113
113
  signed_tx = from_.sign_transaction(tx)
114
- tx_hash = provider.w3.eth.send_raw_transaction(signed_tx.rawTransaction)
114
+ tx_hash = provider.w3.eth.send_raw_transaction(signed_tx.raw_transaction)
115
115
  elif W3_TRANSACT_MODE == "defender-async":
116
116
  from .defender_relay import send_transaction
117
117
 
@@ -211,8 +211,8 @@ class W3EnvAddressBook(AddressBook):
211
211
  if isinstance(name, (Account, LocalAccount)):
212
212
  return name
213
213
  if name is None:
214
- return self.ZERO
215
- if type(name) == str and name.startswith("0x"):
214
+ return list(self.signers.values())[0] if self.signers else self.ZERO
215
+ if isinstance(name, str) and name.startswith("0x"):
216
216
  return name
217
217
  if name in self.name_to_address:
218
218
  return self.name_to_address[name]
@@ -483,7 +483,7 @@ class W3Provider(BaseProvider):
483
483
  for lib, _ in contract_def.libraries():
484
484
  if lib not in libraries:
485
485
  library_def = self.get_contract_factory(lib)
486
- library = self.construct(library_def)
486
+ library = self.construct(library_def, transact_kwargs={"from": eth_wrapper.owner})
487
487
  libraries[lib] = library.address
488
488
 
489
489
  if libraries:
@@ -303,7 +303,7 @@ class ETHWrapper:
303
303
  constructor_args = None
304
304
  initialize_args = None
305
305
 
306
- def __init__(self, owner="owner", *init_params, **kwargs):
306
+ def __init__(self, owner=None, *init_params, **kwargs):
307
307
  self.provider_key = kwargs.get("provider_key", None)
308
308
  init_params = self._parse_init_params(init_params, kwargs)
309
309
  self.provider.init_eth_wrapper(self, owner, init_params, kwargs)
@@ -24,11 +24,11 @@ def local_node_provider(hardhat_node):
24
24
  if os.environ.get("TEST_ENV", None) == "web3py":
25
25
  from web3 import Web3
26
26
 
27
- from ethproto import w3wrappers, wrappers
27
+ from ethproto import w3wrappers
28
28
 
29
- wrappers.register_provider("w3", w3wrappers.W3Provider(Web3(Web3.HTTPProvider(hardhat_node))))
29
+ w3wrappers.register_w3_provider("w3", Web3(Web3.HTTPProvider(hardhat_node)))
30
30
  yield
31
- wrappers.register_provider("w3", w3wrappers.W3Provider(w3))
31
+ w3wrappers.register_w3_provider("w3", w3)
32
32
  return
33
33
  yield
34
34
 
@@ -1,8 +1,9 @@
1
1
  import os
2
2
 
3
3
  import pytest
4
+ from web3 import Web3
4
5
 
5
- from ethproto import wrappers
6
+ from ethproto import w3wrappers, wrappers
6
7
 
7
8
  pytestmark = [
8
9
  pytest.mark.skipif(os.environ.get("TEST_ENV", None) != "web3py", reason="web3py-only tests"),
@@ -36,7 +37,7 @@ class CounterUpgradeableWithLibrary(Counter):
36
37
 
37
38
  @pytest.mark.parametrize("contract_class", [Counter, CounterWithLibrary, CounterUpgradeableWithLibrary])
38
39
  def test_deploy_counter(contract_class):
39
- counter = contract_class(initial_value=0)
40
+ counter = contract_class(initial_value=0, owner="owner")
40
41
  assert counter.value() == 0
41
42
  counter.increase()
42
43
  assert counter.value() == 1
@@ -51,7 +52,7 @@ class Datatypes(wrappers.ETHWrapper):
51
52
  def test_address_arguments():
52
53
  from eth_account import Account
53
54
 
54
- wrapper = Datatypes()
55
+ wrapper = Datatypes(owner="owner")
55
56
 
56
57
  account = Account.create("TEST TEST TEST")
57
58
 
@@ -76,7 +77,7 @@ def test_wrapper_build_from_def():
76
77
  contract_def = provider.get_contract_def("Counter")
77
78
  wrapper = wrappers.ETHWrapper.build_from_def(contract_def)
78
79
 
79
- counter = wrapper(initialValue=0)
80
+ counter = wrapper(initialValue=0, owner="owner")
80
81
  assert counter.value() == 0
81
82
  counter.increase()
82
83
  assert counter.value() == 1
@@ -87,7 +88,7 @@ def test_get_events():
87
88
  contract_def = provider.get_contract_def("EventLauncher")
88
89
  wrapper = wrappers.ETHWrapper.build_from_def(contract_def)
89
90
 
90
- launcher = wrapper()
91
+ launcher = wrapper(owner="owner")
91
92
 
92
93
  launcher.launchEvent1(1)
93
94
 
@@ -109,3 +110,45 @@ def test_get_events():
109
110
  event2 = provider.get_events(launcher, "Event2")
110
111
  assert len(event2) == 1
111
112
  assert event2[0].args.value == 2
113
+
114
+
115
+ @pytest.fixture
116
+ def sign_and_send(mocker, hardhat_node):
117
+ """Sets up sign-and-send transact mode with a well-known address, returns the address"""
118
+ mocker.patch("ethproto.w3wrappers.W3_TRANSACT_MODE", "sign-and-send")
119
+ mocker.patch.dict(
120
+ os.environ,
121
+ {"W3_ADDR_HARDHAT_18": "0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0"},
122
+ )
123
+ # Force recreate the provider and its address book after patching the environment
124
+ w3wrappers.register_w3_provider("w3", Web3(Web3.HTTPProvider(hardhat_node)))
125
+ return "0xdD2FD4581271e230360230F9337D5c0430Bf44C0"
126
+
127
+
128
+ def test_sign_and_send(sign_and_send):
129
+ # Deploy a contract using sign-and-send
130
+ wrapper = Datatypes(owner="HARDHAT_18")
131
+
132
+ assert wrapper.echoAddress("HARDHAT_18") == "HARDHAT_18"
133
+ assert wrappers.get_provider("w3").address_book.get_account("HARDHAT_18") == sign_and_send
134
+
135
+
136
+ def test_sign_and_send_upgradeable(sign_and_send):
137
+ upgradeable = CounterUpgradeableWithLibrary(initial_value=0, owner="HARDHAT_18")
138
+ assert upgradeable.value() == 0
139
+ upgradeable.increase()
140
+ assert upgradeable.value() == 1
141
+
142
+
143
+ def test_sign_and_send_interact_with_existing_contract(sign_and_send):
144
+ counter = Counter(initial_value=0, owner="HARDHAT_18")
145
+ assert counter.value() == 0 # sanity check
146
+
147
+ connected = Counter.connect(counter.contract.address)
148
+
149
+ # Interactions with the connected contract work as expected
150
+ assert connected.value() == 0
151
+ connected.increase()
152
+ assert connected.value() == 1
153
+
154
+ assert counter.value() == 1 # sanity check
@@ -18,13 +18,10 @@ setenv =
18
18
  TOXINIDIR = {toxinidir}
19
19
  TEST_ENV = web3py
20
20
  WEB3_PROVIDER_URI = https://polygon-mainnet.g.alchemy.com/v2/FAKEY
21
+ W3_POA = no
21
22
  passenv =
22
23
  HOME
23
24
  WADRAY_USE_GMPY2
24
- W3_*
25
- TRANSACT_MODE
26
- WEB3_PROVIDER_URI
27
- WEB3_*
28
25
  extras =
29
26
  testing
30
27
  deps =