ContractEvent.processLog (and others?) break when used as classmethod
- Dominant language
- Python
- Stars
- 5.5k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 2
Description
### What was wrong?
When `ContractEvent.processLog()` is called (instead of `ContractEvent().processLog()`), you get this:
```
trinity/components/eth2/eth1_monitor/eth1_data_provider.py:126: in
self._deposit_contract.events.DepositEvent.processLog(log) for log in logs
venv-eth2-trio/lib/python3.6/site-packages/eth_utils/decorators.py:20: in _wrapper
return self.method(objtype, *args, **kwargs)
venv-eth2-trio/lib/python3.6/site-packages/web3/contract.py:1163: in processLog
return get_event_data(self.web3.codec, self.abi, log)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
abi_codec = , event_abi = None
log_entry = {'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b', 'blockHash': HexBytes('0xdf2ab0b165b14772ed33090fb6a9c20dfbf...0000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000', ...}
@curry
def get_event_data(abi_codec: ABICodec, event_abi: ABIEvent, log_entry: LogReceipt) -> EventData:
"""
Given an event ABI and a log entry for that event, return the decoded
event data
"""
> if event_abi['anonymous']:
E TypeError: 'NoneType' object is not subscriptable
```
### How can it be fixed?
The event ABI is only set on initialization, which doesn't make sense to me.
Maybe:
1. make `.abi` a `@property` that caches the result of `_get_event_abi()`
2. drop `.abi` altogether and use `_get_event_abi()` everywhere internally
3. set `.abi` when `ContractEvents` builds all its event attrs
I think my preference is # 1
Most importantly: add a test showing that this is broken, and make sure the test works by seeing it fail before implementing the fix.
Contributor guide
Assessment
This issue has not been assessed yet.