Context reference
Common execution context for handler and hook callbacks.
- Parameters:
- config (DipDupConfig) – DipDup configuration
- package (DipDupPackage) – DipDup package
- datasources (dict[str, dipdup.datasources.Datasource[dipdup.fields.Any]]) – Mapping of available datasources
- logger – Context-aware logger instance
- transactions (TransactionManager) –
- class dipdup.context.HandlerContext(config, package, datasources, transactions, logger, handler_config, datasource)¶
Execution context of handler callbacks.
- Parameters:
- handler_config (HandlerConfig) – Configuration of the current handler
- datasource (IndexDatasource[Any]) – Index datasource instance
- config (DipDupConfig) –
- package (DipDupPackage) –
- datasources (dict[str, dipdup.datasources.Datasource[dipdup.fields.Any]]) –
- transactions (TransactionManager) –
- logger (FormattedLogger) –
- class dipdup.context.HookContext(config, package, datasources, transactions, logger, hook_config)¶
Execution context of hook callbacks.
- Parameters:
- hook_config (HookConfig) – Configuration of the current hook
- config (DipDupConfig) –
- package (DipDupPackage) –
- datasources (dict[str, dipdup.datasources.Datasource[dipdup.fields.Any]]) –
- transactions (TransactionManager) –
- logger (FormattedLogger) –
- async DipDupContext.add_contract(kind, name, address=None, typename=None, code_hash=None)¶
Adds contract to the inventory.
- Parameters:
- name (str) – Contract name
- address (str | None) – Contract address
- typename (str | None) – Alias for the contract script
- code_hash (str | int | None) – Contract code hash
- kind (Literal['tezos'] | ~typing.Literal['evm']) – Either ‘tezos’ or ‘evm’ allowed
- Return type:
None
- async DipDupContext.add_index(name, template, values, first_level=0, last_level=0, state=None)¶
Adds a new contract to the inventory.
- Parameters:
- name (str) – Index name
- template (str) – Index template to use
- values (dict[str, dipdup.fields.Any]) – Mapping of values to fill template with
- first_level (int) –
- last_level (int) –
- state (Index | None) –
- Return type:
None
- async DipDupContext.execute_sql(name, *args, **kwargs)¶
Executes SQL script(s) with given name.
If the name path is a directory, all .sql scripts within it will be executed in alphabetical order.
- Parameters:
- name (str) – File or directory within project’s sql directory
- args (Any) – Positional arguments to pass to the script
- kwargs (Any) – Keyword arguments to pass to the script
- Return type:
None
- async DipDupContext.execute_sql_query(name, *values)¶
Executes SQL query with given name included with the project
- Parameters:
- name (str) – SQL query name within sql directory
- values (Any) –
- Return type:
Any
- async DipDupContext.fire_hook(name, fmt=None, wait=True, *args, **kwargs)¶
Fire hook with given name and arguments.
- Parameters:
- name (str) – Hook name
- fmt (str | None) – Format string for ctx.logger messages
- wait (bool) – Wait for hook to finish or fire and forget
- args (Any) – Positional arguments to pass to the hook
- kwargs (Any) – Keyword arguments to pass to the hook
- Return type:
None
- DipDupContext.get_coinbase_datasource(name)¶
Get coinbase datasource by name
- Parameters:
name (str) –
- Return type:
CoinbaseDatasource
- DipDupContext.get_http_datasource(name)¶
Get http datasource by name
- Parameters:
name (str) –
- Return type:
HttpDatasource
- DipDupContext.get_ipfs_datasource(name)¶
Get ipfs datasource by name
- Parameters:
name (str) –
- Return type:
IpfsDatasource
- DipDupContext.get_metadata_datasource(name)¶
Get metadata datasource by name
- Parameters:
name (str) –
- Return type:
TzipMetadataDatasource
- DipDupContext.get_tzkt_datasource(name)¶
Get tezos.tzkt datasource by name
- Parameters:
name (str) –
- Return type:
TzktDatasource
- async DipDupContext.reindex(reason=None, **context)¶
Drops the entire database and starts the indexing process from scratch.
- Parameters:
- reason (str | ReindexingReason | None) – Reason for reindexing in free-form string
- context (Any) – Additional information to include in exception message
- Return type:
None
- async DipDupContext.restart()¶
Restart process and continue indexing.
- Return type:
None
- async DipDupContext.update_contract_metadata(network, address, metadata)¶
Inserts or updates corresponding rows in the internal dipdup_contract_metadata table to provide a generic metadata interface (see docs).
- Parameters:
- network (str) – Network name (e.g. mainnet)
- address (str) – Contract address
- metadata (dict[str, dipdup.fields.Any] | None) – Contract metadata to insert/update
- Return type:
None
- async DipDupContext.update_token_metadata(network, address, token_id, metadata)¶
Inserts or updates corresponding rows in the internal dipdup_token_metadata table to provide a generic metadata interface (see docs).
- Parameters:
- network (str) – Network name (e.g. mainnet)
- address (str) – Contract address
- token_id (str) – Token ID
- metadata (dict[str, dipdup.fields.Any] | None) – Token metadata to insert/update
- Return type:
None
- async HookContext.rollback(index, from_level, to_level)¶
Rollback index to a given level reverting all changes made since that level.
- Parameters:
- index (str) – Index name
- from_level (int) – Level to rollback from
- to_level (int) – Level to rollback to
- Return type:
None