eth-prototype 1.4.0__py3-none-any.whl → 1.4.1__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.4.0
3
+ Version: 1.4.1
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,18 +1,18 @@
1
- eth_prototype-1.4.0.dist-info/licenses/AUTHORS.rst,sha256=Ui-05yYXtDZxna6o1yNcfdm8Jt68UIDQ01osiLxlYlU,95
2
- eth_prototype-1.4.0.dist-info/licenses/LICENSE.txt,sha256=U_Q6_nDYDwZPIuhttHi37hXZ2qU2-HlV2geo9hzHXFw,1087
1
+ eth_prototype-1.4.1.dist-info/licenses/AUTHORS.rst,sha256=Ui-05yYXtDZxna6o1yNcfdm8Jt68UIDQ01osiLxlYlU,95
2
+ eth_prototype-1.4.1.dist-info/licenses/LICENSE.txt,sha256=U_Q6_nDYDwZPIuhttHi37hXZ2qU2-HlV2geo9hzHXFw,1087
3
3
  ethproto/__init__.py,sha256=YWkAFysBp4tZjLWWB2FFmp5yG23pUYhQvgQW9b3soXs,579
4
4
  ethproto/aa_bundler.py,sha256=W47fIA_w7orUu7yczfHPaHpUJRFh5op0YZHPgW3Iwik,17420
5
5
  ethproto/build_artifacts.py,sha256=3t-MTSFZU1pQtDwf65zNJkceWleLRlzcEo8CFpu4_6s,10031
6
6
  ethproto/contracts.py,sha256=R9lWKPe77jkPBXx798qhnVPWSFF2nhz4AaYowipNIBc,22625
7
7
  ethproto/defender_relay.py,sha256=05A8TfRZwiBhCpo924Pf9CjfKSir2Wvgg1p_asFxJbw,1777
8
- ethproto/w3wrappers.py,sha256=aA5yQ25d01s8gtWkGSxSEZlVRdq6JM1ceS3cfvSj4uM,22614
8
+ ethproto/w3wrappers.py,sha256=14_w4h_gxpLPvL18zbQRL9KvxXt4Tm5pCc9qZD4tLtM,22604
9
9
  ethproto/wadray.py,sha256=JBsu5KcyU9k70bDK03T2IY6qPVFO30WbYPhwrAHdXao,8262
10
10
  ethproto/wrappers.py,sha256=kqv6_1lPbRBlncaeMtXjas80GSxzErflN_KwawYyL3E,17725
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.4.0.dist-info/METADATA,sha256=HuMbngAMXmyOT_pWnyH7f3-uYJcE_1bNcvhT-Pw95eI,2695
16
- eth_prototype-1.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- eth_prototype-1.4.0.dist-info/top_level.txt,sha256=Dl0X7m6N1hxeo4JpGpSNqWC2gtsN0731g-DL1J0mpjc,9
18
- eth_prototype-1.4.0.dist-info/RECORD,,
15
+ eth_prototype-1.4.1.dist-info/METADATA,sha256=5AYCz9-qpNclDeljRLe4nRHZhTap4Ky1FhOHXUKwFyY,2695
16
+ eth_prototype-1.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ eth_prototype-1.4.1.dist-info/top_level.txt,sha256=Dl0X7m6N1hxeo4JpGpSNqWC2gtsN0731g-DL1J0mpjc,9
18
+ eth_prototype-1.4.1.dist-info/RECORD,,
ethproto/w3wrappers.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import os
2
- from collections import defaultdict
2
+ from itertools import groupby
3
3
  from typing import Iterator, List, Union
4
4
 
5
5
  from environs import Env
@@ -246,30 +246,27 @@ class ReceiptWrapper:
246
246
  self._receipt = receipt
247
247
  self._contract = contract
248
248
 
249
+ def _find_event(self, contract, topic0):
250
+ for event in contract.events:
251
+ evt = event()
252
+ if HexBytes(event_abi_to_log_topic(evt.abi)) == topic0:
253
+ return evt
254
+ return None # Not found
255
+
249
256
  @property
250
257
  def events(self):
251
258
  if not hasattr(self, "_events"):
252
- # Lookup the events in all known contracts
253
- addresses = [log.address for log in self._receipt.logs]
254
- contracts = {addr: _contract_map[addr] for addr in addresses if addr in _contract_map}
255
- topic_map = {
256
- HexBytes(event_abi_to_log_topic(event().abi)): event()
257
- for contract in contracts.values()
258
- for event in contract.events
259
+ addr_topic0 = [(log.address, log.topics[0] if log.topics else None) for log in self._receipt.logs]
260
+ # find uniq event types
261
+ events = {topic0: self._find_event(_contract_map[addr], topic0) for (addr, topic0) in addr_topic0}
262
+ parsed_logs = sum(
263
+ [list(evt.process_receipt(self._receipt)) for evt in events.values() if evt is not None], []
264
+ )
265
+ parsed_logs.sort(key=lambda x: x.event)
266
+ self._events = {
267
+ evt_name: EventItem(evt_name, [pl.args for pl in parsed_logs_for_evt_name])
268
+ for (evt_name, parsed_logs_for_evt_name) in groupby(parsed_logs, key=lambda x: x.event)
259
269
  }
260
-
261
- parsed_logs = []
262
- for log in self._receipt.logs:
263
- for topic in log.topics:
264
- if topic in topic_map:
265
- parsed_logs += topic_map[topic].process_receipt(self._receipt)
266
-
267
- evts = defaultdict(list)
268
- for evt in parsed_logs:
269
- evt_name = evt.event
270
- evt_params = evt.args
271
- evts[evt_name].append(evt_params)
272
- self._events = {k: EventItem(k, v) for k, v in evts.items()}
273
270
  return self._events
274
271
 
275
272
  def __getattr__(self, attr_name):