kopia lustrzana https://github.com/bugout-dev/moonstream
Add fixes for mypy and remove old code.
rodzic
f544d43a1b
commit
d021f82ed9
|
@ -26,14 +26,6 @@ ConditionKeys = Literal["$and", "$or"]
|
||||||
|
|
||||||
conditions_keys = ["AND", "OR"]
|
conditions_keys = ["AND", "OR"]
|
||||||
|
|
||||||
|
|
||||||
# {"data.block_number": None},
|
|
||||||
# {"data.address": None},
|
|
||||||
# {"data.transaction_hash": None},
|
|
||||||
# {"data.label_data": None},
|
|
||||||
# {"data.block_timestamp": None},
|
|
||||||
# {"data.log_index": None},
|
|
||||||
# {"data.created_at": None},
|
|
||||||
accessible_columns = [
|
accessible_columns = [
|
||||||
"address",
|
"address",
|
||||||
"transaction_hash",
|
"transaction_hash",
|
||||||
|
@ -307,6 +299,8 @@ class SelectMap(BaseModel):
|
||||||
MAP: List[Dict[str, Any]] = Field(alias="$map")
|
MAP: List[Dict[str, Any]] = Field(alias="$map")
|
||||||
|
|
||||||
|
|
||||||
|
# On progress
|
||||||
|
# Validation of query on pydentic level
|
||||||
class Filters(BaseModel):
|
class Filters(BaseModel):
|
||||||
AND: Optional[List[Dict[str, "Filters"]]] = Field(alias="$and")
|
AND: Optional[List[Dict[str, "Filters"]]] = Field(alias="$and")
|
||||||
OR: Optional[List[Dict[str, "Filters"]]] = Field(alias="$or")
|
OR: Optional[List[Dict[str, "Filters"]]] = Field(alias="$or")
|
||||||
|
|
|
@ -7,12 +7,11 @@ from dataclasses import dataclass, field
|
||||||
from multiprocessing import Condition
|
from multiprocessing import Condition
|
||||||
from re import A, L
|
from re import A, L
|
||||||
from tkinter.messagebox import NO
|
from tkinter.messagebox import NO
|
||||||
from typing import Any, Dict, List, Optional, Tuple, cast
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
from black import patch_click
|
from black import patch_click
|
||||||
|
|
||||||
from bugout.app import Bugout
|
from bugout.app import Bugout
|
||||||
from bugout.data import BugoutResource
|
from bugout.data import BugoutResource
|
||||||
from eth_utils import address
|
|
||||||
from moonstreamdb.blockchain import AvailableBlockchainType, get_label_model
|
from moonstreamdb.blockchain import AvailableBlockchainType, get_label_model
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
and_,
|
and_,
|
||||||
|
@ -53,37 +52,6 @@ default_time_interval_seconds: int = 5 * 60
|
||||||
estimated_events_per_time_interval: float = 5 * 800
|
estimated_events_per_time_interval: float = 5 * 800
|
||||||
|
|
||||||
|
|
||||||
operator_dict = {}
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class ArgsFilters:
|
|
||||||
name: str
|
|
||||||
value: Any
|
|
||||||
type: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class LabelsFilters:
|
|
||||||
|
|
||||||
name: str
|
|
||||||
type: str
|
|
||||||
args: List[ArgsFilters] = field(default_factory=list)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class AddressFilters:
|
|
||||||
|
|
||||||
address: str
|
|
||||||
label_filters: List[LabelsFilters] = field(default_factory=list)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Filters:
|
|
||||||
|
|
||||||
addresses: List[AddressFilters] = field(default_factory=list)
|
|
||||||
|
|
||||||
|
|
||||||
class MoonwormProvider:
|
class MoonwormProvider:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -97,7 +65,9 @@ class MoonwormProvider:
|
||||||
self.description = description
|
self.description = description
|
||||||
self.valid_period_seconds = streamboaundary_range_limit
|
self.valid_period_seconds = streamboaundary_range_limit
|
||||||
|
|
||||||
def default_filters(self, subscriptions: List[BugoutResource]) -> data.EventFilters:
|
def default_filters(
|
||||||
|
self, subscriptions: List[BugoutResource]
|
||||||
|
) -> Tuple[data.EventFilters, List[str]]:
|
||||||
"""
|
"""
|
||||||
Default filter strings for the given list of subscriptions.
|
Default filter strings for the given list of subscriptions.
|
||||||
"""
|
"""
|
||||||
|
@ -114,6 +84,7 @@ class MoonwormProvider:
|
||||||
f"Could not find subscription address for subscription with resource id: {subscription.id}"
|
f"Could not find subscription address for subscription with resource id: {subscription.id}"
|
||||||
)
|
)
|
||||||
# Add addresses only without filters
|
# Add addresses only without filters
|
||||||
|
# Predefined query for usual frontend behaivior
|
||||||
|
|
||||||
if addresses:
|
if addresses:
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,7 @@ class StreamQuery:
|
||||||
subscriptions: List[Tuple[str, str]] = field(default_factory=list)
|
subscriptions: List[Tuple[str, str]] = field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
# custom parser
|
|
||||||
EVENTS_PREFIX = "events:"
|
|
||||||
EVENT_ADDRESS_PREFIX = "event_address:"
|
|
||||||
EVENT_LABEL_PREFIX = "event_label:"
|
|
||||||
EVENT_ARGS_PREFIX = "argument:"
|
|
||||||
|
|
||||||
# parse as custom parser
|
|
||||||
EVENTS_PREFIX = "events:"
|
|
||||||
EVENT_ADDRESS_PREFIX = "address:"
|
|
||||||
EVENT_LABEL_PREFIX = "label:"
|
|
||||||
EVENT_ARGS_PREFIX = "arg_type:"
|
|
||||||
EVENT_ARGS_OPERATOR_PREFIX = "arg_operation:"
|
|
||||||
EVENT_ARGS_VALUE_PREFIX = "arg_value:"
|
|
||||||
|
|
||||||
|
|
||||||
# example of object parser
|
|
||||||
|
|
||||||
EVENT_PREFIX = "event:"
|
EVENT_PREFIX = "event:"
|
||||||
EVENT_ADDRESS_PREFIX = "address:"
|
|
||||||
EVENT_LABEL_PREFIX = "label:"
|
|
||||||
EVENT_ARGS_PREFIX = "arg_type:"
|
|
||||||
EVENT_ARGS_OPERATOR_PREFIX = "arg_operation:"
|
|
||||||
EVENT_ARGS_VALUE_PREFIX = "arg_value:"
|
|
||||||
|
|
||||||
|
|
||||||
SUBSCRIPTION_TYPE_PREFIX = "type:"
|
SUBSCRIPTION_TYPE_PREFIX = "type:"
|
||||||
SUBSCRIPTION_PREFIX = "sub:"
|
SUBSCRIPTION_PREFIX = "sub:"
|
||||||
SUBSCRIPTION_SEPARATOR = ":"
|
SUBSCRIPTION_SEPARATOR = ":"
|
||||||
|
@ -67,71 +43,8 @@ def parse_query_string(q: str) -> StreamQuery:
|
||||||
b. Tokens of the form "type:<subscription_type>" populate the subscription_types field of the resulting StreamQuery.
|
b. Tokens of the form "type:<subscription_type>" populate the subscription_types field of the resulting StreamQuery.
|
||||||
c. Tokens of the form "sub:<subscription_type>:<filter> populate the subscriptions field of the resulting StreamQuery.
|
c. Tokens of the form "sub:<subscription_type>:<filter> populate the subscriptions field of the resulting StreamQuery.
|
||||||
This "<filter>" should be a valid filter for the event provider corresponding to the given subscription type.
|
This "<filter>" should be a valid filter for the event provider corresponding to the given subscription type.
|
||||||
|
d. Tokens of the form "event:<query>" query wich writed via schema defined in https://github.com/bugout-dev/moonstream/issues/534
|
||||||
event:<address>:<event_name>:<argument_name>:<argument_type>:<operator>:<arg_value>
|
This query was transfor to sqlalchemy query to datbase wich give ability request any kind of data from labels tabel.
|
||||||
|
|
||||||
#
|
|
||||||
tx_call
|
|
||||||
event
|
|
||||||
|
|
||||||
{
|
|
||||||
output_statment: [
|
|
||||||
block_timestamp:{
|
|
||||||
func:
|
|
||||||
type:
|
|
||||||
}
|
|
||||||
address:{
|
|
||||||
func:
|
|
||||||
type:
|
|
||||||
}
|
|
||||||
args:{
|
|
||||||
name:
|
|
||||||
unc:
|
|
||||||
type:
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
filters :[ # All times or
|
|
||||||
{
|
|
||||||
"address": "0xe77bbFD8ED65720F187eFdD109e38D75EaCa7385",
|
|
||||||
"label_filters": [
|
|
||||||
{
|
|
||||||
"name": "Transfer"
|
|
||||||
"type": "metod"
|
|
||||||
"args": [
|
|
||||||
{
|
|
||||||
"name": "to"
|
|
||||||
"value": "0x962355fC06e85A341E9f20C395F2fe70f25E793E"
|
|
||||||
"type": "str"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"address": "0x1AaaC93313A263992b682DCA299142eCdA0a43Bc",
|
|
||||||
"label_filters": [
|
|
||||||
{
|
|
||||||
"name": "Transfer"
|
|
||||||
"type": "metod"
|
|
||||||
"args_filters": [
|
|
||||||
"amount[int]>=5"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
},
|
|
||||||
]
|
|
||||||
group_condition: [
|
|
||||||
|
|
||||||
]
|
|
||||||
order_by":[
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns: Parsed StreamQuery object.
|
Returns: Parsed StreamQuery object.
|
||||||
"""
|
"""
|
||||||
|
|
Ładowanie…
Reference in New Issue