kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #332 from bugout-dev/test-ethereum-addresses-removing
Remove import EthereumAddresses from etherscan and fix join on nft derivepull/352/head
commit
9b0a267023
|
@ -12,7 +12,7 @@ from typing import Any, List, Optional, Dict
|
||||||
|
|
||||||
import boto3 # type: ignore
|
import boto3 # type: ignore
|
||||||
from moonstreamdb.db import yield_db_session_ctx
|
from moonstreamdb.db import yield_db_session_ctx
|
||||||
from moonstreamdb.models import EthereumAddress, EthereumLabel
|
from moonstreamdb.models import EthereumLabel
|
||||||
import requests
|
import requests
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ from typing import Any, cast, Iterator, List, Optional, Set
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from moonstreamdb.models import (
|
from moonstreamdb.models import (
|
||||||
EthereumAddress,
|
|
||||||
EthereumLabel,
|
EthereumLabel,
|
||||||
EthereumTransaction,
|
EthereumTransaction,
|
||||||
EthereumBlock,
|
EthereumBlock,
|
||||||
|
@ -49,7 +48,7 @@ def add_events(
|
||||||
db_session.query(
|
db_session.query(
|
||||||
EthereumLabel.id,
|
EthereumLabel.id,
|
||||||
EthereumLabel.label,
|
EthereumLabel.label,
|
||||||
EthereumAddress.address,
|
EthereumLabel.address,
|
||||||
EthereumLabel.label_data,
|
EthereumLabel.label_data,
|
||||||
EthereumLabel.transaction_hash,
|
EthereumLabel.transaction_hash,
|
||||||
EthereumTransaction.value,
|
EthereumTransaction.value,
|
||||||
|
@ -57,7 +56,6 @@ def add_events(
|
||||||
EthereumBlock.timestamp,
|
EthereumBlock.timestamp,
|
||||||
)
|
)
|
||||||
.filter(EthereumLabel.label == event_type.value)
|
.filter(EthereumLabel.label == event_type.value)
|
||||||
.join(EthereumAddress, EthereumLabel.address_id == EthereumAddress.id)
|
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
EthereumTransaction,
|
EthereumTransaction,
|
||||||
EthereumLabel.transaction_hash == EthereumTransaction.hash,
|
EthereumLabel.transaction_hash == EthereumTransaction.hash,
|
||||||
|
@ -66,7 +64,9 @@ def add_events(
|
||||||
EthereumBlock,
|
EthereumBlock,
|
||||||
EthereumTransaction.block_number == EthereumBlock.block_number,
|
EthereumTransaction.block_number == EthereumBlock.block_number,
|
||||||
)
|
)
|
||||||
.order_by(EthereumLabel.created_at.asc(),)
|
.order_by(
|
||||||
|
EthereumLabel.created_at.asc(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if bounds is not None:
|
if bounds is not None:
|
||||||
time_filters = [EthereumTransaction.block_number >= bounds.starting_block]
|
time_filters = [EthereumTransaction.block_number >= bounds.starting_block]
|
||||||
|
@ -145,7 +145,12 @@ def create_dataset(
|
||||||
add_contracts_metadata(datastore_conn, db_session, offset, batch_size)
|
add_contracts_metadata(datastore_conn, db_session, offset, batch_size)
|
||||||
else:
|
else:
|
||||||
add_events(
|
add_events(
|
||||||
datastore_conn, db_session, event_type, offset, bounds, batch_size,
|
datastore_conn,
|
||||||
|
db_session,
|
||||||
|
event_type,
|
||||||
|
offset,
|
||||||
|
bounds,
|
||||||
|
batch_size,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,10 +162,9 @@ def add_contracts_metadata(
|
||||||
) -> None:
|
) -> None:
|
||||||
logger.info("Adding erc721 contract metadata")
|
logger.info("Adding erc721 contract metadata")
|
||||||
query = (
|
query = (
|
||||||
db_session.query(EthereumLabel.label_data, EthereumAddress.address)
|
db_session.query(EthereumLabel.label_data, EthereumLabel.address)
|
||||||
.filter(EthereumLabel.label == EventType.ERC721.value)
|
.filter(EthereumLabel.label == EventType.ERC721.value)
|
||||||
.join(EthereumAddress, EthereumLabel.address_id == EthereumAddress.id)
|
.order_by(EthereumLabel.created_at)
|
||||||
.order_by(EthereumLabel.created_at, EthereumLabel.address_id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
offset = initial_offset
|
offset = initial_offset
|
||||||
|
|
Ładowanie…
Reference in New Issue