Skip to content

Commit

Permalink
Imx zkevm with it's sepolia types
Browse files Browse the repository at this point in the history
  • Loading branch information
kompotkot committed Jul 25, 2024
1 parent f40a077 commit 3b4fee5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
12 changes: 12 additions & 0 deletions types/python/moonstreamtypes/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
from moonstreamdbv3.models import (
Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3,
)
from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3
from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3
from moonstreamdbv3.models import MantleLabel as MantleLabelV3
from moonstreamdbv3.models import MantleSepoliaLabel as MantleSepoliaLabelV3
from moonstreamdbv3.models import MumbaiLabel as MumbaiLabelV3
Expand Down Expand Up @@ -121,6 +123,8 @@ class AvailableBlockchainType(Enum):
STARKNET_SEPOLIA = "starknet_sepolia"
MANTLE = "mantle"
MANTLE_SEPOLIA = "mantle_sepolia"
IMX_ZKEVM = "imx_zkevm"
IMX_ZKEVM_SEPOLIA = "imx_zkevm_sepolia"


def get_block_model(
Expand Down Expand Up @@ -276,6 +280,8 @@ def get_label_model(
StarknetSepoliaLabelV3,
MantleLabelV3,
MantleSepoliaLabelV3,
ImxZkevmLabelV3,
ImxZkevmSepoliaLabelV3,
]
]:
"""
Expand Down Expand Up @@ -332,6 +338,8 @@ def get_label_model(
StarknetSepoliaLabelV3,
MantleLabelV3,
MantleSepoliaLabelV3,
ImxZkevmLabelV3,
ImxZkevmSepoliaLabelV3,
]
]
if version == 2:
Expand Down Expand Up @@ -428,6 +436,10 @@ def get_label_model(
label_model = MantleLabelV3
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
label_model = MantleSepoliaLabelV3
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM:
label_model = ImxZkevmLabelV3
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA:
label_model = ImxZkevmSepoliaLabelV3
else:
raise Exception("Unsupported blockchain type provided")
else:
Expand Down
14 changes: 14 additions & 0 deletions types/python/moonstreamtypes/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
from moonstreamdbv3.models import (
Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3,
)
from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3
from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3
from moonstreamdbv3.models import MantleLabel as MantleLabelV3
from moonstreamdbv3.models import MantleSepoliaLabel as MantleSepoliaLabelV3
from moonstreamdbv3.models import MumbaiLabel as MumbaiLabelV3
Expand Down Expand Up @@ -124,6 +126,8 @@ class Network(Enum):
starknet_sepolia = "starknet_sepolia"
mantle = "mantle"
mantle_sepolia = "mantle_sepolia"
imx_zkevm = "imx_zkevm"
imx_zkevm_sepolia = "imx_zkevm_sepolia"


tx_raw_types = Union[
Expand Down Expand Up @@ -331,6 +335,12 @@ class Network(Enum):
Network.mantle_sepolia: {
"labels": MantleSepoliaLabelV3,
},
Network.imx_zkevm: {
"labels": ImxZkevmLabelV3,
},
Network.imx_zkevm_sepolia: {
"labels": ImxZkevmSepoliaLabelV3,
},
}


Expand Down Expand Up @@ -390,5 +400,9 @@ def blockchain_type_to_network_type(
return Network.mantle
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
return Network.mantle_sepolia
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM:
return Network.imx_zkevm
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA:
return Network.imx_zkevm_sepolia
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")
12 changes: 12 additions & 0 deletions types/python/moonstreamtypes/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class SubscriptionTypes(Enum):
STARKNET_SEPOLIA_BLOCKCHAIN = "starknet_sepolia_smartcontract"
MANTLE_BLOCKCHAIN = "mantle_smartcontract"
MANTLE_SEPOLIA_BLOCKCHAIN = "mantle_sepolia_smartcontract"
IMX_ZKEVM_BLOCKCHAIN = "imx_zkevm_smartcontract"
IMX_ZKEVM_SEPOLIA_BLOCKCHAIN = "imx_zkevm_sepolia_smartcontract"


def blockchain_type_to_subscription_type(
Expand Down Expand Up @@ -89,6 +91,10 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.MANTLE_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA:
return SubscriptionTypes.MANTLE_SEPOLIA_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM:
return SubscriptionTypes.IMX_ZKEVM_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.IMX_ZKEVM_SEPOLIA:
return SubscriptionTypes.IMX_ZKEVM_SEPOLIA_BLOCKCHAIN
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Expand Down Expand Up @@ -120,6 +126,8 @@ def blockchain_type_to_subscription_type(
"starknet_sepolia": "starknet_sepolia_smartcontract",
"mantle": "mantle_smartcontract",
"mantle_sepolia": "mantle_sepolia_smartcontract",
"imx_zkevm": "imx_zkevm_smartcontract",
"imx_zkevm_sepolia": "imx_zkevm_sepolia_smartcontract",
}

blockchain_by_subscription_id = {
Expand Down Expand Up @@ -149,6 +157,8 @@ def blockchain_type_to_subscription_type(
"starknet_sepolia_blockchain": "starknet_sepolia",
"mantle_blockchain": "mantle",
"mantle_sepolia_blockchain": "mantle_sepolia",
"imx_zkevm_blockchain": "imx_zkevm",
"imx_zkevm_sepolia_blockchain": "imx_zkevm_sepolia",
"ethereum_smartcontract": "ethereum",
"polygon_smartcontract": "polygon",
"mumbai_smartcontract": "mumbai",
Expand All @@ -174,4 +184,6 @@ def blockchain_type_to_subscription_type(
"starknet_sepolia_smartcontract": "starknet_sepolia",
"mantle_smartcontract": "mantle",
"mantle_sepolia_smartcontract": "mantle_sepolia",
"imx_zkevm_smartcontract": "imx_zkevm",
"imx_zkevm_sepolia_smartcontract": "imx_zkevm_sepolia",
}
2 changes: 1 addition & 1 deletion types/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
zip_safe=False,
install_requires=[
"moonstreamdb>=0.4.5",
"moonstreamdb-v3>=0.0.9",
"moonstreamdb-v3>=0.0.15",
],
extras_require={
"dev": ["black", "isort", "mypy"],
Expand Down

0 comments on commit 3b4fee5

Please sign in to comment.