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 <genexpr>
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 = <eth_abi.codec.ABICodec object at 0x7fac05cae2e8>, 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:
- make
.abi a @property that caches the result of _get_event_abi()
- drop
.abi altogether and use _get_event_abi() everywhere internally
- 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.
What was wrong?
When
ContractEvent.processLog()is called (instead ofContractEvent().processLog()), you get this:How can it be fixed?
The event ABI is only set on initialization, which doesn't make sense to me.
Maybe:
.abia@propertythat caches the result of_get_event_abi().abialtogether and use_get_event_abi()everywhere internally.abiwhenContractEventsbuilds all its event attrsI 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.