Skip to content

Commit

Permalink
Merge pull request #1149 from moonstream-to/update-types
Browse files Browse the repository at this point in the history
Update moonstream types.
  • Loading branch information
Andrei-Dolgolev authored Dec 18, 2024
2 parents 1de7b7f + 7b901b0 commit 70d0c95
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
13 changes: 12 additions & 1 deletion types/python/moonstreamtypes/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from moonstreamdbv3.models import (
Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3,
)
from moonstreamdbv3.models import Game7Label as Game7LabelV3
from moonstreamdbv3.models import Game7TestnetLabel as Game7TestnetLabelV3
from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3
from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3
Expand All @@ -99,7 +100,8 @@
from moonstreamdbv3.models import ZkSyncEraSepoliaLabel as ZkSyncEraSepoliaLabelV3
from moonstreamdbv3.models import B3Label as B3LabelV3
from moonstreamdbv3.models import B3SepoliaLabel as B3SepoliaLabelV3

from moonstreamdbv3.models import RoninLabel as RoninLabelV3
from moonstreamdbv3.models import RoninSaigonLabel as RoninSaigonLabelV3

class AvailableBlockchainType(Enum):
ETHEREUM = "ethereum"
Expand All @@ -118,6 +120,7 @@ class AvailableBlockchainType(Enum):
ARBITRUM_SEPOLIA = "arbitrum_sepolia"
GAME7_ORBIT_ARBITRUM_SEPOLIA = "game7_orbit_arbitrum_sepolia"
GAME7_TESTNET = "game7_testnet"
GAME7 = "game7"
XAI = "xai"
XAI_SEPOLIA = "xai_sepolia"
AVALANCHE = "avalanche"
Expand All @@ -133,6 +136,8 @@ class AvailableBlockchainType(Enum):
IMX_ZKEVM_SEPOLIA = "imx_zkevm_sepolia"
B3 = "b3"
B3_SEPOLIA = "b3_sepolia"
RONIN = "ronin"
RONIN_SAIGON = "ronin_saigon"


def get_block_model(
Expand Down Expand Up @@ -438,6 +443,8 @@ def get_label_model(
label_model = Game7OrbitArbitrumSepoliaLabelV3
elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET:
label_model = Game7TestnetLabelV3
elif blockchain_type == AvailableBlockchainType.GAME7:
label_model = Game7LabelV3
elif blockchain_type == AvailableBlockchainType.XAI:
label_model = XaiLabelV3
elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA:
Expand Down Expand Up @@ -468,6 +475,10 @@ def get_label_model(
label_model = B3LabelV3
elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA:
label_model = B3SepoliaLabelV3
elif blockchain_type == AvailableBlockchainType.RONIN:
label_model = RoninLabelV3
elif blockchain_type == AvailableBlockchainType.RONIN_SAIGON:
label_model = RoninSaigonLabelV3
else:
raise Exception("Unsupported blockchain type provided")
else:
Expand Down
21 changes: 21 additions & 0 deletions types/python/moonstreamtypes/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
Game7OrbitArbitrumSepoliaLabel as Game7OrbitArbitrumSepoliaLabelV3,
)
from moonstreamdbv3.models import Game7TestnetLabel as Game7TestnetLabelV3
from moonstreamdbv3.models import Game7Label as Game7LabelV3
from moonstreamdbv3.models import ImxZkevmLabel as ImxZkevmLabelV3
from moonstreamdbv3.models import ImxZkevmSepoliaLabel as ImxZkevmSepoliaLabelV3
from moonstreamdbv3.models import MantleLabel as MantleLabelV3
Expand All @@ -98,6 +99,8 @@
from moonstreamdbv3.models import ZkSyncEraSepoliaLabel as ZkSyncEraSepoliaLabelV3
from moonstreamdbv3.models import B3Label as B3LabelV3
from moonstreamdbv3.models import B3SepoliaLabel as B3SepoliaLabelV3
from moonstreamdbv3.models import RoninLabel as RoninLabelV3
from moonstreamdbv3.models import RoninSaigonLabel as RoninSaigonLabelV3

from .blockchain import AvailableBlockchainType

Expand All @@ -119,6 +122,7 @@ class Network(Enum):
arbitrum_sepolia = "arbitrum_sepolia"
game7_orbit_arbitrum_sepolia = "game7_orbit_arbitrum_sepolia"
game7_testnet = "game7_testnet"
game7 = "game7"
xai = "xai"
xai_sepolia = "xai_sepolia"
avalanche = "avalanche"
Expand All @@ -134,6 +138,8 @@ class Network(Enum):
imx_zkevm_sepolia = "imx_zkevm_sepolia"
b3 = "b3"
b3_sepolia = "b3_sepolia"
ronin = "ronin"
ronin_saigon = "ronin_saigon"


tx_raw_types = Union[
Expand Down Expand Up @@ -311,6 +317,9 @@ class Network(Enum):
Network.game7_testnet: {
"labels": Game7TestnetLabelV3,
},
Network.game7: {
"labels": Game7LabelV3,
},
Network.xai: {
"labels": XaiLabelV3,
},
Expand Down Expand Up @@ -356,6 +365,12 @@ class Network(Enum):
Network.b3_sepolia: {
"labels": B3SepoliaLabelV3,
},
Network.ronin: {
"labels": RoninLabelV3,
},
Network.ronin_saigon: {
"labels": RoninSaigonLabelV3,
},
}


Expand Down Expand Up @@ -395,6 +410,8 @@ def blockchain_type_to_network_type(
return Network.game7_orbit_arbitrum_sepolia
elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET:
return Network.game7_testnet
elif blockchain_type == AvailableBlockchainType.GAME7:
return Network.game7
elif blockchain_type == AvailableBlockchainType.XAI:
return Network.xai
elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA:
Expand Down Expand Up @@ -425,5 +442,9 @@ def blockchain_type_to_network_type(
return Network.b3
elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA:
return Network.b3_sepolia
elif blockchain_type == AvailableBlockchainType.RONIN:
return Network.ronin
elif blockchain_type == AvailableBlockchainType.RONIN_SAIGON:
return Network.ronin_saigon
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")
16 changes: 15 additions & 1 deletion types/python/moonstreamtypes/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SubscriptionTypes(Enum):
"game7_orbit_arbitrum_sepolia_smartcontract"
)
GAME7_TESTNET_BLOCKCHAIN = "game7_testnet_smartcontract"
GAME7_BLOCKCHAIN = "game7_smartcontract"
XAI_BLOCKCHAIN = "xai_smartcontract"
XAI_SEPOLIA_BLOCKCHAIN = "xai_sepolia_smartcontract"
AVALANCHE_BLOCKCHAIN = "avalanche_smartcontract"
Expand All @@ -37,7 +38,8 @@ class SubscriptionTypes(Enum):
IMX_ZKEVM_SEPOLIA_BLOCKCHAIN = "imx_zkevm_sepolia_smartcontract"
B3_BLOCKCHAIN = "b3_smartcontract"
B3_SEPOLIA_BLOCKCHAIN = "b3_sepolia_smartcontract"

RONIN_BLOCKCHAIN = "ronin_smartcontract"
RONIN_SAIGON_BLOCKCHAIN = "ronin_saigon_smartcontract"

def blockchain_type_to_subscription_type(
blockchain_type: AvailableBlockchainType,
Expand Down Expand Up @@ -74,6 +76,8 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.GAME7_ORBIT_ARBITRUM_SEPOLIA_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.GAME7_TESTNET:
return SubscriptionTypes.GAME7_TESTNET_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.GAME7:
return SubscriptionTypes.GAME7_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.XAI:
return SubscriptionTypes.XAI_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.XAI_SEPOLIA:
Expand Down Expand Up @@ -104,6 +108,10 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.B3_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.B3_SEPOLIA:
return SubscriptionTypes.B3_SEPOLIA_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.RONIN:
return SubscriptionTypes.RONIN_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.RONIN_SAIGON:
return SubscriptionTypes.RONIN_SAIGON_BLOCKCHAIN
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Expand All @@ -125,6 +133,7 @@ def blockchain_type_to_subscription_type(
"arbitrum_sepolia": "arbitrum_sepolia_smartcontract",
"game7_orbit_arbitrum_sepolia": "game7_orbit_arbitrum_sepolia_smartcontract",
"game7_testnet": "game7_testnet_smartcontract",
"game7": "game7_smartcontract",
"xai": "xai_smartcontract",
"xai_sepolia": "xai_sepolia_smartcontract",
"avalanche": "avalanche_smartcontract",
Expand All @@ -140,6 +149,8 @@ def blockchain_type_to_subscription_type(
"imx_zkevm_sepolia": "imx_zkevm_sepolia_smartcontract",
"b3": "b3_smartcontract",
"b3_sepolia": "b3_sepolia_smartcontract",
"ronin": "ronin_smartcontract",
"ronin_saigon": "ronin_saigon_smartcontract",
}

blockchain_by_subscription_id = {
Expand All @@ -159,6 +170,7 @@ def blockchain_type_to_subscription_type(
"arbitrum_sepolia_blockchain": "arbitrum_sepolia",
"game7_orbit_arbitrum_sepolia_blockchain": "game7_orbit_arbitrum_sepolia",
"game7_testnet_blockchain": "game7_testnet",
"game7_blockchain": "game7",
"xai_blockchain": "xai",
"xai_sepolia_blockchain": "xai_sepolia",
"avalanche_blockchain": "avalanche",
Expand Down Expand Up @@ -202,4 +214,6 @@ def blockchain_type_to_subscription_type(
"imx_zkevm_sepolia_smartcontract": "imx_zkevm_sepolia",
"b3_smartcontract": "b3",
"b3_sepolia_smartcontract": "b3_sepolia",
"ronin_smartcontract": "ronin",
"ronin_saigon_smartcontract": "ronin_saigon",
}
2 changes: 1 addition & 1 deletion types/python/moonstreamtypes/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.8
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.18",
"moonstreamdb-v3>=0.1.2",
],
extras_require={
"dev": ["black", "isort", "mypy"],
Expand Down

0 comments on commit 70d0c95

Please sign in to comment.