/ Docs
7.3
/

Context reference

dipdup.context.DipDupContext

class dipdup.context.DipDupContext(config, package, datasources, transactions)

Common execution context for handler and hook callbacks.

Parameters:
  • config (DipDupConfig) – DipDup configuration
  • package (DipDupPackage) – DipDup package
  • datasources (dict[str, Datasource[Any]]) – Mapping of available datasources
  • transactions (TransactionManager) – Transaction manager (don’t use it directly)
  • logger – Context-aware logger instance

dipdup.context.HandlerContext

class dipdup.context.HandlerContext(config, package, datasources, transactions, logger, handler_config, datasource)

Execution context of handler callbacks.

Parameters:
  • config (DipDupConfig) – DipDup configuration
  • package (DipDupPackage) – DipDup package
  • datasources (dict[str, Datasource[Any]]) – Mapping of available datasources
  • transactions (TransactionManager) – Transaction manager (don’t use it directly)
  • logger (FormattedLogger) – Context-aware logger instance
  • handler_config (HandlerConfig) – Configuration of the current handler
  • datasource (IndexDatasource[Any]) – Index datasource instance

dipdup.context.HookContext

class dipdup.context.HookContext(config, package, datasources, transactions, logger, hook_config)

Execution context of hook callbacks.

Parameters:
  • config (DipDupConfig) – DipDup configuration
  • package (DipDupPackage) – DipDup package
  • datasources (dict[str, Datasource[Any]]) – Mapping of available datasources
  • transactions (TransactionManager) – Transaction manager (don’t use it directly)
  • logger (FormattedLogger) – Context-aware logger instance
  • hook_config (HookConfig) – Configuration of the current hook

dipdup.context.DipDupContext.add_contract

async DipDupContext.add_contract(kind, name, address=None, typename=None, code_hash=None)

Adds contract to the inventory.

Parameters:
  • kind (Literal['tezos'] | ~typing.Literal['evm']) – Either ‘tezos’ or ‘evm’ allowed
  • 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
Return type:

None

dipdup.context.DipDupContext.add_index

async DipDupContext.add_index(name, template, values, first_level=0, last_level=0, state=None)

Adds a new index from template.

Parameters:
  • name (str) – Index name
  • template (str) – Index template to use
  • values (dict[str, Any]) – Mapping of values to fill template with
  • first_level (int) – First level to start indexing from
  • last_level (int) – Last level to index
  • state (Index | None) – Initial index state (dev only)
Return type:

None

dipdup.context.DipDupContext.execute_sql

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

dipdup.context.DipDupContext.execute_sql_query

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) – Values to pass to the query
Return type:

Any

dipdup.context.DipDupContext.fire_hook

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

dipdup.context.DipDupContext.get_coinbase_datasource

DipDupContext.get_coinbase_datasource(name)

Get coinbase datasource by name

Parameters:

name (str) – Name of the datasource

Return type:

CoinbaseDatasource

dipdup.context.DipDupContext.get_http_datasource

DipDupContext.get_http_datasource(name)

Get http datasource by name

Parameters:

name (str) – Name of the datasource

Return type:

HttpDatasource

dipdup.context.DipDupContext.get_ipfs_datasource

DipDupContext.get_ipfs_datasource(name)

Get ipfs datasource by name

Parameters:

name (str) – Name of the datasource

Return type:

IpfsDatasource

dipdup.context.DipDupContext.get_metadata_datasource

DipDupContext.get_metadata_datasource(name)

Get metadata datasource by name

Parameters:

name (str) – Name of the datasource

Return type:

TzipMetadataDatasource

dipdup.context.DipDupContext.get_tzkt_datasource

DipDupContext.get_tzkt_datasource(name)

Get tezos.tzkt datasource by name

Parameters:

name (str) –

Return type:

TzktDatasource

dipdup.context.DipDupContext.reindex

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

dipdup.context.DipDupContext.restart

async DipDupContext.restart()

Restart process and continue indexing.

Return type:

None

dipdup.context.DipDupContext.update_contract_metadata

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, Any] | None) – Contract metadata to insert/update
Return type:

None

dipdup.context.DipDupContext.update_token_metadata

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, Any] | None) – Token metadata to insert/update
Return type:

None

dipdup.context.HookContext.rollback

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

Help and tips -> Join our Discord
Ideas or suggestions -> Issue Tracker