eth-prototype 1.3.2__py3-none-any.whl → 1.3.4__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eth-prototype
3
- Version: 1.3.2
3
+ Version: 1.3.4
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
@@ -33,6 +33,7 @@ Requires-Dist: pytest; extra == "testing"
33
33
  Requires-Dist: pytest-cov; extra == "testing"
34
34
  Requires-Dist: pytest-mock; extra == "testing"
35
35
  Requires-Dist: pytest-recording; extra == "testing"
36
+ Requires-Dist: responses; extra == "testing"
36
37
  Requires-Dist: setuptools; extra == "testing"
37
38
  Requires-Dist: web3[tester]==7.*; extra == "testing"
38
39
  Dynamic: license-file
@@ -1,18 +1,18 @@
1
- eth_prototype-1.3.2.dist-info/licenses/AUTHORS.rst,sha256=Ui-05yYXtDZxna6o1yNcfdm8Jt68UIDQ01osiLxlYlU,95
2
- eth_prototype-1.3.2.dist-info/licenses/LICENSE.txt,sha256=U_Q6_nDYDwZPIuhttHi37hXZ2qU2-HlV2geo9hzHXFw,1087
1
+ eth_prototype-1.3.4.dist-info/licenses/AUTHORS.rst,sha256=Ui-05yYXtDZxna6o1yNcfdm8Jt68UIDQ01osiLxlYlU,95
2
+ eth_prototype-1.3.4.dist-info/licenses/LICENSE.txt,sha256=U_Q6_nDYDwZPIuhttHi37hXZ2qU2-HlV2geo9hzHXFw,1087
3
3
  ethproto/__init__.py,sha256=YWkAFysBp4tZjLWWB2FFmp5yG23pUYhQvgQW9b3soXs,579
4
- ethproto/aa_bundler.py,sha256=yl-kgLtjIi4ratPquD0B71QtA29SNAwOiIOXNLvxCOk,16780
4
+ ethproto/aa_bundler.py,sha256=W47fIA_w7orUu7yczfHPaHpUJRFh5op0YZHPgW3Iwik,17420
5
5
  ethproto/build_artifacts.py,sha256=whIXEqnh5f89UYu4Cb3KDigGV7juUCbDnfZkg-SYMKA,9878
6
6
  ethproto/contracts.py,sha256=rNVbCK1hURy7lWKhzSdXgVWo3wx9O_Ghk-6PfgOsRNk,18662
7
7
  ethproto/defender_relay.py,sha256=05A8TfRZwiBhCpo924Pf9CjfKSir2Wvgg1p_asFxJbw,1777
8
8
  ethproto/w3wrappers.py,sha256=aA5yQ25d01s8gtWkGSxSEZlVRdq6JM1ceS3cfvSj4uM,22614
9
9
  ethproto/wadray.py,sha256=JBsu5KcyU9k70bDK03T2IY6qPVFO30WbYPhwrAHdXao,8262
10
- ethproto/wrappers.py,sha256=Mj2sgZmcLVmqsnNab6PqIXtNMMPyRVvUj2_8ButEd4w,17304
10
+ ethproto/wrappers.py,sha256=ggZxNBCC-EqgvR3qj4DdHPehewQ96FjXGemWl769DGc,17376
11
11
  ethproto/test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  ethproto/test_utils/factories.py,sha256=G8DnUDG_yThRxMTCkymzcjm9lR_ni0_ZmTsb3sEfIdI,1805
13
13
  ethproto/test_utils/hardhat.py,sha256=HzTqIznu6zVd_-doL96ftFJ235ktDCQen1QDQbNuwfM,2361
14
14
  ethproto/test_utils/vcr_utils.py,sha256=1FH2sgJlElSjWkJLuO3C7E2J-4HKyFvjAqkCnGRZJyk,797
15
- eth_prototype-1.3.2.dist-info/METADATA,sha256=vkIpd-qbMF_GtzUe4TW2_rwV9ypTQqxDW3V9uDhtIR8,2650
16
- eth_prototype-1.3.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
17
- eth_prototype-1.3.2.dist-info/top_level.txt,sha256=Dl0X7m6N1hxeo4JpGpSNqWC2gtsN0731g-DL1J0mpjc,9
18
- eth_prototype-1.3.2.dist-info/RECORD,,
15
+ eth_prototype-1.3.4.dist-info/METADATA,sha256=xZ2xRsL3AW-Un8yUO0Dh2uDMORYqdPtD8RdWAbTEKNs,2695
16
+ eth_prototype-1.3.4.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
17
+ eth_prototype-1.3.4.dist-info/top_level.txt,sha256=Dl0X7m6N1hxeo4JpGpSNqWC2gtsN0731g-DL1J0mpjc,9
18
+ eth_prototype-1.3.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
ethproto/aa_bundler.py CHANGED
@@ -29,6 +29,7 @@ AA_BUNDLER_GAS_LIMIT_FACTOR = env.float("AA_BUNDLER_GAS_LIMIT_FACTOR", 1)
29
29
  AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR = env.float("AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR", 1)
30
30
  AA_BUNDLER_BASE_GAS_PRICE_FACTOR = env.float("AA_BUNDLER_BASE_GAS_PRICE_FACTOR", 1)
31
31
  AA_BUNDLER_VERIFICATION_GAS_FACTOR = env.float("AA_BUNDLER_VERIFICATION_GAS_FACTOR", 1)
32
+ AA_BUNDLER_MAX_FEE_PER_GAS = env.int("AA_BUNDLER_MAX_FEE_PER_GAS", 200000000000) # 200 gwei
32
33
 
33
34
  AA_BUNDLER_STATE_OVERRIDES = env.json("AA_BUNDLER_STATE_OVERRIDES", default={})
34
35
 
@@ -329,6 +330,7 @@ class Bundler:
329
330
  gas_limit_factor: float = AA_BUNDLER_GAS_LIMIT_FACTOR,
330
331
  priority_gas_price_factor: float = AA_BUNDLER_PRIORITY_GAS_PRICE_FACTOR,
331
332
  base_gas_price_factor: float = AA_BUNDLER_BASE_GAS_PRICE_FACTOR,
333
+ max_fee_per_gas: int = AA_BUNDLER_MAX_FEE_PER_GAS,
332
334
  executor_pk: HexBytes = AA_BUNDLER_EXECUTOR_PK,
333
335
  overrides: StateOverride = AA_BUNDLER_STATE_OVERRIDES,
334
336
  ):
@@ -343,6 +345,7 @@ class Bundler:
343
345
  self.priority_gas_price_factor = priority_gas_price_factor
344
346
  self.base_gas_price_factor = base_gas_price_factor
345
347
  self.executor_pk = executor_pk
348
+ self.max_fee_per_gas = max_fee_per_gas
346
349
 
347
350
  # stateOverrideSet mapping to use when calling eth_estimateUserOperationGas
348
351
  # https://docs.alchemy.com/reference/eth-estimateuseroperationgas
@@ -353,7 +356,7 @@ class Bundler:
353
356
  f"Bundler(type={self.bundler_type}, entrypoint={self.entrypoint}, nonce_mode={self.nonce_mode}, "
354
357
  f"fixed_nonce_key={self.fixed_nonce_key}, verification_gas_factor={self.verification_gas_factor}, "
355
358
  f"gas_limit_factor={self.gas_limit_factor}, priority_gas_price_factor={self.priority_gas_price_factor}, "
356
- f"base_gas_price_factor={self.base_gas_price_factor})"
359
+ f"base_gas_price_factor={self.base_gas_price_factor}, max_fee_per_gas={self.max_fee_per_gas})"
357
360
  )
358
361
 
359
362
  def get_nonce_and_key(self, tx: Tx, fetch=False):
@@ -406,10 +409,17 @@ class Bundler:
406
409
  if "error" in resp:
407
410
  raise BundlerRevertError(resp["error"]["message"], response=resp)
408
411
  max_priority_fee_per_gas = int(int(resp["result"], 16) * self.priority_gas_price_factor)
409
- max_fee_per_gas = max_priority_fee_per_gas + self.get_base_fee()
412
+ max_fee_per_gas = min(max_priority_fee_per_gas + self.get_base_fee(), self.max_fee_per_gas)
410
413
 
411
414
  return GasPrice(max_priority_fee_per_gas=max_priority_fee_per_gas, max_fee_per_gas=max_fee_per_gas)
412
415
 
416
+ def generic_gas_price(self):
417
+ base_fee = self.get_base_fee()
418
+ priority_fee = self.w3.eth.max_priority_fee
419
+ max_priority_fee_per_gas = int(priority_fee * self.priority_gas_price_factor)
420
+ max_fee_per_gas = min(max_priority_fee_per_gas + base_fee, self.max_fee_per_gas)
421
+ return GasPrice(max_priority_fee_per_gas=max_priority_fee_per_gas, max_fee_per_gas=max_fee_per_gas)
422
+
413
423
  def build_user_operation(self, tx: Tx, retry_nonce=None) -> UserOperation:
414
424
  nonce_key, nonce = self.get_nonce_and_key(tx, fetch=retry_nonce is not None)
415
425
  # Consume the nonce, even if the userop may fail later
@@ -422,16 +432,15 @@ class Bundler:
422
432
 
423
433
  if self.bundler_type == "alchemy":
424
434
  gas_price = self.alchemy_gas_price()
425
- user_operation = user_operation.add_gas_price(gas_price)
426
435
 
427
436
  elif self.bundler_type == "generic":
428
- # At the moment generic just prices the gas at 0
429
- pass
437
+ gas_price = self.generic_gas_price()
430
438
 
431
439
  else:
432
440
  warn(f"Unknown bundler_type: {self.bundler_type}")
441
+ gas_price = GasPrice(0, 0)
433
442
 
434
- return user_operation
443
+ return user_operation.add_gas_price(gas_price)
435
444
 
436
445
  def send_transaction(self, tx: Tx, retry_nonce=None):
437
446
  user_operation = self.build_user_operation(tx, retry_nonce).sign(
ethproto/wrappers.py CHANGED
@@ -17,7 +17,7 @@ DEFAULT_PROVIDER = env.str("DEFAULT_PROVIDER", None)
17
17
 
18
18
  ETHERSCAN_TOKEN = env.str("ETHERSCAN_TOKEN", None)
19
19
  ETHERSCAN_DOMAIN = env.str("ETHERSCAN_DOMAIN", "api.etherscan.io")
20
- ETHERSCAN_URL = env.str("ETHERSCAN_URL", "https://{domain}/api?apikey={token}&")
20
+ ETHERSCAN_URL = env.str("ETHERSCAN_URL", "https://{domain}/v2/api?apikey={token}&chainid={chainid}&")
21
21
  AMOUNT_DECIMALS = env.int("AMOUNT_DECIMALS", 18)
22
22
  AMOUNT_CLASSNAME = env.str("AMOUNT_CLASSNAME", None)
23
23
 
@@ -266,7 +266,9 @@ class BaseProvider(ABC):
266
266
  def get_etherscan_url(self):
267
267
  if ETHERSCAN_TOKEN is None:
268
268
  return None
269
- return ETHERSCAN_URL.format(token=ETHERSCAN_TOKEN, domain=ETHERSCAN_DOMAIN)
269
+ return ETHERSCAN_URL.format(
270
+ token=ETHERSCAN_TOKEN, domain=ETHERSCAN_DOMAIN, chainid=self.w3.eth.chain_id
271
+ )
270
272
 
271
273
  def get_first_block(self, eth_wrapper):
272
274
  etherscan_url = self.get_etherscan_url()
@@ -275,7 +277,7 @@ class BaseProvider(ABC):
275
277
  address = self.get_contract_address(eth_wrapper)
276
278
  url = (
277
279
  etherscan_url
278
- + f"&module=account&action=txlist&address={address}&startblock=0&"
280
+ + f"module=account&action=txlist&address={address}&startblock=0&"
279
281
  + "endblock=99999999&page=1&offset=10&sort=asc"
280
282
  )
281
283
  resp = requests.get(url)