From a1916cfcdca2f64b5700aed87380a2c44ec365cd Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 11 Sep 2024 15:08:40 +0300 Subject: [PATCH] Add B3 moonstream types. --- types/python/moonstreamtypes/blockchain.py | 22 +++++++++++++++++++ types/python/moonstreamtypes/networks.py | 14 ++++++++++++ types/python/moonstreamtypes/subscriptions.py | 10 +++++++++ types/python/moonstreamtypes/version.txt | 2 +- types/python/setup.py | 2 +- 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/types/python/moonstreamtypes/blockchain.py b/types/python/moonstreamtypes/blockchain.py index 7362e4c6..e549caf6 100644 --- a/types/python/moonstreamtypes/blockchain.py +++ b/types/python/moonstreamtypes/blockchain.py @@ -20,6 +20,8 @@ from moonstreamdb.models import ( AvalancheFujiTransaction, AvalancheLabel, AvalancheTransaction, + B3Block, + B3SepoliaBlock, BlastBlock, BlastLabel, BlastSepoliaBlock, @@ -95,6 +97,8 @@ from moonstreamdbv3.models import XaiSepoliaLabel as XaiSepoliaLabelV3 from moonstreamdbv3.models import XDaiLabel as XDaiLabelV3 from moonstreamdbv3.models import ZkSyncEraLabel as ZkSyncEraLabelV3 from moonstreamdbv3.models import ZkSyncEraSepoliaLabel as ZkSyncEraSepoliaLabelV3 +from moonstreamdbv3.models import B3Label as B3LabelV3 +from moonstreamdbv3.models import B3SepoliaLabel as B3SepoliaLabelV3 class AvailableBlockchainType(Enum): @@ -127,6 +131,8 @@ class AvailableBlockchainType(Enum): MANTLE_SEPOLIA = "mantle_sepolia" IMX_ZKEVM = "imx_zkevm" IMX_ZKEVM_SEPOLIA = "imx_zkevm_sepolia" + B3 = "b3" + B3_SEPOLIA = "b3_sepolia" def get_block_model( @@ -154,6 +160,8 @@ def get_block_model( ProofOfPlayApexBlock, MantleBlock, MantleSepoliaBlock, + B3Block, + B3SepoliaBlock, ] ]: """ @@ -182,6 +190,8 @@ def get_block_model( ProofOfPlayApexBlock, MantleBlock, MantleSepoliaBlock, + B3Block, + B3SepoliaBlock, ] ] if blockchain_type == AvailableBlockchainType.ETHEREUM: @@ -226,6 +236,10 @@ def get_block_model( block_model = MantleBlock elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: block_model = MantleSepoliaBlock + elif blockchain_type == AvailableBlockchainType.B3: + block_model = B3Block + elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA: + block_model = B3SepoliaBlock else: raise Exception("Unsupported blockchain type provided") @@ -285,6 +299,8 @@ def get_label_model( MantleSepoliaLabelV3, ImxZkevmLabelV3, ImxZkevmSepoliaLabelV3, + B3LabelV3, + B3SepoliaLabelV3, ] ]: """ @@ -344,6 +360,8 @@ def get_label_model( MantleSepoliaLabelV3, ImxZkevmLabelV3, ImxZkevmSepoliaLabelV3, + B3LabelV3, + B3SepoliaLabelV3, ] ] if version == 2: @@ -446,6 +464,10 @@ def get_label_model( label_model = ImxZkevmLabelV3 elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: label_model = ImxZkevmSepoliaLabelV3 + elif blockchain_type == AvailableBlockchainType.B3: + label_model = B3LabelV3 + elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA: + label_model = B3SepoliaLabelV3 else: raise Exception("Unsupported blockchain type provided") else: diff --git a/types/python/moonstreamtypes/networks.py b/types/python/moonstreamtypes/networks.py index 9717ea30..4b0c7179 100644 --- a/types/python/moonstreamtypes/networks.py +++ b/types/python/moonstreamtypes/networks.py @@ -96,6 +96,8 @@ from moonstreamdbv3.models import XaiSepoliaLabel as XaiSepoliaLabelV3 from moonstreamdbv3.models import XDaiLabel as XDaiLabelV3 from moonstreamdbv3.models import ZkSyncEraLabel as ZkSyncEraLabelV3 from moonstreamdbv3.models import ZkSyncEraSepoliaLabel as ZkSyncEraSepoliaLabelV3 +from moonstreamdbv3.models import B3Label as B3LabelV3 +from moonstreamdbv3.models import B3SepoliaLabel as B3SepoliaLabelV3 from .blockchain import AvailableBlockchainType @@ -130,6 +132,8 @@ class Network(Enum): mantle_sepolia = "mantle_sepolia" imx_zkevm = "imx_zkevm" imx_zkevm_sepolia = "imx_zkevm_sepolia" + b3 = "b3" + b3_sepolia = "b3_sepolia" tx_raw_types = Union[ @@ -346,6 +350,12 @@ MODELS_V3: Dict[Network, Dict[str, Base]] = { Network.imx_zkevm_sepolia: { "labels": ImxZkevmSepoliaLabelV3, }, + Network.b3: { + "labels": B3LabelV3, + }, + Network.b3_sepolia: { + "labels": B3SepoliaLabelV3, + }, } @@ -411,5 +421,9 @@ def blockchain_type_to_network_type( return Network.imx_zkevm elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: return Network.imx_zkevm_sepolia + elif blockchain_type == AvailableBlockchainType.B3: + return Network.b3 + elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA: + return Network.b3_sepolia else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") diff --git a/types/python/moonstreamtypes/subscriptions.py b/types/python/moonstreamtypes/subscriptions.py index 4c1393c8..6266e8d6 100644 --- a/types/python/moonstreamtypes/subscriptions.py +++ b/types/python/moonstreamtypes/subscriptions.py @@ -35,6 +35,8 @@ class SubscriptionTypes(Enum): MANTLE_SEPOLIA_BLOCKCHAIN = "mantle_sepolia_smartcontract" IMX_ZKEVM_BLOCKCHAIN = "imx_zkevm_smartcontract" IMX_ZKEVM_SEPOLIA_BLOCKCHAIN = "imx_zkevm_sepolia_smartcontract" + B3_BLOCKCHAIN = "b3_smartcontract" + B3_SEPOLIA_BLOCKCHAIN = "b3_sepolia_smartcontract" def blockchain_type_to_subscription_type( @@ -98,6 +100,10 @@ def blockchain_type_to_subscription_type( return SubscriptionTypes.IMX_ZKEVM_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA: return SubscriptionTypes.IMX_ZKEVM_SEPOLIA_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.B3: + return SubscriptionTypes.B3_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA: + return SubscriptionTypes.B3_SEPOLIA_BLOCKCHAIN else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") @@ -132,6 +138,8 @@ subscription_id_by_blockchain = { "mantle_sepolia": "mantle_sepolia_smartcontract", "imx_zkevm": "imx_zkevm_smartcontract", "imx_zkevm_sepolia": "imx_zkevm_sepolia_smartcontract", + "b3": "b3_smartcontract", + "b3_sepolia": "b3_sepolia_smartcontract", } blockchain_by_subscription_id = { @@ -192,4 +200,6 @@ blockchain_by_subscription_id = { "mantle_sepolia_smartcontract": "mantle_sepolia", "imx_zkevm_smartcontract": "imx_zkevm", "imx_zkevm_sepolia_smartcontract": "imx_zkevm_sepolia", + "b3_smartcontract": "b3", + "b3_sepolia_smartcontract": "b3_sepolia", } diff --git a/types/python/moonstreamtypes/version.txt b/types/python/moonstreamtypes/version.txt index 1750564f..5a5831ab 100644 --- a/types/python/moonstreamtypes/version.txt +++ b/types/python/moonstreamtypes/version.txt @@ -1 +1 @@ -0.0.6 +0.0.7 diff --git a/types/python/setup.py b/types/python/setup.py index fe03945b..1edae0fb 100644 --- a/types/python/setup.py +++ b/types/python/setup.py @@ -34,7 +34,7 @@ setup( zip_safe=False, install_requires=[ "moonstreamdb>=0.4.5", - "moonstreamdb-v3>=0.0.16", + "moonstreamdb-v3>=0.0.18", ], extras_require={ "dev": ["black", "isort", "mypy"],