kopia lustrzana https://github.com/bugout-dev/moonstream
Add fixes.
rodzic
cdb59e4857
commit
05ea8a72d0
|
@ -17,6 +17,26 @@ from ..settings import (
|
|||
from ..settings import bugout_client as bc
|
||||
|
||||
CANONICAL_SUBSCRIPTION_TYPES = {
|
||||
"ethereum_smartcontract": SubscriptionTypeResourceData(
|
||||
id="ethereum_smartcontract",
|
||||
name="Ethereum smartcontracts",
|
||||
choices=["input:address", "tag:erc721"],
|
||||
description="Contracts events and tx_calls of contract of Ethereum blockchain",
|
||||
icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/ethereum/eth-diamond-purple.png",
|
||||
stripe_product_id=None,
|
||||
stripe_price_id=None,
|
||||
active=True,
|
||||
),
|
||||
"polygon_smartcontract": SubscriptionTypeResourceData(
|
||||
id="polygon_smartcontract",
|
||||
name="Polygon smartcontracts",
|
||||
choices=["input:address", "tag:erc721"],
|
||||
description="Contracts events and tx_calls of contract of Polygon blockchain",
|
||||
icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/ethereum/eth-diamond-purple.png",
|
||||
stripe_product_id=None,
|
||||
stripe_price_id=None,
|
||||
active=True,
|
||||
),
|
||||
"ethereum_blockchain": SubscriptionTypeResourceData(
|
||||
id="ethereum_blockchain",
|
||||
name="Ethereum transactions",
|
||||
|
|
|
@ -10,7 +10,7 @@ from moonstreamdb.blockchain import (
|
|||
AvailableBlockchainType,
|
||||
)
|
||||
from sqlalchemy import or_, and_, text
|
||||
from sqlalchemy.orm import Session, Query
|
||||
from sqlalchemy.orm import Session, Query, query_expression
|
||||
from sqlalchemy.sql.expression import label
|
||||
|
||||
|
||||
|
@ -259,19 +259,19 @@ class MoonwormProvider:
|
|||
for address_filter in parsed_filters.addresses:
|
||||
labels_filters = []
|
||||
for label_filter in address_filter.labels:
|
||||
args_filters = []
|
||||
for arg in label.args:
|
||||
args_filters.append(
|
||||
Labels.label_data["args"][arg.name]
|
||||
== python_type(arg.type)(arg.value)
|
||||
)
|
||||
# args_filters = []
|
||||
# for arg in label.args:
|
||||
# args_filters.append(
|
||||
# Labels.label_data["args"][arg.name]
|
||||
# == python_type(arg.type)(arg.value)
|
||||
# )
|
||||
|
||||
labels_filters.append(
|
||||
and_(
|
||||
*(
|
||||
Labels.label_data["type"] == label_filter.type,
|
||||
Labels.label_data["name"] == label_filter.name,
|
||||
or_(*args_filters),
|
||||
# or_(*args_filters),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -279,18 +279,20 @@ class MoonwormProvider:
|
|||
and_(
|
||||
*(
|
||||
Labels.address == address_filter.address,
|
||||
or_(*args_filters),
|
||||
or_(*labels_filters),
|
||||
)
|
||||
)
|
||||
)
|
||||
query = query.filters(or_(*addresses_filters))
|
||||
|
||||
query = query.filter(or_(*addresses_filters))
|
||||
|
||||
print(query)
|
||||
|
||||
return query
|
||||
|
||||
def get_events(
|
||||
self,
|
||||
db_session: Session,
|
||||
blockchain: AvailableBlockchainType,
|
||||
bugout_client: Bugout,
|
||||
data_journal_id: str,
|
||||
data_access_token: str,
|
||||
|
@ -314,7 +316,9 @@ class MoonwormProvider:
|
|||
db_session, stream_boundary, parsed_filters
|
||||
)
|
||||
|
||||
ethereum_transactions = ethereum_transactions.order_by(text("timestamp desc"))
|
||||
ethereum_transactions = ethereum_transactions.order_by(
|
||||
text("block_timestamp desc")
|
||||
)
|
||||
|
||||
# TODO(zomglings): Catch the operational error denoting that the statement timed out here
|
||||
# and wrap it in an error that tells the API to return the appropriate 400 response. Currently,
|
||||
|
@ -356,7 +360,7 @@ class MoonwormProvider:
|
|||
return None
|
||||
ethereum_transactions = (
|
||||
self.query_events(db_session, stream_boundary, parsed_filters)
|
||||
.order_by(text("timestamp desc"))
|
||||
.order_by(text("block_timestamp desc"))
|
||||
.limit(num_events)
|
||||
)
|
||||
|
||||
|
@ -393,7 +397,7 @@ class MoonwormProvider:
|
|||
|
||||
maybe_ethereum_transaction = (
|
||||
self.query_events(db_session, next_stream_boundary, parsed_filters)
|
||||
.order_by(text("timestamp asc"))
|
||||
.order_by(text("block_timestamp asc"))
|
||||
.limit(1)
|
||||
).one_or_none()
|
||||
|
||||
|
@ -431,7 +435,7 @@ class MoonwormProvider:
|
|||
return None
|
||||
maybe_ethereum_transaction = (
|
||||
self.query_events(db_session, previous_stream_boundary, parsed_filters)
|
||||
.order_by(text("timestamp desc"))
|
||||
.order_by(text("block_timestamp desc"))
|
||||
.limit(1)
|
||||
).one_or_none()
|
||||
if maybe_ethereum_transaction is None:
|
||||
|
@ -440,14 +444,14 @@ class MoonwormProvider:
|
|||
|
||||
|
||||
EthereumMoonwormProvider = MoonwormProvider(
|
||||
event_type="ethereum_blockchain",
|
||||
event_type="ethereum_smartcontract",
|
||||
blockchain=AvailableBlockchainType("ethereum"),
|
||||
description="Provider for resiving transactions from Ethereum tables.",
|
||||
streamboaundary_range_limit=2 * 60 * 60,
|
||||
)
|
||||
|
||||
PolygonMoonwormProvider = MoonwormProvider(
|
||||
event_type="polygon_blockchain",
|
||||
event_type="polygon_smartcontract",
|
||||
blockchain=AvailableBlockchainType("polygon"),
|
||||
description="Provider for resiving transactions from Polygon tables.",
|
||||
streamboaundary_range_limit=2 * 60 * 60,
|
||||
|
|
|
@ -185,7 +185,6 @@ class TransactionsProvider:
|
|||
db_session: Session,
|
||||
stream_boundary: data.StreamBoundary,
|
||||
parsed_filters: Filters,
|
||||
blockchain: AvailableBlockchainType,
|
||||
) -> Query:
|
||||
"""
|
||||
Builds a database query for Ethereum transactions that occurred within the window of time that
|
||||
|
@ -297,7 +296,6 @@ class TransactionsProvider:
|
|||
def get_events(
|
||||
self,
|
||||
db_session: Session,
|
||||
blockchain: AvailableBlockchainType,
|
||||
bugout_client: Bugout,
|
||||
data_journal_id: str,
|
||||
data_access_token: str,
|
||||
|
@ -318,7 +316,7 @@ class TransactionsProvider:
|
|||
return None
|
||||
|
||||
ethereum_transactions = self.query_transactions(
|
||||
db_session, stream_boundary, parsed_filters, blockchain
|
||||
db_session, stream_boundary, parsed_filters
|
||||
)
|
||||
|
||||
ethereum_transactions = ethereum_transactions.order_by(text("timestamp desc"))
|
||||
|
@ -342,7 +340,6 @@ class TransactionsProvider:
|
|||
def latest_events(
|
||||
self,
|
||||
db_session: Session,
|
||||
blockchain: AvailableBlockchainType,
|
||||
bugout_client: Bugout,
|
||||
data_journal_id: str,
|
||||
data_access_token: str,
|
||||
|
@ -365,9 +362,7 @@ class TransactionsProvider:
|
|||
if parsed_filters is None:
|
||||
return None
|
||||
ethereum_transactions = (
|
||||
self.query_transactions(
|
||||
db_session, stream_boundary, parsed_filters, blockchain
|
||||
)
|
||||
self.query_transactions(db_session, stream_boundary, parsed_filters)
|
||||
.order_by(text("timestamp desc"))
|
||||
.limit(num_events)
|
||||
)
|
||||
|
@ -377,7 +372,6 @@ class TransactionsProvider:
|
|||
def next_event(
|
||||
self,
|
||||
db_session: Session,
|
||||
blockchain: AvailableBlockchainType,
|
||||
bugout_client: Bugout,
|
||||
data_journal_id: str,
|
||||
data_access_token: str,
|
||||
|
@ -405,9 +399,7 @@ class TransactionsProvider:
|
|||
return None
|
||||
|
||||
maybe_ethereum_transaction = (
|
||||
self.query_transactions(
|
||||
db_session, next_stream_boundary, parsed_filters, blockchain
|
||||
)
|
||||
self.query_transactions(db_session, next_stream_boundary, parsed_filters)
|
||||
.order_by(text("timestamp asc"))
|
||||
.limit(1)
|
||||
).one_or_none()
|
||||
|
@ -419,7 +411,6 @@ class TransactionsProvider:
|
|||
def previous_event(
|
||||
self,
|
||||
db_session: Session,
|
||||
blockchain: AvailableBlockchainType,
|
||||
bugout_client: Bugout,
|
||||
data_journal_id: str,
|
||||
data_access_token: str,
|
||||
|
@ -447,7 +438,7 @@ class TransactionsProvider:
|
|||
return None
|
||||
maybe_ethereum_transaction = (
|
||||
self.query_transactions(
|
||||
db_session, previous_stream_boundary, parsed_filters, blockchain
|
||||
db_session, previous_stream_boundary, parsed_filters
|
||||
)
|
||||
.order_by(text("timestamp desc"))
|
||||
.limit(1)
|
||||
|
|
Ładowanie…
Reference in New Issue