Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add starknet contracts in runtime #1140

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading