kopia lustrzana https://github.com/bugout-dev/moonstream
Add changes.
rodzic
7aa30542c2
commit
3b13f26514
|
@ -29,8 +29,9 @@ from moonstreamdb.subscriptions import blockchain_by_subscription_id
|
|||
from moonstreamdbv3.db import MoonstreamDBIndexesEngine
|
||||
from moonstreamdbv3.models_indexes import AbiJobs
|
||||
from slugify import slugify # type: ignore
|
||||
from sqlalchemy import text, insert
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
from web3 import Web3
|
||||
from web3._utils.validation import validate_abi
|
||||
|
||||
|
@ -634,6 +635,7 @@ def add_abi_to_db(
|
|||
abis_to_insert = []
|
||||
|
||||
for abi in abis:
|
||||
print(abi)
|
||||
if abi["type"] not in ("event", "function"):
|
||||
continue
|
||||
|
||||
|
@ -689,12 +691,14 @@ def add_abi_to_db(
|
|||
AbiJobs.address,
|
||||
AbiJobs.abi_selector,
|
||||
AbiJobs.customer_id,
|
||||
AbiJobs.user_id,
|
||||
]
|
||||
)
|
||||
|
||||
try:
|
||||
db_session.execute(result_stmt)
|
||||
db_session.commit()
|
||||
print(f"Added {len(abis_to_insert)} abis to db")
|
||||
except Exception as e:
|
||||
logger.error(f"Error inserting abi to db: {str(e)}")
|
||||
db_session.rollback()
|
||||
|
|
|
@ -245,6 +245,7 @@ class UpdateSubscriptionRequest(BaseModel):
|
|||
abi: Optional[str] = Form(None)
|
||||
description: Optional[str] = Form(None)
|
||||
tags: Optional[List[Dict[str, str]]] = Form(None)
|
||||
customer_id: Optional[str] = Form(None)
|
||||
|
||||
@validator("tags", pre=True, always=True)
|
||||
def transform_to_dict(cls, v):
|
||||
|
|
|
@ -26,7 +26,7 @@ from ..actions import (
|
|||
get_moonworm_tasks,
|
||||
validate_abi_json,
|
||||
create_seer_subscription,
|
||||
delete_seer_subscription
|
||||
delete_seer_subscription,
|
||||
)
|
||||
from ..admin import subscription_types
|
||||
from ..middleware import MoonstreamHTTPException
|
||||
|
@ -430,6 +430,8 @@ async def update_subscriptions_handler(
|
|||
|
||||
user = request.state.user
|
||||
|
||||
print("user", user)
|
||||
|
||||
form = await request.form()
|
||||
try:
|
||||
form_data = data.UpdateSubscriptionRequest(**form)
|
||||
|
@ -441,6 +443,7 @@ async def update_subscriptions_handler(
|
|||
abi = form_data.abi
|
||||
description = form_data.description
|
||||
tags = form_data.tags
|
||||
customer_id = form_data.customer_id
|
||||
|
||||
try:
|
||||
journal_id = get_entity_subscription_journal_id(
|
||||
|
@ -563,7 +566,12 @@ async def update_subscriptions_handler(
|
|||
logger.error(f"Error update user subscriptions: {str(e)}")
|
||||
raise MoonstreamHTTPException(status_code=500, internal_error=e)
|
||||
|
||||
if abi:
|
||||
print("subscription", subscription)
|
||||
print("subscription_entity", subscription_entity)
|
||||
print(abi) # noqa
|
||||
|
||||
if abi is not None:
|
||||
print("apply_moonworm_tasks")
|
||||
background_tasks.add_task(
|
||||
apply_moonworm_tasks,
|
||||
subscription_type_id,
|
||||
|
@ -574,9 +582,11 @@ async def update_subscriptions_handler(
|
|||
create_seer_subscription(
|
||||
db_session=db_session,
|
||||
user_id=user.id,
|
||||
customer_id=customer_id,
|
||||
address=address,
|
||||
subscription_type=subscription_type_id,
|
||||
abi=json_abi,
|
||||
subscription_id=subscription_id,
|
||||
abi=abi,
|
||||
subscription_type_id=subscription_type_id,
|
||||
)
|
||||
|
||||
subscription_required_fields = (
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
"""add subscription id
|
||||
|
||||
Revision ID: 6b4ab39794d8
|
||||
Revises: e02c90ea67bb
|
||||
Create Date: 2024-07-05 00:06:29.856486
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "6b4ab39794d8"
|
||||
down_revision: Union[str, None] = "e02c90ea67bb"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("abi_jobs", sa.Column("subscription_id", sa.UUID(), nullable=True))
|
||||
op.create_index(
|
||||
op.f("ix_abi_jobs_subscription_id"),
|
||||
"abi_jobs",
|
||||
["subscription_id"],
|
||||
unique=False,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("abi_jobs", "subscription_id")
|
||||
# ### end Alembic commands ###
|
|
@ -566,7 +566,12 @@ class AbiJobs(Base):
|
|||
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"chain", "address", "abi_selector", "customer_id", name="uq_abi_jobs"
|
||||
"chain",
|
||||
"address",
|
||||
"abi_selector",
|
||||
"customer_id",
|
||||
"user_id",
|
||||
name="uq_abi_jobs",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.0.11
|
||||
0.0.12
|
||||
|
|
Ładowanie…
Reference in New Issue