diff --git a/moonstreamapi/configs/sample.env b/moonstreamapi/configs/sample.env index eae85085..e9a897fa 100644 --- a/moonstreamapi/configs/sample.env +++ b/moonstreamapi/configs/sample.env @@ -16,6 +16,7 @@ export MOONSTREAM_CRAWLERS_SERVER_PORT="" export MOONSTREAM_DATA_JOURNAL_ID="" export HUMBUG_TXPOOL_CLIENT_ID="" export MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_POLYGON_WEB3_PROVIDER_URI="https://" export MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI="https://" export MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI="https://" @@ -36,6 +37,8 @@ export MOONSTREAM_BLAST_WEB3_PROVIDER_URI="https:// export MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_MANTLE_WEB3_PROVIDER_URI="https://" export MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_QUERIES_JOURNAL_ID="" export MOONSTREAM_USAGE_REPORTS_JOURNAL_ID="" diff --git a/moonstreamapi/moonstreamapi/admin/subscription_types.py b/moonstreamapi/moonstreamapi/admin/subscription_types.py index f79efaad..c5e78ee9 100644 --- a/moonstreamapi/moonstreamapi/admin/subscription_types.py +++ b/moonstreamapi/moonstreamapi/admin/subscription_types.py @@ -29,6 +29,17 @@ stripe_price_id=None, active=True, ), + "sepolia_smartcontract": SubscriptionTypeResourceData( + id="sepolia_smartcontract", + name="Sepolia smartcontracts", + blockchain="sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Sepolia blockchain", + icon_url="https://static.simiotics.com/moonstream/assets/ethereum/eth-diamond-purple.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), "polygon_smartcontract": SubscriptionTypeResourceData( id="polygon_smartcontract", name="Polygon smartcontracts", @@ -227,6 +238,50 @@ stripe_price_id=None, active=True, ), + "mantle_smartcontract": SubscriptionTypeResourceData( + id="mantle_smartcontract", + name="Mantle smartcontract", + blockchain="mantle", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "mantle_sepolia_smartcontract": SubscriptionTypeResourceData( + id="mantle_sepolia_smartcontract", + name="Mantle Sepolia smartcontract", + blockchain="mantle_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle Sepolia blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-sepolia-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "imx_zkevm_smartcontract": SubscriptionTypeResourceData( + id="imx_zkevm_smartcontract", + name="Immutable zkEvm smartcontracts", + blockchain="imx_zkevm", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Immutable zkEvm blockchain", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "imx_zkevm_sepolia_smartcontract": SubscriptionTypeResourceData( + id="imx_zkevm_sepolia_smartcontract", + name="Immutable zkEvm Sepolia smartcontracts", + blockchain="imx_zkevm_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Immutable zkEvm Sepolia blockchain", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), "ethereum_blockchain": SubscriptionTypeResourceData( id="ethereum_blockchain", name="Ethereum transactions", @@ -260,28 +315,6 @@ stripe_price_id=None, active=False, ), - "mantle_smartcontract": SubscriptionTypeResourceData( - id="mantle_smartcontract", - name="Mantle smartcontract", - blockchain="mantle", - choices=["input:address", "tag:erc721"], - description="Contracts events and tx_calls of contract of Mantle blockchain.", - icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", - stripe_product_id=None, - stripe_price_id=None, - active=True, - ), - "mantle_sepolia_smartcontract": SubscriptionTypeResourceData( - id="mantle_sepolia_smartcontract", - name="Mantle Sepolia smartcontract", - blockchain="mantle_sepolia", - choices=["input:address", "tag:erc721"], - description="Contracts events and tx_calls of contract of Mantle Sepolia blockchain.", - icon_url="https://static.simiotics.com/moonstream/assets/mantle-sepolia-logo.png", - stripe_product_id=None, - stripe_price_id=None, - active=True, - ), "mumbai_blockchain": SubscriptionTypeResourceData( id="mumbai_blockchain", name="Mumbai transactions", @@ -514,6 +547,39 @@ stripe_price_id=None, active=False, ), + "sepolia_blockchain": SubscriptionTypeResourceData( + id="sepolia_blockchain", + name="Sepolia transactions", + blockchain="sepolia", + choices=["input:address", "tag:erc721"], + description="Sepolia chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/ethereum/eth-diamond-purple.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), + "imx_zkevm_blockchain": SubscriptionTypeResourceData( + id="imx_zkevm_blockchain", + name="Immutable zkEvm transactions", + blockchain="imx_zkevm", + choices=["input:address", "tag:erc721"], + description="Immutable zkEvm chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), + "imx_zkevm_sepolia_blockchain": SubscriptionTypeResourceData( + id="imx_zkevm_sepolia_blockchain", + name="Immutable zkEvm Sepolia transactions", + blockchain="imx_zkevm_sepolia", + choices=["input:address", "tag:erc721"], + description="Immutable zkEvm Sepolia chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), } diff --git a/moonstreamapi/moonstreamapi/settings.py b/moonstreamapi/moonstreamapi/settings.py index 3d1bc7c7..118f538d 100644 --- a/moonstreamapi/moonstreamapi/settings.py +++ b/moonstreamapi/moonstreamapi/settings.py @@ -107,6 +107,15 @@ raise ValueError( "MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI environment variable must be set" ) + +MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI == "": + raise ValueError( + "MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI environment variable must be set" + ) + MOONSTREAM_POLYGON_WEB3_PROVIDER_URI = os.environ.get( "MOONSTREAM_POLYGON_WEB3_PROVIDER_URI", "" ) @@ -159,7 +168,6 @@ "MOONSTREAM_ZKSYNC_ERA_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" ) - MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI = os.environ.get( "MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI", "" ) @@ -243,6 +251,22 @@ "MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" ) +MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI == "": + raise ValueError( + "MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI environment variable must be set" + ) + +MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI == "": + raise ValueError( + "MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI environment variable must be set" + ) + ## QueryAPI MOONSTREAM_S3_QUERIES_BUCKET = os.environ.get("MOONSTREAM_S3_QUERIES_BUCKET", "") diff --git a/moonstreamapi/moonstreamapi/version.py b/moonstreamapi/moonstreamapi/version.py index cc7eaf07..653faa76 100644 --- a/moonstreamapi/moonstreamapi/version.py +++ b/moonstreamapi/moonstreamapi/version.py @@ -2,4 +2,4 @@ Moonstream library and API version. """ -MOONSTREAMAPI_VERSION = "0.4.4" +MOONSTREAMAPI_VERSION = "0.4.5" diff --git a/moonstreamapi/moonstreamapi/web3_provider.py b/moonstreamapi/moonstreamapi/web3_provider.py index 7ebc15aa..b4ba719d 100644 --- a/moonstreamapi/moonstreamapi/web3_provider.py +++ b/moonstreamapi/moonstreamapi/web3_provider.py @@ -21,11 +21,14 @@ MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_BLAST_WEB3_PROVIDER_URI, MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI, + MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI, + MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI, MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_MANTLE_WEB3_PROVIDER_URI, MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI, MOONSTREAM_POLYGON_WEB3_PROVIDER_URI, MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI, + MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_WYRM_WEB3_PROVIDER_URI, MOONSTREAM_XAI_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_XAI_WEB3_PROVIDER_URI, @@ -75,6 +78,8 @@ def connect( if web3_uri is None: if blockchain_type == AvailableBlockchainType.ETHEREUM: web3_uri = MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.SEPOLIA: + web3_uri = MOONSTREAM_SEPOLIA_WEB3_PROVIDER_URI elif blockchain_type == AvailableBlockchainType.POLYGON: web3_uri = MOONSTREAM_POLYGON_WEB3_PROVIDER_URI elif blockchain_type == AvailableBlockchainType.MUMBAI: @@ -115,6 +120,10 @@ def connect( web3_uri = MOONSTREAM_MANTLE_WEB3_PROVIDER_URI elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: web3_uri = MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM: + web3_uri = MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: + web3_uri = MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI else: raise Exception("Wrong blockchain type provided for web3 URI") diff --git a/moonstreamapi/requirements.txt b/moonstreamapi/requirements.txt index 1bb95ee8..d49a32c8 100644 --- a/moonstreamapi/requirements.txt +++ b/moonstreamapi/requirements.txt @@ -38,7 +38,7 @@ Mako==1.2.3 MarkupSafe==2.1.1 moonstream==0.1.1 moonstreamdb==0.4.5 -moonstreamdb-v3==0.0.13 +moonstreamdb-v3==0.0.15 multiaddr==0.0.9 multidict==6.0.2 netaddr==0.8.0 diff --git a/moonstreamapi/setup.py b/moonstreamapi/setup.py index 4983a6cf..79c1f301 100644 --- a/moonstreamapi/setup.py +++ b/moonstreamapi/setup.py @@ -17,7 +17,7 @@ "fastapi", "moonstream", "moonstreamdb>=0.4.5", - "moonstreamdb-v3>=0.0.13", + "moonstreamdb-v3>=0.0.15", "humbug", "pydantic==1.10.2", "pyevmasm", diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py index b44365c1..88c4a2f3 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py @@ -1,9 +1,7 @@ from logging.config import fileConfig -from sqlalchemy import engine_from_config -from sqlalchemy import pool - from alembic import context +from sqlalchemy import engine_from_config, pool # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -27,30 +25,32 @@ # my_important_option = config.get_main_option("my_important_option") # ... etc. from moonstreamdbv3.models import ( - EthereumLabel, - SepoliaLabel, - PolygonLabel, - MumbaiLabel, AmoyLabel, - XDaiLabel, - ZkSyncEraLabel, - ZkSyncEraSepoliaLabel, - BaseLabel, ArbitrumNovaLabel, ArbitrumOneLabel, ArbitrumSepoliaLabel, - Game7OrbitArbitrumSepoliaLabel, - XaiLabel, - XaiSepoliaLabel, - AvalancheLabel, AvalancheFujiLabel, + AvalancheLabel, + BaseLabel, BlastLabel, BlastSepoliaLabel, + EthereumLabel, + Game7OrbitArbitrumSepoliaLabel, + ImxZkevmLabel, + ImxZkevmSepoliaLabel, + MantleLabel, + MantleSepoliaLabel, + MumbaiLabel, + PolygonLabel, ProofOfPlayApexLabel, + SepoliaLabel, StarknetLabel, StarknetSepoliaLabel, - MantleLabel, - MantleSepoliaLabel, + XaiLabel, + XaiSepoliaLabel, + XDaiLabel, + ZkSyncEraLabel, + ZkSyncEraSepoliaLabel, ) @@ -80,6 +80,8 @@ def include_symbol(tablename, schema): StarknetSepoliaLabel.__tablename__, MantleLabel.__tablename__, MantleSepoliaLabel.__tablename__, + ImxZkevmLabel.__tablename__, + ImxZkevmSepoliaLabel.__tablename__, } diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/versions/211646463e9f_immutable_zkevm_with_it_s_sepolia_.py b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/211646463e9f_immutable_zkevm_with_it_s_sepolia_.py new file mode 100644 index 00000000..d6a3b73e --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/211646463e9f_immutable_zkevm_with_it_s_sepolia_.py @@ -0,0 +1,122 @@ +"""Immutable zkEvm with it's sepolia blockchains + +Revision ID: 211646463e9f +Revises: 090c247f8618 +Create Date: 2024-07-25 14:14:41.548326 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = '211646463e9f' +down_revision: Union[str, None] = '090c247f8618' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('imx_zkevm_labels', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('label', sa.VARCHAR(length=256), nullable=False), + sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False), + sa.Column('log_index', sa.Integer(), nullable=True), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('caller_address', sa.LargeBinary(), nullable=True), + sa.Column('origin_address', sa.LargeBinary(), nullable=True), + sa.Column('address', sa.LargeBinary(), nullable=False), + sa.Column('label_name', sa.Text(), nullable=True), + sa.Column('label_type', sa.VARCHAR(length=64), nullable=True), + sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imx_zkevm_labels')), + sa.UniqueConstraint('id', name=op.f('uq_imx_zkevm_labels_id')) + ) + op.create_index('ix_imx_zkevm_labels_addr_block_num', 'imx_zkevm_labels', ['address', 'block_number'], unique=False) + op.create_index('ix_imx_zkevm_labels_addr_block_ts', 'imx_zkevm_labels', ['address', 'block_timestamp'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_address'), 'imx_zkevm_labels', ['address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_block_number'), 'imx_zkevm_labels', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_caller_address'), 'imx_zkevm_labels', ['caller_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_label'), 'imx_zkevm_labels', ['label'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_label_name'), 'imx_zkevm_labels', ['label_name'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_label_type'), 'imx_zkevm_labels', ['label_type'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_origin_address'), 'imx_zkevm_labels', ['origin_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_labels_transaction_hash'), 'imx_zkevm_labels', ['transaction_hash'], unique=False) + op.create_index('uk_imx_zkevm_labels_tx_hash_log_idx_evt', 'imx_zkevm_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'")) + op.create_index('uk_imx_zkevm_labels_tx_hash_log_idx_evt_raw', 'imx_zkevm_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.create_index('uk_imx_zkevm_labels_tx_hash_tx_call', 'imx_zkevm_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.create_index('uk_imx_zkevm_labels_tx_hash_tx_call_raw', 'imx_zkevm_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + op.create_table('imx_zkevm_sepolia_labels', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('label', sa.VARCHAR(length=256), nullable=False), + sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False), + sa.Column('log_index', sa.Integer(), nullable=True), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('caller_address', sa.LargeBinary(), nullable=True), + sa.Column('origin_address', sa.LargeBinary(), nullable=True), + sa.Column('address', sa.LargeBinary(), nullable=False), + sa.Column('label_name', sa.Text(), nullable=True), + sa.Column('label_type', sa.VARCHAR(length=64), nullable=True), + sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imx_zkevm_sepolia_labels')), + sa.UniqueConstraint('id', name=op.f('uq_imx_zkevm_sepolia_labels_id')) + ) + op.create_index('ix_imx_zkevm_sepolia_labels_addr_block_num', 'imx_zkevm_sepolia_labels', ['address', 'block_number'], unique=False) + op.create_index('ix_imx_zkevm_sepolia_labels_addr_block_ts', 'imx_zkevm_sepolia_labels', ['address', 'block_timestamp'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_address'), 'imx_zkevm_sepolia_labels', ['address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_block_number'), 'imx_zkevm_sepolia_labels', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_caller_address'), 'imx_zkevm_sepolia_labels', ['caller_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_label'), 'imx_zkevm_sepolia_labels', ['label'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_label_name'), 'imx_zkevm_sepolia_labels', ['label_name'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_label_type'), 'imx_zkevm_sepolia_labels', ['label_type'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_origin_address'), 'imx_zkevm_sepolia_labels', ['origin_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_labels_transaction_hash'), 'imx_zkevm_sepolia_labels', ['transaction_hash'], unique=False) + op.create_index('uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt', 'imx_zkevm_sepolia_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'")) + op.create_index('uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt_raw', 'imx_zkevm_sepolia_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.create_index('uk_imx_zkevm_sepolia_labels_tx_hash_tx_call', 'imx_zkevm_sepolia_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.create_index('uk_imx_zkevm_sepolia_labels_tx_hash_tx_call_raw', 'imx_zkevm_sepolia_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('uk_imx_zkevm_sepolia_labels_tx_hash_tx_call_raw', table_name='imx_zkevm_sepolia_labels', postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + op.drop_index('uk_imx_zkevm_sepolia_labels_tx_hash_tx_call', table_name='imx_zkevm_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.drop_index('uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt_raw', table_name='imx_zkevm_sepolia_labels', postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.drop_index('uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt', table_name='imx_zkevm_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='event'")) + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_transaction_hash'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_origin_address'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_label_type'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_label_name'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_label'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_caller_address'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_block_number'), table_name='imx_zkevm_sepolia_labels') + op.drop_index(op.f('ix_imx_zkevm_sepolia_labels_address'), table_name='imx_zkevm_sepolia_labels') + op.drop_index('ix_imx_zkevm_sepolia_labels_addr_block_ts', table_name='imx_zkevm_sepolia_labels') + op.drop_index('ix_imx_zkevm_sepolia_labels_addr_block_num', table_name='imx_zkevm_sepolia_labels') + op.drop_table('imx_zkevm_sepolia_labels') + op.drop_index('uk_imx_zkevm_labels_tx_hash_tx_call_raw', table_name='imx_zkevm_labels', postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + op.drop_index('uk_imx_zkevm_labels_tx_hash_tx_call', table_name='imx_zkevm_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.drop_index('uk_imx_zkevm_labels_tx_hash_log_idx_evt_raw', table_name='imx_zkevm_labels', postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.drop_index('uk_imx_zkevm_labels_tx_hash_log_idx_evt', table_name='imx_zkevm_labels', postgresql_where=sa.text("label='seer' and label_type='event'")) + op.drop_index(op.f('ix_imx_zkevm_labels_transaction_hash'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_origin_address'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_label_type'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_label_name'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_label'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_caller_address'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_block_number'), table_name='imx_zkevm_labels') + op.drop_index(op.f('ix_imx_zkevm_labels_address'), table_name='imx_zkevm_labels') + op.drop_index('ix_imx_zkevm_labels_addr_block_ts', table_name='imx_zkevm_labels') + op.drop_index('ix_imx_zkevm_labels_addr_block_num', table_name='imx_zkevm_labels') + op.drop_table('imx_zkevm_labels') + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py index 8a31d7f6..d095e166 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py @@ -1,9 +1,7 @@ from logging.config import fileConfig -from sqlalchemy import engine_from_config -from sqlalchemy import pool - from alembic import context +from sqlalchemy import engine_from_config, pool # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -28,44 +26,52 @@ # ... etc. from moonstreamdbv3.models_indexes import ( - EthereumBlockIndex, - EthereumTransactionIndex, - EthereumLogIndex, - EthereumReorgs, - PolygonBlockIndex, - PolygonTransactionIndex, - PolygonLogIndex, - PolygonReorgs, - XaiBlockIndex, - XaiTransactionIndex, - XaiLogIndex, - XaiReorgs, - XaiSepoliaBlockIndex, - XaiSepoliaTransactionIndex, - XaiSepoliaLogIndex, - XaiSepoliaReorgs, + AbiJobs, + AbiSubscriptions, ArbitrumOneBlockIndex, - ArbitrumOneTransactionIndex, ArbitrumOneLogIndex, ArbitrumOneReorgs, + ArbitrumOneTransactionIndex, ArbitrumSepoliaBlockIndex, - ArbitrumSepoliaTransactionIndex, ArbitrumSepoliaLogIndex, ArbitrumSepoliaReorgs, + ArbitrumSepoliaTransactionIndex, + EthereumBlockIndex, + EthereumLogIndex, + EthereumReorgs, + EthereumTransactionIndex, Game7OrbitArbitrumSepoliaBlockIndex, - Game7OrbitArbitrumSepoliaTransactionIndex, Game7OrbitArbitrumSepoliaLogIndex, Game7OrbitArbitrumSepoliaReorgs, + Game7OrbitArbitrumSepoliaTransactionIndex, + ImxZkevmBlockIndex, + ImxZkevmLogIndex, + ImxZkevmReorgs, + ImxZkevmSepoliaBlockIndex, + ImxZkevmSepoliaLogIndex, + ImxZkevmSepoliaReorgs, + ImxZkevmSepoliaTransactionIndex, + ImxZkevmTransactionIndex, MantleBlockIndex, - MantleTransactionIndex, MantleLogIndex, MantleReorgs, MantleSepoliaBlockIndex, - MantleSepoliaTransactionIndex, MantleSepoliaLogIndex, MantleSepoliaReorgs, - AbiJobs, - AbiSubscriptions, + MantleSepoliaTransactionIndex, + MantleTransactionIndex, + PolygonBlockIndex, + PolygonLogIndex, + PolygonReorgs, + PolygonTransactionIndex, + XaiBlockIndex, + XaiLogIndex, + XaiReorgs, + XaiSepoliaBlockIndex, + XaiSepoliaLogIndex, + XaiSepoliaReorgs, + XaiSepoliaTransactionIndex, + XaiTransactionIndex, ) @@ -109,6 +115,14 @@ def include_symbol(tablename, schema): MantleSepoliaReorgs.__tablename__, AbiJobs.__tablename__, AbiSubscriptions.__tablename__, + ImxZkevmBlockIndex.__tablename__, + ImxZkevmTransactionIndex.__tablename__, + ImxZkevmLogIndex.__tablename__, + ImxZkevmReorgs.__tablename__, + ImxZkevmSepoliaBlockIndex.__tablename__, + ImxZkevmSepoliaTransactionIndex.__tablename__, + ImxZkevmSepoliaLogIndex.__tablename__, + ImxZkevmSepoliaReorgs.__tablename__, } diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/a1ead76c0470_add_sepolia.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/a1ead76c0470_add_sepolia.py new file mode 100644 index 00000000..5bb9c5fa --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/a1ead76c0470_add_sepolia.py @@ -0,0 +1,276 @@ +"""Add sepolia + +Revision ID: a1ead76c0470 +Revises: f2c6aa92e5d2 +Create Date: 2024-07-22 14:07:22.992523 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "a1ead76c0470" +down_revision: Union[str, None] = "f2c6aa92e5d2" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "sepolia_blocks", + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_timestamp", sa.BigInteger(), nullable=False), + sa.Column("parent_hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("row_id", sa.BigInteger(), nullable=False), + sa.Column("path", sa.Text(), nullable=False), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.PrimaryKeyConstraint("block_number", name=op.f("pk_sepolia_blocks")), + ) + op.create_index( + op.f("ix_sepolia_blocks_block_number"), + "sepolia_blocks", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_blocks_block_timestamp"), + "sepolia_blocks", + ["block_timestamp"], + unique=False, + ) + op.create_table( + "sepolia_reorgs", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_sepolia_reorgs")), + ) + op.create_index( + op.f("ix_sepolia_reorgs_block_hash"), + "sepolia_reorgs", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_reorgs_block_number"), + "sepolia_reorgs", + ["block_number"], + unique=False, + ) + op.create_table( + "sepolia_transactions", + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("from_address", sa.LargeBinary(length=20), nullable=False), + sa.Column("to_address", sa.LargeBinary(length=20), nullable=False), + sa.Column("selector", sa.VARCHAR(length=256), nullable=True), + sa.Column("type", sa.Integer(), nullable=True), + sa.Column("row_id", sa.BigInteger(), nullable=False), + sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("index", sa.BigInteger(), nullable=False), + sa.Column("path", sa.Text(), nullable=False), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.ForeignKeyConstraint( + ["block_number"], + ["sepolia_blocks.block_number"], + name=op.f("fk_sepolia_transactions_block_number_sepolia_blocks"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("hash", name=op.f("pk_sepolia_transactions")), + ) + op.create_index( + op.f("ix_sepolia_transactions_block_hash"), + "sepolia_transactions", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_block_number"), + "sepolia_transactions", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_from_address"), + "sepolia_transactions", + ["from_address"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_hash"), + "sepolia_transactions", + ["hash"], + unique=True, + ) + op.create_index( + op.f("ix_sepolia_transactions_index"), + "sepolia_transactions", + ["index"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_selector"), + "sepolia_transactions", + ["selector"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_to_address"), + "sepolia_transactions", + ["to_address"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_transactions_type"), + "sepolia_transactions", + ["type"], + unique=False, + ) + op.create_table( + "sepolia_logs", + sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("address", sa.LargeBinary(length=20), nullable=False), + sa.Column("row_id", sa.BigInteger(), nullable=False), + sa.Column("selector", sa.VARCHAR(length=256), nullable=True), + sa.Column("topic1", sa.VARCHAR(length=256), nullable=True), + sa.Column("topic2", sa.VARCHAR(length=256), nullable=True), + sa.Column("topic3", sa.VARCHAR(length=256), nullable=True), + sa.Column("log_index", sa.BigInteger(), nullable=False), + sa.Column("path", sa.Text(), nullable=False), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.ForeignKeyConstraint( + ["transaction_hash"], + ["sepolia_transactions.hash"], + name=op.f("fk_sepolia_logs_transaction_hash_sepolia_transactions"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_sepolia_log_index" + ), + sa.UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_sepolia_log_index_transaction_hash_log_index", + ), + ) + op.create_index( + "idx_sepolia_logs_address_selector", + "sepolia_logs", + ["address", "selector"], + unique=False, + ) + op.create_index( + "idx_sepolia_logs_block_hash_log_index", + "sepolia_logs", + ["block_hash", "log_index"], + unique=True, + ) + op.create_index( + op.f("ix_sepolia_logs_address"), + "sepolia_logs", + ["address"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_logs_block_hash"), + "sepolia_logs", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_sepolia_logs_transaction_hash"), + "sepolia_logs", + ["transaction_hash"], + unique=False, + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index( + op.f("ix_sepolia_logs_transaction_hash"), + table_name="sepolia_logs", + ) + op.drop_index(op.f("ix_sepolia_logs_block_hash"), table_name="sepolia_logs") + op.drop_index(op.f("ix_sepolia_logs_address"), table_name="sepolia_logs") + op.drop_index( + "idx_sepolia_logs_block_hash_log_index", + table_name="sepolia_logs", + ) + op.drop_index("idx_sepolia_logs_address_selector", table_name="sepolia_logs") + op.drop_table("sepolia_logs") + op.drop_index( + op.f("ix_sepolia_transactions_type"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_to_address"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_selector"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_index"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_hash"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_from_address"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_block_number"), + table_name="sepolia_transactions", + ) + op.drop_index( + op.f("ix_sepolia_transactions_block_hash"), + table_name="sepolia_transactions", + ) + op.drop_table("sepolia_transactions") + op.drop_index( + op.f("ix_sepolia_reorgs_block_number"), + table_name="sepolia_reorgs", + ) + op.drop_index( + op.f("ix_sepolia_reorgs_block_hash"), + table_name="sepolia_reorgs", + ) + op.drop_table("sepolia_reorgs") + op.drop_index( + op.f("ix_sepolia_blocks_block_timestamp"), + table_name="sepolia_blocks", + ) + op.drop_index( + op.f("ix_sepolia_blocks_block_number"), + table_name="sepolia_blocks", + ) + op.drop_table("sepolia_blocks") + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/f19652e59bc5_immutable_zkevm_with_it_s_sepolia_.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/f19652e59bc5_immutable_zkevm_with_it_s_sepolia_.py new file mode 100644 index 00000000..3848860f --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/f19652e59bc5_immutable_zkevm_with_it_s_sepolia_.py @@ -0,0 +1,198 @@ +"""Immutable zkEvm with it's sepolia blockchains + +Revision ID: f19652e59bc5 +Revises: a1ead76c0470 +Create Date: 2024-07-25 11:34:09.513131 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'f19652e59bc5' +down_revision: Union[str, None] = 'a1ead76c0470' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('imx_zkevm_blocks', + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('block_number', name=op.f('pk_imx_zkevm_blocks')) + ) + op.create_index(op.f('ix_imx_zkevm_blocks_block_number'), 'imx_zkevm_blocks', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_blocks_block_timestamp'), 'imx_zkevm_blocks', ['block_timestamp'], unique=False) + op.create_table('imx_zkevm_reorgs', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imx_zkevm_reorgs')) + ) + op.create_index(op.f('ix_imx_zkevm_reorgs_block_hash'), 'imx_zkevm_reorgs', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_reorgs_block_number'), 'imx_zkevm_reorgs', ['block_number'], unique=False) + op.create_table('imx_zkevm_sepolia_blocks', + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('block_number', name=op.f('pk_imx_zkevm_sepolia_blocks')) + ) + op.create_index(op.f('ix_imx_zkevm_sepolia_blocks_block_number'), 'imx_zkevm_sepolia_blocks', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_blocks_block_timestamp'), 'imx_zkevm_sepolia_blocks', ['block_timestamp'], unique=False) + op.create_table('imx_zkevm_sepolia_reorgs', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imx_zkevm_sepolia_reorgs')) + ) + op.create_index(op.f('ix_imx_zkevm_sepolia_reorgs_block_hash'), 'imx_zkevm_sepolia_reorgs', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_reorgs_block_number'), 'imx_zkevm_sepolia_reorgs', ['block_number'], unique=False) + op.create_table('imx_zkevm_sepolia_transactions', + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('from_address', sa.LargeBinary(length=20), nullable=False), + sa.Column('to_address', sa.LargeBinary(length=20), nullable=False), + sa.Column('selector', sa.VARCHAR(length=256), nullable=True), + sa.Column('type', sa.Integer(), nullable=True), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('index', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.ForeignKeyConstraint(['block_number'], ['imx_zkevm_sepolia_blocks.block_number'], name=op.f('fk_imx_zkevm_sepolia_transactions_block_number_imx_zkevm_sepolia_blocks'), ondelete='CASCADE'), + sa.PrimaryKeyConstraint('hash', name=op.f('pk_imx_zkevm_sepolia_transactions')) + ) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_block_hash'), 'imx_zkevm_sepolia_transactions', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_block_number'), 'imx_zkevm_sepolia_transactions', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_from_address'), 'imx_zkevm_sepolia_transactions', ['from_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_hash'), 'imx_zkevm_sepolia_transactions', ['hash'], unique=True) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_index'), 'imx_zkevm_sepolia_transactions', ['index'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_selector'), 'imx_zkevm_sepolia_transactions', ['selector'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_to_address'), 'imx_zkevm_sepolia_transactions', ['to_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_transactions_type'), 'imx_zkevm_sepolia_transactions', ['type'], unique=False) + op.create_table('imx_zkevm_transactions', + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('from_address', sa.LargeBinary(length=20), nullable=False), + sa.Column('to_address', sa.LargeBinary(length=20), nullable=False), + sa.Column('selector', sa.VARCHAR(length=256), nullable=True), + sa.Column('type', sa.Integer(), nullable=True), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('index', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.ForeignKeyConstraint(['block_number'], ['imx_zkevm_blocks.block_number'], name=op.f('fk_imx_zkevm_transactions_block_number_imx_zkevm_blocks'), ondelete='CASCADE'), + sa.PrimaryKeyConstraint('hash', name=op.f('pk_imx_zkevm_transactions')) + ) + op.create_index(op.f('ix_imx_zkevm_transactions_block_hash'), 'imx_zkevm_transactions', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_block_number'), 'imx_zkevm_transactions', ['block_number'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_from_address'), 'imx_zkevm_transactions', ['from_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_hash'), 'imx_zkevm_transactions', ['hash'], unique=True) + op.create_index(op.f('ix_imx_zkevm_transactions_index'), 'imx_zkevm_transactions', ['index'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_selector'), 'imx_zkevm_transactions', ['selector'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_to_address'), 'imx_zkevm_transactions', ['to_address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_transactions_type'), 'imx_zkevm_transactions', ['type'], unique=False) + op.create_table('imx_zkevm_logs', + sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('address', sa.LargeBinary(length=20), nullable=False), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('selector', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic1', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic2', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic3', sa.VARCHAR(length=256), nullable=True), + sa.Column('log_index', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.ForeignKeyConstraint(['transaction_hash'], ['imx_zkevm_transactions.hash'], name=op.f('fk_imx_zkevm_logs_transaction_hash_imx_zkevm_transactions'), ondelete='CASCADE'), + sa.PrimaryKeyConstraint('transaction_hash', 'log_index', name='pk_imx_zkevm_log_index'), + sa.UniqueConstraint('transaction_hash', 'log_index', name='uq_imx_zkevm_log_index_transaction_hash_log_index') + ) + op.create_index('idx_imx_zkevm_logs_address_selector', 'imx_zkevm_logs', ['address', 'selector'], unique=False) + op.create_index('idx_imx_zkevm_logs_block_hash_log_index', 'imx_zkevm_logs', ['block_hash', 'log_index'], unique=True) + op.create_index(op.f('ix_imx_zkevm_logs_address'), 'imx_zkevm_logs', ['address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_logs_block_hash'), 'imx_zkevm_logs', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_logs_transaction_hash'), 'imx_zkevm_logs', ['transaction_hash'], unique=False) + op.create_table('imx_zkevm_sepolia_logs', + sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('address', sa.LargeBinary(length=20), nullable=False), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('selector', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic1', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic2', sa.VARCHAR(length=256), nullable=True), + sa.Column('topic3', sa.VARCHAR(length=256), nullable=True), + sa.Column('log_index', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.ForeignKeyConstraint(['transaction_hash'], ['imx_zkevm_sepolia_transactions.hash'], name=op.f('fk_imx_zkevm_sepolia_logs_transaction_hash_imx_zkevm_sepolia_transactions'), ondelete='CASCADE'), + sa.PrimaryKeyConstraint('transaction_hash', 'log_index', name='pk_imx_zkevm_sepolia_log_index'), + sa.UniqueConstraint('transaction_hash', 'log_index', name='uq_imx_zkevm_sepolia_log_index_transaction_hash_log_index') + ) + op.create_index('idx_imx_zkevm_sepolia_logs_address_selector', 'imx_zkevm_sepolia_logs', ['address', 'selector'], unique=False) + op.create_index('idx_imx_zkevm_sepolia_logs_block_hash_log_index', 'imx_zkevm_sepolia_logs', ['block_hash', 'log_index'], unique=True) + op.create_index(op.f('ix_imx_zkevm_sepolia_logs_address'), 'imx_zkevm_sepolia_logs', ['address'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_logs_block_hash'), 'imx_zkevm_sepolia_logs', ['block_hash'], unique=False) + op.create_index(op.f('ix_imx_zkevm_sepolia_logs_transaction_hash'), 'imx_zkevm_sepolia_logs', ['transaction_hash'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_imx_zkevm_sepolia_logs_transaction_hash'), table_name='imx_zkevm_sepolia_logs') + op.drop_index(op.f('ix_imx_zkevm_sepolia_logs_block_hash'), table_name='imx_zkevm_sepolia_logs') + op.drop_index(op.f('ix_imx_zkevm_sepolia_logs_address'), table_name='imx_zkevm_sepolia_logs') + op.drop_index('idx_imx_zkevm_sepolia_logs_block_hash_log_index', table_name='imx_zkevm_sepolia_logs') + op.drop_index('idx_imx_zkevm_sepolia_logs_address_selector', table_name='imx_zkevm_sepolia_logs') + op.drop_table('imx_zkevm_sepolia_logs') + op.drop_index(op.f('ix_imx_zkevm_logs_transaction_hash'), table_name='imx_zkevm_logs') + op.drop_index(op.f('ix_imx_zkevm_logs_block_hash'), table_name='imx_zkevm_logs') + op.drop_index(op.f('ix_imx_zkevm_logs_address'), table_name='imx_zkevm_logs') + op.drop_index('idx_imx_zkevm_logs_block_hash_log_index', table_name='imx_zkevm_logs') + op.drop_index('idx_imx_zkevm_logs_address_selector', table_name='imx_zkevm_logs') + op.drop_table('imx_zkevm_logs') + op.drop_index(op.f('ix_imx_zkevm_transactions_type'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_to_address'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_selector'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_index'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_hash'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_from_address'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_block_number'), table_name='imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_transactions_block_hash'), table_name='imx_zkevm_transactions') + op.drop_table('imx_zkevm_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_type'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_to_address'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_selector'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_index'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_hash'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_from_address'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_block_number'), table_name='imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_transactions_block_hash'), table_name='imx_zkevm_sepolia_transactions') + op.drop_table('imx_zkevm_sepolia_transactions') + op.drop_index(op.f('ix_imx_zkevm_sepolia_reorgs_block_number'), table_name='imx_zkevm_sepolia_reorgs') + op.drop_index(op.f('ix_imx_zkevm_sepolia_reorgs_block_hash'), table_name='imx_zkevm_sepolia_reorgs') + op.drop_table('imx_zkevm_sepolia_reorgs') + op.drop_index(op.f('ix_imx_zkevm_sepolia_blocks_block_timestamp'), table_name='imx_zkevm_sepolia_blocks') + op.drop_index(op.f('ix_imx_zkevm_sepolia_blocks_block_number'), table_name='imx_zkevm_sepolia_blocks') + op.drop_table('imx_zkevm_sepolia_blocks') + op.drop_index(op.f('ix_imx_zkevm_reorgs_block_number'), table_name='imx_zkevm_reorgs') + op.drop_index(op.f('ix_imx_zkevm_reorgs_block_hash'), table_name='imx_zkevm_reorgs') + op.drop_table('imx_zkevm_reorgs') + op.drop_index(op.f('ix_imx_zkevm_blocks_block_timestamp'), table_name='imx_zkevm_blocks') + op.drop_index(op.f('ix_imx_zkevm_blocks_block_number'), table_name='imx_zkevm_blocks') + op.drop_table('imx_zkevm_blocks') + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/blockchain.py b/moonstreamdb-v3/moonstreamdbv3/blockchain.py index 094ff305..fa89db91 100644 --- a/moonstreamdb-v3/moonstreamdbv3/blockchain.py +++ b/moonstreamdb-v3/moonstreamdbv3/blockchain.py @@ -36,6 +36,7 @@ class AvailableBlockchainType(Enum): MUMBAI = "mumbai" AMOY = "amoy" XDAI = "xdai" + SEPOLIA = "sepolia" ZKSYNC_ERA = "zksync_era" ZKSYNC_ERA_TESTNET = "zksync_era_testnet" ZKSYNC_ERA_SEPOLIA = "zksync_era_sepolia" @@ -119,6 +120,8 @@ def get_label_model(blockchain_type: AvailableBlockchainType) -> Type[ if blockchain_type == AvailableBlockchainType.ETHEREUM: label_model = EthereumLabel + elif blockchain_type == AvailableBlockchainType.SEPOLIA: + label_model = SepoliaLabel elif blockchain_type == AvailableBlockchainType.POLYGON: label_model = PolygonLabel elif blockchain_type == AvailableBlockchainType.MUMBAI: diff --git a/moonstreamdb-v3/moonstreamdbv3/models.py b/moonstreamdb-v3/moonstreamdbv3/models.py index 99a3f3c5..b7cdcc91 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models.py +++ b/moonstreamdb-v3/moonstreamdbv3/models.py @@ -24,9 +24,9 @@ DateTime, Index, Integer, + LargeBinary, MetaData, Text, - LargeBinary, ) from sqlalchemy.dialects.postgresql import JSONB, UUID from sqlalchemy.ext.compiler import compiles @@ -1197,3 +1197,93 @@ class MantleSepoliaLabel(EvmBasedLabel): # type: ignore postgresql_where=text("label='seer-raw' and label_type='event'"), ), ) + + +class ImxZkevmLabel(EvmBasedLabel): # type: ignore + __tablename__ = "imx_zkevm_labels" + + __table_args__ = ( + Index( + "ix_imx_zkevm_labels_addr_block_num", + "address", + "block_number", + unique=False, + ), + Index( + "ix_imx_zkevm_labels_addr_block_ts", + "address", + "block_timestamp", + unique=False, + ), + Index( + "uk_imx_zkevm_labels_tx_hash_tx_call", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer' and label_type='tx_call'"), + ), + Index( + "uk_imx_zkevm_labels_tx_hash_log_idx_evt", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer' and label_type='event'"), + ), + Index( + "uk_imx_zkevm_labels_tx_hash_tx_call_raw", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='tx_call'"), + ), + Index( + "uk_imx_zkevm_labels_tx_hash_log_idx_evt_raw", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='event'"), + ), + ) + + +class ImxZkevmSepoliaLabel(EvmBasedLabel): # type: ignore + __tablename__ = "imx_zkevm_sepolia_labels" + + __table_args__ = ( + Index( + "ix_imx_zkevm_sepolia_labels_addr_block_num", + "address", + "block_number", + unique=False, + ), + Index( + "ix_imx_zkevm_sepolia_labels_addr_block_ts", + "address", + "block_timestamp", + unique=False, + ), + Index( + "uk_imx_zkevm_sepolia_labels_tx_hash_tx_call", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer' and label_type='tx_call'"), + ), + Index( + "uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer' and label_type='event'"), + ), + Index( + "uk_imx_zkevm_sepolia_labels_tx_hash_tx_call_raw", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='tx_call'"), + ), + Index( + "uk_imx_zkevm_sepolia_labels_tx_hash_log_idx_evt_raw", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='event'"), + ), + ) diff --git a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py index 439e654b..d67d25c0 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py +++ b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py @@ -153,6 +153,62 @@ class EthereumReorgs(EvmBasedReorgs): __tablename__ = "ethereum_reorgs" +### Sepolia + + +class SepoliaBlockIndex(EvmBasedBlocks): + __tablename__ = "sepolia_blocks" + + +class SepoliaTransactionIndex(EvmBasedTransactions): + __tablename__ = "sepolia_transactions" + + block_number = Column( + BigInteger, + ForeignKey("sepolia_blocks.block_number", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class SepoliaLogIndex(EvmBasedLogs): + + __tablename__ = "sepolia_logs" + + __table_args__ = ( + Index( + "idx_sepolia_logs_address_selector", + "address", + "selector", + unique=False, + ), + Index( + "idx_sepolia_logs_block_hash_log_index", + "block_hash", + "log_index", + unique=True, + ), + UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_sepolia_log_index_transaction_hash_log_index", + ), + PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_sepolia_log_index" + ), + ) + transaction_hash = Column( + VARCHAR(256), + ForeignKey("sepolia_transactions.hash", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class SepoliaReorgs(EvmBasedReorgs): + __tablename__ = "sepolia_reorgs" + + ### Polygon @@ -559,6 +615,116 @@ class MantleSepoliaReorgs(EvmBasedReorgs): __tablename__ = "mantle_sepolia_reorgs" +### Immutable zkEvm + + +class ImxZkevmBlockIndex(EvmBasedBlocks): + __tablename__ = "imx_zkevm_blocks" + + +class ImxZkevmTransactionIndex(EvmBasedTransactions): + __tablename__ = "imx_zkevm_transactions" + + block_number = Column( + BigInteger, + ForeignKey("imx_zkevm_blocks.block_number", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class ImxZkevmLogIndex(EvmBasedLogs): + __tablename__ = "imx_zkevm_logs" + + __table_args__ = ( + Index( + "idx_imx_zkevm_logs_address_selector", + "address", + "selector", + unique=False, + ), + Index( + "idx_imx_zkevm_logs_block_hash_log_index", + "block_hash", + "log_index", + unique=True, + ), + UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_imx_zkevm_log_index_transaction_hash_log_index", + ), + PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_imx_zkevm_log_index" + ), + ) + transaction_hash = Column( + VARCHAR(256), + ForeignKey("imx_zkevm_transactions.hash", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class ImxZkevmReorgs(EvmBasedReorgs): + __tablename__ = "imx_zkevm_reorgs" + + +### Immutable zkEvm Sepolia + + +class ImxZkevmSepoliaBlockIndex(EvmBasedBlocks): + __tablename__ = "imx_zkevm_sepolia_blocks" + + +class ImxZkevmSepoliaTransactionIndex(EvmBasedTransactions): + __tablename__ = "imx_zkevm_sepolia_transactions" + + block_number = Column( + BigInteger, + ForeignKey("imx_zkevm_sepolia_blocks.block_number", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class ImxZkevmSepoliaLogIndex(EvmBasedLogs): + __tablename__ = "imx_zkevm_sepolia_logs" + + __table_args__ = ( + Index( + "idx_imx_zkevm_sepolia_logs_address_selector", + "address", + "selector", + unique=False, + ), + Index( + "idx_imx_zkevm_sepolia_logs_block_hash_log_index", + "block_hash", + "log_index", + unique=True, + ), + UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_imx_zkevm_sepolia_log_index_transaction_hash_log_index", + ), + PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_imx_zkevm_sepolia_log_index" + ), + ) + transaction_hash = Column( + VARCHAR(256), + ForeignKey("imx_zkevm_sepolia_transactions.hash", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class ImxZkevmSepoliaReorgs(EvmBasedReorgs): + __tablename__ = "imx_zkevm_sepolia_reorgs" + + ### ABI Jobs diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index 9789c4cc..ceddfb28 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.0.14 +0.0.15 diff --git a/types/python/moonstreamtypes/blockchain.py b/types/python/moonstreamtypes/blockchain.py index 54a86074..df4116f5 100644 --- a/types/python/moonstreamtypes/blockchain.py +++ b/types/python/moonstreamtypes/blockchain.py @@ -79,6 +79,8 @@ from moonstreamdbv3.models import ( Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3, ) +from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3 +from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3 from moonstreamdbv3.models import MantleLabel as MantleLabelV3 from moonstreamdbv3.models import MantleSepoliaLabel as MantleSepoliaLabelV3 from moonstreamdbv3.models import MumbaiLabel as MumbaiLabelV3 @@ -121,6 +123,8 @@ class AvailableBlockchainType(Enum): STARKNET_SEPOLIA = "starknet_sepolia" MANTLE = "mantle" MANTLE_SEPOLIA = "mantle_sepolia" + IMX_ZKEVM = "imx_zkevm" + IMX_ZKEVM_SEPOLIA = "imx_zkevm_sepolia" def get_block_model( @@ -276,6 +280,8 @@ def get_label_model( StarknetSepoliaLabelV3, MantleLabelV3, MantleSepoliaLabelV3, + ImxZkevmLabelV3, + ImxZkevmSepoliaLabelV3, ] ]: """ @@ -332,6 +338,8 @@ def get_label_model( StarknetSepoliaLabelV3, MantleLabelV3, MantleSepoliaLabelV3, + ImxZkevmLabelV3, + ImxZkevmSepoliaLabelV3, ] ] if version == 2: @@ -428,6 +436,10 @@ def get_label_model( label_model = MantleLabelV3 elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: label_model = MantleSepoliaLabelV3 + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM: + label_model = ImxZkevmLabelV3 + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: + label_model = ImxZkevmSepoliaLabelV3 else: raise Exception("Unsupported blockchain type provided") else: diff --git a/types/python/moonstreamtypes/networks.py b/types/python/moonstreamtypes/networks.py index f7738b84..cd9c65be 100644 --- a/types/python/moonstreamtypes/networks.py +++ b/types/python/moonstreamtypes/networks.py @@ -80,6 +80,8 @@ from moonstreamdbv3.models import ( Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3, ) +from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3 +from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3 from moonstreamdbv3.models import MantleLabel as MantleLabelV3 from moonstreamdbv3.models import MantleSepoliaLabel as MantleSepoliaLabelV3 from moonstreamdbv3.models import MumbaiLabel as MumbaiLabelV3 @@ -124,6 +126,8 @@ class Network(Enum): starknet_sepolia = "starknet_sepolia" mantle = "mantle" mantle_sepolia = "mantle_sepolia" + imx_zkevm = "imx_zkevm" + imx_zkevm_sepolia = "imx_zkevm_sepolia" tx_raw_types = Union[ @@ -331,9 +335,16 @@ class Network(Enum): Network.mantle_sepolia: { "labels": MantleSepoliaLabelV3, }, + Network.imx_zkevm: { + "labels": ImxZkevmLabelV3, + }, + Network.imx_zkevm_sepolia: { + "labels": ImxZkevmSepoliaLabelV3, + }, } +## Used only in crawlers def blockchain_type_to_network_type( blockchain_type: AvailableBlockchainType, ) -> Network: @@ -389,5 +400,9 @@ def blockchain_type_to_network_type( return Network.mantle elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: return Network.mantle_sepolia + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM: + return Network.imx_zkevm + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: + return Network.imx_zkevm_sepolia else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") diff --git a/types/python/moonstreamtypes/subscriptions.py b/types/python/moonstreamtypes/subscriptions.py index cdae4826..07a401f1 100644 --- a/types/python/moonstreamtypes/subscriptions.py +++ b/types/python/moonstreamtypes/subscriptions.py @@ -32,6 +32,8 @@ class SubscriptionTypes(Enum): STARKNET_SEPOLIA_BLOCKCHAIN = "starknet_sepolia_smartcontract" MANTLE_BLOCKCHAIN = "mantle_smartcontract" MANTLE_SEPOLIA_BLOCKCHAIN = "mantle_sepolia_smartcontract" + IMX_ZKEVM_BLOCKCHAIN = "imx_zkevm_smartcontract" + IMX_ZKEVM_SEPOLIA_BLOCKCHAIN = "imx_zkevm_sepolia_smartcontract" def blockchain_type_to_subscription_type( @@ -39,6 +41,8 @@ def blockchain_type_to_subscription_type( ) -> SubscriptionTypes: if blockchain_type == AvailableBlockchainType.ETHEREUM: return SubscriptionTypes.ETHEREUM_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.SEPOLIA: + return SubscriptionTypes.SEPOLIA_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.POLYGON: return SubscriptionTypes.POLYGON_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.MUMBAI: @@ -87,12 +91,17 @@ def blockchain_type_to_subscription_type( return SubscriptionTypes.MANTLE_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: return SubscriptionTypes.MANTLE_SEPOLIA_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM: + return SubscriptionTypes.IMX_ZKEVM_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: + return SubscriptionTypes.IMX_ZKEVM_SEPOLIA_BLOCKCHAIN else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") subscription_id_by_blockchain = { "ethereum": "ethereum_smartcontract", + "sepolia": "sepolia_smartcontract", "polygon": "polygon_smartcontract", "mumbai": "mumbai_smartcontract", "amoy": "amoy_smartcontract", @@ -117,10 +126,13 @@ def blockchain_type_to_subscription_type( "starknet_sepolia": "starknet_sepolia_smartcontract", "mantle": "mantle_smartcontract", "mantle_sepolia": "mantle_sepolia_smartcontract", + "imx_zkevm": "imx_zkevm_smartcontract", + "imx_zkevm_sepolia": "imx_zkevm_sepolia_smartcontract", } blockchain_by_subscription_id = { "ethereum_blockchain": "ethereum", + "sepolia_blockchain": "sepolia", "polygon_blockchain": "polygon", "mumbai_blockchain": "mumbai", "amoy_blockchain": "amoy", @@ -145,6 +157,8 @@ def blockchain_type_to_subscription_type( "starknet_sepolia_blockchain": "starknet_sepolia", "mantle_blockchain": "mantle", "mantle_sepolia_blockchain": "mantle_sepolia", + "imx_zkevm_blockchain": "imx_zkevm", + "imx_zkevm_sepolia_blockchain": "imx_zkevm_sepolia", "ethereum_smartcontract": "ethereum", "polygon_smartcontract": "polygon", "mumbai_smartcontract": "mumbai", @@ -170,4 +184,6 @@ def blockchain_type_to_subscription_type( "starknet_sepolia_smartcontract": "starknet_sepolia", "mantle_smartcontract": "mantle", "mantle_sepolia_smartcontract": "mantle_sepolia", + "imx_zkevm_smartcontract": "imx_zkevm", + "imx_zkevm_sepolia_smartcontract": "imx_zkevm_sepolia", } diff --git a/types/python/moonstreamtypes/version.txt b/types/python/moonstreamtypes/version.txt index 81340c7e..bbdeab62 100644 --- a/types/python/moonstreamtypes/version.txt +++ b/types/python/moonstreamtypes/version.txt @@ -1 +1 @@ -0.0.4 +0.0.5 diff --git a/types/python/setup.py b/types/python/setup.py index f21ab72e..f7a9e351 100644 --- a/types/python/setup.py +++ b/types/python/setup.py @@ -34,7 +34,7 @@ zip_safe=False, install_requires=[ "moonstreamdb>=0.4.5", - "moonstreamdb-v3>=0.0.9", + "moonstreamdb-v3>=0.0.15", ], extras_require={ "dev": ["black", "isort", "mypy"],