From 168fecfa29a62da7bb8cb83674107dad3afd525e Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 21 Feb 2024 22:47:42 +0200 Subject: [PATCH 1/2] Add Arbitrum Nova, Arbitrum Sepolia, Xai api support. --- moonstreamapi/moonstreamapi/actions.py | 6 ++++ .../moonstreamapi/admin/subscription_types.py | 34 +++++++++++++++++++ .../moonstreamapi/providers/__init__.py | 6 ++++ .../providers/moonworm_provider.py | 24 +++++++++++++ .../moonstreamapi/providers/transactions.py | 22 ++++++++++++ .../moonstreamapi/routes/subscriptions.py | 27 +++++++++------ moonstreamapi/moonstreamapi/settings.py | 30 ++++++++++++++++ moonstreamapi/moonstreamapi/version.py | 2 +- moonstreamapi/requirements.txt | 2 +- moonstreamapi/setup.py | 2 +- 10 files changed, 142 insertions(+), 13 deletions(-) diff --git a/moonstreamapi/moonstreamapi/actions.py b/moonstreamapi/moonstreamapi/actions.py index 2aac67a3..af0f2c72 100644 --- a/moonstreamapi/moonstreamapi/actions.py +++ b/moonstreamapi/moonstreamapi/actions.py @@ -58,6 +58,9 @@ blockchain_by_subscription_id = { "mumbai_blockchain": "mumbai", "xdai_blockchain": "xdai", "wyrm_blockchain": "wyrm", + "arbitrum_nova_blockchain": "arbitrum_nova", + "arbitrum_sepolia_blockchain": "arbitrum_sepolia", + "xai_blockchain": "xai", "zksync_era_testnet_blockchain": "zksync_era_testnet", "zksync_era_blockchain": "zksync_era", "ethereum_smartcontract": "ethereum", @@ -67,6 +70,9 @@ blockchain_by_subscription_id = { "wyrm_smartcontract": "wyrm", "zksync_era_testnet_smartcontract": "zksync_era_testnet", "zksync_era_smartcontract": "zksync_era", + "arbitrum_nova_smartcontract": "arbitrum_nova", + "arbitrum_sepolia_smartcontract": "arbitrum_sepolia", + "xai_smartcontract": "xai", } diff --git a/moonstreamapi/moonstreamapi/admin/subscription_types.py b/moonstreamapi/moonstreamapi/admin/subscription_types.py index e1c4896e..65cf1ecd 100644 --- a/moonstreamapi/moonstreamapi/admin/subscription_types.py +++ b/moonstreamapi/moonstreamapi/admin/subscription_types.py @@ -1,6 +1,7 @@ """ Utilities for managing subscription type resources for a Moonstream application. """ + import argparse import json from typing import Dict, List, Optional @@ -94,6 +95,39 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=True, ), + "arbitrum_nova_smartcontract": SubscriptionTypeResourceData( + id="arbitrum_nova_smartcontract", + name="Arbitrum Nova smartcontract", + blockchain="arbitrum_nova", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Arbitrum Nova blockchain.", + icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/arbitrum-nova-token-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "arbitrum_sepolia_smartcontract": SubscriptionTypeResourceData( + id="arbitrum_sepolia_smartcontract", + name="Arbitrum Sepolia smartcontract", + blockchain="arbitrum_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Arbitrum Sepolia blockchain.", + icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/arbitrum-sepolia-token-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "xai_smartcontract": SubscriptionTypeResourceData( + id="xai_smartcontract", + name="Xai smartcontract", + blockchain="xai", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Xai blockchain.", + icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/xai-token-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), "ethereum_blockchain": SubscriptionTypeResourceData( id="ethereum_blockchain", name="Ethereum transactions", diff --git a/moonstreamapi/moonstreamapi/providers/__init__.py b/moonstreamapi/moonstreamapi/providers/__init__.py index c206be66..41553322 100644 --- a/moonstreamapi/moonstreamapi/providers/__init__.py +++ b/moonstreamapi/moonstreamapi/providers/__init__.py @@ -53,12 +53,18 @@ event_providers: Dict[str, Any] = { moonworm_provider.XDaiMoonwormProvider.event_type: moonworm_provider.XDaiMoonwormProvider, moonworm_provider.ZkSyncEraTestnetMoonwormProvider.event_type: moonworm_provider.ZkSyncEraTestnetMoonwormProvider, moonworm_provider.ZkSyncEraMoonwormProvider.event_type: moonworm_provider.ZkSyncEraMoonwormProvider, + moonworm_provider.ArbitrumNovaMoonwormProvider.event_type: moonworm_provider.ArbitrumNovaMoonwormProvider, + moonworm_provider.ArbitrumSepoliaMoonwormProvider.event_type: moonworm_provider.ArbitrumSepoliaMoonwormProvider, + moonworm_provider.XaiMoonwormProvider.event_type: moonworm_provider.XaiMoonwormProvider, transactions.EthereumTransactions.event_type: transactions.EthereumTransactions, transactions.PolygonTransactions.event_type: transactions.PolygonTransactions, transactions.MumbaiTransactions.event_type: transactions.MumbaiTransactions, transactions.XDaiTransactions.event_type: transactions.XDaiTransactions, transactions.ZkSyncEraTestnetTransactions.event_type: transactions.ZkSyncEraTestnetTransactions, transactions.ZkSyncEraTransactions.event_type: transactions.ZkSyncEraTransactions, + transactions.ArbitrumNovaTransactions.event_type: transactions.ArbitrumNovaTransactions, + transactions.ArbitrumSepoliaTransactions.event_type: transactions.ArbitrumSepoliaTransactions, + transactions.XaiTransactions.event_type: transactions.XaiTransactions, bugout.polygon_whalewatch_provider.event_type: bugout.polygon_whalewatch_provider, bugout.ethereum_txpool_provider.event_type: bugout.ethereum_txpool_provider, bugout.ethereum_whalewatch_provider.event_type: bugout.ethereum_whalewatch_provider, diff --git a/moonstreamapi/moonstreamapi/providers/moonworm_provider.py b/moonstreamapi/moonstreamapi/providers/moonworm_provider.py index c7d83d58..f377eceb 100644 --- a/moonstreamapi/moonstreamapi/providers/moonworm_provider.py +++ b/moonstreamapi/moonstreamapi/providers/moonworm_provider.py @@ -23,6 +23,9 @@ mumbai_event_type = "mumbai_blockchain" xdai_event_type = "xdai_blockchain" zksync_era_testnet_event_type = "zksync_era_testnet_blockchain" zksync_era_event_type = "zksync_era_blockchain" +arbitrum_nova_event_type = "arbitrum_nova_blockchain" +arbitrum_sepolia_event_type = "arbitrum_sepolia_blockchain" +xai_event_type = "xai_blockchain" allowed_tags = ["tag:erc721"] description = f"""Event provider for transactions from the Ethereum blockchain. @@ -429,3 +432,24 @@ ZkSyncEraMoonwormProvider = MoonwormProvider( description="Provider for reviving transactions from zkSync Era tables.", streamboaundary_range_limit=2 * 60 * 60, ) + +ArbitrumNovaMoonwormProvider = MoonwormProvider( + event_type="arbitrum_nova_smartcontract", + blockchain=AvailableBlockchainType("arbitrum_nova"), + description="Provider for reviving transactions from Arbitrum Nova tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +ArbitrumSepoliaMoonwormProvider = MoonwormProvider( + event_type="arbitrum_sepolia_smartcontract", + blockchain=AvailableBlockchainType("arbitrum_sepolia"), + description="Provider for reviving transactions from Arbitrum Sepolia tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +XaiMoonwormProvider = MoonwormProvider( + event_type="xai_smartcontract", + blockchain=AvailableBlockchainType("xai"), + description="Provider for reviving transactions from Xai tables.", + streamboaundary_range_limit=2 * 60 * 60, +) diff --git a/moonstreamapi/moonstreamapi/providers/transactions.py b/moonstreamapi/moonstreamapi/providers/transactions.py index e3c51f13..be2cd759 100644 --- a/moonstreamapi/moonstreamapi/providers/transactions.py +++ b/moonstreamapi/moonstreamapi/providers/transactions.py @@ -489,3 +489,25 @@ ZkSyncEraTransactions = TransactionsProvider( description="Provider for resiving transactions from ZkSync Era tables.", streamboaundary_range_limit=2 * 60 * 60, ) + + +ArbitrumNovaTransactions = TransactionsProvider( + event_type="arbitrum_nova_blockchain", + blockchain=AvailableBlockchainType("arbitrum_nova"), + description="Provider for resiving transactions from Arbitrum Nova tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +ArbitrumSepoliaTransactions = TransactionsProvider( + event_type="arbitrum_sepolia_blockchain", + blockchain=AvailableBlockchainType("arbitrum_sepolia"), + description="Provider for resiving transactions from Arbitrum Sepolia tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +XaiTransactions = TransactionsProvider( + event_type="xai_blockchain", + blockchain=AvailableBlockchainType("xai"), + description="Provider for resiving transactions from Xai tables.", + streamboaundary_range_limit=2 * 60 * 60, +) diff --git a/moonstreamapi/moonstreamapi/routes/subscriptions.py b/moonstreamapi/moonstreamapi/routes/subscriptions.py index af4977af..b8806314 100644 --- a/moonstreamapi/moonstreamapi/routes/subscriptions.py +++ b/moonstreamapi/moonstreamapi/routes/subscriptions.py @@ -1,6 +1,7 @@ """ The Moonstream subscriptions HTTP API """ + import hashlib import json import logging @@ -374,9 +375,11 @@ async def get_subscriptions_handler( address=subscription.address, color=color, label=label, - abi="True" - if subscription.secondary_fields.get("abi", None) - else "False", ### TODO(ANDREY): remove this hack when frontend is updated + abi=( + "True" + if subscription.secondary_fields.get("abi", None) + else "False" + ), ### TODO(ANDREY): remove this hack when frontend is updated description=subscription.secondary_fields.get("description"), tags=normalized_entity_tags, subscription_type_id=subscription_type_id, @@ -520,13 +523,17 @@ async def update_subscriptions_handler( token=token, journal_id=journal_id, entity_id=subscription_id, - title=subscription_entity.title - if subscription_entity.title is not None - else "", + title=( + subscription_entity.title + if subscription_entity.title is not None + else "" + ), address=address, - blockchain=subscription_entity.blockchain - if subscription_entity.blockchain is not None - else "", + blockchain=( + subscription_entity.blockchain + if subscription_entity.blockchain is not None + else "" + ), required_fields=update_required_fields, secondary_fields=update_secondary_fields, ) @@ -707,7 +714,7 @@ async def address_info(request: Request, address: str = Query(...)): user_token = request.state.token try: - Web3.toChecksumAddress(address) + address = Web3.toChecksumAddress(address) except ValueError as e: raise MoonstreamHTTPException( status_code=400, diff --git a/moonstreamapi/moonstreamapi/settings.py b/moonstreamapi/moonstreamapi/settings.py index cf1db9a0..37ca5c58 100644 --- a/moonstreamapi/moonstreamapi/settings.py +++ b/moonstreamapi/moonstreamapi/settings.py @@ -144,6 +144,30 @@ MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI = os.environ.get( if MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI == "": raise Exception("MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI env variable is not set") +MOONSTREAM_ARBITRUM_NOVA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_ARBITRUM_NOVA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_ARBITRUM_NOVA_WEB3_PROVIDER_URI == "": + raise Exception( + "MOONSTREAM_ARBITRUM_NOVA_WEB3_PROVIDER_URI env variable is not set" + ) + +MOONSTREAM_ARBITRUM_SEPOLIA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_ARBITRUM_SEPOLIA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_ARBITRUM_SEPOLIA_WEB3_PROVIDER_URI == "": + raise Exception( + "MOONSTREAM_ARBITRUM_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" + ) + +MOONSTREAM_XAI_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_XAI_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_XAI_WEB3_PROVIDER_URI == "": + raise Exception("MOONSTREAM_XAI_WEB3_PROVIDER_URI env variable is not set") + +## QueryAPI + MOONSTREAM_S3_QUERIES_BUCKET = os.environ.get("MOONSTREAM_S3_QUERIES_BUCKET", "") if MOONSTREAM_S3_QUERIES_BUCKET == "": raise ValueError("MOONSTREAM_S3_QUERIES_BUCKET environment variable must be set") @@ -193,6 +217,12 @@ multicall_contracts: Dict[AvailableBlockchainType, str] = { AvailableBlockchainType.POLYGON: "0xc8E51042792d7405184DfCa245F2d27B94D013b6", AvailableBlockchainType.MUMBAI: "0xe9939e7Ea7D7fb619Ac57f648Da7B1D425832631", AvailableBlockchainType.ETHEREUM: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696", + AvailableBlockchainType.ARBITRUM_NOVA: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.ARBITRUM_SEPOLIA: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.XAI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.XDAI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.ZKSYNC_ERA: "0xF9cda624FBC7e059355ce98a31693d299FACd963", + AvailableBlockchainType.ZKSYNC_ERA_TESTNET: "0xF9cda624FBC7e059355ce98a31693d299FACd963", } diff --git a/moonstreamapi/moonstreamapi/version.py b/moonstreamapi/moonstreamapi/version.py index b6d3c966..bb58c7f4 100644 --- a/moonstreamapi/moonstreamapi/version.py +++ b/moonstreamapi/moonstreamapi/version.py @@ -2,4 +2,4 @@ Moonstream library and API version. """ -MOONSTREAMAPI_VERSION = "0.3.2" +MOONSTREAMAPI_VERSION = "0.3.3" diff --git a/moonstreamapi/requirements.txt b/moonstreamapi/requirements.txt index cbc41057..93486104 100644 --- a/moonstreamapi/requirements.txt +++ b/moonstreamapi/requirements.txt @@ -36,7 +36,7 @@ jsonschema==4.17.0 lru-dict==1.1.8 Mako==1.2.3 MarkupSafe==2.1.1 -moonstreamdb==0.3.5 +moonstreamdb==0.3.8 multiaddr==0.0.9 multidict==6.0.2 netaddr==0.8.0 diff --git a/moonstreamapi/setup.py b/moonstreamapi/setup.py index 40514803..9ce7d330 100644 --- a/moonstreamapi/setup.py +++ b/moonstreamapi/setup.py @@ -15,7 +15,7 @@ setup( "boto3", "bugout>=0.2.15", "fastapi", - "moonstreamdb>=0.3.5", + "moonstreamdb>=0.3.8", "humbug", "pydantic==1.10.2", "pyevmasm", From e3cc04f1c5cafa2a7e18e22a0442bd9e901be055 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 22 Feb 2024 00:30:10 +0200 Subject: [PATCH 2/2] Add temp icons. --- moonstreamapi/moonstreamapi/admin/subscription_types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/moonstreamapi/moonstreamapi/admin/subscription_types.py b/moonstreamapi/moonstreamapi/admin/subscription_types.py index 65cf1ecd..80d5ff5c 100644 --- a/moonstreamapi/moonstreamapi/admin/subscription_types.py +++ b/moonstreamapi/moonstreamapi/admin/subscription_types.py @@ -101,7 +101,7 @@ CANONICAL_SUBSCRIPTION_TYPES = { blockchain="arbitrum_nova", choices=["input:address", "tag:erc721"], description="Contracts events and tx_calls of contract of Arbitrum Nova blockchain.", - icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/arbitrum-nova-token-logo.png", + 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, @@ -112,7 +112,7 @@ CANONICAL_SUBSCRIPTION_TYPES = { blockchain="arbitrum_sepolia", choices=["input:address", "tag:erc721"], description="Contracts events and tx_calls of contract of Arbitrum Sepolia blockchain.", - icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/arbitrum-sepolia-token-logo.png", + 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, @@ -123,7 +123,7 @@ CANONICAL_SUBSCRIPTION_TYPES = { blockchain="xai", choices=["input:address", "tag:erc721"], description="Contracts events and tx_calls of contract of Xai blockchain.", - icon_url="https://s3.amazonaws.com/static.simiotics.com/moonstream/assets/xai-token-logo.png", + 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,