Mantle and Mantle Sepolia blockchains model

pull/1099/head
kompotkot 2024-06-25 08:51:53 +00:00
rodzic 317f5fe1af
commit a8cc69babf
7 zmienionych plików z 523 dodań i 17 usunięć

Wyświetl plik

@ -26,8 +26,8 @@ target_metadata = MoonstreamBase.metadata
# ... etc.
from moonstreamdb.models import (
AmoyBlock,
AmoyTransaction,
AmoyLabel,
AmoyTransaction,
ArbitrumNovaBlock,
ArbitrumNovaLabel,
ArbitrumNovaTransaction,
@ -43,11 +43,23 @@ from moonstreamdb.models import (
AvalancheFujiTransaction,
AvalancheLabel,
AvalancheTransaction,
BlastBlock,
BlastLabel,
BlastSepoliaBlock,
BlastSepoliaLabel,
BlastSepoliaTransaction,
BlastTransaction,
ESDEventSignature,
ESDFunctionSignature,
EthereumBlock,
EthereumLabel,
EthereumTransaction,
MantleBlock,
MantleLabel,
MantleSepoliaBlock,
MantleSepoliaLabel,
MantleSepoliaTransaction,
MantleTransaction,
MumbaiBlock,
MumbaiLabel,
MumbaiTransaction,
@ -55,6 +67,9 @@ from moonstreamdb.models import (
PolygonBlock,
PolygonLabel,
PolygonTransaction,
ProofOfPlayApexBlock,
ProofOfPlayApexLabel,
ProofOfPlayApexTransaction,
WyrmBlock,
WyrmLabel,
WyrmTransaction,
@ -76,15 +91,6 @@ from moonstreamdb.models import (
ZkSyncEraTestnetLabel,
ZkSyncEraTestnetTransaction,
ZkSyncEraTransaction,
BlastBlock,
BlastLabel,
BlastTransaction,
BlastSepoliaBlock,
BlastSepoliaLabel,
BlastSepoliaTransaction,
ProofOfPlayApexBlock,
ProofOfPlayApexLabel,
ProofOfPlayApexTransaction,
)
@ -150,6 +156,12 @@ def include_symbol(tablename, schema):
ProofOfPlayApexBlock.__tablename__,
ProofOfPlayApexLabel.__tablename__,
ProofOfPlayApexTransaction.__tablename__,
MantleBlock,
MantleLabel.__tablename__,
MantleSepoliaBlock.__tablename__,
MantleSepoliaLabel.__tablename__,
MantleSepoliaTransaction.__tablename__,
MantleTransaction.__tablename__,
}

Wyświetl plik

@ -0,0 +1,208 @@
"""Mantle with sepolia blockchains
Revision ID: 595ccb96f7cf
Revises: 0071b7b26b7b
Create Date: 2024-06-25 08:49:05.312893
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '595ccb96f7cf'
down_revision = '0071b7b26b7b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('mantle_blocks',
sa.Column('block_number', sa.BigInteger(), nullable=False),
sa.Column('difficulty', sa.BigInteger(), nullable=True),
sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True),
sa.Column('gas_limit', sa.BigInteger(), nullable=True),
sa.Column('gas_used', sa.BigInteger(), nullable=True),
sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True),
sa.Column('miner', sa.VARCHAR(length=256), nullable=True),
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('uncles', sa.VARCHAR(length=256), nullable=True),
sa.Column('size', sa.Integer(), nullable=True),
sa.Column('state_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('timestamp', sa.BigInteger(), nullable=True),
sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True),
sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
sa.Column('mix_hash', sa.VARCHAR(length=256), nullable=True),
sa.PrimaryKeyConstraint('block_number', name=op.f('pk_mantle_blocks'))
)
op.create_index(op.f('ix_mantle_blocks_block_number'), 'mantle_blocks', ['block_number'], unique=True)
op.create_index(op.f('ix_mantle_blocks_hash'), 'mantle_blocks', ['hash'], unique=False)
op.create_index(op.f('ix_mantle_blocks_timestamp'), 'mantle_blocks', ['timestamp'], unique=False)
op.create_table('mantle_labels',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
sa.Column('block_number', sa.BigInteger(), nullable=True),
sa.Column('address', sa.VARCHAR(length=256), nullable=True),
sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('block_timestamp', sa.BigInteger(), nullable=True),
sa.Column('log_index', sa.Integer(), 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_mantle_labels')),
sa.UniqueConstraint('id', name=op.f('uq_mantle_labels_id'))
)
op.create_index(op.f('ix_mantle_labels_address'), 'mantle_labels', ['address'], unique=False)
op.create_index('ix_mantle_labels_address_block_number', 'mantle_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_mantle_labels_address_block_timestamp', 'mantle_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_labels_block_number'), 'mantle_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_labels_block_timestamp'), 'mantle_labels', ['block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_labels_label'), 'mantle_labels', ['label'], unique=False)
op.create_index(op.f('ix_mantle_labels_transaction_hash'), 'mantle_labels', ['transaction_hash'], unique=False)
op.create_table('mantle_sepolia_blocks',
sa.Column('block_number', sa.BigInteger(), nullable=False),
sa.Column('difficulty', sa.BigInteger(), nullable=True),
sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True),
sa.Column('gas_limit', sa.BigInteger(), nullable=True),
sa.Column('gas_used', sa.BigInteger(), nullable=True),
sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True),
sa.Column('miner', sa.VARCHAR(length=256), nullable=True),
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('uncles', sa.VARCHAR(length=256), nullable=True),
sa.Column('size', sa.Integer(), nullable=True),
sa.Column('state_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('timestamp', sa.BigInteger(), nullable=True),
sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True),
sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True),
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
sa.Column('mix_hash', sa.VARCHAR(length=256), nullable=True),
sa.PrimaryKeyConstraint('block_number', name=op.f('pk_mantle_sepolia_blocks'))
)
op.create_index(op.f('ix_mantle_sepolia_blocks_block_number'), 'mantle_sepolia_blocks', ['block_number'], unique=True)
op.create_index(op.f('ix_mantle_sepolia_blocks_hash'), 'mantle_sepolia_blocks', ['hash'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_blocks_timestamp'), 'mantle_sepolia_blocks', ['timestamp'], unique=False)
op.create_table('mantle_sepolia_labels',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
sa.Column('block_number', sa.BigInteger(), nullable=True),
sa.Column('address', sa.VARCHAR(length=256), nullable=True),
sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=True),
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('block_timestamp', sa.BigInteger(), nullable=True),
sa.Column('log_index', sa.Integer(), 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_mantle_sepolia_labels')),
sa.UniqueConstraint('id', name=op.f('uq_mantle_sepolia_labels_id'))
)
op.create_index(op.f('ix_mantle_sepolia_labels_address'), 'mantle_sepolia_labels', ['address'], unique=False)
op.create_index('ix_mantle_sepolia_labels_address_block_number', 'mantle_sepolia_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_mantle_sepolia_labels_address_block_timestamp', 'mantle_sepolia_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_block_number'), 'mantle_sepolia_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_block_timestamp'), 'mantle_sepolia_labels', ['block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_label'), 'mantle_sepolia_labels', ['label'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_transaction_hash'), 'mantle_sepolia_labels', ['transaction_hash'], unique=False)
op.create_table('mantle_sepolia_transactions',
sa.Column('hash', sa.VARCHAR(length=256), nullable=False),
sa.Column('block_number', sa.BigInteger(), nullable=False),
sa.Column('from_address', sa.VARCHAR(length=256), nullable=True),
sa.Column('to_address', sa.VARCHAR(length=256), nullable=True),
sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('input', sa.Text(), nullable=True),
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
sa.Column('transaction_index', sa.BigInteger(), nullable=True),
sa.Column('transaction_type', sa.Integer(), nullable=True),
sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
sa.ForeignKeyConstraint(['block_number'], ['mantle_sepolia_blocks.block_number'], name=op.f('fk_mantle_sepolia_transactions_block_number_mantle_sepolia_blocks'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('hash', name=op.f('pk_mantle_sepolia_transactions'))
)
op.create_index(op.f('ix_mantle_sepolia_transactions_block_number'), 'mantle_sepolia_transactions', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_transactions_from_address'), 'mantle_sepolia_transactions', ['from_address'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_transactions_gas'), 'mantle_sepolia_transactions', ['gas'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_transactions_gas_price'), 'mantle_sepolia_transactions', ['gas_price'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_transactions_hash'), 'mantle_sepolia_transactions', ['hash'], unique=True)
op.create_index(op.f('ix_mantle_sepolia_transactions_to_address'), 'mantle_sepolia_transactions', ['to_address'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_transactions_value'), 'mantle_sepolia_transactions', ['value'], unique=False)
op.create_table('mantle_transactions',
sa.Column('hash', sa.VARCHAR(length=256), nullable=False),
sa.Column('block_number', sa.BigInteger(), nullable=False),
sa.Column('from_address', sa.VARCHAR(length=256), nullable=True),
sa.Column('to_address', sa.VARCHAR(length=256), nullable=True),
sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('input', sa.Text(), nullable=True),
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
sa.Column('transaction_index', sa.BigInteger(), nullable=True),
sa.Column('transaction_type', sa.Integer(), nullable=True),
sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True),
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
sa.ForeignKeyConstraint(['block_number'], ['mantle_blocks.block_number'], name=op.f('fk_mantle_transactions_block_number_mantle_blocks'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('hash', name=op.f('pk_mantle_transactions'))
)
op.create_index(op.f('ix_mantle_transactions_block_number'), 'mantle_transactions', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_transactions_from_address'), 'mantle_transactions', ['from_address'], unique=False)
op.create_index(op.f('ix_mantle_transactions_gas'), 'mantle_transactions', ['gas'], unique=False)
op.create_index(op.f('ix_mantle_transactions_gas_price'), 'mantle_transactions', ['gas_price'], unique=False)
op.create_index(op.f('ix_mantle_transactions_hash'), 'mantle_transactions', ['hash'], unique=True)
op.create_index(op.f('ix_mantle_transactions_to_address'), 'mantle_transactions', ['to_address'], unique=False)
op.create_index(op.f('ix_mantle_transactions_value'), 'mantle_transactions', ['value'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_mantle_transactions_value'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_to_address'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_hash'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_gas_price'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_gas'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_from_address'), table_name='mantle_transactions')
op.drop_index(op.f('ix_mantle_transactions_block_number'), table_name='mantle_transactions')
op.drop_table('mantle_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_value'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_to_address'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_hash'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_gas_price'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_gas'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_from_address'), table_name='mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_transactions_block_number'), table_name='mantle_sepolia_transactions')
op.drop_table('mantle_sepolia_transactions')
op.drop_index(op.f('ix_mantle_sepolia_labels_transaction_hash'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_label'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_block_timestamp'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_block_number'), table_name='mantle_sepolia_labels')
op.drop_index('ix_mantle_sepolia_labels_address_block_timestamp', table_name='mantle_sepolia_labels')
op.drop_index('ix_mantle_sepolia_labels_address_block_number', table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_address'), table_name='mantle_sepolia_labels')
op.drop_table('mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_blocks_timestamp'), table_name='mantle_sepolia_blocks')
op.drop_index(op.f('ix_mantle_sepolia_blocks_hash'), table_name='mantle_sepolia_blocks')
op.drop_index(op.f('ix_mantle_sepolia_blocks_block_number'), table_name='mantle_sepolia_blocks')
op.drop_table('mantle_sepolia_blocks')
op.drop_index(op.f('ix_mantle_labels_transaction_hash'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_label'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_block_timestamp'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_block_number'), table_name='mantle_labels')
op.drop_index('ix_mantle_labels_address_block_timestamp', table_name='mantle_labels')
op.drop_index('ix_mantle_labels_address_block_number', table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_address'), table_name='mantle_labels')
op.drop_table('mantle_labels')
op.drop_index(op.f('ix_mantle_blocks_timestamp'), table_name='mantle_blocks')
op.drop_index(op.f('ix_mantle_blocks_hash'), table_name='mantle_blocks')
op.drop_index(op.f('ix_mantle_blocks_block_number'), table_name='mantle_blocks')
op.drop_table('mantle_blocks')
# ### end Alembic commands ###

Wyświetl plik

@ -5,12 +5,12 @@ from .models import (
AmoyBlock,
AmoyLabel,
AmoyTransaction,
ArbitrumOneBlock,
ArbitrumOneLabel,
ArbitrumOneTransaction,
ArbitrumNovaBlock,
ArbitrumNovaLabel,
ArbitrumNovaTransaction,
ArbitrumOneBlock,
ArbitrumOneLabel,
ArbitrumOneTransaction,
ArbitrumSepoliaBlock,
ArbitrumSepoliaLabel,
ArbitrumSepoliaTransaction,
@ -29,6 +29,12 @@ from .models import (
EthereumBlock,
EthereumLabel,
EthereumTransaction,
MantleBlock,
MantleLabel,
MantleSepoliaBlock,
MantleSepoliaLabel,
MantleSepoliaTransaction,
MantleTransaction,
MumbaiBlock,
MumbaiLabel,
MumbaiTransaction,
@ -82,6 +88,8 @@ class AvailableBlockchainType(Enum):
BLAST = "blast"
BLAST_SEPOLIA = "blast_sepolia"
PROOFOFPLAY_APEX = "proofofplay_apex"
MANTLE = "mantle"
MANTLE_SEPOLIA = "mantle_sepolia"
def get_block_model(
@ -107,6 +115,8 @@ def get_block_model(
BlastBlock,
BlastSepoliaBlock,
ProofOfPlayApexBlock,
MantleBlock,
MantleSepoliaBlock,
]
]:
"""
@ -133,6 +143,8 @@ def get_block_model(
BlastBlock,
BlastSepoliaBlock,
ProofOfPlayApexBlock,
MantleBlock,
MantleSepoliaBlock,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -173,6 +185,10 @@ def get_block_model(
block_model = BlastSepoliaBlock
elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX:
block_model = ProofOfPlayApexBlock
elif blockchain_type == AvailableBlockchainType.MANTLE:
block_model = MantleBlock
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
block_model = MantleSepoliaBlock
else:
raise Exception("Unsupported blockchain type provided")
@ -202,6 +218,8 @@ def get_label_model(
BlastLabel,
BlastSepoliaLabel,
ProofOfPlayApexLabel,
MantleLabel,
MantleSepoliaLabel,
]
]:
"""
@ -228,6 +246,8 @@ def get_label_model(
BlastLabel,
BlastSepoliaLabel,
ProofOfPlayApexLabel,
MantleLabel,
MantleSepoliaLabel,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -268,6 +288,10 @@ def get_label_model(
label_model = BlastSepoliaLabel
elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX:
label_model = ProofOfPlayApexLabel
elif blockchain_type == AvailableBlockchainType.MANTLE:
label_model = MantleLabel
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
label_model = MantleSepoliaLabel
else:
raise Exception("Unsupported blockchain type provided")
@ -297,6 +321,8 @@ def get_transaction_model(
BlastTransaction,
BlastSepoliaTransaction,
ProofOfPlayApexTransaction,
MantleTransaction,
MantleSepoliaTransaction,
]
]:
"""
@ -323,6 +349,8 @@ def get_transaction_model(
BlastTransaction,
BlastSepoliaTransaction,
ProofOfPlayApexTransaction,
MantleTransaction,
MantleSepoliaTransaction,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -363,6 +391,10 @@ def get_transaction_model(
transaction_model = BlastSepoliaTransaction
elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX:
transaction_model = ProofOfPlayApexTransaction
elif blockchain_type == AvailableBlockchainType.MANTLE:
transaction_model = MantleTransaction
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
transaction_model = MantleSepoliaTransaction
else:
raise Exception("Unsupported blockchain type provided")

Wyświetl plik

@ -2171,6 +2171,224 @@ class ArbitrumOneLabel(Base): # type: ignore
)
class MantleBlock(Base): # type: ignore
__tablename__ = "mantle_blocks"
block_number = Column(
BigInteger, primary_key=True, unique=True, nullable=False, index=True
)
difficulty = Column(BigInteger)
extra_data = Column(VARCHAR(128))
gas_limit = Column(BigInteger)
gas_used = Column(BigInteger)
base_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
hash = Column(VARCHAR(256), index=True)
logs_bloom = Column(VARCHAR(1024))
miner = Column(VARCHAR(256))
nonce = Column(VARCHAR(256))
parent_hash = Column(VARCHAR(256))
receipt_root = Column(VARCHAR(256))
uncles = Column(VARCHAR(256))
size = Column(Integer)
state_root = Column(VARCHAR(256))
timestamp = Column(BigInteger, index=True)
total_difficulty = Column(VARCHAR(256))
transactions_root = Column(VARCHAR(256))
indexed_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
mix_hash = Column(VARCHAR(256), nullable=True)
class MantleTransaction(Base): # type: ignore
__tablename__ = "mantle_transactions"
hash = Column(
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
)
block_number = Column(
BigInteger,
ForeignKey("mantle_blocks.block_number", ondelete="CASCADE"),
nullable=False,
index=True,
)
from_address = Column(VARCHAR(256), index=True)
to_address = Column(VARCHAR(256), index=True)
gas = Column(Numeric(precision=78, scale=0), index=True)
gas_price = Column(Numeric(precision=78, scale=0), index=True)
max_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
max_priority_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
input = Column(Text)
nonce = Column(VARCHAR(256))
transaction_index = Column(BigInteger)
transaction_type = Column(Integer, nullable=True)
value = Column(Numeric(precision=78, scale=0), index=True)
indexed_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class MantleLabel(Base): # type: ignore
__tablename__ = "mantle_labels"
__table_args__ = (
Index(
"ix_mantle_labels_address_block_number",
"address",
"block_number",
unique=False,
),
Index(
"ix_mantle_labels_address_block_timestamp",
"address",
"block_timestamp",
unique=False,
),
)
id = Column(
UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4,
unique=True,
nullable=False,
)
label = Column(VARCHAR(256), nullable=False, index=True)
block_number = Column(
BigInteger,
nullable=True,
index=True,
)
address = Column(
VARCHAR(256),
nullable=True,
index=True,
)
transaction_hash = Column(
VARCHAR(256),
nullable=True,
index=True,
)
label_data = Column(JSONB, nullable=True)
block_timestamp = Column(BigInteger, index=True)
log_index = Column(Integer, nullable=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class MantleSepoliaBlock(Base): # type: ignore
__tablename__ = "mantle_sepolia_blocks"
block_number = Column(
BigInteger, primary_key=True, unique=True, nullable=False, index=True
)
difficulty = Column(BigInteger)
extra_data = Column(VARCHAR(128))
gas_limit = Column(BigInteger)
gas_used = Column(BigInteger)
base_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
hash = Column(VARCHAR(256), index=True)
logs_bloom = Column(VARCHAR(1024))
miner = Column(VARCHAR(256))
nonce = Column(VARCHAR(256))
parent_hash = Column(VARCHAR(256))
receipt_root = Column(VARCHAR(256))
uncles = Column(VARCHAR(256))
size = Column(Integer)
state_root = Column(VARCHAR(256))
timestamp = Column(BigInteger, index=True)
total_difficulty = Column(VARCHAR(256))
transactions_root = Column(VARCHAR(256))
indexed_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
mix_hash = Column(VARCHAR(256), nullable=True)
class MantleSepoliaTransaction(Base): # type: ignore
__tablename__ = "mantle_sepolia_transactions"
hash = Column(
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
)
block_number = Column(
BigInteger,
ForeignKey("mantle_sepolia_blocks.block_number", ondelete="CASCADE"),
nullable=False,
index=True,
)
from_address = Column(VARCHAR(256), index=True)
to_address = Column(VARCHAR(256), index=True)
gas = Column(Numeric(precision=78, scale=0), index=True)
gas_price = Column(Numeric(precision=78, scale=0), index=True)
max_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
max_priority_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
input = Column(Text)
nonce = Column(VARCHAR(256))
transaction_index = Column(BigInteger)
transaction_type = Column(Integer, nullable=True)
value = Column(Numeric(precision=78, scale=0), index=True)
indexed_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class MantleSepoliaLabel(Base): # type: ignore
__tablename__ = "mantle_sepolia_labels"
__table_args__ = (
Index(
"ix_mantle_sepolia_labels_address_block_number",
"address",
"block_number",
unique=False,
),
Index(
"ix_mantle_sepolia_labels_address_block_timestamp",
"address",
"block_timestamp",
unique=False,
),
)
id = Column(
UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4,
unique=True,
nullable=False,
)
label = Column(VARCHAR(256), nullable=False, index=True)
block_number = Column(
BigInteger,
nullable=True,
index=True,
)
address = Column(
VARCHAR(256),
nullable=True,
index=True,
)
transaction_hash = Column(
VARCHAR(256),
nullable=True,
index=True,
)
label_data = Column(JSONB, nullable=True)
block_timestamp = Column(BigInteger, index=True)
log_index = Column(Integer, nullable=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class ESDFunctionSignature(Base): # type: ignore
"""
Function signature from blockchain (Ethereum/Polygon) Signature Database.

Wyświetl plik

@ -6,12 +6,12 @@ from .models import (
AmoyBlock,
AmoyLabel,
AmoyTransaction,
ArbitrumOneBlock,
ArbitrumOneLabel,
ArbitrumOneTransaction,
ArbitrumNovaBlock,
ArbitrumNovaLabel,
ArbitrumNovaTransaction,
ArbitrumOneBlock,
ArbitrumOneLabel,
ArbitrumOneTransaction,
ArbitrumSepoliaBlock,
ArbitrumSepoliaLabel,
ArbitrumSepoliaTransaction,
@ -31,6 +31,12 @@ from .models import (
EthereumBlock,
EthereumLabel,
EthereumTransaction,
MantleBlock,
MantleLabel,
MantleSepoliaBlock,
MantleSepoliaLabel,
MantleSepoliaTransaction,
MantleTransaction,
MumbaiBlock,
MumbaiLabel,
MumbaiTransaction,
@ -84,6 +90,8 @@ class Network(Enum):
blast = "blast"
blast_sepolia = "blast_sepolia"
proofofplay_apex = "proofofplay_apex"
mantle = "mantle"
mantle_sepolia = "mantle_sepolia"
tx_raw_types = Union[
@ -106,6 +114,8 @@ tx_raw_types = Union[
BlastTransaction,
BlastSepoliaTransaction,
ProofOfPlayApexTransaction,
MantleTransaction,
MantleSepoliaTransaction,
]
MODELS: Dict[Network, Dict[str, Base]] = {
@ -204,6 +214,16 @@ MODELS: Dict[Network, Dict[str, Base]] = {
"labels": ProofOfPlayApexLabel,
"transactions": ProofOfPlayApexTransaction,
},
Network.mantle: {
"blocks": MantleBlock,
"labels": MantleLabel,
"transactions": MantleTransaction,
},
Network.mantle_sepolia: {
"blocks": MantleSepoliaBlock,
"labels": MantleSepoliaLabel,
"transactions": MantleSepoliaTransaction,
},
}
@ -248,5 +268,9 @@ def blockchain_type_to_network_type(
return Network.blast_sepolia
elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX:
return Network.proofofplay_apex
elif blockchain_type == AvailableBlockchainType.MANTLE:
return Network.mantle
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
return Network.mantle_sepolia
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Wyświetl plik

@ -23,6 +23,8 @@ class SubscriptionTypes(Enum):
BLAST_BLOCKCHAIN = "blast_smartcontract"
BLAST_SEPOLIA_BLOCKCHAIN = "blast_sepolia_smartcontract"
PROOFOFPLAY_APEX_BLOCKCHAIN = "proofofplay_apex_smartcontract"
MANTLE_BLOCKCHAIN = "mantle_smartcontract"
MANTLE_SEPOLIA_BLOCKCHAIN = "mantle_sepolia_smartcontract"
def blockchain_type_to_subscription_type(
@ -66,6 +68,10 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.BLAST_SEPOLIA_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX:
return SubscriptionTypes.PROOFOFPLAY_APEX_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.MANTLE:
return SubscriptionTypes.MANTLE_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
return SubscriptionTypes.MANTLE_SEPOLIA_BLOCKCHAIN
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")
@ -90,6 +96,8 @@ subscription_id_by_blockchain = {
"blast": "blast_smartcontract",
"blast_sepolia": "blast_sepolia_smartcontract",
"proofofplay_apex": "proofofplay_apex_smartcontract",
"mantle": "mantle_smartcontract",
"mantle_sepolia": "mantle_sepolia_smartcontract",
}
blockchain_by_subscription_id = {
@ -111,6 +119,8 @@ blockchain_by_subscription_id = {
"avalanche_fuji_blockchain": "avalanche_fuji",
"blast_blockchain": "blast",
"blast_sepolia_blockchain": "blast_sepolia",
"mantle_blockchain": "mantle",
"mantle_sepolia_blockchain": "mantle_sepolia",
"proofofplay_apex_blockchain": "proofofplay_apex",
"ethereum_smartcontract": "ethereum",
"polygon_smartcontract": "polygon",
@ -131,4 +141,6 @@ blockchain_by_subscription_id = {
"blast_smartcontract": "blast",
"blast_sepolia_smartcontract": "blast_sepolia",
"proofofplay_apex_smartcontract": "proofofplay_apex",
"mantle_smartcontract": "mantle",
"mantle_sepolia_smartcontract": "mantle_sepolia",
}

Wyświetl plik

@ -2,4 +2,4 @@
Moonstream database version.
"""
MOONSTREAMDB_VERSION = "0.4.4"
MOONSTREAMDB_VERSION = "0.4.5"