Skip to content

Commit

Permalink
notes
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Oct 30, 2024
1 parent 9fc2160 commit 839bd21
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dipdup/codegen/substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def event_metadata_to_jsonschema(
description = '\n'.join(metadata['docs']).replace(r'\[', '[').replace(r'\]', ']')
args_name = [a for a in metadata.get('args_name', ()) if a]
if not args_name:
args_name = extract_args_name(description)
args_name = extract_args_name(description) # type: ignore[assignment]
schema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'title': metadata['name'],
Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/config/substrate_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ def merge_subscriptions(self) -> bool:

@property
def rollback_depth(self) -> int:
# FIXME:
# FIXME: detect from node or/and document how to set it
return 0
1 change: 1 addition & 0 deletions src/dipdup/datasources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AbiDatasource(Datasource[DatasourceConfigT], Generic[DatasourceConfigT]):
async def get_abi(self, address: str) -> dict[str, Any]: ...


# FIXME: inconsistent usage
class IndexDatasource(Datasource[DatasourceConfigT], Generic[DatasourceConfigT]):
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions src/dipdup/datasources/substrate_subscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class SubstrateSubscanDatasource(AbiDatasource[SubstrateSubscanDatasourceConfig]):
# FIXME: not used in codegen
async def get_abi(self, address: str) -> dict[str, Any]:
raise NotImplementedError

Expand Down
7 changes: 6 additions & 1 deletion src/dipdup/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@
_EnumFieldT = TypeVar('_EnumFieldT', bound=Enum)


JSONField = partial(_JSONField, encoder=partial(json_dumps, option=None), decoder=orjson.loads) # type: ignore
# TODO: changelog
JSONField = partial(
_JSONField,
encoder=partial(json_dumps, option=None), # type: ignore[arg-type]
decoder=orjson.loads,
)


class EnumField(Field[_EnumFieldT]):
Expand Down
3 changes: 2 additions & 1 deletion src/dipdup/indexes/substrate_events/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from dipdup.config.substrate_events import SubstrateEventsHandlerConfig
from dipdup.config.substrate_events import SubstrateEventsIndexConfig
from dipdup.datasources.substrate_node import SubstrateNodeDatasource
from dipdup.datasources.substrate_subsquid import SubstrateSubsquidDatasource
from dipdup.indexes.substrate import SubstrateDatasource
from dipdup.indexes.substrate import SubstrateIndex
Expand Down Expand Up @@ -34,8 +35,8 @@ def __init__(
) -> None:
super().__init__(ctx, config, datasources)
self._names = tuple(c.name for c in self._config.handlers)
# FIXME: it's not EVM index
self.subsquid_datasources = tuple(d for d in datasources if isinstance(d, SubstrateSubsquidDatasource))
self.node_datasources = tuple(d for d in datasources if isinstance(d, SubstrateNodeDatasource))

async def _synchronize_subsquid(self, sync_level: int) -> None:
first_level = self.state.level + 1
Expand Down
1 change: 1 addition & 0 deletions src/dipdup/models/substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SubstrateEvent(Generic[PayloadT]):
data: SubstrateEventData
runtime: SubstrateRuntime

# TODO: could be used in other models with typed payload
@cached_property
def payload(self) -> PayloadT:
return cast(
Expand Down
5 changes: 3 additions & 2 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
_logger = logging.getLogger(__name__)


def extract_args_name(description: str) -> list[str]:
@cache
def extract_args_name(description: str) -> tuple[str, ...]:
pattern = r'\((.*?)\)|\[(.*?)\]'
match = re.search(pattern, description)

if not match:
raise ValueError('No valid bracket pairs found in the description')

args_str = match.group(1) or match.group(2)
return [arg.strip('\\') for arg in args_str.split(', ')]
return tuple(arg.strip('\\') for arg in args_str.split(', '))


@cache
Expand Down

0 comments on commit 839bd21

Please sign in to comment.