From ca8425fbfadae878dd21101716f073e573cd70bb Mon Sep 17 00:00:00 2001 From: kompotkot Date: Thu, 25 Jul 2024 15:15:46 +0000 Subject: [PATCH] Imx zkevm with it's sepolia for mapi --- moonstreamapi/configs/sample.env | 2 + .../moonstreamapi/admin/subscription_types.py | 99 ++++++++++++++----- moonstreamapi/moonstreamapi/settings.py | 17 +++- moonstreamapi/moonstreamapi/web3_provider.py | 6 ++ moonstreamapi/requirements.txt | 2 +- moonstreamapi/setup.py | 2 +- 6 files changed, 103 insertions(+), 25 deletions(-) diff --git a/moonstreamapi/configs/sample.env b/moonstreamapi/configs/sample.env index 5e010987..e9a897fa 100644 --- a/moonstreamapi/configs/sample.env +++ b/moonstreamapi/configs/sample.env @@ -37,6 +37,8 @@ export MOONSTREAM_BLAST_WEB3_PROVIDER_URI="https:// export MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_MANTLE_WEB3_PROVIDER_URI="https://" export MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_QUERIES_JOURNAL_ID="" export MOONSTREAM_USAGE_REPORTS_JOURNAL_ID="" diff --git a/moonstreamapi/moonstreamapi/admin/subscription_types.py b/moonstreamapi/moonstreamapi/admin/subscription_types.py index 3284a9ed..c5e78ee9 100644 --- a/moonstreamapi/moonstreamapi/admin/subscription_types.py +++ b/moonstreamapi/moonstreamapi/admin/subscription_types.py @@ -238,6 +238,50 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=True, ), + "mantle_smartcontract": SubscriptionTypeResourceData( + id="mantle_smartcontract", + name="Mantle smartcontract", + blockchain="mantle", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "mantle_sepolia_smartcontract": SubscriptionTypeResourceData( + id="mantle_sepolia_smartcontract", + name="Mantle Sepolia smartcontract", + blockchain="mantle_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle Sepolia blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-sepolia-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "imx_zkevm_smartcontract": SubscriptionTypeResourceData( + id="imx_zkevm_smartcontract", + name="Immutable zkEvm smartcontracts", + blockchain="imx_zkevm", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Immutable zkEvm blockchain", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "imx_zkevm_sepolia_smartcontract": SubscriptionTypeResourceData( + id="imx_zkevm_sepolia_smartcontract", + name="Immutable zkEvm Sepolia smartcontracts", + blockchain="imx_zkevm_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Immutable zkEvm Sepolia blockchain", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), "ethereum_blockchain": SubscriptionTypeResourceData( id="ethereum_blockchain", name="Ethereum transactions", @@ -271,28 +315,6 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=False, ), - "mantle_smartcontract": SubscriptionTypeResourceData( - id="mantle_smartcontract", - name="Mantle smartcontract", - blockchain="mantle", - choices=["input:address", "tag:erc721"], - description="Contracts events and tx_calls of contract of Mantle blockchain.", - icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", - stripe_product_id=None, - stripe_price_id=None, - active=True, - ), - "mantle_sepolia_smartcontract": SubscriptionTypeResourceData( - id="mantle_sepolia_smartcontract", - name="Mantle Sepolia smartcontract", - blockchain="mantle_sepolia", - choices=["input:address", "tag:erc721"], - description="Contracts events and tx_calls of contract of Mantle Sepolia blockchain.", - icon_url="https://static.simiotics.com/moonstream/assets/mantle-sepolia-logo.png", - stripe_product_id=None, - stripe_price_id=None, - active=True, - ), "mumbai_blockchain": SubscriptionTypeResourceData( id="mumbai_blockchain", name="Mumbai transactions", @@ -525,6 +547,39 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=False, ), + "sepolia_blockchain": SubscriptionTypeResourceData( + id="sepolia_blockchain", + name="Sepolia transactions", + blockchain="sepolia", + choices=["input:address", "tag:erc721"], + description="Sepolia chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/ethereum/eth-diamond-purple.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), + "imx_zkevm_blockchain": SubscriptionTypeResourceData( + id="imx_zkevm_blockchain", + name="Immutable zkEvm transactions", + blockchain="imx_zkevm", + choices=["input:address", "tag:erc721"], + description="Immutable zkEvm chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), + "imx_zkevm_sepolia_blockchain": SubscriptionTypeResourceData( + id="imx_zkevm_sepolia_blockchain", + name="Immutable zkEvm Sepolia transactions", + blockchain="imx_zkevm_sepolia", + choices=["input:address", "tag:erc721"], + description="Immutable zkEvm Sepolia chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/immutable-zkevm-icon-grey.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), } diff --git a/moonstreamapi/moonstreamapi/settings.py b/moonstreamapi/moonstreamapi/settings.py index 86d81a20..118f538d 100644 --- a/moonstreamapi/moonstreamapi/settings.py +++ b/moonstreamapi/moonstreamapi/settings.py @@ -168,7 +168,6 @@ if MOONSTREAM_ZKSYNC_ERA_SEPOLIA_WEB3_PROVIDER_URI == "": "MOONSTREAM_ZKSYNC_ERA_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" ) - MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI = os.environ.get( "MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI", "" ) @@ -252,6 +251,22 @@ if MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI == "": "MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" ) +MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI == "": + raise ValueError( + "MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI environment variable must be set" + ) + +MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI == "": + raise ValueError( + "MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI environment variable must be set" + ) + ## QueryAPI MOONSTREAM_S3_QUERIES_BUCKET = os.environ.get("MOONSTREAM_S3_QUERIES_BUCKET", "") diff --git a/moonstreamapi/moonstreamapi/web3_provider.py b/moonstreamapi/moonstreamapi/web3_provider.py index ad099cea..b4ba719d 100644 --- a/moonstreamapi/moonstreamapi/web3_provider.py +++ b/moonstreamapi/moonstreamapi/web3_provider.py @@ -21,6 +21,8 @@ from .settings import ( MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_BLAST_WEB3_PROVIDER_URI, MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI, + MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI, + MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI, MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_MANTLE_WEB3_PROVIDER_URI, MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI, @@ -118,6 +120,10 @@ def connect( web3_uri = MOONSTREAM_MANTLE_WEB3_PROVIDER_URI elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: web3_uri = MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM: + web3_uri = MOONSTREAM_IMX_ZKEVM_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: + web3_uri = MOONSTREAM_IMX_ZKEVM_SEPOLIA_WEB3_PROVIDER_URI else: raise Exception("Wrong blockchain type provided for web3 URI") diff --git a/moonstreamapi/requirements.txt b/moonstreamapi/requirements.txt index 1bb95ee8..d49a32c8 100644 --- a/moonstreamapi/requirements.txt +++ b/moonstreamapi/requirements.txt @@ -38,7 +38,7 @@ Mako==1.2.3 MarkupSafe==2.1.1 moonstream==0.1.1 moonstreamdb==0.4.5 -moonstreamdb-v3==0.0.13 +moonstreamdb-v3==0.0.15 multiaddr==0.0.9 multidict==6.0.2 netaddr==0.8.0 diff --git a/moonstreamapi/setup.py b/moonstreamapi/setup.py index 4983a6cf..79c1f301 100644 --- a/moonstreamapi/setup.py +++ b/moonstreamapi/setup.py @@ -17,7 +17,7 @@ setup( "fastapi", "moonstream", "moonstreamdb>=0.4.5", - "moonstreamdb-v3>=0.0.13", + "moonstreamdb-v3>=0.0.15", "humbug", "pydantic==1.10.2", "pyevmasm",