From 02592bed4867d6079ce43cd504c23ec349049c50 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Thu, 21 Nov 2024 17:00:26 +0000 Subject: [PATCH] Allow to add starknet contracts in runtime --- src/dipdup/context.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dipdup/context.py b/src/dipdup/context.py index e5d27812f..8ea74db8b 100644 --- a/src/dipdup/context.py +++ b/src/dipdup/context.py @@ -27,7 +27,7 @@ from dipdup.config.evm import EvmIndexConfig from dipdup.config.evm_events import EvmEventsIndexConfig from dipdup.config.evm_transactions import EvmTransactionsIndexConfig -from dipdup.config.starknet import StarknetIndexConfig +from dipdup.config.starknet import StarknetIndexConfig, StarknetContractConfig from dipdup.config.starknet_events import StarknetEventsIndexConfig from dipdup.config.tezos import TezosContractConfig from dipdup.config.tezos import TezosIndexConfig @@ -239,7 +239,7 @@ async def reindex( async def add_contract( self, - kind: Literal['tezos'] | Literal['evm'], + kind: Literal['tezos'] | Literal['evm'] | Literal['starknet'], name: str, address: str | None = None, typename: str | None = None, @@ -247,7 +247,7 @@ async def add_contract( ) -> None: """Adds contract to the inventory. - :param kind: Either 'tezos' or 'evm' allowed + :param kind: Either 'tezos' or 'evm' or 'starknet' allowed :param name: Contract name :param address: Contract address :param typename: Alias for the contract script @@ -274,6 +274,14 @@ async def add_contract( address=address, typename=typename, ) + elif kind == 'starknet': + if address is None: + raise ConfigurationError('Starknet contract address is required') + contract_config = StarknetContractConfig( + kind=kind, + address=address, + typename=typename, + ) else: raise NotImplementedError('Unknown contract kind', kind)