Add Wyrm chain.

pull/761/head
Andrey 2023-03-06 17:58:25 +02:00
rodzic 1e60876519
commit d2836d7d41
10 zmienionych plików z 231 dodań i 164 usunięć

Wyświetl plik

@ -48,12 +48,12 @@ blockchain_by_subscription_id = {
"polygon_blockchain": "polygon",
"mumbai_blockchain": "mumbai",
"xdai_blockchain": "xdai",
"caldera_blockchain": "caldera",
"wyrm_blockchain": "caldera",
"ethereum_smartcontract": "ethereum",
"polygon_smartcontract": "polygon",
"mumbai_smartcontract": "mumbai",
"xdai_smartcontract": "xdai",
"caldera_smartcontract": "caldera",
"wyrm_smartcontract": "caldera",
}

Wyświetl plik

@ -57,11 +57,11 @@ CANONICAL_SUBSCRIPTION_TYPES = {
stripe_price_id=None,
active=True,
),
"caldera_smartcontract": SubscriptionTypeResourceData(
id="caldera_smartcontract",
name="Caldera smartcontract",
"wyrm_smartcontract": SubscriptionTypeResourceData(
id="wyrm_smartcontract",
name="Wyrm smartcontract",
choices=["input:address", "tag:erc721"],
description="Contracts events and tx_calls of contract of Caldera blockchain.",
description="Contracts events and tx_calls of contract of Wyrm blockchain.",
icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/xdai-token-logo.png",
stripe_product_id=None,
stripe_price_id=None,
@ -107,11 +107,11 @@ CANONICAL_SUBSCRIPTION_TYPES = {
stripe_price_id=None,
active=True,
),
"caldera_blockchain": SubscriptionTypeResourceData(
id="caldera_blockchain",
name="Caldera transactions",
"wyrm_blockchain": SubscriptionTypeResourceData(
id="wyrm_blockchain",
name="Wyrm transactions",
choices=["input:address", "tag:erc721"],
description="Caldera chain transactions subscription.",
description="Wyrm chain transactions subscription.",
icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/xdai-token-logo.png",
stripe_product_id=None,
stripe_price_id=None,

Wyświetl plik

@ -29,7 +29,7 @@ from .settings import (
MOONSTREAM_POLYGON_WEB3_PROVIDER_URI,
MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI,
MOONSTREAM_XDAI_WEB3_PROVIDER_URI,
MOONSTREAM_CALDERA_WEB3_PROVIDER_URI,
MOONSTREAM_WYRM_WEB3_PROVIDER_URI,
NB_ACCESS_ID_HEADER,
NB_DATA_SOURCE_HEADER,
WEB3_CLIENT_REQUEST_TIMEOUT_SECONDS,
@ -71,8 +71,8 @@ def connect(
web3_uri = MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI
elif blockchain_type == AvailableBlockchainType.XDAI:
web3_uri = MOONSTREAM_XDAI_WEB3_PROVIDER_URI
elif blockchain_type == AvailableBlockchainType.CALDERA:
web3_uri = MOONSTREAM_CALDERA_WEB3_PROVIDER_URI
elif blockchain_type == AvailableBlockchainType.WYRM:
web3_uri = MOONSTREAM_WYRM_WEB3_PROVIDER_URI
else:
raise Exception("Wrong blockchain type provided for web3 URI")

Wyświetl plik

@ -31,7 +31,7 @@ class SubscriptionTypes(Enum):
ETHEREUM_BLOCKCHAIN = "ethereum_smartcontract"
MUMBAI_BLOCKCHAIN = "mumbai_smartcontract"
XDAI_BLOCKCHAIN = "xdai_smartcontract"
CALDERA_BLOCKCHAIN = "caldera_smartcontract"
WYRM_BLOCKCHAIN = "wyrm_smartcontract"
def abi_input_signature(input_abi: Dict[str, Any]) -> str:
@ -134,8 +134,8 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.MUMBAI_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.XDAI:
return SubscriptionTypes.XDAI_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.CALDERA:
return SubscriptionTypes.CALDERA_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.WYRM:
return SubscriptionTypes.WYRM_BLOCKCHAIN
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Wyświetl plik

@ -99,11 +99,11 @@ MOONSTREAM_XDAI_WEB3_PROVIDER_URI = os.environ.get(
if MOONSTREAM_XDAI_WEB3_PROVIDER_URI == "":
raise Exception("MOONSTREAM_XDAI_WEB3_PROVIDER_URI env variable is not set")
MOONSTREAM_CALDERA_WEB3_PROVIDER_URI = os.environ.get(
"MOONSTREAM_CALDERA_WEB3_PROVIDER_URI", ""
MOONSTREAM_WYRM_WEB3_PROVIDER_URI = os.environ.get(
"MOONSTREAM_WYRM_WEB3_PROVIDER_URI", ""
)
if MOONSTREAM_CALDERA_WEB3_PROVIDER_URI == "":
raise Exception("MOONSTREAM_CALDERA_WEB3_PROVIDER_URI env variable is not set")
if MOONSTREAM_WYRM_WEB3_PROVIDER_URI == "":
raise Exception("MOONSTREAM_WYRM_WEB3_PROVIDER_URI env variable is not set")
MOONSTREAM_CRAWL_WORKERS = 4
MOONSTREAM_CRAWL_WORKERS_RAW = os.environ.get("MOONSTREAM_CRAWL_WORKERS")

Wyświetl plik

@ -1,116 +0,0 @@
"""Create caldera blockchain tables
Revision ID: 5093601738e5
Revises: 11233cf42d62
Create Date: 2023-03-01 17:16:32.033661
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '5093601738e5'
down_revision = '11233cf42d62'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('caldera_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.PrimaryKeyConstraint('block_number', name=op.f('pk_caldera_blocks'))
)
op.create_index(op.f('ix_caldera_blocks_block_number'), 'caldera_blocks', ['block_number'], unique=True)
op.create_index(op.f('ix_caldera_blocks_hash'), 'caldera_blocks', ['hash'], unique=False)
op.create_index(op.f('ix_caldera_blocks_timestamp'), 'caldera_blocks', ['timestamp'], unique=False)
op.create_table('caldera_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_caldera_labels')),
sa.UniqueConstraint('id', name=op.f('uq_caldera_labels_id'))
)
op.create_index(op.f('ix_caldera_labels_address'), 'caldera_labels', ['address'], unique=False)
op.create_index('ix_caldera_labels_address_block_number', 'caldera_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_caldera_labels_address_block_timestamp', 'caldera_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_caldera_labels_block_number'), 'caldera_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_caldera_labels_block_timestamp'), 'caldera_labels', ['block_timestamp'], unique=False)
op.create_index(op.f('ix_caldera_labels_label'), 'caldera_labels', ['label'], unique=False)
op.create_index(op.f('ix_caldera_labels_transaction_hash'), 'caldera_labels', ['transaction_hash'], unique=False)
op.create_table('caldera_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'], ['caldera_blocks.block_number'], name=op.f('fk_caldera_transactions_block_number_caldera_blocks'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('hash', name=op.f('pk_caldera_transactions'))
)
op.create_index(op.f('ix_caldera_transactions_block_number'), 'caldera_transactions', ['block_number'], unique=False)
op.create_index(op.f('ix_caldera_transactions_from_address'), 'caldera_transactions', ['from_address'], unique=False)
op.create_index(op.f('ix_caldera_transactions_gas'), 'caldera_transactions', ['gas'], unique=False)
op.create_index(op.f('ix_caldera_transactions_gas_price'), 'caldera_transactions', ['gas_price'], unique=False)
op.create_index(op.f('ix_caldera_transactions_hash'), 'caldera_transactions', ['hash'], unique=True)
op.create_index(op.f('ix_caldera_transactions_to_address'), 'caldera_transactions', ['to_address'], unique=False)
op.create_index(op.f('ix_caldera_transactions_value'), 'caldera_transactions', ['value'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_caldera_transactions_value'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_to_address'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_hash'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_gas_price'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_gas'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_from_address'), table_name='caldera_transactions')
op.drop_index(op.f('ix_caldera_transactions_block_number'), table_name='caldera_transactions')
op.drop_table('caldera_transactions')
op.drop_index(op.f('ix_caldera_labels_transaction_hash'), table_name='caldera_labels')
op.drop_index(op.f('ix_caldera_labels_label'), table_name='caldera_labels')
op.drop_index(op.f('ix_caldera_labels_block_timestamp'), table_name='caldera_labels')
op.drop_index(op.f('ix_caldera_labels_block_number'), table_name='caldera_labels')
op.drop_index('ix_caldera_labels_address_block_timestamp', table_name='caldera_labels')
op.drop_index('ix_caldera_labels_address_block_number', table_name='caldera_labels')
op.drop_index(op.f('ix_caldera_labels_address'), table_name='caldera_labels')
op.drop_table('caldera_labels')
op.drop_index(op.f('ix_caldera_blocks_timestamp'), table_name='caldera_blocks')
op.drop_index(op.f('ix_caldera_blocks_hash'), table_name='caldera_blocks')
op.drop_index(op.f('ix_caldera_blocks_block_number'), table_name='caldera_blocks')
op.drop_table('caldera_blocks')
# ### end Alembic commands ###

Wyświetl plik

@ -0,0 +1,116 @@
"""add-wyrm-chain
Revision ID: c413d5265f76
Revises: 11233cf42d62
Create Date: 2023-03-02 18:02:58.934085
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'c413d5265f76'
down_revision = '11233cf42d62'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('wyrm_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.PrimaryKeyConstraint('block_number', name=op.f('pk_wyrm_blocks'))
)
op.create_index(op.f('ix_wyrm_blocks_block_number'), 'wyrm_blocks', ['block_number'], unique=True)
op.create_index(op.f('ix_wyrm_blocks_hash'), 'wyrm_blocks', ['hash'], unique=False)
op.create_index(op.f('ix_wyrm_blocks_timestamp'), 'wyrm_blocks', ['timestamp'], unique=False)
op.create_table('wyrm_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_wyrm_labels')),
sa.UniqueConstraint('id', name=op.f('uq_wyrm_labels_id'))
)
op.create_index(op.f('ix_wyrm_labels_address'), 'wyrm_labels', ['address'], unique=False)
op.create_index('ix_wyrm_labels_address_block_number', 'wyrm_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_wyrm_labels_address_block_timestamp', 'wyrm_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_wyrm_labels_block_number'), 'wyrm_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_wyrm_labels_block_timestamp'), 'wyrm_labels', ['block_timestamp'], unique=False)
op.create_index(op.f('ix_wyrm_labels_label'), 'wyrm_labels', ['label'], unique=False)
op.create_index(op.f('ix_wyrm_labels_transaction_hash'), 'wyrm_labels', ['transaction_hash'], unique=False)
op.create_table('wyrm_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'], ['wyrm_blocks.block_number'], name=op.f('fk_wyrm_transactions_block_number_wyrm_blocks'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('hash', name=op.f('pk_wyrm_transactions'))
)
op.create_index(op.f('ix_wyrm_transactions_block_number'), 'wyrm_transactions', ['block_number'], unique=False)
op.create_index(op.f('ix_wyrm_transactions_from_address'), 'wyrm_transactions', ['from_address'], unique=False)
op.create_index(op.f('ix_wyrm_transactions_gas'), 'wyrm_transactions', ['gas'], unique=False)
op.create_index(op.f('ix_wyrm_transactions_gas_price'), 'wyrm_transactions', ['gas_price'], unique=False)
op.create_index(op.f('ix_wyrm_transactions_hash'), 'wyrm_transactions', ['hash'], unique=True)
op.create_index(op.f('ix_wyrm_transactions_to_address'), 'wyrm_transactions', ['to_address'], unique=False)
op.create_index(op.f('ix_wyrm_transactions_value'), 'wyrm_transactions', ['value'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_wyrm_transactions_value'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_to_address'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_hash'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_gas_price'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_gas'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_from_address'), table_name='wyrm_transactions')
op.drop_index(op.f('ix_wyrm_transactions_block_number'), table_name='wyrm_transactions')
op.drop_table('wyrm_transactions')
op.drop_index(op.f('ix_wyrm_labels_transaction_hash'), table_name='wyrm_labels')
op.drop_index(op.f('ix_wyrm_labels_label'), table_name='wyrm_labels')
op.drop_index(op.f('ix_wyrm_labels_block_timestamp'), table_name='wyrm_labels')
op.drop_index(op.f('ix_wyrm_labels_block_number'), table_name='wyrm_labels')
op.drop_index('ix_wyrm_labels_address_block_timestamp', table_name='wyrm_labels')
op.drop_index('ix_wyrm_labels_address_block_number', table_name='wyrm_labels')
op.drop_index(op.f('ix_wyrm_labels_address'), table_name='wyrm_labels')
op.drop_table('wyrm_labels')
op.drop_index(op.f('ix_wyrm_blocks_timestamp'), table_name='wyrm_blocks')
op.drop_index(op.f('ix_wyrm_blocks_hash'), table_name='wyrm_blocks')
op.drop_index(op.f('ix_wyrm_blocks_block_number'), table_name='wyrm_blocks')
op.drop_table('wyrm_blocks')
# ### end Alembic commands ###

Wyświetl plik

@ -12,9 +12,9 @@ from .models import (
XDaiBlock,
XDaiLabel,
XDaiTransaction,
CalderaBlock,
CalderaLabel,
CalderaTransaction
WyrmBlock,
WyrmLabel,
WyrmTransaction
)
from enum import Enum
@ -27,17 +27,17 @@ class AvailableBlockchainType(Enum):
POLYGON = "polygon"
MUMBAI = "mumbai"
XDAI = "xdai"
CALDERA = "caldera"
WYRM = "wyrm"
def get_block_model(
blockchain_type: AvailableBlockchainType,
) -> Type[Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock]]:
) -> Type[Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock, WyrmBlock]]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai or XDai,
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm
set proper blocks model.
"""
block_model: Type[Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock]]
block_model: Type[Union[EthereumBlock, PolygonBlock, MumbaiBlock, XDaiBlock,WyrmBlock]]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
block_model = EthereumBlock
elif blockchain_type == AvailableBlockchainType.POLYGON:
@ -46,8 +46,8 @@ def get_block_model(
block_model = MumbaiBlock
elif blockchain_type == AvailableBlockchainType.XDAI:
block_model = XDaiBlock
elif blockchain_type == AvailableBlockchainType.CALDERA:
block_model = CalderaBlock
elif blockchain_type == AvailableBlockchainType.WYRM:
block_model = WyrmBlock
else:
raise Exception("Unsupported blockchain type provided")
@ -56,12 +56,12 @@ def get_block_model(
def get_label_model(
blockchain_type: AvailableBlockchainType,
) -> Type[Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel]]:
) -> Type[Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel, WyrmLabel]]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai or XDai,
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm
set proper block label model.
"""
label_model: Type[Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel]]
label_model: Type[Union[EthereumLabel, PolygonLabel, MumbaiLabel, XDaiLabel, WyrmLabel]]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
label_model = EthereumLabel
elif blockchain_type == AvailableBlockchainType.POLYGON:
@ -70,8 +70,8 @@ def get_label_model(
label_model = MumbaiLabel
elif blockchain_type == AvailableBlockchainType.XDAI:
label_model = XDaiLabel
elif blockchain_type == AvailableBlockchainType.CALDERA:
label_model = CalderaLabel
elif blockchain_type == AvailableBlockchainType.WYRM:
label_model = WyrmLabel
else:
raise Exception("Unsupported blockchain type provided")
@ -81,15 +81,15 @@ def get_label_model(
def get_transaction_model(
blockchain_type: AvailableBlockchainType,
) -> Type[
Union[EthereumTransaction, PolygonTransaction, MumbaiTransaction, XDaiTransaction]
Union[EthereumTransaction, PolygonTransaction, MumbaiTransaction, XDaiTransaction, WyrmTransaction]
]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai or XDai,
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm
set proper block transactions model.
"""
transaction_model: Type[
Union[
EthereumTransaction, PolygonTransaction, MumbaiTransaction, XDaiTransaction
EthereumTransaction, PolygonTransaction, MumbaiTransaction, XDaiTransaction, WyrmTransaction
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -100,8 +100,8 @@ def get_transaction_model(
transaction_model = MumbaiTransaction
elif blockchain_type == AvailableBlockchainType.XDAI:
transaction_model = XDaiTransaction
elif blockchain_type == AvailableBlockchainType.CALDERA:
transaction_model = CalderaTransaction
elif blockchain_type == AvailableBlockchainType.WYRM:
transaction_model = WyrmTransaction
else:
raise Exception("Unsupported blockchain type provided")

Wyświetl plik

@ -493,8 +493,8 @@ class XDaiLabel(Base): # type: ignore
)
class CalderaBlock(Base): # type: ignore
__tablename__ = "caldera_blocks"
class WyrmBlock(Base): # type: ignore
__tablename__ = "wyrm_blocks"
block_number = Column(
BigInteger, primary_key=True, unique=True, nullable=False, index=True
@ -521,15 +521,15 @@ class CalderaBlock(Base): # type: ignore
)
class CalderaTransaction(Base): # type: ignore
__tablename__ = "caldera_transactions"
class WyrmTransaction(Base): # type: ignore
__tablename__ = "wyrm_transactions"
hash = Column(
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
)
block_number = Column(
BigInteger,
ForeignKey("caldera_blocks.block_number", ondelete="CASCADE"),
ForeignKey("wyrm_blocks.block_number", ondelete="CASCADE"),
nullable=False,
index=True,
)
@ -550,7 +550,7 @@ class CalderaTransaction(Base): # type: ignore
)
class CalderaLabel(Base): # type: ignore
class WyrmLabel(Base): # type: ignore
"""
Example of label_data:
{
@ -566,17 +566,17 @@ class CalderaLabel(Base): # type: ignore
}
"""
__tablename__ = "caldera_labels"
__tablename__ = "wyrm_labels"
__table_args__ = (
Index(
"ix_caldera_labels_address_block_number",
"ix_wyrm_labels_address_block_number",
"address",
"block_number",
unique=False,
),
Index(
"ix_caldera_labels_address_block_timestamp",
"ix_wyrm_labels_address_block_timestamp",
"address",
"block_timestamp",
unique=False,

Wyświetl plik

@ -0,0 +1,67 @@
from enum import Enum
from typing import Dict, Union
from .models import (
Base,
EthereumBlock,
EthereumLabel,
EthereumTransaction,
MumbaiBlock,
MumbaiLabel,
MumbaiTransaction,
PolygonBlock,
PolygonLabel,
PolygonTransaction,
WyrmBlock,
WyrmLabel,
WyrmTransaction,
XDaiBlock,
XDaiLabel,
XDaiTransaction,
)
class Network(Enum):
ethereum = "ethereum"
polygon = "polygon"
mumbai = "mumbai"
xdai = "xdai"
wyrm = "wyrm"
tx_raw_types = Union[
EthereumTransaction,
MumbaiTransaction,
PolygonTransaction,
WyrmTransaction,
XDaiTransaction
]
MODELS: Dict[Network, Dict[str, Base]] = {
Network.ethereum: {
"blocks": EthereumBlock,
"labels": EthereumLabel,
"transactions": EthereumTransaction,
},
Network.mumbai: {
"blocks": MumbaiBlock,
"labels": MumbaiLabel,
"transactions": MumbaiTransaction,
},
Network.polygon: {
"blocks": PolygonBlock,
"labels": PolygonLabel,
"transactions": PolygonTransaction,
},
Network.xdai: {
"blocks": XDaiBlock,
"labels": XDaiLabel,
"transactions": XDaiTransaction,
},
Network.wyrm: {
"blocks": WyrmBlock,
"labels": WyrmLabel,
"transactions": WyrmTransaction,
},
}