From 912f3e41de5d8dbea742d16a476aee0886446596 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Aug 2024 16:47:39 +0300 Subject: [PATCH] Add game 7 testnet. --- moonstreamapi/configs/sample.env | 1 + .../moonstreamapi/admin/subscription_types.py | 11 + moonstreamapi/moonstreamapi/settings.py | 9 + moonstreamapi/moonstreamapi/version.py | 2 +- moonstreamapi/moonstreamapi/web3_provider.py | 3 + moonstreamapi/requirements.txt | 2 +- moonstreamapi/setup.py | 2 +- moonstreamdb-v3/moonstreamdbv3/alembic/env.py | 2 + .../db9559f9566c_add_game7_testnet.py | 195 +++++++++++++ .../moonstreamdbv3/alembic_indexes/env.py | 8 + .../b89a8affe2c3_add_game7_testnet.py | 273 ++++++++++++++++++ moonstreamdb-v3/moonstreamdbv3/blockchain.py | 6 + moonstreamdb-v3/moonstreamdbv3/models.py | 45 +++ .../moonstreamdbv3/models_indexes.py | 48 +++ moonstreamdb-v3/moonstreamdbv3/version.txt | 2 +- types/python/moonstreamtypes/blockchain.py | 6 + types/python/moonstreamtypes/networks.py | 7 + types/python/moonstreamtypes/subscriptions.py | 6 + types/python/moonstreamtypes/version.txt | 2 +- types/python/setup.py | 2 +- 20 files changed, 626 insertions(+), 6 deletions(-) create mode 100644 moonstreamdb-v3/moonstreamdbv3/alembic/versions/db9559f9566c_add_game7_testnet.py create mode 100644 moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/b89a8affe2c3_add_game7_testnet.py diff --git a/moonstreamapi/configs/sample.env b/moonstreamapi/configs/sample.env index e9a897faf..560cfeaa6 100644 --- a/moonstreamapi/configs/sample.env +++ b/moonstreamapi/configs/sample.env @@ -39,6 +39,7 @@ export MOONSTREAM_MANTLE_WEB3_PROVIDER_URI="https://=0.4.5", - "moonstreamdb-v3>=0.0.15", + "moonstreamdb-v3>=0.0.16", "humbug", "pydantic==1.10.2", "pyevmasm", diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py index 88c4a2f3b..966d697a9 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py @@ -36,6 +36,7 @@ BlastSepoliaLabel, EthereumLabel, Game7OrbitArbitrumSepoliaLabel, + Game7TestnetLabel, ImxZkevmLabel, ImxZkevmSepoliaLabel, MantleLabel, @@ -69,6 +70,7 @@ def include_symbol(tablename, schema): ArbitrumOneLabel.__tablename__, ArbitrumSepoliaLabel.__tablename__, Game7OrbitArbitrumSepoliaLabel.__tablename__, + Game7TestnetLabel.__tablename__, XaiLabel.__tablename__, XaiSepoliaLabel.__tablename__, AvalancheLabel.__tablename__, diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/versions/db9559f9566c_add_game7_testnet.py b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/db9559f9566c_add_game7_testnet.py new file mode 100644 index 000000000..4e1750660 --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/db9559f9566c_add_game7_testnet.py @@ -0,0 +1,195 @@ +"""Add game7 testnet + +Revision ID: db9559f9566c +Revises: 211646463e9f +Create Date: 2024-08-05 16:24:26.159323 + +""" + +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 = "db9559f9566c" +down_revision: Union[str, None] = "211646463e9f" +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( + "game7_testnet_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_game7_testnet_labels")), + sa.UniqueConstraint("id", name=op.f("uq_game7_testnet_labels_id")), + ) + op.create_index( + "ix_game7_testnet_labels_addr_block_num", + "game7_testnet_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_game7_testnet_labels_addr_block_ts", + "game7_testnet_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_address"), + "game7_testnet_labels", + ["address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_block_number"), + "game7_testnet_labels", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_caller_address"), + "game7_testnet_labels", + ["caller_address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_label"), + "game7_testnet_labels", + ["label"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_label_name"), + "game7_testnet_labels", + ["label_name"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_label_type"), + "game7_testnet_labels", + ["label_type"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_origin_address"), + "game7_testnet_labels", + ["origin_address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_labels_transaction_hash"), + "game7_testnet_labels", + ["transaction_hash"], + unique=False, + ) + op.create_index( + "uk_game7_testnet_labels_tx_hash_log_idx_evt", + "game7_testnet_labels", + ["transaction_hash", "log_index"], + unique=True, + postgresql_where=sa.text("label='seer' and label_type='event'"), + ) + op.create_index( + "uk_game7_testnet_labels_tx_hash_log_idx_evt_raw", + "game7_testnet_labels", + ["transaction_hash", "log_index"], + unique=True, + postgresql_where=sa.text("label='seer-raw' and label_type='event'"), + ) + op.create_index( + "uk_game7_testnet_labels_tx_hash_tx_call", + "game7_testnet_labels", + ["transaction_hash"], + unique=True, + postgresql_where=sa.text("label='seer' and label_type='tx_call'"), + ) + op.create_index( + "uk_game7_testnet_labels_tx_hash_tx_call_raw", + "game7_testnet_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_game7_testnet_labels_tx_hash_tx_call_raw", + table_name="game7_testnet_labels", + postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'"), + ) + op.drop_index( + "uk_game7_testnet_labels_tx_hash_tx_call", + table_name="game7_testnet_labels", + postgresql_where=sa.text("label='seer' and label_type='tx_call'"), + ) + op.drop_index( + "uk_game7_testnet_labels_tx_hash_log_idx_evt_raw", + table_name="game7_testnet_labels", + postgresql_where=sa.text("label='seer-raw' and label_type='event'"), + ) + op.drop_index( + "uk_game7_testnet_labels_tx_hash_log_idx_evt", + table_name="game7_testnet_labels", + postgresql_where=sa.text("label='seer' and label_type='event'"), + ) + op.drop_index( + op.f("ix_game7_testnet_labels_transaction_hash"), + table_name="game7_testnet_labels", + ) + op.drop_index( + op.f("ix_game7_testnet_labels_origin_address"), + table_name="game7_testnet_labels", + ) + op.drop_index( + op.f("ix_game7_testnet_labels_label_type"), table_name="game7_testnet_labels" + ) + op.drop_index( + op.f("ix_game7_testnet_labels_label_name"), table_name="game7_testnet_labels" + ) + op.drop_index( + op.f("ix_game7_testnet_labels_label"), table_name="game7_testnet_labels" + ) + op.drop_index( + op.f("ix_game7_testnet_labels_caller_address"), + table_name="game7_testnet_labels", + ) + op.drop_index( + op.f("ix_game7_testnet_labels_block_number"), table_name="game7_testnet_labels" + ) + op.drop_index( + op.f("ix_game7_testnet_labels_address"), table_name="game7_testnet_labels" + ) + op.drop_index( + "ix_game7_testnet_labels_addr_block_ts", table_name="game7_testnet_labels" + ) + op.drop_index( + "ix_game7_testnet_labels_addr_block_num", table_name="game7_testnet_labels" + ) + op.drop_table("game7_testnet_labels") + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py index d095e1663..0d39ef6c9 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py @@ -44,6 +44,10 @@ Game7OrbitArbitrumSepoliaLogIndex, Game7OrbitArbitrumSepoliaReorgs, Game7OrbitArbitrumSepoliaTransactionIndex, + Game7TestnetBlockIndex, + Game7TestnetLogIndex, + Game7TestnetReorgs, + Game7TestnetTransactionIndex, ImxZkevmBlockIndex, ImxZkevmLogIndex, ImxZkevmReorgs, @@ -105,6 +109,10 @@ def include_symbol(tablename, schema): Game7OrbitArbitrumSepoliaTransactionIndex.__tablename__, Game7OrbitArbitrumSepoliaLogIndex.__tablename__, Game7OrbitArbitrumSepoliaReorgs.__tablename__, + Game7TestnetBlockIndex.__tablename__, + Game7TestnetTransactionIndex.__tablename__, + Game7TestnetLogIndex.__tablename__, + Game7TestnetReorgs.__tablename__, MantleBlockIndex.__tablename__, MantleTransactionIndex.__tablename__, MantleLogIndex.__tablename__, diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/b89a8affe2c3_add_game7_testnet.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/b89a8affe2c3_add_game7_testnet.py new file mode 100644 index 000000000..76f1bdca3 --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/b89a8affe2c3_add_game7_testnet.py @@ -0,0 +1,273 @@ +"""Add game7 testnet + +Revision ID: b89a8affe2c3 +Revises: f19652e59bc5 +Create Date: 2024-08-05 16:29:33.091636 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "b89a8affe2c3" +down_revision: Union[str, None] = "f19652e59bc5" +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( + "game7_testnet_blocks", + sa.Column("l1_block_number", sa.BigInteger(), nullable=False), + 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_game7_testnet_blocks")), + ) + op.create_index( + op.f("ix_game7_testnet_blocks_block_number"), + "game7_testnet_blocks", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_blocks_block_timestamp"), + "game7_testnet_blocks", + ["block_timestamp"], + unique=False, + ) + op.create_table( + "game7_testnet_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_game7_testnet_reorgs")), + ) + op.create_index( + op.f("ix_game7_testnet_reorgs_block_hash"), + "game7_testnet_reorgs", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_reorgs_block_number"), + "game7_testnet_reorgs", + ["block_number"], + unique=False, + ) + op.create_table( + "game7_testnet_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"], + ["game7_testnet_blocks.block_number"], + name=op.f( + "fk_game7_testnet_transactions_block_number_game7_testnet_blocks" + ), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("hash", name=op.f("pk_game7_testnet_transactions")), + ) + op.create_index( + op.f("ix_game7_testnet_transactions_block_hash"), + "game7_testnet_transactions", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_block_number"), + "game7_testnet_transactions", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_from_address"), + "game7_testnet_transactions", + ["from_address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_hash"), + "game7_testnet_transactions", + ["hash"], + unique=True, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_index"), + "game7_testnet_transactions", + ["index"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_selector"), + "game7_testnet_transactions", + ["selector"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_to_address"), + "game7_testnet_transactions", + ["to_address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_transactions_type"), + "game7_testnet_transactions", + ["type"], + unique=False, + ) + op.create_table( + "game7_testnet_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"], + ["game7_testnet_transactions.hash"], + name=op.f( + "fk_game7_testnet_logs_transaction_hash_game7_testnet_transactions" + ), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_game7_testnet_log_index" + ), + sa.UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_game7_testnet_log_index_transaction_hash_log_index", + ), + ) + op.create_index( + "idx_game7_testnet_logs_address_selector", + "game7_testnet_logs", + ["address", "selector"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_logs_address"), + "game7_testnet_logs", + ["address"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_logs_block_hash"), + "game7_testnet_logs", + ["block_hash"], + unique=False, + ) + op.create_index( + op.f("ix_game7_testnet_logs_transaction_hash"), + "game7_testnet_logs", + ["transaction_hash"], + unique=False, + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index( + op.f("ix_game7_testnet_logs_transaction_hash"), table_name="game7_testnet_logs" + ) + op.drop_index( + op.f("ix_game7_testnet_logs_block_hash"), table_name="game7_testnet_logs" + ) + op.drop_index( + op.f("ix_game7_testnet_logs_address"), table_name="game7_testnet_logs" + ) + op.drop_index( + "idx_game7_testnet_logs_address_selector", table_name="game7_testnet_logs" + ) + op.drop_table("game7_testnet_logs") + op.drop_index( + op.f("ix_game7_testnet_transactions_type"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_to_address"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_selector"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_index"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_hash"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_from_address"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_block_number"), + table_name="game7_testnet_transactions", + ) + op.drop_index( + op.f("ix_game7_testnet_transactions_block_hash"), + table_name="game7_testnet_transactions", + ) + op.drop_table("game7_testnet_transactions") + op.drop_index( + op.f("ix_game7_testnet_reorgs_block_number"), table_name="game7_testnet_reorgs" + ) + op.drop_index( + op.f("ix_game7_testnet_reorgs_block_hash"), table_name="game7_testnet_reorgs" + ) + op.drop_table("game7_testnet_reorgs") + op.drop_index( + op.f("ix_game7_testnet_blocks_block_timestamp"), + table_name="game7_testnet_blocks", + ) + op.drop_index( + op.f("ix_game7_testnet_blocks_block_number"), table_name="game7_testnet_blocks" + ) + op.drop_table("game7_testnet_blocks") + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/blockchain.py b/moonstreamdb-v3/moonstreamdbv3/blockchain.py index fa89db913..a2b713e35 100644 --- a/moonstreamdb-v3/moonstreamdbv3/blockchain.py +++ b/moonstreamdb-v3/moonstreamdbv3/blockchain.py @@ -16,6 +16,7 @@ ArbitrumOneLabel, ArbitrumSepoliaLabel, Game7OrbitArbitrumSepoliaLabel, + Game7TestnetLabel, XaiLabel, XaiSepoliaLabel, AvalancheLabel, @@ -55,6 +56,7 @@ class AvailableBlockchainType(Enum): MANTLE = "mantle" MANTLE_SEPOLIA = "mantle_sepolia" GAME7_ORBIT_ARBITRUM_SEPOLIA = "game7_orbit_arbitrum_sepolia" + GAME7_TESTNET = "game7_testnet" def get_label_model(blockchain_type: AvailableBlockchainType) -> Type[ @@ -72,6 +74,7 @@ def get_label_model(blockchain_type: AvailableBlockchainType) -> Type[ ArbitrumOneLabel, ArbitrumSepoliaLabel, Game7OrbitArbitrumSepoliaLabel, + Game7TestnetLabel, XaiLabel, XaiSepoliaLabel, AvalancheLabel, @@ -104,6 +107,7 @@ def get_label_model(blockchain_type: AvailableBlockchainType) -> Type[ ArbitrumOneLabel, ArbitrumSepoliaLabel, Game7OrbitArbitrumSepoliaLabel, + Game7TestnetLabel, XaiLabel, XaiSepoliaLabel, AvalancheLabel, @@ -164,6 +168,8 @@ def get_label_model(blockchain_type: AvailableBlockchainType) -> Type[ label_model = MantleSepoliaLabel elif blockchain_type == AvailableBlockchainType.GAME7_ORBIT_ARBITRUM_SEPOLIA: label_model = Game7OrbitArbitrumSepoliaLabel + elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET: + label_model = Game7TestnetLabel else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") diff --git a/moonstreamdb-v3/moonstreamdbv3/models.py b/moonstreamdb-v3/moonstreamdbv3/models.py index b7cdcc91a..51ad0a487 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models.py +++ b/moonstreamdb-v3/moonstreamdbv3/models.py @@ -1287,3 +1287,48 @@ class ImxZkevmSepoliaLabel(EvmBasedLabel): # type: ignore postgresql_where=text("label='seer-raw' and label_type='event'"), ), ) + + +class Game7TestnetLabel(EvmBasedLabel): # type: ignore + __tablename__ = "game7_testnet_labels" + + __table_args__ = ( + Index( + "ix_game7_testnet_labels_addr_block_num", + "address", + "block_number", + unique=False, + ), + Index( + "ix_game7_testnet_labels_addr_block_ts", + "address", + "block_timestamp", + unique=False, + ), + Index( + "uk_game7_testnet_labels_tx_hash_tx_call", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer' and label_type='tx_call'"), + ), + Index( + "uk_game7_testnet_labels_tx_hash_log_idx_evt", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer' and label_type='event'"), + ), + Index( + "uk_game7_testnet_labels_tx_hash_tx_call_raw", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='tx_call'"), + ), + Index( + "uk_game7_testnet_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 d67d25c06..1cabb7d5d 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py +++ b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py @@ -725,6 +725,54 @@ class ImxZkevmSepoliaReorgs(EvmBasedReorgs): __tablename__ = "imx_zkevm_sepolia_reorgs" +class Game7TestnetBlockIndex(EvmBasedBlocks): + __tablename__ = "game7_testnet_blocks" + + l1_block_number = Column(BigInteger, nullable=False) + + +class Game7TestnetTransactionIndex(EvmBasedTransactions): + __tablename__ = "game7_testnet_transactions" + + block_number = Column( + BigInteger, + ForeignKey("game7_testnet_blocks.block_number", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class Game7TestnetLogIndex(EvmBasedLogs): + __tablename__ = "game7_testnet_logs" + + __table_args__ = ( + Index( + "idx_game7_testnet_logs_address_selector", + "address", + "selector", + unique=False, + ), + UniqueConstraint( + "transaction_hash", + "log_index", + name="uq_game7_testnet_log_index_transaction_hash_log_index", + ), + PrimaryKeyConstraint( + "transaction_hash", "log_index", name="pk_game7_testnet_log_index" + ), + ) + transaction_hash = Column( + VARCHAR(256), + ForeignKey("game7_testnet_transactions.hash", ondelete="CASCADE"), + nullable=False, + index=True, + ) + + +class Game7TestnetReorgs(EvmBasedReorgs): + __tablename__ = "game7_testnet_reorgs" + + ### ABI Jobs diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index ceddfb28f..e3b86dd9c 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.0.15 +0.0.16 diff --git a/types/python/moonstreamtypes/blockchain.py b/types/python/moonstreamtypes/blockchain.py index df4116f5e..7362e4c66 100644 --- a/types/python/moonstreamtypes/blockchain.py +++ b/types/python/moonstreamtypes/blockchain.py @@ -79,6 +79,7 @@ from moonstreamdbv3.models import ( Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3, ) +from moonstreamdbv3.models import Game7TestnetLabel as Game7TestnetLabelV3 from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3 from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3 from moonstreamdbv3.models import MantleLabel as MantleLabelV3 @@ -112,6 +113,7 @@ class AvailableBlockchainType(Enum): ARBITRUM_NOVA = "arbitrum_nova" ARBITRUM_SEPOLIA = "arbitrum_sepolia" GAME7_ORBIT_ARBITRUM_SEPOLIA = "game7_orbit_arbitrum_sepolia" + GAME7_TESTNET = "game7_testnet" XAI = "xai" XAI_SEPOLIA = "xai_sepolia" AVALANCHE = "avalanche" @@ -269,6 +271,7 @@ def get_label_model( ArbitrumOneLabelV3, ArbitrumSepoliaLabelV3, Game7OrbitArbitrumSepoliaLabelV3, + Game7TestnetLabelV3, XaiLabelV3, XaiSepoliaLabelV3, AvalancheLabelV3, @@ -327,6 +330,7 @@ def get_label_model( ArbitrumOneLabelV3, ArbitrumSepoliaLabelV3, Game7OrbitArbitrumSepoliaLabelV3, + Game7TestnetLabelV3, XaiLabelV3, XaiSepoliaLabelV3, AvalancheLabelV3, @@ -414,6 +418,8 @@ def get_label_model( label_model = ArbitrumSepoliaLabelV3 elif blockchain_type == AvailableBlockchainType.GAME7_ORBIT_ARBITRUM_SEPOLIA: label_model = Game7OrbitArbitrumSepoliaLabelV3 + elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET: + label_model = Game7TestnetLabelV3 elif blockchain_type == AvailableBlockchainType.XAI: label_model = XaiLabelV3 elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA: diff --git a/types/python/moonstreamtypes/networks.py b/types/python/moonstreamtypes/networks.py index cd9c65be6..9717ea304 100644 --- a/types/python/moonstreamtypes/networks.py +++ b/types/python/moonstreamtypes/networks.py @@ -80,6 +80,7 @@ from moonstreamdbv3.models import ( Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3, ) +from moonstreamdbv3.models import Game7TestnetLabel as Game7TestnetLabelV3 from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3 from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3 from moonstreamdbv3.models import MantleLabel as MantleLabelV3 @@ -115,6 +116,7 @@ class Network(Enum): arbitrum_nova = "arbitrum_nova" arbitrum_sepolia = "arbitrum_sepolia" game7_orbit_arbitrum_sepolia = "game7_orbit_arbitrum_sepolia" + game7_testnet = "game7_testnet" xai = "xai" xai_sepolia = "xai_sepolia" avalanche = "avalanche" @@ -302,6 +304,9 @@ class Network(Enum): Network.game7_orbit_arbitrum_sepolia: { "labels": Game7OrbitArbitrumSepoliaLabelV3, }, + Network.game7_testnet: { + "labels": Game7TestnetLabelV3, + }, Network.xai: { "labels": XaiLabelV3, }, @@ -378,6 +383,8 @@ def blockchain_type_to_network_type( return Network.arbitrum_sepolia elif blockchain_type == AvailableBlockchainType.GAME7_ORBIT_ARBITRUM_SEPOLIA: return Network.game7_orbit_arbitrum_sepolia + elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET: + return Network.game7_testnet elif blockchain_type == AvailableBlockchainType.XAI: return Network.xai elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA: diff --git a/types/python/moonstreamtypes/subscriptions.py b/types/python/moonstreamtypes/subscriptions.py index 07a401f16..4c1393c85 100644 --- a/types/python/moonstreamtypes/subscriptions.py +++ b/types/python/moonstreamtypes/subscriptions.py @@ -21,6 +21,7 @@ class SubscriptionTypes(Enum): GAME7_ORBIT_ARBITRUM_SEPOLIA_BLOCKCHAIN = ( "game7_orbit_arbitrum_sepolia_smartcontract" ) + GAME7_TESTNET_BLOCKCHAIN = "game7_testnet_smartcontract" XAI_BLOCKCHAIN = "xai_smartcontract" XAI_SEPOLIA_BLOCKCHAIN = "xai_sepolia_smartcontract" AVALANCHE_BLOCKCHAIN = "avalanche_smartcontract" @@ -69,6 +70,8 @@ def blockchain_type_to_subscription_type( return SubscriptionTypes.ARBITRUM_SEPOLIA_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.GAME7_ORBIT_ARBITRUM_SEPOLIA: return SubscriptionTypes.GAME7_ORBIT_ARBITRUM_SEPOLIA_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET: + return SubscriptionTypes.GAME7_TESTNET_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.XAI: return SubscriptionTypes.XAI_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA: @@ -115,6 +118,7 @@ def blockchain_type_to_subscription_type( "arbitrum_nova": "arbitrum_nova_smartcontract", "arbitrum_sepolia": "arbitrum_sepolia_smartcontract", "game7_orbit_arbitrum_sepolia": "game7_orbit_arbitrum_sepolia_smartcontract", + "game7_testnet": "game7_testnet_smartcontract", "xai": "xai_smartcontract", "xai_sepolia": "xai_sepolia_smartcontract", "avalanche": "avalanche_smartcontract", @@ -146,6 +150,7 @@ def blockchain_type_to_subscription_type( "arbitrum_nova_blockchain": "arbitrum_nova", "arbitrum_sepolia_blockchain": "arbitrum_sepolia", "game7_orbit_arbitrum_sepolia_blockchain": "game7_orbit_arbitrum_sepolia", + "game7_testnet_blockchain": "game7_testnet", "xai_blockchain": "xai", "xai_sepolia_blockchain": "xai_sepolia", "avalanche_blockchain": "avalanche", @@ -173,6 +178,7 @@ def blockchain_type_to_subscription_type( "arbitrum_nova_smartcontract": "arbitrum_nova", "arbitrum_sepolia_smartcontract": "arbitrum_sepolia", "game7_orbit_arbitrum_sepolia_smartcontract": "game7_orbit_arbitrum_sepolia", + "game7_testnet_smartcontract": "game7_testnet", "xai_smartcontract": "xai", "xai_sepolia_smartcontract": "xai_sepolia", "avalanche_smartcontract": "avalanche", diff --git a/types/python/moonstreamtypes/version.txt b/types/python/moonstreamtypes/version.txt index bbdeab622..1750564f2 100644 --- a/types/python/moonstreamtypes/version.txt +++ b/types/python/moonstreamtypes/version.txt @@ -1 +1 @@ -0.0.5 +0.0.6 diff --git a/types/python/setup.py b/types/python/setup.py index f7a9e351d..fe03945bb 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.15", + "moonstreamdb-v3>=0.0.16", ], extras_require={ "dev": ["black", "isort", "mypy"],