Skip to content

Commit

Permalink
lint and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 9, 2025
1 parent 6a55938 commit bfe0274
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Releases prior to 7.0 has been removed from this file to declutter search result

### Fixed

- subsquid: Fixed float type for `timestamp` field on event / transaction deserialization.
- subsquid: Fixed empty field base conversion on event deserialization.
- evm: Fixed parsing tuple types in ABI.
- evm.subsquid: Fixed type of `timestamp` field of event/transaction models.
- evm.subsquid: Fixed empty field base conversion on event deserialization.

## [8.1.3] - 2024-12-20

Expand Down
3 changes: 3 additions & 0 deletions docs/9.release-notes/_8.0_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
- database: Fixed concurrency issue when using `get_or_create` method.
- evm.events: Fixed matching logs when filtering by topic0.
- evm.events: Improve fetching event batches from node.
- evm.subsquid: Fixed empty field base conversion on event deserialization.
- evm.subsquid: Fixed type of `timestamp` field of event/transaction models.
- evm.subsquid: Fixed typo in `iter_events` method name.
- evm: Fixed crash when contract ABI contains overloaded methods.
- evm: Fixed parsing tuple types in ABI.
- install: Fixed reinstalling package when `--force` flag is used.
- models: Fixed `CachedModel` preloading.
- models: Fixed setting default value for `Meta.maxsize`.
Expand Down
2 changes: 0 additions & 2 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

.. autoclass:: dipdup.config.DipDupConfig

.. autoclass:: dipdup.config.AbiDatasourceConfig
.. autoclass:: dipdup.config.abi_etherscan.AbiEtherscanDatasourceConfig
.. autoclass:: dipdup.config.AdvancedConfig
.. autoclass:: dipdup.config.ApiConfig
.. autoclass:: dipdup.config.coinbase.CoinbaseDatasourceConfig
.. autoclass:: dipdup.config.ContractConfig
.. autoclass:: dipdup.config.DatasourceConfig
.. autoclass:: dipdup.config.evm.EvmContractConfig
.. autoclass:: dipdup.config.evm_node.EvmNodeDatasourceConfig
.. autoclass:: dipdup.config.evm_events.EvmEventsHandlerConfig
Expand Down
4 changes: 2 additions & 2 deletions src/dipdup/abi/evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _convert_abi(abi_path: Path) -> EvmAbi:
EvmEventAbi(
name=abi_item['name'],
topic0=topic0_from_abi(abi_item),
inputs=inputs,
inputs=tuple(inputs),
topic_count=len([i for i in inputs if i[1]]),
)
)
Expand Down Expand Up @@ -195,7 +195,7 @@ def topic0_from_abi(event: dict[str, Any]) -> str:
raise FrameworkException(f'`{event["name"]}` is not an event')

types = []
from web3._utils.abi import collapse_if_tuple
from eth_utils.abi import collapse_if_tuple

for input in event['inputs']:
types.append(collapse_if_tuple(input))
Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/indexes/evm_transactions/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def prepare_transaction_handler_args(
name=handler_config.method,
signature=handler_config.signature,
)['inputs']
from web3._utils.abi import collapse_if_tuple
from eth_utils.abi import collapse_if_tuple

data = decode_abi(
types=tuple(collapse_if_tuple(input) for input in inputs),
Expand Down
10 changes: 7 additions & 3 deletions src/dipdup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,13 @@ def parse_object(

if nested:
for k, v in model_dict.items():
if isinstance(v, Sequence):
nested_type = type_.model_fields[k].annotation
model_dict[k] = parse_object(nested_type, v, plain=True)
if not isinstance(v, list | tuple):
continue

# NOTE: Might be `from_` or other reserved keyword
field_k = '{k}_ ' if k not in type_.model_fields else k
nested_type = type_.model_fields[field_k].annotation # type: ignore[arg-type]
model_dict[k] = parse_object(nested_type, v, plain=True)

return type_(**model_dict)
except ValidationError as e:
Expand Down

0 comments on commit bfe0274

Please sign in to comment.