kopia lustrzana https://github.com/bugout-dev/moonstream
ZkSync Era testnet model
rodzic
3cc70294a0
commit
a7f5e6507f
|
@ -0,0 +1,3 @@
|
|||
[settings]
|
||||
profile = black
|
||||
multi_line_output = 3
|
|
@ -1,7 +1,6 @@
|
|||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
|
@ -26,18 +25,27 @@ target_metadata = MoonstreamBase.metadata
|
|||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
from moonstreamdb.models import (
|
||||
EthereumBlock,
|
||||
EthereumTransaction,
|
||||
EthereumLabel,
|
||||
PolygonBlock,
|
||||
PolygonTransaction,
|
||||
PolygonLabel,
|
||||
MumbaiBlock,
|
||||
MumbaiTransaction,
|
||||
MumbaiLabel,
|
||||
ESDFunctionSignature,
|
||||
ESDEventSignature,
|
||||
ESDFunctionSignature,
|
||||
EthereumBlock,
|
||||
EthereumLabel,
|
||||
EthereumTransaction,
|
||||
MumbaiBlock,
|
||||
MumbaiLabel,
|
||||
MumbaiTransaction,
|
||||
OpenSeaCrawlingState,
|
||||
PolygonBlock,
|
||||
PolygonLabel,
|
||||
PolygonTransaction,
|
||||
WyrmBlock,
|
||||
WyrmLabel,
|
||||
WyrmTransaction,
|
||||
XDaiBlock,
|
||||
XDaiLabel,
|
||||
XDaiTransaction,
|
||||
ZkSyncEraTestnetBlock,
|
||||
ZkSyncEraTestnetLabel,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
)
|
||||
|
||||
|
||||
|
@ -55,6 +63,15 @@ def include_symbol(tablename, schema):
|
|||
ESDFunctionSignature.__tablename__,
|
||||
ESDEventSignature.__tablename__,
|
||||
OpenSeaCrawlingState.__tablename__,
|
||||
WyrmBlock.__tablename__,
|
||||
WyrmLabel.__tablename__,
|
||||
WyrmTransaction.__tablename__,
|
||||
XDaiBlock.__tablename__,
|
||||
XDaiLabel.__tablename__,
|
||||
XDaiTransaction.__tablename__,
|
||||
ZkSyncEraTestnetBlock.__tablename__,
|
||||
ZkSyncEraTestnetLabel.__tablename__,
|
||||
ZkSyncEraTestnetTransaction.__tablename__,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
"""ZkSync Era model
|
||||
|
||||
Revision ID: b171fd85e058
|
||||
Revises: c413d5265f76
|
||||
Create Date: 2023-07-12 11:20:19.295553
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b171fd85e058'
|
||||
down_revision = 'c413d5265f76'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('zksync_era_testnet_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.Column('sha3_uncles', sa.VARCHAR(length=256), nullable=True),
|
||||
sa.Column('l1_batch_number', sa.BigInteger(), nullable=True),
|
||||
sa.Column('l1_batch_timestamp', sa.BigInteger(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('block_number', name=op.f('pk_zksync_era_testnet_blocks'))
|
||||
)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_blocks_block_number'), 'zksync_era_testnet_blocks', ['block_number'], unique=True)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_blocks_hash'), 'zksync_era_testnet_blocks', ['hash'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_blocks_l1_batch_number'), 'zksync_era_testnet_blocks', ['l1_batch_number'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_blocks_timestamp'), 'zksync_era_testnet_blocks', ['timestamp'], unique=False)
|
||||
op.create_table('zksync_era_testnet_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_zksync_era_testnet_labels')),
|
||||
sa.UniqueConstraint('id', name=op.f('uq_zksync_era_testnet_labels_id'))
|
||||
)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_labels_address'), 'zksync_era_testnet_labels', ['address'], unique=False)
|
||||
op.create_index('ix_zksync_era_testnet_labels_address_block_number', 'zksync_era_testnet_labels', ['address', 'block_number'], unique=False)
|
||||
op.create_index('ix_zksync_era_testnet_labels_address_block_timestamp', 'zksync_era_testnet_labels', ['address', 'block_timestamp'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_labels_block_number'), 'zksync_era_testnet_labels', ['block_number'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_labels_block_timestamp'), 'zksync_era_testnet_labels', ['block_timestamp'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_labels_label'), 'zksync_era_testnet_labels', ['label'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_labels_transaction_hash'), 'zksync_era_testnet_labels', ['transaction_hash'], unique=False)
|
||||
op.create_table('zksync_era_testnet_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.Column('l1_batch_number', sa.BigInteger(), nullable=True),
|
||||
sa.Column('l1_batch_tx_index', sa.BigInteger(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['block_number'], ['zksync_era_testnet_blocks.block_number'], name=op.f('fk_zksync_era_testnet_transactions_block_number_zksync_era_testnet_blocks'), ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('hash', name=op.f('pk_zksync_era_testnet_transactions'))
|
||||
)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_block_number'), 'zksync_era_testnet_transactions', ['block_number'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_from_address'), 'zksync_era_testnet_transactions', ['from_address'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_gas'), 'zksync_era_testnet_transactions', ['gas'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_gas_price'), 'zksync_era_testnet_transactions', ['gas_price'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_hash'), 'zksync_era_testnet_transactions', ['hash'], unique=True)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_l1_batch_number'), 'zksync_era_testnet_transactions', ['l1_batch_number'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_l1_batch_tx_index'), 'zksync_era_testnet_transactions', ['l1_batch_tx_index'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_to_address'), 'zksync_era_testnet_transactions', ['to_address'], unique=False)
|
||||
op.create_index(op.f('ix_zksync_era_testnet_transactions_value'), 'zksync_era_testnet_transactions', ['value'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_value'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_to_address'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_l1_batch_tx_index'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_l1_batch_number'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_hash'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_gas_price'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_gas'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_from_address'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_transactions_block_number'), table_name='zksync_era_testnet_transactions')
|
||||
op.drop_table('zksync_era_testnet_transactions')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_labels_transaction_hash'), table_name='zksync_era_testnet_labels')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_labels_label'), table_name='zksync_era_testnet_labels')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_labels_block_timestamp'), table_name='zksync_era_testnet_labels')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_labels_block_number'), table_name='zksync_era_testnet_labels')
|
||||
op.drop_index('ix_zksync_era_testnet_labels_address_block_timestamp', table_name='zksync_era_testnet_labels')
|
||||
op.drop_index('ix_zksync_era_testnet_labels_address_block_number', table_name='zksync_era_testnet_labels')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_labels_address'), table_name='zksync_era_testnet_labels')
|
||||
op.drop_table('zksync_era_testnet_labels')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_blocks_timestamp'), table_name='zksync_era_testnet_blocks')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_blocks_l1_batch_number'), table_name='zksync_era_testnet_blocks')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_blocks_hash'), table_name='zksync_era_testnet_blocks')
|
||||
op.drop_index(op.f('ix_zksync_era_testnet_blocks_block_number'), table_name='zksync_era_testnet_blocks')
|
||||
op.drop_table('zksync_era_testnet_blocks')
|
||||
# ### end Alembic commands ###
|
|
@ -1,26 +1,27 @@
|
|||
from .db import yield_db_session, yield_db_session_ctx
|
||||
from enum import Enum
|
||||
from typing import Type, Union
|
||||
|
||||
from .models import (
|
||||
EthereumBlock,
|
||||
EthereumLabel,
|
||||
EthereumTransaction,
|
||||
PolygonBlock,
|
||||
PolygonLabel,
|
||||
PolygonTransaction,
|
||||
MumbaiBlock,
|
||||
MumbaiLabel,
|
||||
MumbaiTransaction,
|
||||
XDaiBlock,
|
||||
XDaiLabel,
|
||||
XDaiTransaction,
|
||||
PolygonBlock,
|
||||
PolygonLabel,
|
||||
PolygonTransaction,
|
||||
WyrmBlock,
|
||||
WyrmLabel,
|
||||
WyrmTransaction,
|
||||
XDaiBlock,
|
||||
XDaiLabel,
|
||||
XDaiTransaction,
|
||||
ZkSyncEraTestnetBlock,
|
||||
ZkSyncEraTestnetLabel,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
)
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from typing import Type, Union
|
||||
|
||||
|
||||
class AvailableBlockchainType(Enum):
|
||||
ETHEREUM = "ethereum"
|
||||
|
@ -28,17 +29,34 @@ class AvailableBlockchainType(Enum):
|
|||
MUMBAI = "mumbai"
|
||||
XDAI = "xdai"
|
||||
WYRM = "wyrm"
|
||||
ZKSYNC_ERA_TESTNET = "zksync_era_testnet"
|
||||
|
||||
|
||||
def get_block_model(
|
||||
blockchain_type: AvailableBlockchainType,
|
||||
) -> Type[Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock, WyrmBlock]]:
|
||||
) -> Type[
|
||||
Union[
|
||||
EthereumBlock,
|
||||
PolygonBlock,
|
||||
MumbaiBlock,
|
||||
XDaiBlock,
|
||||
WyrmBlock,
|
||||
ZkSyncEraTestnetBlock,
|
||||
]
|
||||
]:
|
||||
"""
|
||||
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm
|
||||
set proper blocks model.
|
||||
"""
|
||||
block_model: Type[
|
||||
Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock, WyrmBlock]
|
||||
Union[
|
||||
EthereumBlock,
|
||||
PolygonBlock,
|
||||
MumbaiBlock,
|
||||
XDaiBlock,
|
||||
WyrmBlock,
|
||||
ZkSyncEraTestnetBlock,
|
||||
]
|
||||
]
|
||||
if blockchain_type == AvailableBlockchainType.ETHEREUM:
|
||||
block_model = EthereumBlock
|
||||
|
@ -50,6 +68,8 @@ def get_block_model(
|
|||
block_model = XDaiBlock
|
||||
elif blockchain_type == AvailableBlockchainType.WYRM:
|
||||
block_model = WyrmBlock
|
||||
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
|
||||
block_model = ZkSyncEraTestnetBlock
|
||||
else:
|
||||
raise Exception("Unsupported blockchain type provided")
|
||||
|
||||
|
@ -58,13 +78,29 @@ def get_block_model(
|
|||
|
||||
def get_label_model(
|
||||
blockchain_type: AvailableBlockchainType,
|
||||
) -> Type[Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel, WyrmLabel]]:
|
||||
) -> Type[
|
||||
Union[
|
||||
EthereumLabel,
|
||||
PolygonLabel,
|
||||
MumbaiLabel,
|
||||
XDaiLabel,
|
||||
WyrmLabel,
|
||||
ZkSyncEraTestnetLabel,
|
||||
]
|
||||
]:
|
||||
"""
|
||||
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm
|
||||
set proper block label model.
|
||||
"""
|
||||
label_model: Type[
|
||||
Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel, WyrmLabel]
|
||||
Union[
|
||||
EthereumLabel,
|
||||
PolygonLabel,
|
||||
MumbaiLabel,
|
||||
XDaiLabel,
|
||||
WyrmLabel,
|
||||
ZkSyncEraTestnetLabel,
|
||||
]
|
||||
]
|
||||
if blockchain_type == AvailableBlockchainType.ETHEREUM:
|
||||
label_model = EthereumLabel
|
||||
|
@ -76,6 +112,8 @@ def get_label_model(
|
|||
label_model = XDaiLabel
|
||||
elif blockchain_type == AvailableBlockchainType.WYRM:
|
||||
label_model = WyrmLabel
|
||||
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
|
||||
label_model = ZkSyncEraTestnetLabel
|
||||
else:
|
||||
raise Exception("Unsupported blockchain type provided")
|
||||
|
||||
|
@ -91,6 +129,7 @@ def get_transaction_model(
|
|||
MumbaiTransaction,
|
||||
XDaiTransaction,
|
||||
WyrmTransaction,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
]
|
||||
]:
|
||||
"""
|
||||
|
@ -104,6 +143,7 @@ def get_transaction_model(
|
|||
MumbaiTransaction,
|
||||
XDaiTransaction,
|
||||
WyrmTransaction,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
]
|
||||
]
|
||||
if blockchain_type == AvailableBlockchainType.ETHEREUM:
|
||||
|
@ -116,6 +156,8 @@ def get_transaction_model(
|
|||
transaction_model = XDaiTransaction
|
||||
elif blockchain_type == AvailableBlockchainType.WYRM:
|
||||
transaction_model = WyrmTransaction
|
||||
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
|
||||
transaction_model = ZkSyncEraTestnetTransaction
|
||||
else:
|
||||
raise Exception("Unsupported blockchain type provided")
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""
|
||||
Moonstream database connection.
|
||||
"""
|
||||
from contextlib import contextmanager
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from typing import Generator
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, Session
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
MOONSTREAM_DB_URI = os.environ.get("MOONSTREAM_DB_URI")
|
||||
if MOONSTREAM_DB_URI is None:
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import uuid
|
||||
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy import (
|
||||
VARCHAR,
|
||||
BigInteger,
|
||||
Column,
|
||||
DateTime,
|
||||
ForeignKey,
|
||||
Index,
|
||||
Integer,
|
||||
ForeignKey,
|
||||
MetaData,
|
||||
Numeric,
|
||||
Text,
|
||||
VARCHAR,
|
||||
)
|
||||
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
||||
from sqlalchemy.sql import expression
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.sql import expression
|
||||
|
||||
"""
|
||||
Naming conventions doc
|
||||
|
@ -614,6 +614,137 @@ class WyrmLabel(Base): # type: ignore
|
|||
)
|
||||
|
||||
|
||||
class ZkSyncEraTestnetBlock(Base): # type: ignore
|
||||
__tablename__ = "zksync_era_testnet_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))
|
||||
sha3_uncles = Column(VARCHAR(256))
|
||||
|
||||
l1_batch_number = Column(BigInteger, index=True)
|
||||
l1_batch_timestamp = Column(BigInteger)
|
||||
|
||||
|
||||
class ZkSyncEraTestnetTransaction(Base): # type: ignore
|
||||
__tablename__ = "zksync_era_testnet_transactions"
|
||||
|
||||
hash = Column(
|
||||
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
|
||||
)
|
||||
block_number = Column(
|
||||
BigInteger,
|
||||
ForeignKey("zksync_era_testnet_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
|
||||
)
|
||||
|
||||
l1_batch_number = Column(BigInteger, index=True)
|
||||
l1_batch_tx_index = Column(BigInteger, index=True)
|
||||
|
||||
|
||||
class ZkSyncEraTestnetLabel(Base): # type: ignore
|
||||
"""
|
||||
Example of label_data:
|
||||
{
|
||||
"label": "ERC20",
|
||||
"label_data": {
|
||||
"name": "Uniswap",
|
||||
"symbol": "UNI"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Exchange"
|
||||
"label_data": {...}
|
||||
}
|
||||
"""
|
||||
|
||||
__tablename__ = "zksync_era_testnet_labels"
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"ix_zksync_era_testnet_labels_address_block_number",
|
||||
"address",
|
||||
"block_number",
|
||||
unique=False,
|
||||
),
|
||||
Index(
|
||||
"ix_zksync_era_testnet_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.
|
||||
|
|
|
@ -18,6 +18,9 @@ from .models import (
|
|||
XDaiBlock,
|
||||
XDaiLabel,
|
||||
XDaiTransaction,
|
||||
ZkSyncEraTestnetBlock,
|
||||
ZkSyncEraTestnetLabel,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
)
|
||||
|
||||
|
||||
|
@ -27,6 +30,7 @@ class Network(Enum):
|
|||
mumbai = "mumbai"
|
||||
xdai = "xdai"
|
||||
wyrm = "wyrm"
|
||||
zksync_era_testnet = "zksync_era_testnet"
|
||||
|
||||
|
||||
tx_raw_types = Union[
|
||||
|
@ -35,6 +39,7 @@ tx_raw_types = Union[
|
|||
PolygonTransaction,
|
||||
WyrmTransaction,
|
||||
XDaiTransaction,
|
||||
ZkSyncEraTestnetTransaction,
|
||||
]
|
||||
|
||||
MODELS: Dict[Network, Dict[str, Base]] = {
|
||||
|
@ -63,4 +68,9 @@ MODELS: Dict[Network, Dict[str, Base]] = {
|
|||
"labels": WyrmLabel,
|
||||
"transactions": WyrmTransaction,
|
||||
},
|
||||
Network.zksync_era_testnet: {
|
||||
"blocks": ZkSyncEraTestnetBlock,
|
||||
"labels": ZkSyncEraTestnetLabel,
|
||||
"transactions": ZkSyncEraTestnetTransaction,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
Moonstream database version.
|
||||
"""
|
||||
|
||||
MOONSTREAMDB_VERSION = "0.3.3"
|
||||
MOONSTREAMDB_VERSION = "0.3.4"
|
||||
|
|
Ładowanie…
Reference in New Issue