Skip to content

Commit

Permalink
Allow to add starknet contracts in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed Nov 21, 2024
1 parent bed745f commit 02592be
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/dipdup/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -239,15 +239,15 @@ 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,
code_hash: str | int | None = None,
) -> 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
Expand All @@ -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)

Expand Down

0 comments on commit 02592be

Please sign in to comment.