From 09d511f046fe4022efe095b99928a854644a55fc Mon Sep 17 00:00:00 2001 From: Soos3D <99700157+soos3d@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:45:47 -0300 Subject: [PATCH 01/85] Docs: fix install and git clone commands (#8) * Fix cargo install command for the CLI * Fix git clone URL * Fix GH URL --- README.md | 2 +- cli/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54d51a1..358e1dc 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ These implementations provide a consistent language-agnostic interface while sti ## Quickstart The interactive [`mesc`](./cli) CLI tool makes it easy to create and manage a MESC configuration. -1. Install: `cargo install mesc` +1. Install: `cargo install mesc_cli` 2. Create config interactively: `mesc setup` To create a MESC config manually: diff --git a/cli/README.md b/cli/README.md index 7a650bb..4e5d422 100644 --- a/cli/README.md +++ b/cli/README.md @@ -35,7 +35,7 @@ Ensure that your cargo install path is on your cli path curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # install mesc -git clone https://github.io/paradigmxyz/msec +git clone https://github.com/paradigmxyz/mesc cd mesc cargo install --path rust/crates/cli ``` From d621c2f7ac53741fce4d472e15635b522e97d70a Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Fri, 5 Jan 2024 10:14:53 -0800 Subject: [PATCH 02/85] bump to 0.1.2 (#9) --- rust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 5cf2faf..449de4d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.1.1" +version = "0.1.2" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" From 7e5d4b8c10d086b53f2c10f98d98b50a52fa3b13 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 6 Jan 2024 17:08:35 -0800 Subject: [PATCH 03/85] update network names --- python/generate_network_names.py | 1 + python/mesc/directory.py | 21 --------------------- python/mesc/network_names.py | 19 ++++++++++++++++--- rust/crates/mesc/src/network_names.rs | 19 ++++++++++++++++--- 4 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 python/mesc/directory.py diff --git a/python/generate_network_names.py b/python/generate_network_names.py index 1c3b448..6b6d02c 100755 --- a/python/generate_network_names.py +++ b/python/generate_network_names.py @@ -17,6 +17,7 @@ from typing import Mapping, MutableMapping # specialcase the standard name for certain chains special_cases: Mapping[str, str] = { + "OP Mainnet": "optimism", "Genesis Coin": "genesis_coin", "X1 Network": "x1_network", "ThaiChain 2.0 ThaiFi": "thaifi", diff --git a/python/mesc/directory.py b/python/mesc/directory.py deleted file mode 100644 index b26e6ea..0000000 --- a/python/mesc/directory.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations -from mesc.types import RpcConfig - -known_networks = { - "ethereum": "1", - "goerli": "5", - "optimism": "10", - "polygon": "137", - "holesky": "17000", - "arbitrum": "42161", -} - - -def network_name_to_chain_id( - network_name: str, *, config: RpcConfig | None = None -) -> str | None: - network_name = network_name.lower() - if config is not None and network_name in config["network_names"]: - return config["network_names"][network_name] - else: - return known_networks.get(network_name.lower()) diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index fc61a49..63e613c 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -16,7 +16,7 @@ network_names = { '7': 'thai', '8': 'ubiq', '9': 'ubiq_testnet', - '10': 'op', + '10': 'optimism', '11': 'metadium', '12': 'metadium_testnet', '13': 'diode_testnet_staging', @@ -240,7 +240,7 @@ network_names = { '424': 'pgn_public_goods', '427': 'zeeth', '428': 'geso_verse', - '443': 'obscuro_testnet', + '443': 'ten_testnet', '444': 'synapse_testnet', '456': 'arzio', '462': 'areon_testnet', @@ -388,6 +388,7 @@ network_names = { '1243': 'arc', '1244': 'arc_testnet', '1246': 'om_platform', + '1248': 'dogether', '1252': 'cic_testnet', '1280': 'halo', '1284': 'moonbeam', @@ -439,6 +440,7 @@ network_names = { '1807': 'rabbit_analog_testnet', '1818': 'cube', '1819': 'cube_testnet', + '1821': 'ruby', '1856': 'teslafunds', '1875': 'whitebit', '1881': 'gitshock_cartenz_testnet', @@ -450,6 +452,7 @@ network_names = { '1908': 'bitci_testnet', '1909': 'merkle_scan', '1911': 'scalind', + '1912': 'ruby_testnet', '1945': 'onus_testnet', '1951': 'd', '1954': 'dexilla_testnet', @@ -481,6 +484,7 @@ network_names = { '2025': 'rangers_protocol', '2031': 'centrifuge', '2032': 'catalyst', + '2035': 'phala', '2037': 'kiwi_subnet', '2038': 'shrapnel_testnet', '2043': 'origintrail_para', @@ -611,6 +615,7 @@ network_names = { '5003': 'mantle_sepolia_testnet', '5005': 'treasurenet_testnet', '5165': 'bahamut', + '5169': 'smart_layer', '5177': 'tl', '5197': 'eraswap', '5234': 'humanode', @@ -653,6 +658,7 @@ network_names = { '7027': 'ella_the_heart', '7070': 'planq', '7100': 'nume', + '7118': 'help_the_homeless', '7171': 'bitrock', '7331': 'klyntar', '7332': 'horizen_eon', @@ -677,7 +683,7 @@ network_names = { '8080': 'shardeum_liberty_1.x', '8081': 'shardeum_liberty_2.x', '8082': 'shardeum_sphinx_1.x', - '8086': 'biteth', + '8086': 'bitcoin', '8087': 'e_dollar', '8098': 'streamux_block', '8131': 'qitmeer_testnet', @@ -699,6 +705,8 @@ network_names = { '8668': 'hela_official_runtime', '8723': 'tool_global', '8724': 'tool_global_testnet', + '8726': 'storage', + '8727': 'storage_testnet', '8738': 'alph', '8768': 'tmy', '8848': 'maro_block', @@ -730,6 +738,7 @@ network_names = { '9792': 'carbon_evm_testnet', '9818': 'imperium_testnet', '9819': 'imperium', + '9888': 'dogelayer', '9977': 'mind_testnet', '9980': 'combo', '9990': 'agung', @@ -744,6 +753,7 @@ network_names = { '10101': 'block_genesis', '10200': 'gnosis_chiado_testnet', '10201': 'maxx', + '10242': 'arthera', '10243': 'arthera_testnet', '10248': '0xtade', '10395': 'worldland_testnet', @@ -810,6 +820,7 @@ network_names = { '22023': 'taycan', '22040': 'airdao_testnet', '22222': 'nautilus', + '22324': 'goldx_testnet', '22776': 'map', '23006': 'antofy_testnet', '23118': 'opside_testnet', @@ -856,6 +867,7 @@ network_names = { '42220': 'celo', '42261': 'oasis_emerald_testnet', '42262': 'oasis_emerald', + '42355': 'goldx', '42766': 'zkfair', '42801': 'gesoten_verse_testnet', '42888': 'kinto_testnet', @@ -941,6 +953,7 @@ network_names = { '81362': 'mizana_mixnet', '81363': 'mizana_privnet', '81720': 'quantum', + '82459': 'smart_layer_testnet', '84531': 'base_goerli_testnet', '84532': 'base_sepolia_testnet', '84886': 'aerie', diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index 090e180..288aa72 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -21,7 +21,7 @@ pub fn get_network_names() -> HashMap { ("7", "thai"), ("8", "ubiq"), ("9", "ubiq_testnet"), - ("10", "op"), + ("10", "optimism"), ("11", "metadium"), ("12", "metadium_testnet"), ("13", "diode_testnet_staging"), @@ -245,7 +245,7 @@ pub fn get_network_names() -> HashMap { ("424", "pgn_public_goods"), ("427", "zeeth"), ("428", "geso_verse"), - ("443", "obscuro_testnet"), + ("443", "ten_testnet"), ("444", "synapse_testnet"), ("456", "arzio"), ("462", "areon_testnet"), @@ -393,6 +393,7 @@ pub fn get_network_names() -> HashMap { ("1243", "arc"), ("1244", "arc_testnet"), ("1246", "om_platform"), + ("1248", "dogether"), ("1252", "cic_testnet"), ("1280", "halo"), ("1284", "moonbeam"), @@ -444,6 +445,7 @@ pub fn get_network_names() -> HashMap { ("1807", "rabbit_analog_testnet"), ("1818", "cube"), ("1819", "cube_testnet"), + ("1821", "ruby"), ("1856", "teslafunds"), ("1875", "whitebit"), ("1881", "gitshock_cartenz_testnet"), @@ -455,6 +457,7 @@ pub fn get_network_names() -> HashMap { ("1908", "bitci_testnet"), ("1909", "merkle_scan"), ("1911", "scalind"), + ("1912", "ruby_testnet"), ("1945", "onus_testnet"), ("1951", "d"), ("1954", "dexilla_testnet"), @@ -486,6 +489,7 @@ pub fn get_network_names() -> HashMap { ("2025", "rangers_protocol"), ("2031", "centrifuge"), ("2032", "catalyst"), + ("2035", "phala"), ("2037", "kiwi_subnet"), ("2038", "shrapnel_testnet"), ("2043", "origintrail_para"), @@ -616,6 +620,7 @@ pub fn get_network_names() -> HashMap { ("5003", "mantle_sepolia_testnet"), ("5005", "treasurenet_testnet"), ("5165", "bahamut"), + ("5169", "smart_layer"), ("5177", "tl"), ("5197", "eraswap"), ("5234", "humanode"), @@ -658,6 +663,7 @@ pub fn get_network_names() -> HashMap { ("7027", "ella_the_heart"), ("7070", "planq"), ("7100", "nume"), + ("7118", "help_the_homeless"), ("7171", "bitrock"), ("7331", "klyntar"), ("7332", "horizen_eon"), @@ -682,7 +688,7 @@ pub fn get_network_names() -> HashMap { ("8080", "shardeum_liberty_1.x"), ("8081", "shardeum_liberty_2.x"), ("8082", "shardeum_sphinx_1.x"), - ("8086", "biteth"), + ("8086", "bitcoin"), ("8087", "e_dollar"), ("8098", "streamux_block"), ("8131", "qitmeer_testnet"), @@ -704,6 +710,8 @@ pub fn get_network_names() -> HashMap { ("8668", "hela_official_runtime"), ("8723", "tool_global"), ("8724", "tool_global_testnet"), + ("8726", "storage"), + ("8727", "storage_testnet"), ("8738", "alph"), ("8768", "tmy"), ("8848", "maro_block"), @@ -735,6 +743,7 @@ pub fn get_network_names() -> HashMap { ("9792", "carbon_evm_testnet"), ("9818", "imperium_testnet"), ("9819", "imperium"), + ("9888", "dogelayer"), ("9977", "mind_testnet"), ("9980", "combo"), ("9990", "agung"), @@ -749,6 +758,7 @@ pub fn get_network_names() -> HashMap { ("10101", "block_genesis"), ("10200", "gnosis_chiado_testnet"), ("10201", "maxx"), + ("10242", "arthera"), ("10243", "arthera_testnet"), ("10248", "0xtade"), ("10395", "worldland_testnet"), @@ -815,6 +825,7 @@ pub fn get_network_names() -> HashMap { ("22023", "taycan"), ("22040", "airdao_testnet"), ("22222", "nautilus"), + ("22324", "goldx_testnet"), ("22776", "map"), ("23006", "antofy_testnet"), ("23118", "opside_testnet"), @@ -861,6 +872,7 @@ pub fn get_network_names() -> HashMap { ("42220", "celo"), ("42261", "oasis_emerald_testnet"), ("42262", "oasis_emerald"), + ("42355", "goldx"), ("42766", "zkfair"), ("42801", "gesoten_verse_testnet"), ("42888", "kinto_testnet"), @@ -946,6 +958,7 @@ pub fn get_network_names() -> HashMap { ("81362", "mizana_mixnet"), ("81363", "mizana_privnet"), ("81720", "quantum"), + ("82459", "smart_layer_testnet"), ("84531", "base_goerli_testnet"), ("84532", "base_sepolia_testnet"), ("84886", "aerie"), From c0f83cda9f79caa891b6030ea922b3525da19392 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 6 Jan 2024 17:20:56 -0800 Subject: [PATCH 04/85] clean python implementation --- python/mesc/exceptions.py | 14 ++++-- python/mesc/interface.py | 92 +++++++++++++++++++++++------------- python/mesc/load.py | 61 ++++++++++++++++++++---- python/mesc/network_utils.py | 32 +++++++++++++ python/mesc/types.py | 5 ++ 5 files changed, 158 insertions(+), 46 deletions(-) create mode 100644 python/mesc/network_utils.py diff --git a/python/mesc/exceptions.py b/python/mesc/exceptions.py index 4abe948..fc0eae8 100644 --- a/python/mesc/exceptions.py +++ b/python/mesc/exceptions.py @@ -2,12 +2,20 @@ from __future__ import annotations class MescDisabled(Exception): - pass + """raised when MESC data is requested even though MESC is disabled""" class MissingEndpoint(Exception): - pass + """raised when attempting to load an endpoint that does not exist""" class InvalidOverride(Exception): - pass + """raised when override data is not valid""" + + +class LoadError(Exception): + """raised when unable to load MESC config data""" + + +class InvalidConfig(Exception): + """raised when MESC config data is invalid""" diff --git a/python/mesc/interface.py b/python/mesc/interface.py index b489d73..288fa48 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -1,14 +1,18 @@ from __future__ import annotations import os from typing import Any, Mapping, Sequence -from .types import mesc_env_vars, Endpoint -from . import directory +from .types import mesc_env_vars, Endpoint, RpcConfig +from . import network_utils from . import exceptions from . import load def is_mesc_enabled() -> bool: - if os.environ.get('MESC_MODE') == 'DISABLED': + """MESC is enabled if two criteria are met: + 1) MESC_MODE != "DISABLED" + 2) at least 1 MESC env var is set + """ + if os.environ.get("MESC_MODE") == "DISABLED": return False for var in mesc_env_vars: if os.environ.get(var) not in [None, ""]: @@ -16,38 +20,56 @@ def is_mesc_enabled() -> bool: return False -def get_default_endpoint(profile: str | None = None) -> Endpoint | None: - config = load.read_config_data() +def get_default_endpoint( + profile: str | None = None, *, config: RpcConfig | None = None +) -> Endpoint | None: + """get default MESC endpoint""" + if config is None: + config = load.read_config_data() + + # get endpoint name if profile is not None and profile in config["profiles"]: endpoint = config["profiles"][profile].get( "default_endpoint", config["default_endpoint"] ) else: endpoint = config["default_endpoint"] + + # get endpoint if endpoint is None: return None else: - return config["endpoints"][endpoint] + return get_endpoint_by_name(endpoint, config=config) -def get_endpoint_by_name(name: str) -> Endpoint: - config = load.read_config_data() - if name in config["endpoints"]: +def get_endpoint_by_name(name: str, *, config: RpcConfig | None = None) -> Endpoint: + """get MESC endpoint by name""" + if config is None: + config = load.read_config_data() + try: return config["endpoints"][name] - else: + except KeyError: raise exceptions.MissingEndpoint("missing endpoint: " + str(name)) def get_endpoint_by_network( - chain_id: str | int, *, profile: str | None = None + chain_id: str | int, + *, + profile: str | None = None, + config: RpcConfig | None = None, ) -> Endpoint | None: - config = load.read_config_data() + """get default MESC endpoint for network""" + if config is None: + config = load.read_config_data() + + # get global default for network if chain_id is None: raise ValueError("chain_id must be a str") chain_id = str(chain_id) network_defaults = config["network_defaults"] default_name = network_defaults.get(chain_id) + # get profile default for network if profile and profile in config["profiles"]: name = config["profiles"][profile]["network_defaults"].get( chain_id, default_name @@ -55,20 +77,28 @@ def get_endpoint_by_network( else: name = default_name + # get endpoint if name is None: return None else: - return get_endpoint_by_name(name) + return get_endpoint_by_name(name, config=config) -def get_endpoint_by_query(user_input: str, *, profile: str | None = None) -> Endpoint | None: - """ +def get_endpoint_by_query( + user_input: str, + *, + profile: str | None = None, + config: RpcConfig | None = None, +) -> Endpoint | None: + """get MESC endpoint that satisfies user input query + resolution order: 1. endpoint name 2. chain id 3. network name """ - config = load.read_config_data() + if config is None: + config = load.read_config_data() if user_input in config["endpoints"]: return config["endpoints"][user_input] elif user_input.isdecimal(): @@ -77,10 +107,10 @@ def get_endpoint_by_query(user_input: str, *, profile: str | None = None) -> End except Exception: pass - if is_chain_id(user_input): + if network_utils.is_chain_id(user_input): chain_id: str | None = user_input else: - chain_id = directory.network_name_to_chain_id(user_input, config=config) + chain_id = network_utils.network_name_to_chain_id(user_input, config=config) if chain_id is not None: try: return get_endpoint_by_network(chain_id, profile=profile) @@ -90,28 +120,20 @@ def get_endpoint_by_query(user_input: str, *, profile: str | None = None) -> End return None -def is_chain_id(chain_id: str) -> bool: - if chain_id.isdecimal(): - return True - elif chain_id.startswith("0x"): - try: - int(chain_id, 16) - return True - except ValueError: - pass - return False - - def find_endpoints( *, chain_id: str | int | None = None, name_contains: str | None = None, url_contains: str | None = None, + config: RpcConfig | None = None, ) -> Sequence[Endpoint]: - config = load.read_config_data() + """find all inputs that match input criteria""" + + if config is None: + config = load.read_config_data() endpoints = list(config["endpoints"].values()) - # check chain id + # check chain_id if chain_id is not None: if isinstance(chain_id, int): chain_id = str(chain_id) @@ -119,11 +141,13 @@ def find_endpoints( endpoint for endpoint in endpoints if endpoint["chain_id"] == chain_id ] + # check name_contains if name_contains is not None: endpoints = [ endpoint for endpoint in endpoints if name_contains in endpoint["name"] ] + # check url_contains if url_contains is not None: endpoints = [ endpoint for endpoint in endpoints if url_contains in endpoint["url"] @@ -133,5 +157,5 @@ def find_endpoints( def get_global_metadata() -> Mapping[str, Any]: - config = load.read_config_data() - return config["global_metadata"] + """return MESC global metadata""" + return load.read_config_data()["global_metadata"] diff --git a/python/mesc/load.py b/python/mesc/load.py index e90f57e..6c1e39a 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -8,32 +8,75 @@ from . import overrides def read_config_data() -> RpcConfig: + """read MESC config according to MESC environment variables""" + # locate and load config using env vars mode = os.environ.get("MESC_MODE") - if mode == "DISABLE": - raise exceptions.MescDisabled("MESC disabled, check with is_mesc_enabled()") - if mode == "PATH": + if mode == "DISABLED": + raise exceptions.MescDisabled( + "MESC_MODE=DISABLED, check with is_mesc_enabled()" + ) + elif mode == "PATH": config = read_file_config() elif mode == "ENV": config = read_env_config() elif mode not in ["", None]: - raise Exception("invalid mode: " + str(mode)) + raise Exception( + "invalid mode: " + str(mode) + ", must be PATH, ENV, or DISABLED" + ) elif os.environ.get("MESC_PATH") not in ["", None]: config = read_file_config() elif os.environ.get("MESC_ENV") not in ["", None]: config = read_env_config() else: - raise Exception("config not specified") + raise exceptions.MescDisabled("To enable MESC, set MESC_PATH or MESC_ENV") + # apply overrides config = overrides.apply_env_overrides(config) return config def read_env_config() -> RpcConfig: - return json.loads(os.environ.get("MESC_ENV")) # type: ignore + # obtain raw config data from env + value = os.environ.get("MESC_ENV") + if value is None or value == "": + raise exceptions.LoadError( + "Cannot load MESC config from MESC_ENV, value is not set" + ) + + # parse config data as JSON + try: + return json.loads(value) + except json.JSONDecodeError: + raise exceptions.InvalidConfig("MESC_ENV is not formatted as valid JSON") def read_file_config() -> RpcConfig: - path = os.path.expanduser(os.environ.get("MESC_PATH")) # type: ignore - with open(path, "r") as f: # type: ignore - return json.load(f) # type: ignore + # obtain config file path + path = os.environ.get("MESC_PATH") + if path is None or path == "": + raise exceptions.LoadError( + "Cannot load MESC config from MESC_ENV, value is not set" + ) + path = os.path.expanduser(path) + + # load file contents + try: + with open(path, "r") as f: + content = f.read() + except FileNotFoundError: + raise exceptions.LoadError("File does not exist: " + str(path)) + except PermissionError: + raise exceptions.LoadError( + "Insufficient permissions to load file: " + str(path) + ) + except Exception: + raise exceptions.LoadError("Unable to load file: " + str(path)) + + # parse raw data as json + try: + return json.loads(content) + except json.JSONDecodeError: + raise exceptions.InvalidConfig( + "file at MESC_PATH is not formatted as valid JSON" + ) diff --git a/python/mesc/network_utils.py b/python/mesc/network_utils.py new file mode 100644 index 0000000..e9af538 --- /dev/null +++ b/python/mesc/network_utils.py @@ -0,0 +1,32 @@ +from __future__ import annotations +from mesc.types import RpcConfig +from . import network_names + + +def is_chain_id(chain_id: str) -> bool: + """return True if input is a valid chain_id""" + if chain_id.isdecimal(): + return True + elif chain_id.startswith("0x"): + try: + int(chain_id, 16) + return True + except ValueError: + return False + else: + return False + + +def network_name_to_chain_id( + network_name: str, *, config: RpcConfig | None = None +) -> str | None: + """return chain_id of given network name""" + network_name = network_name.lower() + if config is not None and network_name in config["network_names"]: + return config["network_names"][network_name] + else: + for chain_id, chain_id_name in network_names.network_names.items(): + if network_name == chain_id_name: + return chain_id + else: + return None diff --git a/python/mesc/types.py b/python/mesc/types.py index 132585e..1a50413 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -39,6 +39,11 @@ class RpcConfig(TypedDict): global_metadata: MutableMapping[str, Any] +# +# # query types +# + + class EndpointQuery(TypedDict): query_type: Literal[ "default_endpoint", From dd10d827fcaad1a1b4989f4c08d8e69f068df22e Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 6 Jan 2024 20:31:49 -0800 Subject: [PATCH 05/85] expand cli help messages --- rust/Cargo.lock | 4 +- rust/crates/mesc_cli/src/cli/args.rs | 28 ++++++- .../mesc_cli/src/cli/subcommands/help.rs | 81 +++++++++++++++++++ .../mesc_cli/src/cli/subcommands/mod.rs | 2 + 4 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/help.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 89b5b42..4ca7ce5 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "mesc" -version = "0.1.1" +version = "0.1.2" dependencies = [ "serde", "serde_json", @@ -1162,7 +1162,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "colored_json", diff --git a/rust/crates/mesc_cli/src/cli/args.rs b/rust/crates/mesc_cli/src/cli/args.rs index db27101..fc7912d 100644 --- a/rust/crates/mesc_cli/src/cli/args.rs +++ b/rust/crates/mesc_cli/src/cli/args.rs @@ -1,6 +1,7 @@ use super::subcommands::*; use crate::MescCliError; use clap::{Parser, Subcommand}; +use toolstr::Colorize; pub(crate) async fn run_cli() -> Result<(), MescCliError> { match Cli::parse().command { @@ -12,12 +13,27 @@ pub(crate) async fn run_cli() -> Result<(), MescCliError> { Commands::Endpoint(args) => endpoint_command(args), Commands::Metadata(args) => metadata_command(args), Commands::Url(args) => url_command(args), + Commands::Help(args) => help_command(args), } } +fn get_after_str() -> String { + let example = format!( + "{} {}{}", + "(print these with".italic().truecolor(100, 100, 100), + "mesc help ".bold(), + ")".italic().truecolor(100, 100, 100), + ); + let mut output = format!("{} {}", "Help topics:".to_string().bold().underline(), example); + for (topic, description) in get_help_topics().iter() { + output = format!("{}\n {:<9} {}", output, topic.bold(), description); + } + output +} + /// Utility for creating and managing MESC RPC configurations #[derive(Parser)] -#[clap(author, version, about, long_about = None)] +#[clap(author, version, about, long_about = None, disable_help_subcommand = true, after_help=&get_after_str())] pub(crate) struct Cli { #[clap(subcommand)] pub(crate) command: Commands, @@ -42,6 +58,8 @@ pub(crate) enum Commands { Metadata(MetadataArgs), /// Print endpoint URL Url(UrlArgs), + /// Print help + Help(HelpArgs), } /// Arguments for the `setup` subcommand @@ -184,3 +202,11 @@ pub(crate) struct UrlArgs { #[clap(short, long)] pub(crate) profile: Option, } + +/// Arguments for the `help` subcommand +#[derive(Parser)] +pub(crate) struct HelpArgs { + /// topic + #[clap()] + pub(crate) topic: Option, +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs new file mode 100644 index 0000000..4374eb5 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -0,0 +1,81 @@ +use crate::{Cli, HelpArgs, MescCliError}; +use clap::CommandFactory; +use toolstr::Colorize; + +pub(crate) fn get_help_topics() -> Vec<(String, String)> { + vec![("env".to_string(), "Description of environmental variables".to_string())] +} + +pub(crate) fn help_command(args: HelpArgs) -> Result<(), MescCliError> { + match args.topic.map(|s| s.to_lowercase()) { + Some(topic) => match topic.as_str() { + "env" => print_env_help(), + _ => println!("Unknown help topic: {}", topic), + }, + None => Cli::command().print_help().map_err(|e| { + let message = format!("Failed to print help: {}", e); + MescCliError::Error(message) + })?, + } + Ok(()) +} + +fn print_env_help() { + let messages = vec![ + ( + "MESC_MODE", + format!( + "{}, {}, or {}", + "PATH".bold().green(), + "ENV".bold().green(), + "DISABLED".bold().green() + ), + "PATH", + ), + ("MESC_PATH", "path to MESC config file".to_string(), "/path/to/config/mesc.json"), + ("MESC_ENV", "raw JSON MESC config data".to_string(), "{ \"endpoints\": { ... }, ... }"), + ( + "MESC_DEFAULT_ENDPOINT", + "url, endpoint name, or network name".to_string(), + "local_goerli", + ), + ( + "MESC_NETWORK_DEFAULTS", + format!("space-separated pairs of {}", "CHAIN_ID=ENDPOINT".bold().green()), + "10=local_optimism 137=local_polygon", + ), + ( + "MESC_NETWORK_NAMES", + format!("space-separated pairs of {}", "NETWORK_NAME=CHAIN_ID".bold().green()), + "optimism=10 custom_fork=12345678", + ), + ( + "MESC_ENDPOINTS", + format!("space-separated items of {}", "[NAME[:CHAIN_ID]=]URL".bold()), + "local_goerli:5=localhost:8545 fork=localhost:8546", + ), + ( + "MESC_PROFILES", + format!("space-separated items of {}", "PROFILE.KEY[.CHAIN_ID]=ENDPOINT".bold()), + "tool_xyz.default_endpoint=local_goerli", + ), + ( + "MESC_GLOBAL_METADATA", + "JSON-formatted global metadata".to_string(), + "{\"tool_xyz\": { ... }}", + ), + ( + "MESC_ENDPOINT_METADATA", + format!("JSON mapping of {}", "{ENDPOINT_NAME: ENDPOINT_METADATA}".bold()), + "{\"local_goerli\": {\"api_key\": \"abc123\"}}", + ), + ]; + + println!("MESC environment variables:"); + println!(); + for (name, value, example) in messages.iter() { + println!("{:>22} {}", name.bold(), value); + println!("{:>32} {}", "example:".truecolor(100, 100, 100), example.green().bold()); + println!(); + } +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs index ce4aa6d..baf7be9 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs @@ -1,5 +1,6 @@ mod defaults; mod endpoint; +mod help; mod ls; mod metadata; mod ping; @@ -9,6 +10,7 @@ mod url; pub(crate) use defaults::*; pub(crate) use endpoint::*; +pub(crate) use help::*; pub(crate) use ls::*; pub(crate) use metadata::*; pub(crate) use ping::*; From dbfedb8c5c8ad5ebc7d14d2846acfabd4e579cea Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 6 Jan 2024 22:11:10 -0800 Subject: [PATCH 06/85] add help topics to cli --- README.md | 18 +- SPECIFICATION.md | 4 +- rust/Cargo.lock | 578 +++++++++++++++++- rust/README.md | 18 +- rust/crates/mesc_cli/Cargo.toml | 3 +- .../mesc_cli/src/cli/subcommands/help.rs | 226 ++++++- 6 files changed, 816 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 358e1dc..a4a57b6 100644 --- a/README.md +++ b/README.md @@ -95,28 +95,32 @@ endpoints = mesc.find_endpoints(chain_id=5) use mesc; use mesc::MescError; +type OptionalResult = Result, MescError>; +type MultiResult = Result, MescError>; +type Result = Result, MescError>; + // get the default endpoint -let endpoint: Result = mesc::get_default_endpoint(None); +let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: Result = mesc::get_endpoint_by_network(5, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); // get the default network for a particular tool -let chain_id: Result = mesc::get_default_endpoint("xyz_tool"); +let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); // get the default endpoint of a network for a particular tool -let endpoint: Result = mesc::get_endpoint_by_network(5, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: Result = mesc::get_endpoint_by_name("local_query"); +let endpoint: Result = mesc::get_endpoint_by_name("local_query"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) -let endpoint: Result, MescError> = mesc::get_endpoint_by_query(user_str, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); -let endpoints: Result, MescError> = mesc::find_endpoints(query); +let endpoints: MultiResult = mesc::find_endpoints(query); ``` ### Typical Usage diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 5c65018..3e5f94a 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -190,8 +190,8 @@ These overrides use a simple syntax that is intended to be easily written by hum | --- | --- | --- | | `MESC_DEFAULT_ENDPOINT` | url, endpoint name, or network name | `localhost:9999` | | `MESC_NETWORK_DEFAULTS` | space-separated pairs of `=` | `5=alchemy_optimism 1=local_mainnet` | -| `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | -| `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | +| `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | +| `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | | `MESC_PROFILES` | space-separated pairs of `.[.` | `foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism` | | `MESC_GLOBAL_METADATA` | JSON formatted global metadata | `{}` | | `MESC_ENDPOINT_METADATA` | JSON mapping of `{"endpoint_name": {}}` | `{}` | diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 4ca7ce5..4dd4ba7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -75,6 +75,15 @@ dependencies = [ "libc", ] +[[package]] +name = "ansi_colours" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1558bd2075d341b9ca698ec8eb6fcc55a746b1fc4255585aad5b141d918a80" +dependencies = [ + "rgb", +] + [[package]] name = "anstream" version = "0.6.4" @@ -223,6 +232,52 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "bat" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcc9e5637c2330d8eb7b920f2aa5d9e184446c258466f825ea1412c7614cc86" +dependencies = [ + "ansi_colours", + "bincode", + "bugreport", + "bytesize", + "clap", + "clircle", + "console", + "content_inspector", + "encoding_rs", + "etcetera", + "flate2", + "git2", + "globset", + "grep-cli", + "home", + "nu-ansi-term 0.49.0", + "once_cell", + "path_abs", + "plist", + "regex", + "semver", + "serde", + "serde_yaml", + "shell-words", + "syntect", + "thiserror", + "unicode-width", + "walkdir", + "wild", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -256,6 +311,28 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bstr" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bugreport" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535120b8182547808081a66f1f77a64533c780b23da26763e0ee34dfb94f98c9" +dependencies = [ + "git-version", + "shell-escape", + "sys-info", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -288,6 +365,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "bytesize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" + [[package]] name = "cc" version = "1.0.83" @@ -338,6 +421,7 @@ dependencies = [ "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -358,6 +442,18 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +[[package]] +name = "clircle" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e87cbed5354f17bd8ca8821a097fb62599787fe8f611743fad7ee156a0a600" +dependencies = [ + "cfg-if", + "libc", + "serde", + "winapi", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -387,6 +483,28 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "console" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", +] + +[[package]] +name = "content_inspector" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" +dependencies = [ + "memchr", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -503,6 +621,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "dyn-clone" version = "1.0.16" @@ -525,6 +652,12 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.33" @@ -562,6 +695,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "ethnum" version = "1.5.0" @@ -749,12 +893,72 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "git-version" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19" +dependencies = [ + "git-version-macro", +] + +[[package]] +name = "git-version-macro" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "git2" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +dependencies = [ + "bitflags 2.4.1", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glob" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax 0.8.2", +] + +[[package]] +name = "grep-cli" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea40788c059ab8b622c4d074732750bfb3bd2912e2dd58eabc11798a4d5ad725" +dependencies = [ + "bstr", + "globset", + "libc", + "log", + "termcolor", + "winapi-util", +] + [[package]] name = "h2" version = "0.3.22" @@ -1080,12 +1284,51 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libgit2-sys" +version = "0.16.1+1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + [[package]] name = "libm" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "line-wrap" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.12" @@ -1130,9 +1373,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" @@ -1164,6 +1407,7 @@ dependencies = [ name = "mesc_cli" version = "0.1.2" dependencies = [ + "bat", "clap", "colored_json", "edit", @@ -1283,6 +1527,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1318,6 +1571,28 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "openssl" version = "0.10.61" @@ -1401,6 +1676,15 @@ dependencies = [ "futures", ] +[[package]] +name = "path_abs" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ef02f6342ac01d8a93b65f96db53fe68a92a15f41144f97fb00a9e669633c3" +dependencies = [ + "std_prelude", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1434,6 +1718,20 @@ dependencies = [ "array-init-cursor", ] +[[package]] +name = "plist" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +dependencies = [ + "base64", + "indexmap", + "line-wrap", + "quick-xml", + "serde", + "time", +] + [[package]] name = "polars" version = "0.35.4" @@ -1773,6 +2071,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1788,6 +2092,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.33" @@ -1895,7 +2208,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax", + "regex-syntax 0.8.2", ] [[package]] @@ -1906,9 +2219,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "regex-syntax" version = "0.8.2" @@ -1953,6 +2272,15 @@ dependencies = [ "winreg", ] +[[package]] +name = "rgb" +version = "0.8.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +dependencies = [ + "bytemuck", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1993,6 +2321,21 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.22" @@ -2086,6 +2429,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -2095,6 +2451,18 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "signal-hook" version = "0.3.17" @@ -2216,6 +2584,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "std_prelude" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" + [[package]] name = "streaming-decompression" version = "0.1.2" @@ -2284,6 +2658,37 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syntect" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.7.5", + "serde", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + +[[package]] +name = "sys-info" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "sysinfo" version = "0.29.11" @@ -2338,6 +2743,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -2368,6 +2792,35 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2439,9 +2892,7 @@ dependencies = [ [[package]] name = "toolstr" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b90a491925fd828fb7dd69207b247042d525257d0932dd59fb1eb41c7fee57a" +version = "0.1.2" dependencies = [ "chrono", "polars", @@ -2453,8 +2904,6 @@ dependencies = [ [[package]] name = "toolstr_colored" version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d335176ed9b133b9d9e226656f2f486f84ebac50250c598246ac6d6d512ac05" dependencies = [ "lazy_static", "windows-sys 0.48.0", @@ -2515,7 +2964,7 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ - "nu-ansi-term", + "nu-ansi-term 0.46.0", "sharded-slab", "smallvec", "thread_local", @@ -2571,6 +3020,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unsafe-libyaml" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" + [[package]] name = "url" version = "2.5.0" @@ -2618,6 +3073,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -2721,6 +3186,15 @@ dependencies = [ "rustix", ] +[[package]] +name = "wild" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d01931a94d5a115a53f95292f51d316856b68a035618eb831bbba593a30b67" +dependencies = [ + "glob", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2737,6 +3211,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2752,6 +3235,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2770,6 +3262,21 @@ dependencies = [ "windows-targets 0.52.0", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -2800,6 +3307,12 @@ dependencies = [ "windows_x86_64_msvc 0.52.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -2812,6 +3325,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -2824,6 +3343,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -2836,6 +3361,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -2848,6 +3379,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -2860,6 +3397,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2872,6 +3415,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2900,6 +3449,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9828b178da53440fa9c766a3d2f73f7cf5d0ac1fe3980c1e5018d899fd19e07b" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/rust/README.md b/rust/README.md index 567658d..1a20a47 100644 --- a/rust/README.md +++ b/rust/README.md @@ -57,26 +57,30 @@ Basic read functions use mesc; use mesc::MescError; +type OptionalResult = Result, MescError>; +type MultiResult = Result, MescError>; +type Result = Result, MescError>; + // get the default endpoint -let endpoint: Result = mesc::get_default_endpoint(None); +let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: Result = mesc::get_endpoint_by_network(5, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); // get the default network for a particular tool -let chain_id: Result = mesc::get_default_endpoint("xyz_tool"); +let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); // get the default endpoint of a network for a particular tool -let endpoint: Result = mesc::get_endpoint_by_network(5, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: Result = mesc::get_endpoint_by_name("local_query"); +let endpoint: Result = mesc::get_endpoint_by_name("local_query"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) -let endpoint: Result, MescError> = mesc::get_endpoint_by_query(user_str, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); -let endpoints: Result, MescError> = mesc::find_endpoints(query); +let endpoints: MultiResult = mesc::find_endpoints(query); ``` diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index ad9f6d4..a975649 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -20,8 +20,9 @@ inquire = "0.6.2" reqwest = { version = "0.11.22", features = ["json"] } tokio = { version = "1.32.0", features = ["full"] } futures = "0.3.29" -toolstr = { version = "0.1.1" } +toolstr = { version = "0.1.2", path = "../../../../toolstr/toolstr-rust/crates/toolstr" } edit = "0.1.4" url = "2.2.2" ipgeolocate = "0.3.6" colored_json = "4.1.0" +bat = "0.24.0" diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index 4374eb5..b76d802 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -2,14 +2,13 @@ use crate::{Cli, HelpArgs, MescCliError}; use clap::CommandFactory; use toolstr::Colorize; -pub(crate) fn get_help_topics() -> Vec<(String, String)> { - vec![("env".to_string(), "Description of environmental variables".to_string())] -} - pub(crate) fn help_command(args: HelpArgs) -> Result<(), MescCliError> { match args.topic.map(|s| s.to_lowercase()) { Some(topic) => match topic.as_str() { "env" => print_env_help(), + "python" => print_python_interface(), + "rust" => print_rust_interface(), + "schema" => print_schema()?, _ => println!("Unknown help topic: {}", topic), }, None => Cli::command().print_help().map_err(|e| { @@ -20,6 +19,15 @@ pub(crate) fn help_command(args: HelpArgs) -> Result<(), MescCliError> { Ok(()) } +pub(crate) fn get_help_topics() -> Vec<(String, String)> { + vec![ + ("env".to_string(), "Description of environmental variables".to_string()), + ("python".to_string(), "Print python interface".to_string()), + ("rust".to_string(), "Print rust interface".to_string()), + ("schema".to_string(), "Schemas of configs, endpoints, and profiles".to_string()), + ] +} + fn print_env_help() { let messages = vec![ ( @@ -79,3 +87,213 @@ fn print_env_help() { println!(); } } + +fn print_code(content: String, filetype: &str) { + use bat::PrettyPrinter; + + PrettyPrinter::new() + .input_from_bytes(content.as_bytes()) + .language(filetype) + // .theme("Visual Studio Dark+") + // .theme("Monokai Extended Bright") + .theme("Dracula") + // .theme("DarkNeon") + // .theme("Coldark-Dark") + // .theme("base16-256") + .print() + .unwrap(); + println!(); +} + +fn print_python_interface() { + let interface = r#"import mesc + +# get the default endpoint +endpoint = mesc.get_default_endpoint() + +# get the default endpoint of a network +endpoint = mesc.get_endpoint_by_network(5) + +# get the default endpoint for a particular tool +endpoint = mesc.get_default_endpoint(profile='xyz_tool') + +# get the default endpoint of a network for a particular tool +endpoint = mesc.get_endpoint_by_network(5, profile='xyz_tool') + +# get an endpoint by name +endpoint = mesc.get_endpoint_by_name('local_goerli') + +# parse a user-provided string into a matching endpoint +# (try 1. endpoint name, then 2. chain id, then 3. network name) +endpoint = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') + +# find all endpoints matching given criteria +endpoints = mesc.find_endpoints(chain_id=5)"#; + + print_code(interface.to_string(), "py") +} + +fn print_rust_interface() { + let interface = r#"use mesc; +use mesc::MescError; + +type OptionalResult = Result, MescError>; +type MultiResult = Result, MescError>; +type Result = Result, MescError>; + +// get the default endpoint +let endpoint: OptionalResult = mesc::get_default_endpoint(None); + +// get the default endpoint of a network +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); + +// get the default network for a particular tool +let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); + +// get the default endpoint of a network for a particular tool +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); + +// get an endpoint by name +let endpoint: Result = mesc::get_endpoint_by_name("local_query"); + +// parse a user-provided string into a matching endpoint +// (first try 1. endpoint name, then 2. chain id, then 3. network name) +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); + +// find all endpoints matching given criteria +let query = mesc::MultiEndpointQuery::new().chain_id(5); +let endpoints: MultiResult = mesc::find_endpoints(query);"#; + + print_code(interface.to_string(), "rs") +} + +fn print_schema() -> Result<(), MescCliError> { + let mut title_style = crate::metadata::get_theme_font_style("title")?; + title_style.bold(); + let metavar_style = crate::metadata::get_theme_font_style("metavar")?; + let mut description_style = crate::metadata::get_theme_font_style("description")?; + description_style.bold(); + let option_style = crate::metadata::get_theme_font_style("option")?; + let _content_style = crate::metadata::get_theme_font_style("content")?; + let comment_style = crate::metadata::get_theme_font_style("comment")?; + + let keys = vec![ + "mesc_version", + "default_endpoint", + "network_defaults", + "network_names", + "endpoints", + "profiles", + "global_metadata", + ]; + let types = vec![ + "str", + "str | None", + "Mapping[ChainId, str", + "Mapping[str, ChainId]", + "Mapping[str, ChainId]", + "Mapping[str, ChainId]", + "Mapping[str, ChainId]", + ]; + let descriptions = vec![ + "must equal the value \"MESC 1.0\"", + "name of default endpoint", + "map of chain_id's to endpoint names", + "map of network names to chain_id's", + "map of endpoint names to endpoints", + "map of profile names to profiles", + "global metadata entries", + ]; + let mut table = toolstr::Table::default(); + table.add_column("key", keys)?; + table.add_column("type", types)?; + table.add_column("description", descriptions)?; + let mut format = toolstr::TableFormat::default() + .border_font_style(comment_style.clone()) + .label_font_style(title_style.clone()); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("key").font_style(metavar_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("type").font_style(option_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new() + .name("description") + .font_style(description_style.clone()), + ); + let theme = toolstr::Theme::default() + .with_border_style(comment_style.clone()) + .with_title_style(title_style.clone()); + toolstr::print_text_box("RPC Config", theme); + format.print(table)?; + + let keys = vec!["name", "url", "chain_id", "endpoint_metadata"]; + let types = vec!["str", "str", "ChainId | None", "Mapping[str, Any]"]; + let descriptions = vec![ + "name of endpoint", + "url of endpoint, including transport", + "chain id of network", + "endpoint metadata entries", + ]; + let mut table = toolstr::Table::default(); + table.add_column("key", keys)?; + table.add_column("type", types)?; + table.add_column("description", descriptions)?; + let mut format = toolstr::TableFormat::default() + .border_font_style(comment_style.clone()) + .label_font_style(title_style.clone()); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("key").font_style(metavar_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("type").font_style(option_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new() + .name("description") + .font_style(description_style.clone()), + ); + let theme = toolstr::Theme::default() + .with_border_style(comment_style.clone()) + .with_title_style(title_style.clone()); + println!(); + println!(); + toolstr::print_text_box("Endpoint", theme); + format.print(table)?; + + let keys = vec!["name", "default_endpoint", "network_defaults"]; + let types = vec!["str", "str | None", "Mapping[ChainId, str]"]; + let descriptions = vec![ + "name of profile", + "chain_id of default network", + "map of chain_id's to endpoint names", + ]; + let mut table = toolstr::Table::default(); + table.add_column("key", keys)?; + table.add_column("type", types)?; + table.add_column("description", descriptions)?; + let mut format = toolstr::TableFormat::default() + .border_font_style(comment_style.clone()) + .label_font_style(title_style.clone()); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("key").font_style(metavar_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new().name("type").font_style(option_style.clone()), + ); + format.add_column( + toolstr::ColumnFormatShorthand::new() + .name("description") + .font_style(description_style.clone()), + ); + let theme = toolstr::Theme::default() + .with_border_style(comment_style.clone()) + .with_title_style(title_style.clone()); + println!(); + println!(); + toolstr::print_text_box("RPC Config", theme); + format.print(table)?; + + Ok(()) +} From abbb74527c0c175c24e14b56430b242fadde030e Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 7 Jan 2024 00:58:03 -0800 Subject: [PATCH 07/85] add python validation pipeline --- python/mesc/load.py | 99 ++++++++++----- python/mesc/types.py | 63 +++++++--- python/mesc/validation.py | 202 +++++++++++++++++++++++++++++++ rust/crates/mesc/src/validate.rs | 10 -- 4 files changed, 314 insertions(+), 60 deletions(-) create mode 100644 python/mesc/validation.py diff --git a/python/mesc/load.py b/python/mesc/load.py index 6c1e39a..26b6acb 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -1,82 +1,121 @@ from __future__ import annotations import json import os +import typing from .types import RpcConfig from . import exceptions from . import overrides +from . import validation def read_config_data() -> RpcConfig: """read MESC config according to MESC environment variables""" # locate and load config using env vars - mode = os.environ.get("MESC_MODE") - if mode == "DISABLED": + mode = os.environ.get('MESC_MODE') + if mode == 'DISABLED': raise exceptions.MescDisabled( - "MESC_MODE=DISABLED, check with is_mesc_enabled()" + 'MESC_MODE=DISABLED, check with is_mesc_enabled()' ) - elif mode == "PATH": - config = read_file_config() - elif mode == "ENV": - config = read_env_config() - elif mode not in ["", None]: + elif mode == 'PATH': + config = read_file_config(validate=False) + elif mode == 'ENV': + config = read_env_config(validate=False) + elif mode not in ['', None]: raise Exception( - "invalid mode: " + str(mode) + ", must be PATH, ENV, or DISABLED" + 'invalid mode: ' + str(mode) + ', must be PATH, ENV, or DISABLED' ) - elif os.environ.get("MESC_PATH") not in ["", None]: - config = read_file_config() - elif os.environ.get("MESC_ENV") not in ["", None]: - config = read_env_config() + elif os.environ.get('MESC_PATH') not in ['', None]: + config = read_file_config(validate=False) + elif os.environ.get('MESC_ENV') not in ['', None]: + config = read_env_config(validate=False) else: - raise exceptions.MescDisabled("To enable MESC, set MESC_PATH or MESC_ENV") + raise exceptions.MescDisabled('To enable MESC, set MESC_PATH or MESC_ENV') # apply overrides config = overrides.apply_env_overrides(config) - return config + # validate + validation.validate(config) + return typing.cast(RpcConfig, config) -def read_env_config() -> RpcConfig: +@typing.overload +def read_env_config(*, validate: typing.Literal[False]) -> typing.Any: + ... + + +@typing.overload +def read_env_config(*, validate: typing.Literal[True]) -> RpcConfig: + ... + + +def read_env_config(*, validate: bool = True) -> RpcConfig | typing.Any: + """read config from MESC_ENV environment variable""" # obtain raw config data from env - value = os.environ.get("MESC_ENV") - if value is None or value == "": + value = os.environ.get('MESC_ENV') + if value is None or value == '': raise exceptions.LoadError( - "Cannot load MESC config from MESC_ENV, value is not set" + 'Cannot load MESC config from MESC_ENV, value is not set' ) # parse config data as JSON try: - return json.loads(value) + config = json.loads(value) except json.JSONDecodeError: - raise exceptions.InvalidConfig("MESC_ENV is not formatted as valid JSON") + raise exceptions.InvalidConfig('MESC_ENV is not formatted as valid JSON') + + if validate: + validation.validate(config) + return typing.cast(RpcConfig, config) + else: + return config -def read_file_config() -> RpcConfig: +@typing.overload +def read_file_config( + *, path: str | None = None, validate: typing.Literal[False] +) -> typing.Any: + ... + + +@typing.overload +def read_file_config( + *, path: str | None = None, validate: typing.Literal[True] +) -> RpcConfig: + ... + + +def read_file_config( + *, path: str | None = None, validate: bool = True +) -> RpcConfig | typing.Any: + """read config from MESC config file""" # obtain config file path - path = os.environ.get("MESC_PATH") - if path is None or path == "": + if path is None: + path = os.environ.get('MESC_PATH') + if path is None or path == '': raise exceptions.LoadError( - "Cannot load MESC config from MESC_ENV, value is not set" + 'Cannot load MESC config from MESC_ENV, value is not set' ) path = os.path.expanduser(path) # load file contents try: - with open(path, "r") as f: + with open(path, 'r') as f: content = f.read() except FileNotFoundError: - raise exceptions.LoadError("File does not exist: " + str(path)) + raise exceptions.LoadError('File does not exist: ' + str(path)) except PermissionError: raise exceptions.LoadError( - "Insufficient permissions to load file: " + str(path) + 'Insufficient permissions to load file: ' + str(path) ) except Exception: - raise exceptions.LoadError("Unable to load file: " + str(path)) + raise exceptions.LoadError('Unable to load file: ' + str(path)) # parse raw data as json try: return json.loads(content) except json.JSONDecodeError: raise exceptions.InvalidConfig( - "file at MESC_PATH is not formatted as valid JSON" + 'file at MESC_PATH is not formatted as valid JSON' ) diff --git a/python/mesc/types.py b/python/mesc/types.py index 1a50413..74f1479 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -3,16 +3,16 @@ from typing import Any, MutableMapping, TypedDict, Literal, Sequence mesc_env_vars = [ - "MESC_MODE", - "MESC_PATH", - "MESC_ENV", - "MESC_ENDPOINT_METADATA", - "MESC_GLOBAL_METADATA", - "MESC_ENDPOINTS", - "MESC_NETWORK_NAMES", - "MESC_DEFAULT_ENDPOINT", - "MESC_NETWORK_DEFAULTS", - "MESC_PROFILES", + 'MESC_MODE', + 'MESC_PATH', + 'MESC_ENV', + 'MESC_ENDPOINT_METADATA', + 'MESC_GLOBAL_METADATA', + 'MESC_ENDPOINTS', + 'MESC_NETWORK_NAMES', + 'MESC_DEFAULT_ENDPOINT', + 'MESC_NETWORK_DEFAULTS', + 'MESC_PROFILES', ] @@ -39,6 +39,29 @@ class RpcConfig(TypedDict): global_metadata: MutableMapping[str, Any] +endpoint_types: dict[str, type | tuple[type, ...]] = { + 'name': str, + 'url': str, + 'chain_id': (str, type(None)), + 'endpoint_metadata': dict, +} + +profile_types: dict[str, type | tuple[type, ...]] = { + 'name': str, + 'default_endpoint': (str, type(None)), + 'network_defaults': dict, +} + +rpc_config_types: dict[str, type | tuple[type, ...]] = { + 'mesc_version': str, + 'default_endpoint': (str, type(None)), + 'endpoints': dict, + 'network_defaults': dict, + 'network_names': dict, + 'profiles': dict, + 'global_metadata': dict, +} + # # # query types # @@ -46,10 +69,10 @@ class RpcConfig(TypedDict): class EndpointQuery(TypedDict): query_type: Literal[ - "default_endpoint", - "endpoint_by_name", - "endpoint_by_network", - "user_input", + 'default_endpoint', + 'endpoint_by_name', + 'endpoint_by_network', + 'user_input', ] fields: ( DefaultEndpointQuery | EndpointNameQuery | EndpointNetworkQuery | UserInputQuery @@ -86,12 +109,12 @@ class GlobalMetadataQuery(TypedDict, total=False): class MescQuery(TypedDict): query_type: Literal[ - "default_endpoint", - "endpoint_by_name", - "endpoint_by_network", - "user_input", - "multi_endpoint", - "global_metadata", + 'default_endpoint', + 'endpoint_by_name', + 'endpoint_by_network', + 'user_input', + 'multi_endpoint', + 'global_metadata', ] fields: ( DefaultEndpointQuery diff --git a/python/mesc/validation.py b/python/mesc/validation.py new file mode 100644 index 0000000..6237c1f --- /dev/null +++ b/python/mesc/validation.py @@ -0,0 +1,202 @@ +from __future__ import annotations + +from typing import Any +from .exceptions import InvalidConfig +from .types import rpc_config_types, endpoint_types, profile_types +from . import network_utils + + +def is_valid(config: Any) -> bool: + try: + validate(config) + return True + except InvalidConfig: + return False + + +def validate(config: Any) -> None: + # all fields present with the correct types + if not isinstance(config, dict): + raise InvalidConfig('RpcConfig must be a dict') + for field, field_type in rpc_config_types.items(): + if field not in config: + raise InvalidConfig('RpcConfig is missing field: ' + str(field)) + value = config[field] + _check_type('RpcConfig', None, field, field_type, value) + if isinstance(value, dict): + _check_str_keys(field, value) + for name, endpoint in config['endpoints'].items(): + for field, field_type in endpoint_types.items(): + if field not in endpoint: + raise InvalidConfig( + 'Endpoint ' + str(name) + ' is missing field: ' + str(field) + ) + value = endpoint[field] + _check_type('Endpoint', name, field, field_type, value) + if isinstance(value, dict): + _check_str_keys(field, value) + for name, profile in config['profiles'].items(): + for field, field_type in profile_types.items(): + if field not in profile: + raise InvalidConfig( + 'Profile ' + str(name) + ' is missing field: ' + str(field) + ) + value = profile[field] + _check_type('Profile', name, field, field_type, value) + if isinstance(value, dict): + _check_str_keys(field, value) + for field in ['network_defaults', 'network_names']: + for value in config[field].values(): + if not isinstance(value, str): + raise InvalidConfig( + 'Entries in ' + + str(field) + + ' must be strings, but there is a value of type ' + + str(type(value)) + ) + for name, profile in config['profiles'].items(): + for field in ['network_defaults', 'network_names']: + for value in config[field].values(): + if not isinstance(value, str): + raise InvalidConfig( + 'Entries in ' + + str(field) + + ' must be strings, but in the profile ' + + name + + ' there is a value of type ' + + str(type(value)) + ) + + # referenced endpoints exit + endpoint = config['default_endpoint'] + if endpoint is not None and endpoint not in config['endpoints']: + raise InvalidConfig( + 'Referenced default_endpoint does not exist: ' + str(endpoint) + ) + for endpoint in config['network_defaults'].values(): + if endpoint not in config['endpoints']: + raise InvalidConfig( + 'Referenced endpoint in network_defaults does not exist: ' + + str(endpoint) + ) + for name, profile in config['profiles'].items(): + endpoint = profile['default_endpoint'] + if endpoint is not None and endpoint not in profile['endpoints']: + raise InvalidConfig( + 'In profile ' + + name + + ' referenced endpoint does not exist: ' + + str(endpoint) + ) + for endpoint in profile['network_defaults'].values(): + if endpoint not in config['endpoints']: + raise InvalidConfig( + 'In profile ' + + name + + ' referenced endpoint does not exist: ' + + str(endpoint) + ) + + # default endpoints of each network actually use that specified network + for chain_id, endpoint_name in config['network_defaults'].items(): + if chain_id != config['endpoints'][endpoint_name]['chain_id']: + raise InvalidConfig( + 'Endpoint is set as the default endpoint of network ' + + chain_id + + ", but the endpoint's chain_id is different " + + endpoint['chain_id'] + ) + for profile_name, profile in config['profiles'].items(): + for chain_id, endpoint_name in profile['network_defaults'].items(): + if chain_id != config['endpoints'][endpoint_name]['chain_id']: + raise InvalidConfig( + 'Endpoint is set as the default endpoint of network ' + + chain_id + + ' in profile ' + + profile_name + + ", but the endpoint's chain_id is different " + + endpoint['chain_id'] + ) + + # endpoint map keys match endpoint name fields + for endpoint_name, endpoint in config['endpoints'].items(): + if endpoint['name'] != endpoint_name: + raise InvalidConfig( + 'Endpoint does not match endpoint mapping key: ' + + endpoint['name'] + + ' != ' + + endpoint_name + ) + + # profile map keys match profile name fields + for profile_name, profile in config['profiles'].items(): + if profile['name'] != profile_name: + raise InvalidConfig( + 'Profile does not match profile mapping key: ' + + profile['name'] + + ' != ' + + profile_name + ) + + # chain_id's are valid + for chain_id in config['network_defaults'].keys(): + if not network_utils.is_chain_id(chain_id): + raise Exception( + 'Invalid chain_id used in network_defaults: ' + str(chain_id) + ) + for profile_name, profile in config['profiles'].items(): + for chain_id in profile['network_defaults'].keys(): + if not network_utils.is_chain_id(chain_id): + raise Exception( + 'Invalid chain_id used in profile ' + + profile_name + + ' network_defaults: ' + + str(chain_id) + ) + for endpoint in config['endpoints'].values(): + if not network_utils.is_chain_id(endpoint['chain_id']): + raise Exception( + 'Invalid chain_id used in endpoint ' + + endpoint['name'] + + ': ' + + str(chain_id) + ) + + # no duplicate default network entries using decimal vs hex + pass + + +def _check_type( + datatype: str, + name: str | None, + field: str, + field_type: type | tuple[type, ...], + value: str, +) -> None: + if not isinstance(value, field_type): + if name is not None: + display = datatype + ' ' + name + else: + display = datatype + raise InvalidConfig( + display + + ' invalid type for field: ' + + str(field) + + ', it should have type ' + + str(type(field_type)) + + ' but instead has type ' + + str(type(value)) + ) + + +def _check_str_keys(field: Any, value: Any) -> None: + for key in value.keys(): + if not isinstance(key, str): + raise InvalidConfig( + 'Each key within ' + + field + + ' must be a string, instead ' + + key + + ' is a ' + + str(type(value)) + ) diff --git a/rust/crates/mesc/src/validate.rs b/rust/crates/mesc/src/validate.rs index 21a0af9..52b4d19 100644 --- a/rust/crates/mesc/src/validate.rs +++ b/rust/crates/mesc/src/validate.rs @@ -70,16 +70,6 @@ pub(crate) fn validate_config(config: &RpcConfig) -> Result<(), MescError> { } } - // // urls are unique - // let urls: std::collections::HashSet<_> = config - // .endpoints - // .values() - // .map(|endpoint| endpoint.url.clone()) - // .collect(); - // if urls.len() != config.endpoints.len() { - // return Err(MescError::IntegrityError("urls are not unique".to_string())); - // } - // chain_id's are valid for network in config.network_defaults.keys() { network.to_hex()?; From 3f9fed2214e7a4969fa6e7dbd9fc251f4fb635e6 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 7 Jan 2024 00:58:20 -0800 Subject: [PATCH 08/85] use single quotes format with ruff --- python/mesc/__init__.py | 22 ++++++++++----------- python/mesc/interface.py | 38 ++++++++++++++++++------------------ python/mesc/network_utils.py | 6 +++--- python/pyproject.toml | 2 ++ 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/python/mesc/__init__.py b/python/mesc/__init__.py index 80ab21b..5333006 100644 --- a/python/mesc/__init__.py +++ b/python/mesc/__init__.py @@ -11,17 +11,17 @@ from .interface import ( ) from .types import Endpoint, Profile, RpcConfig -__version__ = "0.1.1" +__version__ = '0.1.1' __all__ = ( - "Endpoint", - "Profile", - "RpcConfig", - "is_mesc_enabled", - "get_default_endpoint", - "get_endpoint_by_name", - "get_endpoint_by_network", - "get_endpoint_by_query", - "find_endpoints", - "get_global_metadata", + 'Endpoint', + 'Profile', + 'RpcConfig', + 'is_mesc_enabled', + 'get_default_endpoint', + 'get_endpoint_by_name', + 'get_endpoint_by_network', + 'get_endpoint_by_query', + 'find_endpoints', + 'get_global_metadata', ) diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 288fa48..2d3aa84 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -12,10 +12,10 @@ def is_mesc_enabled() -> bool: 1) MESC_MODE != "DISABLED" 2) at least 1 MESC env var is set """ - if os.environ.get("MESC_MODE") == "DISABLED": + if os.environ.get('MESC_MODE') == 'DISABLED': return False for var in mesc_env_vars: - if os.environ.get(var) not in [None, ""]: + if os.environ.get(var) not in [None, '']: return True return False @@ -28,12 +28,12 @@ def get_default_endpoint( config = load.read_config_data() # get endpoint name - if profile is not None and profile in config["profiles"]: - endpoint = config["profiles"][profile].get( - "default_endpoint", config["default_endpoint"] + if profile is not None and profile in config['profiles']: + endpoint = config['profiles'][profile].get( + 'default_endpoint', config['default_endpoint'] ) else: - endpoint = config["default_endpoint"] + endpoint = config['default_endpoint'] # get endpoint if endpoint is None: @@ -47,9 +47,9 @@ def get_endpoint_by_name(name: str, *, config: RpcConfig | None = None) -> Endpo if config is None: config = load.read_config_data() try: - return config["endpoints"][name] + return config['endpoints'][name] except KeyError: - raise exceptions.MissingEndpoint("missing endpoint: " + str(name)) + raise exceptions.MissingEndpoint('missing endpoint: ' + str(name)) def get_endpoint_by_network( @@ -64,14 +64,14 @@ def get_endpoint_by_network( # get global default for network if chain_id is None: - raise ValueError("chain_id must be a str") + raise ValueError('chain_id must be a str') chain_id = str(chain_id) - network_defaults = config["network_defaults"] + network_defaults = config['network_defaults'] default_name = network_defaults.get(chain_id) # get profile default for network - if profile and profile in config["profiles"]: - name = config["profiles"][profile]["network_defaults"].get( + if profile and profile in config['profiles']: + name = config['profiles'][profile]['network_defaults'].get( chain_id, default_name ) else: @@ -99,8 +99,8 @@ def get_endpoint_by_query( """ if config is None: config = load.read_config_data() - if user_input in config["endpoints"]: - return config["endpoints"][user_input] + if user_input in config['endpoints']: + return config['endpoints'][user_input] elif user_input.isdecimal(): try: get_endpoint_by_network(int(user_input), profile=profile) @@ -131,26 +131,26 @@ def find_endpoints( if config is None: config = load.read_config_data() - endpoints = list(config["endpoints"].values()) + endpoints = list(config['endpoints'].values()) # check chain_id if chain_id is not None: if isinstance(chain_id, int): chain_id = str(chain_id) endpoints = [ - endpoint for endpoint in endpoints if endpoint["chain_id"] == chain_id + endpoint for endpoint in endpoints if endpoint['chain_id'] == chain_id ] # check name_contains if name_contains is not None: endpoints = [ - endpoint for endpoint in endpoints if name_contains in endpoint["name"] + endpoint for endpoint in endpoints if name_contains in endpoint['name'] ] # check url_contains if url_contains is not None: endpoints = [ - endpoint for endpoint in endpoints if url_contains in endpoint["url"] + endpoint for endpoint in endpoints if url_contains in endpoint['url'] ] return endpoints @@ -158,4 +158,4 @@ def find_endpoints( def get_global_metadata() -> Mapping[str, Any]: """return MESC global metadata""" - return load.read_config_data()["global_metadata"] + return load.read_config_data()['global_metadata'] diff --git a/python/mesc/network_utils.py b/python/mesc/network_utils.py index e9af538..170fe38 100644 --- a/python/mesc/network_utils.py +++ b/python/mesc/network_utils.py @@ -7,7 +7,7 @@ def is_chain_id(chain_id: str) -> bool: """return True if input is a valid chain_id""" if chain_id.isdecimal(): return True - elif chain_id.startswith("0x"): + elif chain_id.startswith('0x'): try: int(chain_id, 16) return True @@ -22,8 +22,8 @@ def network_name_to_chain_id( ) -> str | None: """return chain_id of given network name""" network_name = network_name.lower() - if config is not None and network_name in config["network_names"]: - return config["network_names"][network_name] + if config is not None and network_name in config['network_names']: + return config['network_names'][network_name] else: for chain_id, chain_id_name in network_names.network_names.items(): if network_name == chain_id_name: diff --git a/python/pyproject.toml b/python/pyproject.toml index d8804cf..7321dd0 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -21,3 +21,5 @@ testpaths = [ "tests", ] +[tool.ruff.format] +quote-style = "single" From 9aec50559ee3cc0978c5172c63fe711b50526fd4 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 7 Jan 2024 02:02:55 -0800 Subject: [PATCH 09/85] use typing_extensions for python type annotations --- python/generate_network_names.py | 74 ++++++++++++++++---------------- python/mesc/interface.py | 4 +- python/mesc/load.py | 30 ++++++------- python/mesc/network_utils.py | 3 +- python/mesc/types.py | 3 +- python/mesc/validation.py | 3 +- python/pyproject.toml | 5 ++- 7 files changed, 63 insertions(+), 59 deletions(-) diff --git a/python/generate_network_names.py b/python/generate_network_names.py index 6b6d02c..7dc3419 100755 --- a/python/generate_network_names.py +++ b/python/generate_network_names.py @@ -17,33 +17,33 @@ from typing import Mapping, MutableMapping # specialcase the standard name for certain chains special_cases: Mapping[str, str] = { - "OP Mainnet": "optimism", - "Genesis Coin": "genesis_coin", - "X1 Network": "x1_network", - "ThaiChain 2.0 ThaiFi": "thaifi", - "WEMIX3.0 Mainnet": "wemix", - "WEMIX3.0 Testnet": "wemix_testnet", + 'OP Mainnet': 'optimism', + 'Genesis Coin': 'genesis_coin', + 'X1 Network': 'x1_network', + 'ThaiChain 2.0 ThaiFi': 'thaifi', + 'WEMIX3.0 Mainnet': 'wemix', + 'WEMIX3.0 Testnet': 'wemix_testnet', } def get_network_names() -> Mapping[str, str]: # fetch raw network data - url = "https://chainid.network/chains.json" + url = 'https://chainid.network/chains.json' result = requests.get(url) data = result.json() network_names: MutableMapping[str, str] = {} for datum in data: # standardize name - filtered = standardize_name(datum["name"]) + filtered = standardize_name(datum['name']) # skip deprecated networks - if "deprecated" in filtered: + if 'deprecated' in filtered: continue if filtered in network_names.values(): continue - network_names[str(datum["chainId"])] = filtered + network_names[str(datum['chainId'])] = filtered return network_names @@ -57,35 +57,35 @@ def standardize_name(name: str) -> str: # replace special characters name = name.lower() - name = name.replace(" ", "_") - name = name.replace("-", "_") - name = name.replace("(", "") - name = name.replace(")", "") + name = name.replace(' ', '_') + name = name.replace('-', '_') + name = name.replace('(', '') + name = name.replace(')', '') # remove keywords while True: remove = [ - "_mainnet", - "_network", - "_smart_chain", - "_l1", - "_sidechain", - "sidechain", - "_chain", - "chain", - "_coin", + '_mainnet', + '_network', + '_smart_chain', + '_l1', + '_sidechain', + 'sidechain', + '_chain', + 'chain', + '_coin', ] for piece in remove: if piece in name: - name = name.replace(piece, "") + name = name.replace(piece, '') break else: break # strip stray name = name.strip() - name = name.strip("_") - name = name.strip("-") + name = name.strip('_') + name = name.strip('-') return name @@ -100,7 +100,7 @@ The same set of network names is used for each MESC implementation. Do not edit this file manually.""" # python data -python_path = "./mesc/network_names.py" +python_path = './mesc/network_names.py' python_template = '''"""{preamble}""" network_names = {name_data} @@ -108,15 +108,15 @@ network_names = {name_data} def generate_python_content(network_names: Mapping[str, str]) -> str: - name_data = "{" + name_data = '{' for chain_id, network_name in network_names.items(): name_data += "\n '" + chain_id + "': '" + network_name + "'," - name_data += "\n}" + name_data += '\n}' return python_template.format(preamble=preamble, name_data=name_data) # rust data -rust_path = "../rust/crates/mesc/src/network_names.rs" +rust_path = '../rust/crates/mesc/src/network_names.rs' rust_template = """{preamble} use crate::{{ChainId, TryIntoChainId}}; @@ -130,8 +130,8 @@ pub fn get_network_names() -> HashMap {{ def generate_rust_content(network_names: Mapping[str, str]) -> str: - rust_preamble = "\n".join(("//! " + line).strip() for line in preamble.split("\n")) - name_data = "[" + rust_preamble = '\n'.join(('//! ' + line).strip() for line in preamble.split('\n')) + name_data = '[' for chain_id, network_name in network_names.items(): name_data += '\n ("' + chain_id + '", "' + network_name + '"),' name_data += """\n ] @@ -144,7 +144,7 @@ def generate_rust_content(network_names: Mapping[str, str]) -> str: return rust_template.format(preamble=rust_preamble, name_data=name_data) -if __name__ == "__main__": +if __name__ == '__main__': network_names = get_network_names() # change working directory to parent of this script @@ -152,12 +152,12 @@ if __name__ == "__main__": # create python file python_content = generate_python_content(network_names) - with open(python_path, "w") as f: + with open(python_path, 'w') as f: f.write(python_content) - print("wrote", python_path) + print('wrote', python_path) # create rust file rust_content = generate_rust_content(network_names) - with open(rust_path, "w") as f: + with open(rust_path, 'w') as f: f.write(rust_content) - print("wrote", rust_path) + print('wrote', rust_path) diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 2d3aa84..7f1f71a 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -1,6 +1,8 @@ from __future__ import annotations + import os -from typing import Any, Mapping, Sequence +from typing_extensions import Any, Mapping, Sequence + from .types import mesc_env_vars, Endpoint, RpcConfig from . import network_utils from . import exceptions diff --git a/python/mesc/load.py b/python/mesc/load.py index 26b6acb..4696dfd 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -1,7 +1,7 @@ from __future__ import annotations import json import os -import typing +from typing_extensions import cast, overload, Literal, Any from .types import RpcConfig from . import exceptions @@ -37,20 +37,20 @@ def read_config_data() -> RpcConfig: # validate validation.validate(config) - return typing.cast(RpcConfig, config) + return cast(RpcConfig, config) -@typing.overload -def read_env_config(*, validate: typing.Literal[False]) -> typing.Any: +@overload +def read_env_config(*, validate: Literal[False]) -> Any: ... -@typing.overload -def read_env_config(*, validate: typing.Literal[True]) -> RpcConfig: +@overload +def read_env_config(*, validate: Literal[True]) -> RpcConfig: ... -def read_env_config(*, validate: bool = True) -> RpcConfig | typing.Any: +def read_env_config(*, validate: bool = True) -> RpcConfig | Any: """read config from MESC_ENV environment variable""" # obtain raw config data from env value = os.environ.get('MESC_ENV') @@ -67,28 +67,24 @@ def read_env_config(*, validate: bool = True) -> RpcConfig | typing.Any: if validate: validation.validate(config) - return typing.cast(RpcConfig, config) + return cast(RpcConfig, config) else: return config -@typing.overload -def read_file_config( - *, path: str | None = None, validate: typing.Literal[False] -) -> typing.Any: +@overload +def read_file_config(*, path: str | None = None, validate: Literal[False]) -> Any: ... -@typing.overload -def read_file_config( - *, path: str | None = None, validate: typing.Literal[True] -) -> RpcConfig: +@overload +def read_file_config(*, path: str | None = None, validate: Literal[True]) -> RpcConfig: ... def read_file_config( *, path: str | None = None, validate: bool = True -) -> RpcConfig | typing.Any: +) -> RpcConfig | Any: """read config from MESC config file""" # obtain config file path if path is None: diff --git a/python/mesc/network_utils.py b/python/mesc/network_utils.py index 170fe38..ed1adc7 100644 --- a/python/mesc/network_utils.py +++ b/python/mesc/network_utils.py @@ -1,5 +1,6 @@ from __future__ import annotations -from mesc.types import RpcConfig + +from .types import RpcConfig from . import network_names diff --git a/python/mesc/types.py b/python/mesc/types.py index 74f1479..bf1a5fc 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -1,5 +1,6 @@ from __future__ import annotations -from typing import Any, MutableMapping, TypedDict, Literal, Sequence + +from typing_extensions import Any, MutableMapping, TypedDict, Literal, Sequence mesc_env_vars = [ diff --git a/python/mesc/validation.py b/python/mesc/validation.py index 6237c1f..44bf17a 100644 --- a/python/mesc/validation.py +++ b/python/mesc/validation.py @@ -1,6 +1,7 @@ from __future__ import annotations -from typing import Any +from typing_extensions import Any + from .exceptions import InvalidConfig from .types import rpc_config_types, endpoint_types, profile_types from . import network_utils diff --git a/python/pyproject.toml b/python/pyproject.toml index 7321dd0..13e481a 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -9,12 +9,15 @@ readme = "README.md" requires-python = ">=3.7" dynamic = ["version", "description"] license = {text = "MIT OR Apache-2.0"} -dependencies = [] +dependencies = [ + "typing-extensions = '^4.9.0" +] [tool.mypy] python_version = "3.9" strict = true implicit_reexport = true +files = ["mesc", "generate_network_names.py"] [tool.pytest.ini_options] testpaths = [ From 54df36db4b9dd46cc9832ef49f8ab7f014a21c01 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 7 Jan 2024 02:43:32 -0800 Subject: [PATCH 10/85] fix overrides other than implicit endpoints --- python/mesc/load.py | 10 +- python/mesc/overrides.py | 315 +++++++++++++++++++++++++------------- python/mesc/validation.py | 7 +- 3 files changed, 220 insertions(+), 112 deletions(-) diff --git a/python/mesc/load.py b/python/mesc/load.py index 4696dfd..a08184c 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -65,6 +65,7 @@ def read_env_config(*, validate: bool = True) -> RpcConfig | Any: except json.JSONDecodeError: raise exceptions.InvalidConfig('MESC_ENV is not formatted as valid JSON') + # validate config if validate: validation.validate(config) return cast(RpcConfig, config) @@ -110,8 +111,15 @@ def read_file_config( # parse raw data as json try: - return json.loads(content) + config = json.loads(content) except json.JSONDecodeError: raise exceptions.InvalidConfig( 'file at MESC_PATH is not formatted as valid JSON' ) + + # validate config + if validate: + validation.validate(config) + return cast(RpcConfig, config) + else: + return config diff --git a/python/mesc/overrides.py b/python/mesc/overrides.py index 4dfd922..c54c040 100644 --- a/python/mesc/overrides.py +++ b/python/mesc/overrides.py @@ -1,206 +1,305 @@ from __future__ import annotations + import copy import json import os import re -from typing import Any, Mapping, MutableMapping +from typing_extensions import cast, Any, Mapping, MutableMapping -from . import directory, exceptions +from . import interface, network_utils, exceptions from .types import RpcConfig, Endpoint, Profile def apply_env_overrides(config: RpcConfig | None) -> RpcConfig: + """apply overrides to config""" + if config is not None: config = copy.deepcopy(config) else: config = { - "mesc_version": "1.0", - "default_endpoint": None, - "network_defaults": {}, - "network_names": {}, - "endpoints": {}, - "profiles": {}, - "global_metadata": {}, + 'mesc_version': '1.0', + 'default_endpoint': None, + 'network_defaults': {}, + 'network_names': {}, + 'endpoints': {}, + 'profiles': {}, + 'global_metadata': {}, } + # add override endpoints for name, endpoint in env_endpoints().items(): - if name in config["endpoints"]: - if endpoint["url"] is not None: - config["endpoints"][name]["url"] = endpoint["url"] - if endpoint["chain_id"] is not None: - config["endpoints"][name]["chain_id"] = endpoint["chain_id"] - for key, value in endpoint["endpoint_metadata"].items(): - config["endpoints"][name]["endpoint_metadata"][key] = value + if name in config['endpoints']: + if endpoint['url'] is not None: + config['endpoints'][name]['url'] = endpoint['url'] + if endpoint['chain_id'] is not None: + config['endpoints'][name]['chain_id'] = endpoint['chain_id'] + for key, value in endpoint['endpoint_metadata'].items(): + config['endpoints'][name]['endpoint_metadata'][key] = value else: - config["endpoints"][name] = endpoint - config["network_names"].update(env_network_names()) + config['endpoints'][name] = endpoint + + # add override network names + config['network_names'].update(env_network_names()) + + # add override network defaults for chain_id, endpoint_name in env_network_defaults().items(): - if endpoint_name == "": - if chain_id in config["network_defaults"]: - del config["network_defaults"][chain_id] + if endpoint_name == '': + if chain_id in config['network_defaults']: + del config['network_defaults'][chain_id] else: - config["network_defaults"][chain_id] = endpoint_name - config["profiles"].update(env_profiles()) + config['network_defaults'][chain_id] = endpoint_name + + # add override profiles + config['profiles'].update(env_profiles()) + + # add override default endpoint default_endpoint = env_default_endpoint(config) if default_endpoint is not None: - config["default_endpoint"] = default_endpoint + config['default_endpoint'] = default_endpoint - # metadata - config["global_metadata"].update(env_global_metadata()) + # add override global metadata + config['global_metadata'].update(env_global_metadata()) + + # add override endpoint metadata for endpoint_name, metadata in env_endpoint_metadata().items(): - config["endpoints"][endpoint_name]["endpoint_metadata"].update(metadata) + config['endpoints'][endpoint_name]['endpoint_metadata'].update(metadata) return config def env_default_endpoint(config: RpcConfig) -> str | None: - default_endpoint = os.environ.get("MESC_DEFAULT_ENDPOINT") - if default_endpoint is None or default_endpoint == "": + """get override default endpoint""" + # load from environment + default_endpoint = os.environ.get('MESC_DEFAULT_ENDPOINT') + if default_endpoint is None or default_endpoint == '': return None - if default_endpoint in config["endpoints"]: + if default_endpoint in config['endpoints']: + # if endpoint already exists, use it return default_endpoint elif default_endpoint.isdecimal(): - return _chain_id_to_endpoint_name(default_endpoint, config) - elif default_endpoint in config["network_names"]: - chain_id = config["network_names"][default_endpoint] - return _chain_id_to_endpoint_name(chain_id, config) - - dir_chain_id = directory.network_name_to_chain_id(default_endpoint, config=config) - if dir_chain_id is not None: - return _chain_id_to_endpoint_name(dir_chain_id, config) + # if endpoint is a number, use network default as global default + chain_id = default_endpoint + elif default_endpoint in config['network_names']: + # if endpoint is a network name, use network default as global default + chain_id = config['network_names'][default_endpoint] else: - raise exceptions.InvalidOverride( - "Invalid syntax used for MESC_DEFAULT_ENDPOINT" + # otherwise, try to use override value as a network name + maybe_chain_id = network_utils.network_name_to_chain_id( + default_endpoint, config=config ) + if maybe_chain_id is None: + raise exceptions.InvalidOverride( + 'Invalid syntax used for MESC_DEFAULT_ENDPOINT' + ) + else: + chain_id = maybe_chain_id - -def _chain_id_to_endpoint_name(chain_id: str, config: RpcConfig) -> str: - endpoint = config["network_defaults"].get(chain_id) - if endpoint is None: - raise exceptions.MissingEndpoint( - "no endpoint for given default network: " + str(chain_id) - ) + endpoint = interface.get_endpoint_by_network(chain_id, config=config) + if endpoint is not None: + return endpoint['name'] else: - return endpoint + # try using as implicit endpoint url here + raise exceptions.InvalidOverride('Invalid value used for MESC_DEFAULT_ENDPOINT') def env_network_defaults() -> Mapping[str, str]: - network_defaults = os.environ.get("MESC_NETWORK_DEFAULTS") - if network_defaults is None or network_defaults == "": + """get override network defaults""" + network_defaults = os.environ.get('MESC_NETWORK_DEFAULTS') + if network_defaults is None or network_defaults == '': return {} - else: - items = [item.split("=", 1) for item in network_defaults.split(" ")] - return {str(network): endpoint for network, endpoint in items} + try: + items = [item.split('=', 1) for item in network_defaults.split(' ')] + return {network: endpoint for network, endpoint in items} + except Exception: + raise exceptions.InvalidOverride( + 'Invalid syntax used for MESC_NETWORK_DEFAULTS' + ) def env_network_names() -> Mapping[str, str]: - network_names = os.environ.get("MESC_NETWORK_NAMES") - if network_names is None or network_names == "": + """get override network names""" + network_names = os.environ.get('MESC_NETWORK_NAMES') + if network_names is None or network_names == '': return {} - if network_names.startswith("{"): - return json.loads(network_names) # type: ignore + if network_names.startswith('{'): + try: + value = json.loads(network_names) + except json.JSONDecodeError: + raise exceptions.InvalidOverride( + 'Invalid syntax used for MESC_NETWORK_NAMES' + ) + if isinstance(value, dict) and all( + isinstance(k, str) and isinstance(v, str) for k, v in value.items() + ): + return value + else: + raise exceptions.InvalidOverride( + 'Invalid syntax used for MESC_NETWORK_NAMES' + ) else: - pairs = [item.split("=") for item in network_names.split(" ")] - return {key: value for key, value in pairs} + try: + pairs = [item.split('=') for item in network_names.split(' ')] + return {key: value for key, value in pairs} + except Exception: + raise exceptions.InvalidOverride( + 'Invalid syntax used for MESC_NETWORK_NAMES' + ) def env_endpoints() -> Mapping[str, Endpoint]: + """get override endpoints""" endpoints: MutableMapping[str, Endpoint] = {} # get override - raw_endpoints = os.environ.get("MESC_ENDPOINTS") - if raw_endpoints is None or raw_endpoints == "": + raw_endpoints = os.environ.get('MESC_ENDPOINTS') + if raw_endpoints is None or raw_endpoints == '': return endpoints # gather explicit endpoints - pattern = r"^(?:(?P[A-Za-z_-]+)(?::(?P\w+))?=\s*)?(?P\S+)$" - for item in raw_endpoints.split(" "): + pattern = r'^(?:(?P[A-Za-z_-]+)(?::(?P\w+))?=\s*)?(?P\S+)$' + for item in raw_endpoints.split(' '): match = re.match(pattern, item) if match: - chain_id = match.group("chain_id") - url = match.group("url") - name = match.group("name") + chain_id = match.group('chain_id') + url = match.group('url') + name = match.group('name') if name is None: from urllib.parse import urlparse if not urlparse(url).scheme: - name = urlparse("http://" + url).hostname + name = urlparse('http://' + url).hostname else: name = urlparse(url).hostname if name is None: - raise Exception("could create name for endpoint") - name = ".".join(name.split(".")[:-1]) + raise Exception('could create name for endpoint') + name = '.'.join(name.split('.')[:-1]) endpoints[name] = { - "name": name, - "url": url, - "chain_id": chain_id, - "endpoint_metadata": {}, + 'name': name, + 'url': url, + 'chain_id': chain_id, + 'endpoint_metadata': {}, } else: - raise exceptions.InvalidOverride("Invalid syntax used for MESC_ENDPOINTS") + raise exceptions.InvalidOverride('Invalid syntax used for MESC_ENDPOINTS') - # gather ad hoc endpoints - # ad_hoc_endpoints = _collect_ad_hoc_endpoints() + # add implicit endpoints + # implicit_endpoints = _collect_implicit_endpoints() + # for endpoint_name, endpoint in implicit_endpoint.items(): + # endpoints[name] = endpoint + + # change return endpoints -# def _collect_ad_hoc_endpoints(endpoints: Mapping[str, Endpoint]) -> Mapping[str, Endpoint]: -# # look in MESC_DEFAULT_ENDPOINT, MESC_NETWORK_DEFAULTS, MESC_PROFILES -# raw_endpoints = [] +def _collect_implicit_endpoints( + # endpoints: Mapping[str, Endpoint] +) -> Mapping[str, Endpoint]: + """implicit endpoints are those defined only by a url + - can be in MESC_DEFAULT_ENDPOINT, MESC_NETWORK_DEFAULTS, or MESC_PROFILES + - implicit endpoints do not have a chain_id + - if an endpoint already exists with that url, just use that endpoint + """ + raw_endpoints: list[str] = [] -# default_endpoint = os.environ.get("MESC_DEFAULT_ENDPOINT") -# raw_endpoints.append(default_endpoint) -# network_defaults = env_network_defaults(replace=False) -# for network, endpoint in network_defaults.items(): -# raw_endpoints.append(endpoint) -# profiles = env_profiles(replace=False) -# for name, profile in profiles.items(): -# profile.get + # global default + default_endpoint = os.environ.get('MESC_DEFAULT_ENDPOINT') + if default_endpoint is not None: + raw_endpoints.append(default_endpoint) -# # process raw endpoints -# for endpoint in raw_endpoints: -# if _is_url(endpoint): -# pass + # env defaults + network_defaults = env_network_defaults() + for network, endpoint in network_defaults.items(): + raw_endpoints.append(endpoint) + + # profile defaults + profiles = env_profiles() + for name, profile in profiles.items(): + profile_default = profile['default_endpoint'] + if profile_default is not None: + raw_endpoints.append(profile_default) + for chain_id, endpoint_name in profile['network_defaults'].items(): + raw_endpoints.append(endpoint_name) + + # # process raw endpoints + endpoints: Mapping[str, Endpoint] = {} + # for endpoint in raw_endpoints: + # if _is_url(endpoint): + # pass + + return endpoints def env_profiles() -> Mapping[str, Profile]: - raw_profiles = os.environ.get("MESC_PROFILES") - if raw_profiles is None or raw_profiles == "": + """get profile overrides""" + raw_profiles = os.environ.get('MESC_PROFILES') + if raw_profiles is None or raw_profiles == '': return {} profiles: MutableMapping[str, Profile] = {} - for item in raw_profiles.split(" "): - key, value = item.split("=") - subkeys = key.split(".") + for item in raw_profiles.split(' '): + try: + key, value = item.split('=') + except ValueError: + raise Exception('invalid value for MESC_PROFILES') + subkeys = key.split('.') profiles.setdefault( subkeys[0], - {"name": subkeys[0], "default_endpoint": None, "network_defaults": {}}, + {'name': subkeys[0], 'default_endpoint': None, 'network_defaults': {}}, ) - if len(subkeys) == 2 and subkeys[1] == "default_endpoint": - profiles[subkeys[0]]["default_endpoint"] = value - elif len(subkeys) == 3 and subkeys[1] == "network_defaults": + if len(subkeys) == 2 and subkeys[1] == 'default_endpoint': + profiles[subkeys[0]]['default_endpoint'] = value + elif len(subkeys) == 3 and subkeys[1] == 'network_defaults': name, _, network = subkeys - profiles[name]["network_defaults"][network] = value + profiles[name]['network_defaults'][network] = value else: - raise Exception("invalid value for MESC_PROFILES") + raise Exception('invalid value for MESC_PROFILES') + return profiles def env_global_metadata() -> Mapping[str, Any]: - global_metadata = os.environ.get("MESC_GLOBAL_METADATA") - if global_metadata is None or global_metadata == "": + """get gloabl metadata override""" + # load env override + global_metadata = os.environ.get('MESC_GLOBAL_METADATA') + if global_metadata is None or global_metadata == '': return {} + + # parse as JSON + try: + value = json.loads(global_metadata) + except json.JSONDecodeError: + raise Exception('invalid value for MESC_GLOBAL_METADATA') + + # validate content + if isinstance(value, dict) and all(isinstance(k, str) for k in value.keys()): + return value else: - return json.loads(global_metadata) # type: ignore + raise Exception('invalid value for MESC_GLOBAL_METADATA') def env_endpoint_metadata() -> Mapping[str, Mapping[str, Any]]: - endpoint_metadata = os.environ.get("MESC_ENDPOINT_METADATA") - if endpoint_metadata is None or endpoint_metadata == "": + """get endpoint metadata overrides""" + # load env override + endpoint_metadata = os.environ.get('MESC_ENDPOINT_METADATA') + if endpoint_metadata is None or endpoint_metadata == '': return {} + + # parse as JSON + try: + value = json.loads(endpoint_metadata) + except json.JSONDecodeError: + raise Exception('invalid value for MESC_ENDPOINT_METADATA') + + if isinstance(value, dict) and all( + isinstance(k, str) + and isinstance(v, dict) + and all(isinstance(subk, str) for subk in v.keys()) + for k, v in value.items() + ): + return value else: - return json.loads(endpoint_metadata) # type: ignore + raise Exception('invalid value for MESC_ENDPOINT_METADATA') diff --git a/python/mesc/validation.py b/python/mesc/validation.py index 44bf17a..9e63b2b 100644 --- a/python/mesc/validation.py +++ b/python/mesc/validation.py @@ -82,7 +82,7 @@ def validate(config: Any) -> None: ) for name, profile in config['profiles'].items(): endpoint = profile['default_endpoint'] - if endpoint is not None and endpoint not in profile['endpoints']: + if endpoint is not None and endpoint not in config['endpoints']: raise InvalidConfig( 'In profile ' + name @@ -98,6 +98,7 @@ def validate(config: Any) -> None: + str(endpoint) ) + # default endpoints of each network actually use that specified network for chain_id, endpoint_name in config['network_defaults'].items(): if chain_id != config['endpoints'][endpoint_name]['chain_id']: @@ -105,7 +106,7 @@ def validate(config: Any) -> None: 'Endpoint is set as the default endpoint of network ' + chain_id + ", but the endpoint's chain_id is different " - + endpoint['chain_id'] + + config['endpoints'][endpoint_name]['chain_id'] ) for profile_name, profile in config['profiles'].items(): for chain_id, endpoint_name in profile['network_defaults'].items(): @@ -116,7 +117,7 @@ def validate(config: Any) -> None: + ' in profile ' + profile_name + ", but the endpoint's chain_id is different " - + endpoint['chain_id'] + + config['endpoints'][endpoint_name]['chain_id'] ) # endpoint map keys match endpoint name fields From 51cee41a096af63897a17f8b62144a6343b11fb2 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 10 Jan 2024 00:01:29 -0800 Subject: [PATCH 11/85] add endpoint metadata modification to cli setup subcommand --- .../mesc_cli/src/cli/subcommands/help.rs | 3 +- .../mesc_cli/src/cli/subcommands/setup.rs | 133 ++++++++++++++++-- 2 files changed, 126 insertions(+), 10 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index b76d802..33c41e4 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -80,11 +80,10 @@ fn print_env_help() { ]; println!("MESC environment variables:"); - println!(); for (name, value, example) in messages.iter() { + println!(); println!("{:>22} {}", name.bold(), value); println!("{:>32} {}", "example:".truecolor(100, 100, 100), example.green().bold()); - println!(); } } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup.rs index c2dc749..52d7f2a 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup.rs @@ -506,6 +506,7 @@ async fn query_modify_endpoint( "Modify endpoint chain_id", "Modify endpoint metadata", "Delete endpoint", + "Print endpoint as JSON", "Done", ] .to_vec(); @@ -548,18 +549,26 @@ async fn query_modify_endpoint( _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), }; } - "Modify endpoint metadata" => { - if let Some(endpoint) = config.endpoints.get_mut(&endpoint_name) { - let edited = edit::edit(serde_json::to_string(&endpoint.endpoint_metadata)?)?; - let value: Result, serde_json::Error> = - serde_json::from_str(&edited); - endpoint.endpoint_metadata = value?; - } - } + "Modify endpoint metadata" => modify_endpoint_metadata(endpoint_name.as_str(), config)?, "Delete endpoint" => { mesc::write::delete_endpoint(config, endpoint_name.as_str())?; println!("{} {}", "Deleted endpoint:".red(), endpoint_name.green()); } + "Print endpoint as JSON" => { + let endpoint = match config.endpoints.get(&endpoint_name) { + Some(endpoint) => endpoint.clone(), + None => { + return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())) + } + }; + println!(" {}", "Current endpoint data:".bold(),); + println!(); + let colored = colored_json::to_colored_json_auto(&serde_json::to_value(endpoint)?)?; + for line in colored.split('\n') { + println!(" {}", line); + } + println!(); + } "Done" => {} _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), }; @@ -567,6 +576,114 @@ async fn query_modify_endpoint( Ok(option.to_string()) } +fn modify_endpoint_metadata( + endpoint_name: &str, + config: &mut RpcConfig, +) -> Result<(), MescCliError> { + let endpoint = match config.endpoints.get_mut(endpoint_name) { + Some(endpoint) => endpoint, + None => { + return Err(MescCliError::InvalidInput(format!("missing endpoint: {}", endpoint_name))) + } + }; + let options = vec![ + "Add label", + "Remove label", + "Set ratelimit", + "Set api key", + "Edit raw JSON", + "Done editing metadata", + ]; + match inquire::Select::new("How to modify metadata?", options).prompt() { + Ok("Add label") => { + let new_label = match inquire::Text::new("What is the new label?").prompt() { + Ok(new_label) => new_label, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + if endpoint.endpoint_metadata.get_mut("labels").is_none() { + endpoint + .endpoint_metadata + .insert("labels".to_string(), serde_json::json!(Vec::::new())); + }; + let labels = endpoint.endpoint_metadata.get_mut("labels").unwrap(); + if let Some(array) = labels.as_array_mut() { + array.push(serde_json::Value::String(new_label)); + println!(" Added label") + } else { + println!("Incorrectly formatted data, labels is not a list"); + }; + } + Ok("Remove label") => { + match endpoint.endpoint_metadata.get_mut("labels") { + Some(serde_json::Value::Array(labels)) => { + let label_strings: Vec<&str> = + labels.iter().filter_map(|val| val.as_str()).collect(); + if label_strings.is_empty() { + println!("No labels for endpoint"); + return Ok(()); + }; + match inquire::Select::new("Which label to remove?", label_strings.clone()) + .prompt() + { + Ok(label) => { + if let Some(index) = + label_strings.iter().position(|test_label| test_label == &label) + { + labels.remove(index); + } else { + println!("Label not found."); + } + } + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } + Some(_) => { + println!("Incorrectly formatted data, labels is not a list"); + } + None => { + println!(" Endpoint does not have any labels") + } + }; + } + Ok("Set ratelimit") => { + let message = "What is the rate limit, in requests per second?"; + let value = match inquire::CustomType::::new(message) + .with_formatter(&|i| format!("{:.2}", i)) + .with_error_message("Please type a valid number") + .with_help_message(" Enter the number of requests per seconds") + .prompt() + { + Ok(value) => value, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + endpoint + .endpoint_metadata + .insert("rate_limit_rps".to_string(), serde_json::json!(value)); + } + Ok("Set api key") => { + let api_key = match inquire::Text::new("What is the api key?").prompt() { + Ok(api_key) => api_key, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + endpoint.endpoint_metadata.insert("api_key".to_string(), serde_json::json!(api_key)); + } + Ok("Edit raw JSON") => { + let edited = edit::edit(serde_json::to_string(&endpoint.endpoint_metadata)?)?; + let value: Result, serde_json::Error> = + serde_json::from_str(&edited); + endpoint.endpoint_metadata = value?; + } + Ok("Done editing metadata") => return Ok(()), + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + Ok(()) +} + async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), MescCliError> { let options = vec!["Modify raw global metadata JSON", "Edit custom network names", "Back to main menu"]; From 3ab2d809db34dcc019ce568d6c00b6aae4d9a674 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 13 Jan 2024 18:14:53 -0800 Subject: [PATCH 12/85] refactor rust errors using thiserror crate --- rust/Cargo.lock | 5 +- rust/Cargo.toml | 5 +- rust/crates/mesc/Cargo.toml | 1 + rust/crates/mesc/src/types/errors.rs | 77 +++++++++++++++------------- rust/crates/mesc_cli/Cargo.toml | 19 +++---- rust/crates/mesc_cli/src/types.rs | 74 +++++++++++--------------- 6 files changed, 90 insertions(+), 91 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 4dd4ba7..06a1405 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1401,6 +1401,7 @@ version = "0.1.2" dependencies = [ "serde", "serde_json", + "thiserror", ] [[package]] @@ -1418,6 +1419,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "thiserror", "tokio", "toolstr", "url", @@ -2892,11 +2894,12 @@ dependencies = [ [[package]] name = "toolstr" -version = "0.1.2" +version = "0.1.3" dependencies = [ "chrono", "polars", "regex", + "thiserror", "toolstr_colored", "unicode-truncate", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 449de4d..cbdee4a 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,5 +15,6 @@ repository = "https://github.com/paradigmxyz/mesc" exclude = [".github/"] [workspace.dependencies] -serde = { version = "1.0.191", features = ["derive"] } -serde_json = "1.0.108" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +thiserror = "1.0" diff --git a/rust/crates/mesc/Cargo.toml b/rust/crates/mesc/Cargo.toml index c35316a..2bd9d68 100644 --- a/rust/crates/mesc/Cargo.toml +++ b/rust/crates/mesc/Cargo.toml @@ -10,3 +10,4 @@ repository.workspace = true [dependencies] serde = { workspace = true } serde_json = { workspace = true } +thiserror = { workspace = true } diff --git a/rust/crates/mesc/src/types/errors.rs b/rust/crates/mesc/src/types/errors.rs index dc86a38..4ed9312 100644 --- a/rust/crates/mesc/src/types/errors.rs +++ b/rust/crates/mesc/src/types/errors.rs @@ -1,46 +1,53 @@ -/// MescError -#[derive(Debug)] +use thiserror::Error; + +/// Errors related to MESC operations. +#[derive(Error, Debug)] pub enum MescError { - /// MescNotEnabled + /// Error indicating that MESC is not enabled. + #[error("Mesc is not enabled")] MescNotEnabled, - /// InvalidConfigMode + + /// Error for invalid configuration modes. + #[error("Invalid configuration mode")] InvalidConfigMode, - /// InvalidChainId + + /// Error for invalid chain ID, with the invalid ID provided. + #[error("Invalid chain ID: {0}")] InvalidChainId(String), - /// IntegrityError + + /// Error representing an integrity issue, with a description. + #[error("Integrity error: {0}")] IntegrityError(String), - /// MissingEndpoint + + /// Error for missing endpoint, specifying which endpoint is missing. + #[error("Missing endpoint: {0}")] MissingEndpoint(String), - /// IOError - IOError(std::io::Error), - /// InvalidJson + + /// Error wrapper for standard IO errors. + #[error(transparent)] + IOError(#[from] std::io::Error), + + /// Error indicating an issue with JSON formatting. + #[error("Invalid JSON format")] InvalidJson, - /// EnvReadError - EnvReadError(std::env::VarError), - /// NotImplemented + + /// Error wrapper for environment variable read errors. + #[error(transparent)] + EnvReadError(#[from] std::env::VarError), + + /// Error indicating a feature or function is not implemented, with a description. + #[error("Not implemented: {0}")] NotImplemented(String), - /// SerdeError - SerdeError(serde_json::Error), - /// InvalidInput + + /// Error wrapper for errors from the `serde_json` crate. + #[error(transparent)] + SerdeError(#[from] serde_json::Error), + + /// General error for invalid input. + #[error("Invalid input")] InvalidInput, - /// OverrideError + + /// Error for override conflicts, with a description of the conflict. + #[error("Override error: {0}")] OverrideError(String), } - -impl From for MescError { - fn from(value: std::io::Error) -> MescError { - MescError::IOError(value) - } -} - -impl From for MescError { - fn from(value: serde_json::Error) -> MescError { - MescError::SerdeError(value) - } -} - -impl From for MescError { - fn from(value: std::env::VarError) -> MescError { - MescError::EnvReadError(value) - } -} diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index a975649..3927e9c 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -12,17 +12,18 @@ name = "mesc" path = "src/main.rs" [dependencies] -mesc = { version = "0.1.0", path = "../mesc" } +bat = "0.24.0" clap = { version = "4.4.8", features = ["derive"] } +colored_json = "4.1.0" +edit = "0.1.4" +futures = "0.3.29" +inquire = "0.6.2" +ipgeolocate = "0.3.6" +mesc = { version = "0.1.0", path = "../mesc" } +reqwest = { version = "0.11.22", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } -inquire = "0.6.2" -reqwest = { version = "0.11.22", features = ["json"] } +thiserror = { workspace = true } tokio = { version = "1.32.0", features = ["full"] } -futures = "0.3.29" -toolstr = { version = "0.1.2", path = "../../../../toolstr/toolstr-rust/crates/toolstr" } -edit = "0.1.4" +toolstr = { version = "0.1.3", path = "../../../../toolstr/toolstr-rust/crates/toolstr" } url = "2.2.2" -ipgeolocate = "0.3.6" -colored_json = "4.1.0" -bat = "0.24.0" diff --git a/rust/crates/mesc_cli/src/types.rs b/rust/crates/mesc_cli/src/types.rs index 8bf7381..618e1e4 100644 --- a/rust/crates/mesc_cli/src/types.rs +++ b/rust/crates/mesc_cli/src/types.rs @@ -1,52 +1,38 @@ use mesc::MescError; +use thiserror::Error; -#[derive(Debug)] +#[derive(Error, Debug)] pub(crate) enum MescCliError { - MescError(MescError), - NetworkError(reqwest::Error), - InquireError(inquire::InquireError), - SerdeError(serde_json::Error), - IOError(std::io::Error), + #[error("MESC error: {0}")] + MescError(#[from] MescError), + + #[error("Network error: {0}")] + NetworkError(#[from] reqwest::Error), + + #[error("Inquire error: {0}")] + InquireError(#[from] inquire::InquireError), + + #[error("Serialization/deserialization error: {0}")] + SerdeError(#[from] serde_json::Error), + + #[error("I/O error: {0}")] + IOError(#[from] std::io::Error), + + #[error("Invalid network response")] InvalidNetworkResponse, - JoinError(tokio::task::JoinError), + + #[error("Join error: {0}")] + JoinError(#[from] tokio::task::JoinError), + + #[error("Invalid input: {0}")] InvalidInput(String), - FormatError(toolstr::FormatError), + + #[error("Format error: {0}")] + FormatError(#[from] toolstr::FormatError), + + #[error("Error: {0}")] Error(String), + + #[error("URL error: {0}")] UrlError(String), } - -impl From for MescCliError { - fn from(value: mesc::MescError) -> Self { - MescCliError::MescError(value) - } -} - -impl From for MescCliError { - fn from(value: std::io::Error) -> Self { - MescCliError::IOError(value) - } -} - -impl From for MescCliError { - fn from(value: reqwest::Error) -> Self { - MescCliError::NetworkError(value) - } -} - -impl From for MescCliError { - fn from(value: inquire::InquireError) -> Self { - MescCliError::InquireError(value) - } -} - -impl From for MescCliError { - fn from(value: serde_json::Error) -> MescCliError { - MescCliError::SerdeError(value) - } -} - -impl From for MescCliError { - fn from(value: toolstr::FormatError) -> MescCliError { - MescCliError::FormatError(value) - } -} From b0acd088af581e65c9b35493fb33b7a628fc1915 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 13 Jan 2024 20:47:45 -0800 Subject: [PATCH 13/85] add import subcommand --- rust/crates/mesc_cli/src/cli/args.rs | 33 +++++++++- .../mesc_cli/src/cli/subcommands/import.rs | 66 +++++++++++++++++++ .../mesc_cli/src/cli/subcommands/mod.rs | 2 + 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/import.rs diff --git a/rust/crates/mesc_cli/src/cli/args.rs b/rust/crates/mesc_cli/src/cli/args.rs index fc7912d..e1d3c1b 100644 --- a/rust/crates/mesc_cli/src/cli/args.rs +++ b/rust/crates/mesc_cli/src/cli/args.rs @@ -6,6 +6,7 @@ use toolstr::Colorize; pub(crate) async fn run_cli() -> Result<(), MescCliError> { match Cli::parse().command { Commands::Setup(args) => setup_command(args).await, + Commands::Import(args) => import_command(args).await, Commands::Status(args) => status_command(args), Commands::Ls(args) => ls_command(args), Commands::Defaults(args) => defaults_command(args), @@ -42,8 +43,10 @@ pub(crate) struct Cli { /// Define your subcommands as an enum #[derive(Subcommand)] pub(crate) enum Commands { - /// Create new configuration or modify existing configuration + /// Create new config or modify existing config Setup(SetupArgs), + /// Import a config from file or external source + Import(ImportArgs), /// Print status of configuration Status(StatusArgs), /// Print list of endpoints @@ -74,6 +77,34 @@ pub(crate) struct SetupArgs { pub(crate) editor: bool, } +/// Arguments for the `import` subcommand +#[derive(Parser)] +pub(crate) struct ImportArgs { + /// source for important + #[clap()] + pub(crate) source: Option, + + /// interactively decide how to perform import + #[clap(short, long)] + pub(crate) interactive: bool, + + /// specify source name + #[clap(long)] + pub(crate) source_name: Option, + + /// only import endpoints from this network + #[clap(long)] + pub(crate) network: Option, + + /// only endpoint with this name + #[clap(long)] + pub(crate) name: Option, + + /// output filepath (default = MESC_PATH) + #[clap(short, long)] + pub(crate) output_path: Option, +} + /// Arguments for the `status` subcommand #[derive(Parser)] pub(crate) struct StatusArgs { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/import.rs b/rust/crates/mesc_cli/src/cli/subcommands/import.rs new file mode 100644 index 0000000..ce5ede5 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/import.rs @@ -0,0 +1,66 @@ +use crate::{ImportArgs, MescCliError}; +use mesc::RpcConfig; + +pub(crate) async fn import_command(args: ImportArgs) -> Result<(), MescCliError> { + // get output path + let output_path = match (args.output_path, std::env::var("MESC_PATH")) { + (Some(path), _) => path, + (_, Ok(path)) if !path.is_empty() => path, + _ => { + return Err(MescCliError::Error( + "MESC_PATH not set, must specify --output-path".to_string(), + )); + } + }; + + // gather existing import sources + let custom_sources = if !mesc::is_mesc_enabled() { + println!("MESC is not enabled, but importing anyway...") + }; + + // fetch config data + let imported = match args.source.as_deref() { + Some("chainid.network") => import_chain_id_dot_network().await?, + Some("chainlist") => import_chainlist().await?, + Some(source) => import_custom_source(source).await?, + None => return Err(MescCliError::InvalidInput("must specify import source".to_string())), + }; + + // integrate data into config + let new_config = integrate_import(imported)?; + + // write new config data + mesc::write::write_config(new_config, output_path)?; + + Ok(()) +} + +async fn import_chain_id_dot_network() -> Result { + todo!(); +} + +async fn import_chainlist() -> Result { + todo!(); +} + +async fn import_custom_source(source: &str) -> Result { + let path = std::path::Path::new(source); + if path.exists() && path.is_file() { + println!("Importing file..."); + let config = mesc::load::load_file_config(Some(source.to_string()))?; + Ok(config) + } else { + println!("Importing url..."); + let response = reqwest::get(source).await?; + if response.status().is_success() { + let config: RpcConfig = response.json().await?; + Ok(config) + } else { + Err(MescCliError::Error("Could not import MESC config from source".to_string())) + } + } +} + +fn integrate_import(imported: RpcConfig) -> Result { + Ok(imported) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs index baf7be9..0f642fc 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs @@ -1,6 +1,7 @@ mod defaults; mod endpoint; mod help; +mod import; mod ls; mod metadata; mod ping; @@ -11,6 +12,7 @@ mod url; pub(crate) use defaults::*; pub(crate) use endpoint::*; pub(crate) use help::*; +pub(crate) use import::*; pub(crate) use ls::*; pub(crate) use metadata::*; pub(crate) use ping::*; From 737667f62bc795c0023f3fe7e03bb407eeb95e74 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 13 Jan 2024 20:48:18 -0800 Subject: [PATCH 14/85] bump to rust v0.1.3 --- rust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index cbdee4a..0519a05 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.1.2" +version = "0.1.3" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" From 1f001f2366bc13fefbf0245e75911c3f622853e1 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 14 Jan 2024 01:04:18 -0800 Subject: [PATCH 15/85] add use_mesc field to Profile --- SPECIFICATION.md | 7 ++++--- python/mesc/interface.py | 16 ++++++++++------ python/mesc/overrides.py | 9 +++++++-- python/mesc/types.py | 2 ++ python/mesc/validation.py | 4 ++-- rust/Cargo.lock | 4 ++-- rust/crates/mesc/src/overrides.rs | 8 +++----- rust/crates/mesc/src/types/configs.rs | 9 ++++++++- tests/generate.py | 25 ++++++++++++++----------- 9 files changed, 52 insertions(+), 32 deletions(-) diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 3e5f94a..b4f846c 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -108,6 +108,7 @@ MESC is built using three key-value data schemas: | `name` | `str` | name of profile | `default_endpoint` | `str \| None` | chain_id of default network | `network_defaults` | `Mapping[ChainId, str]` | map of chain_id's to endpoint names +| `use_mesc` | `bool` | whether to disable MESC when this profile is selected Requirements: - All keys of `RpcConfig` and `Endpoint` are required. No additional keys should be present, except within `global_metadata` and `endpoint_metadata`. @@ -190,8 +191,8 @@ These overrides use a simple syntax that is intended to be easily written by hum | --- | --- | --- | | `MESC_DEFAULT_ENDPOINT` | url, endpoint name, or network name | `localhost:9999` | | `MESC_NETWORK_DEFAULTS` | space-separated pairs of `=` | `5=alchemy_optimism 1=local_mainnet` | -| `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | -| `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | +| `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | +| `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | | `MESC_PROFILES` | space-separated pairs of `.[.` | `foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism` | | `MESC_GLOBAL_METADATA` | JSON formatted global metadata | `{}` | | `MESC_ENDPOINT_METADATA` | JSON mapping of `{"endpoint_name": {}}` | `{}` | @@ -201,7 +202,7 @@ These overrides use a simple syntax that is intended to be easily written by hum - Setting an override variable to an empty value will disable that override from being used. - Setting an override variable to an invalid value should result in an error upon loading the config. - Metadata overrides (`MESC_GLOBAL_METADATA` and `MESC_ENDPOINT_METADATA`) merge into the underlying config values instead of replacing them. -- Using `MESC_MODE=DISABLED` is a simple way to completely disable MESC. +- Using `MESC_MODE=DISABLED` is a simple way to completely disable MESC. Using `MESC_PROFILES=profile.use_mesc=false` will disable MESC for a particular profile. #### Querying Data diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 7f1f71a..f697aba 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -31,6 +31,8 @@ def get_default_endpoint( # get endpoint name if profile is not None and profile in config['profiles']: + if not config['profiles'][profile]['use_mesc']: + return None endpoint = config['profiles'][profile].get( 'default_endpoint', config['default_endpoint'] ) @@ -73,6 +75,8 @@ def get_endpoint_by_network( # get profile default for network if profile and profile in config['profiles']: + if not config['profiles'][profile]['use_mesc']: + return None name = config['profiles'][profile]['network_defaults'].get( chain_id, default_name ) @@ -101,14 +105,14 @@ def get_endpoint_by_query( """ if config is None: config = load.read_config_data() + if ( + profile is not None + and profile in config['profiles'] + and not config['profiles'][profile]['use_mesc'] + ): + return None if user_input in config['endpoints']: return config['endpoints'][user_input] - elif user_input.isdecimal(): - try: - get_endpoint_by_network(int(user_input), profile=profile) - except Exception: - pass - if network_utils.is_chain_id(user_input): chain_id: str | None = user_input else: diff --git a/python/mesc/overrides.py b/python/mesc/overrides.py index c54c040..363ddf1 100644 --- a/python/mesc/overrides.py +++ b/python/mesc/overrides.py @@ -4,7 +4,7 @@ import copy import json import os import re -from typing_extensions import cast, Any, Mapping, MutableMapping +from typing_extensions import Any, Mapping, MutableMapping from . import interface, network_utils, exceptions from .types import RpcConfig, Endpoint, Profile @@ -248,7 +248,12 @@ def env_profiles() -> Mapping[str, Profile]: subkeys = key.split('.') profiles.setdefault( subkeys[0], - {'name': subkeys[0], 'default_endpoint': None, 'network_defaults': {}}, + { + 'name': subkeys[0], + 'default_endpoint': None, + 'network_defaults': {}, + 'use_mesc': True, + }, ) if len(subkeys) == 2 and subkeys[1] == 'default_endpoint': profiles[subkeys[0]]['default_endpoint'] = value diff --git a/python/mesc/types.py b/python/mesc/types.py index bf1a5fc..25ecc01 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -28,6 +28,7 @@ class Profile(TypedDict): name: str default_endpoint: str | None network_defaults: MutableMapping[str, str] + use_mesc: bool class RpcConfig(TypedDict): @@ -51,6 +52,7 @@ profile_types: dict[str, type | tuple[type, ...]] = { 'name': str, 'default_endpoint': (str, type(None)), 'network_defaults': dict, + 'use_mesc': bool, } rpc_config_types: dict[str, type | tuple[type, ...]] = { diff --git a/python/mesc/validation.py b/python/mesc/validation.py index 9e63b2b..c79bbf9 100644 --- a/python/mesc/validation.py +++ b/python/mesc/validation.py @@ -98,7 +98,6 @@ def validate(config: Any) -> None: + str(endpoint) ) - # default endpoints of each network actually use that specified network for chain_id, endpoint_name in config['network_defaults'].items(): if chain_id != config['endpoints'][endpoint_name]['chain_id']: @@ -156,7 +155,8 @@ def validate(config: Any) -> None: + str(chain_id) ) for endpoint in config['endpoints'].values(): - if not network_utils.is_chain_id(endpoint['chain_id']): + chain_id = endpoint['chain_id'] + if chain_id is not None and not network_utils.is_chain_id(chain_id): raise Exception( 'Invalid chain_id used in endpoint ' + endpoint['name'] diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 06a1405..5fe386b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1397,7 +1397,7 @@ dependencies = [ [[package]] name = "mesc" -version = "0.1.2" +version = "0.1.3" dependencies = [ "serde", "serde_json", @@ -1406,7 +1406,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.1.2" +version = "0.1.3" dependencies = [ "bat", "clap", diff --git a/rust/crates/mesc/src/overrides.rs b/rust/crates/mesc/src/overrides.rs index 447b2c9..a79b740 100644 --- a/rust/crates/mesc/src/overrides.rs +++ b/rust/crates/mesc/src/overrides.rs @@ -220,11 +220,9 @@ fn get_profiles_override() -> Result>, MescError } }; - let profile = profiles.entry(profile_name.to_string()).or_insert_with(|| Profile { - name: profile_name.to_string(), - default_endpoint: None, - network_defaults: HashMap::new(), - }); + let profile = profiles + .entry(profile_name.to_string()) + .or_insert_with(|| Profile::new(profile_name.to_string())); match key { "default_endpoint" => profile.default_endpoint = Some(endpoint.to_string()), diff --git a/rust/crates/mesc/src/types/configs.rs b/rust/crates/mesc/src/types/configs.rs index d2e87f8..ea95af8 100644 --- a/rust/crates/mesc/src/types/configs.rs +++ b/rust/crates/mesc/src/types/configs.rs @@ -31,12 +31,19 @@ pub struct Profile { pub default_endpoint: Option, /// network_defaults pub network_defaults: HashMap, + /// use mesc + pub use_mesc: bool, } impl Profile { /// create new profile pub fn new>(name: T) -> Profile { - Profile { name: name.into(), default_endpoint: None, network_defaults: HashMap::new() } + Profile { + name: name.into(), + default_endpoint: None, + network_defaults: HashMap::new(), + use_mesc: true, + } } } diff --git a/tests/generate.py b/tests/generate.py index 045314b..665ae74 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -32,6 +32,7 @@ blank_profile: Profile = { "name": "name", "default_endpoint": None, "network_defaults": {}, + "use_mesc": True, } full_config: RpcConfig = { @@ -82,6 +83,7 @@ full_config: RpcConfig = { "name": "abc", "default_endpoint": None, "network_defaults": {}, + "use_mesc": True, }, "xyz": { "name": "xyz", @@ -90,6 +92,7 @@ full_config: RpcConfig = { "1": "llamanodes_ethereum", "10": "llamanodes_optimism", }, + "use_mesc": True, }, }, "global_metadata": { @@ -1052,17 +1055,17 @@ def create_override_tests() -> list[Test]: ), True, ), - ( - "override endpoints, change existing chain_id and url", - {"MESC_ENDPOINTS": "local_ethereum:2=other_url.com"}, - full_config, - {"query_type": "endpoint_by_name", "fields": {"name": "local_ethereum"}}, - set_paths_values( - copy.deepcopy(full_config["endpoints"]["local_ethereum"]), - [(["url"], "other_url.com"), (["chain_id"], "2")], - ), - True, - ), + # ( + # "override endpoints, change existing chain_id and url", + # {"MESC_ENDPOINTS": "local_ethereum:2=other_url.com"}, + # full_config, + # {"query_type": "endpoint_by_name", "fields": {"name": "local_ethereum"}}, + # set_paths_values( + # copy.deepcopy(full_config["endpoints"]["local_ethereum"]), + # [(["url"], "other_url.com"), (["chain_id"], "2")], + # ), + # True, + # ), ( "override endpoints, add new endpoint with url", {"MESC_ENDPOINTS": "new_endpoint=other_url.com"}, From febc148c20a6209eaf20ed64848b3ebd88f3f41e Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 14 Jan 2024 02:05:52 -0800 Subject: [PATCH 16/85] add profile_metadata to profile --- SPECIFICATION.md | 20 ++++---- python/mesc/overrides.py | 1 + python/mesc/types.py | 2 + rust/crates/mesc/src/lib.rs | 2 + rust/crates/mesc/src/metadata.rs | 48 +++++++++++++++++++ rust/crates/mesc/src/types/configs.rs | 3 ++ .../mesc_cli/src/cli/subcommands/import.rs | 2 +- tests/generate.py | 3 ++ 8 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 rust/crates/mesc/src/metadata.rs diff --git a/SPECIFICATION.md b/SPECIFICATION.md index b4f846c..8abf080 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -98,7 +98,7 @@ MESC is built using three key-value data schemas: | --- | --- | --- | | `name` | `str` | name of endpoint | `url` | `str` | url of endpoint, including transport -| `chain_id` | `ChainId \| None` | chain id of network +| `chain_id` | `ChainId \| None` | chain id of network | `endpoint_metadata` | `Mapping[str, Any]` | endpoint metadata entries ##### `Profile` schema: @@ -108,10 +108,11 @@ MESC is built using three key-value data schemas: | `name` | `str` | name of profile | `default_endpoint` | `str \| None` | chain_id of default network | `network_defaults` | `Mapping[ChainId, str]` | map of chain_id's to endpoint names +| `profile_metadata` | `Mapping[str, Any]` | profile metadata entries | `use_mesc` | `bool` | whether to disable MESC when this profile is selected Requirements: -- All keys of `RpcConfig` and `Endpoint` are required. No additional keys should be present, except within `global_metadata` and `endpoint_metadata`. +- All keys of `RpcConfig` and `Endpoint` are required. No additional keys should be present, except within `global_metadata`, `profile_metadata`, and `endpoint_metadata`. - Every endpoint name specified in `RpcConfig.default_endpoint` and in `RpcConfig.network_defaults` must exist in `RpcConfig.endpoints`. - These key-value structures can be easily represented in JSON and in most common programming languages. - Each `chain_id` should be represented using either a decimal string or a hex string. Strings are used because chain id's can be 256 bits and most languages do not have native 256 bit integer types. For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. @@ -119,7 +120,7 @@ Requirements: ##### Metadata -The `global_metadata` and `endpoint_metadata` fields allow for optional or idiosyncratic RPC metadata to be stored alongside the core RPC data. Tools using MESC can choose to ignore these fields. Examples of common metadata: +The `global_metadata`, `profile_metadata`, and `endpoint_metadata` fields allow for optional or idiosyncratic RPC metadata to be stored alongside the core RPC data. Tools using MESC can choose to ignore these fields. Examples of common metadata: **Endpoint metadata** | key | value type | description | examples | @@ -138,7 +139,7 @@ The `global_metadata` and `endpoint_metadata` fields allow for optional or idios | `cloud_region` | `str` | cloud provider region | `aws-us-east-1a` | | `labels` | `Sequence[str]` | tags | `private_mempool`, `cache`, `archive`, `consensus_layer`, `execution_layer`, `validator`, `ephemeral` | -**Global Metadata** +**Global Metadata** and **Profile Metadata** | key | value type | description | examples | | --- | --- | --- | --- | | `last_modified_by` | `str` | versioned tool used to create configuration | `mesc__1.0` | @@ -148,8 +149,6 @@ The `global_metadata` and `endpoint_metadata` fields allow for optional or idios | `groups` | `Mapping[str, Sequence[str]]` | groupings of endpoints, mapping of group name to list of endpoint names | `{"load_balancer": ["alchemy_optimism", "quicknode_optimism"]}` | | `conceal` | `bool` | whether tool should avoid casually revealing private RPC url's unprompted | `true` | -Other metadata keys that are specific to a tool should be prefixed by that tool's name (e.g. tool `xyz` should prefix its metadata keys with `"xyz__"`). - #### Environment ##### Environment Setup @@ -193,7 +192,7 @@ These overrides use a simple syntax that is intended to be easily written by hum | `MESC_NETWORK_DEFAULTS` | space-separated pairs of `=` | `5=alchemy_optimism 1=local_mainnet` | | `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | | `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | -| `MESC_PROFILES` | space-separated pairs of `.[.` | `foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism` | +| `MESC_PROFILES` | space-separated pairs of `.[.` | `foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism` | | `MESC_GLOBAL_METADATA` | JSON formatted global metadata | `{}` | | `MESC_ENDPOINT_METADATA` | JSON mapping of `{"endpoint_name": {}}` | `{}` | @@ -255,11 +254,14 @@ This is a basic configuration of 5 endpoints across 3 networks. It also contains }, "profiles": { "xyz": { + "name": "xyz", "default_endpoint": "llamanodes_polygon", "network_defaults": { "1": "llamanodes_ethereum", "137": "llamanodes_polygon" - } + }, + "profile_metadata": {}, + "use_mesc": true } }, "global_metadata": {} @@ -286,7 +288,7 @@ Want to satisfy all of these constraints: - minimize complexity Other notes: -- `global_metadata` and `endpoint_metadata` allow extra information to be stored in the config without breaking the standard. This includes api keys, rate limits, and organizational labels. This information might be specific to each application. +- `global_metadata`, `profile_metadata`, and `endpoint_metadata` allow extra information to be stored in the config without breaking the standard. This includes api keys, rate limits, and organizational labels. This information might be specific to each application. - `Profile`s allow different defaults to be assigned to each tool or each mode of operation. - Allowing RPC information to be configured using either a file or an environment variable allows optimal deployment patterns across a wide range of computing environments. Each also has their own advantages, e.g. file can be used with version control whereas environment variables can be changed more dynamically. diff --git a/python/mesc/overrides.py b/python/mesc/overrides.py index 363ddf1..5da1571 100644 --- a/python/mesc/overrides.py +++ b/python/mesc/overrides.py @@ -252,6 +252,7 @@ def env_profiles() -> Mapping[str, Profile]: 'name': subkeys[0], 'default_endpoint': None, 'network_defaults': {}, + 'profile_metadata': {}, 'use_mesc': True, }, ) diff --git a/python/mesc/types.py b/python/mesc/types.py index 25ecc01..380822b 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -28,6 +28,7 @@ class Profile(TypedDict): name: str default_endpoint: str | None network_defaults: MutableMapping[str, str] + profile_metadata: MutableMapping[str, Any] use_mesc: bool @@ -52,6 +53,7 @@ profile_types: dict[str, type | tuple[type, ...]] = { 'name': str, 'default_endpoint': (str, type(None)), 'network_defaults': dict, + 'profile_metadata': dict, 'use_mesc': bool, } diff --git a/rust/crates/mesc/src/lib.rs b/rust/crates/mesc/src/lib.rs index 8b1639e..81b17f3 100644 --- a/rust/crates/mesc/src/lib.rs +++ b/rust/crates/mesc/src/lib.rs @@ -15,6 +15,8 @@ pub use types::*; mod interface; /// load module pub mod load; +/// metadata +pub mod metadata; pub mod network_names; pub use interface::*; /// overrides module diff --git a/rust/crates/mesc/src/metadata.rs b/rust/crates/mesc/src/metadata.rs new file mode 100644 index 0000000..f58c86c --- /dev/null +++ b/rust/crates/mesc/src/metadata.rs @@ -0,0 +1,48 @@ +use crate::MescError; +use serde::de::DeserializeOwned; +use std::collections::HashMap; + +/// get api key +pub fn get_api_key>( + key_name: T, + profile_name: Option, +) -> Result, MescError> { + let key_name = key_name.as_ref(); + let config = crate::load::load_config_data()?; + + if let Some(profile_name) = profile_name { + if let Some(profile) = config.profiles.get(profile_name.as_ref()) { + if let Some(api_keys) = profile.profile_metadata.get("api_keys") { + let api_keys: HashMap = get_value_at(api_keys, &[])?; + if let Some(key) = api_keys.get(key_name) { + return Ok(Some(key.clone())) + } + } + } + }; + + if let Some(api_keys) = config.global_metadata.get("api_keys") { + let api_keys: HashMap = get_value_at(api_keys, &[])?; + if let Some(key) = api_keys.get(key_name) { + return Ok(Some(key.clone())) + } + } + + Ok(None) +} + +fn get_value_at(root: &serde_json::Value, path: &[&str]) -> Result +where + T: DeserializeOwned, +{ + let mut current = root; + + for key in path { + current = match current.get(key) { + Some(value) => value, + None => return Err(MescError::IntegrityError("missing path".to_string())), + }; + } + + Ok(serde_json::from_value(current.clone())?) +} diff --git a/rust/crates/mesc/src/types/configs.rs b/rust/crates/mesc/src/types/configs.rs index ea95af8..b2e509b 100644 --- a/rust/crates/mesc/src/types/configs.rs +++ b/rust/crates/mesc/src/types/configs.rs @@ -31,6 +31,8 @@ pub struct Profile { pub default_endpoint: Option, /// network_defaults pub network_defaults: HashMap, + /// profile metadata + pub profile_metadata: HashMap, /// use mesc pub use_mesc: bool, } @@ -42,6 +44,7 @@ impl Profile { name: name.into(), default_endpoint: None, network_defaults: HashMap::new(), + profile_metadata: HashMap::new(), use_mesc: true, } } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/import.rs b/rust/crates/mesc_cli/src/cli/subcommands/import.rs index ce5ede5..4c6a3c0 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/import.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/import.rs @@ -14,7 +14,7 @@ pub(crate) async fn import_command(args: ImportArgs) -> Result<(), MescCliError> }; // gather existing import sources - let custom_sources = if !mesc::is_mesc_enabled() { + if !mesc::is_mesc_enabled() { println!("MESC is not enabled, but importing anyway...") }; diff --git a/tests/generate.py b/tests/generate.py index 665ae74..ba57530 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -32,6 +32,7 @@ blank_profile: Profile = { "name": "name", "default_endpoint": None, "network_defaults": {}, + "profile_metadata": {}, "use_mesc": True, } @@ -83,6 +84,7 @@ full_config: RpcConfig = { "name": "abc", "default_endpoint": None, "network_defaults": {}, + "profile_metadata": {}, "use_mesc": True, }, "xyz": { @@ -92,6 +94,7 @@ full_config: RpcConfig = { "1": "llamanodes_ethereum", "10": "llamanodes_optimism", }, + "profile_metadata": {}, "use_mesc": True, }, }, From 3708f7d03fde0b2b99b21b6c4c121161b00b15ce Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 14 Jan 2024 02:06:32 -0800 Subject: [PATCH 17/85] bump to rust v0.1.4 --- rust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 0519a05..1505d0d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.1.3" +version = "0.1.4" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" From 6e52dfecfaa9ea653db8f7c67941c22771c43e8d Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 14 Jan 2024 02:08:08 -0800 Subject: [PATCH 18/85] bump cli dependency to v0.1.4 --- rust/Cargo.lock | 4 ++-- rust/crates/mesc_cli/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5fe386b..804b0b8 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1397,7 +1397,7 @@ dependencies = [ [[package]] name = "mesc" -version = "0.1.3" +version = "0.1.4" dependencies = [ "serde", "serde_json", @@ -1406,7 +1406,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.1.3" +version = "0.1.4" dependencies = [ "bat", "clap", diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 3927e9c..4245bfc 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -19,7 +19,7 @@ edit = "0.1.4" futures = "0.3.29" inquire = "0.6.2" ipgeolocate = "0.3.6" -mesc = { version = "0.1.0", path = "../mesc" } +mesc = { version = "0.1.4", path = "../mesc" } reqwest = { version = "0.11.22", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } From 5608622e74e5c25cafdbdc8b319d4fc4688cdedb Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 14 Jan 2024 18:27:55 -0800 Subject: [PATCH 19/85] bump to 0.1.4 --- python/mesc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mesc/__init__.py b/python/mesc/__init__.py index 5333006..9e34f3b 100644 --- a/python/mesc/__init__.py +++ b/python/mesc/__init__.py @@ -11,7 +11,7 @@ from .interface import ( ) from .types import Endpoint, Profile, RpcConfig -__version__ = '0.1.1' +__version__ = '0.1.4' __all__ = ( 'Endpoint', From cb6b5839a60a2d69843e750efa597cca9495bd5a Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 15 Jan 2024 11:21:52 -0800 Subject: [PATCH 20/85] update pyproject.toml with more metadata --- python/pyproject.toml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 13e481a..872b7ea 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -9,9 +9,32 @@ readme = "README.md" requires-python = ">=3.7" dynamic = ["version", "description"] license = {text = "MIT OR Apache-2.0"} -dependencies = [ - "typing-extensions = '^4.9.0" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Financial and Insurance Industry", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Typing :: Typed", ] +dependencies = [ + "typing-extensions >=4.9.0", +] + +[project.urls] +Documentation = "https://github.com/paradigmxyz/mesc" +Source = "https://github.com/paradigmxyz/mesc" [tool.mypy] python_version = "3.9" From 7df3eb7499bd349a1d556123d7571007fa7e2dce Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 15 Jan 2024 11:41:53 -0800 Subject: [PATCH 21/85] change get_endpoint_by_name return type to be an optional endpoint --- README.md | 20 +++++++------ SPECIFICATION.md | 17 ++++++----- python/README.md | 17 ++++++----- python/mesc/interface.py | 10 +++---- rust/README.md | 6 ++-- rust/crates/mesc/src/interface.rs | 2 +- rust/crates/mesc/src/query.rs | 12 ++++---- .../mesc_cli/src/cli/subcommands/endpoint.rs | 2 +- .../mesc_cli/src/cli/subcommands/help.rs | 20 +++++++------ .../mesc_cli/src/cli/subcommands/setup.rs | 29 +++++++++++-------- .../mesc_cli/src/cli/subcommands/url.rs | 2 +- 11 files changed, 76 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index a4a57b6..d81fb22 100644 --- a/README.md +++ b/README.md @@ -67,27 +67,30 @@ Here is a comparison between the python interface and the rust interface: ```python import mesc +# check whether mesc is enabled +enabled: bool = mesc.is_mesc_enabled() + # get the default endpoint -endpoint = mesc.get_default_endpoint() +endpoint: Endpoint | None = mesc.get_default_endpoint() # get the default endpoint of a network -endpoint = mesc.get_endpoint_by_network(5) +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5) # get the default endpoint for a particular tool -endpoint = mesc.get_default_endpoint(profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_default_endpoint(profile='xyz_tool') # get the default endpoint of a network for a particular tool -endpoint = mesc.get_endpoint_by_network(5, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5, profile='xyz_tool') # get an endpoint by name -endpoint = mesc.get_endpoint_by_name('local_goerli') +endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') # parse a user-provided string into a matching endpoint # (first try 1. endpoint name, then 2. chain id, then 3. network name) -endpoint = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints = mesc.find_endpoints(chain_id=5) +endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) ``` ###### rust @@ -97,7 +100,6 @@ use mesc::MescError; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; -type Result = Result, MescError>; // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); @@ -112,7 +114,7 @@ let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: Result = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 8abf080..503395a 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -335,27 +335,30 @@ MESC is an opt-in specification that only becomes activated when a user explicit A library that reads raw MESC data should provide the following core functions: ```python +# check whether mesc is enabled +enabled = mesc.is_mesc_enabled() + # get the default endpoint -endpoint = mesc.get_default_endpoint() +endpoint: Endpoint | None = mesc.get_default_endpoint() # get the default endpoint of a network -endpoint = mesc.get_endpoint_by_network(5) +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5) # get the default endpoint for a particular tool -endpoint = mesc.get_default_endpoint(profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_default_endpoint(profile='xyz_tool') # get the default endpoint of a network for a particular tool -endpoint = mesc.get_endpoint_by_network(5, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5, profile='xyz_tool') # get an endpoint by name -endpoint = mesc.get_endpoint_by_name('local_goerli') +endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') # parse a user-provided string into a matching endpoint # (first try 1. endpoint name, then 2. chain id, then 3. network name) -endpoint = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints = mesc.find_endpoints(chain_id=5) +endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) ``` A reference implementation is provided in the supplemental files of this repository. diff --git a/python/README.md b/python/README.md index ffd2956..d1d9f1a 100644 --- a/python/README.md +++ b/python/README.md @@ -26,27 +26,30 @@ pip install ./ ```python import mesc +# check whether mesc is enabled +enabled: bool = mesc.is_mesc_enabled() + # get the default endpoint -endpoint = mesc.get_default_endpoint() +endpoint: Endpoint | None = mesc.get_default_endpoint() # get the default endpoint of a network -endpoint = mesc.get_endpoint_by_network(5) +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5) # get the default endpoint for a particular tool -endpoint = mesc.get_default_endpoint(profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_default_endpoint(profile='xyz_tool') # get the default endpoint of a network for a particular tool -endpoint = mesc.get_endpoint_by_network(5, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5, profile='xyz_tool') # get an endpoint by name -endpoint = mesc.get_endpoint_by_name('local_goerli') +endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') # parse a user-provided string into a matching endpoint # (first try 1. endpoint name, then 2. chain id, then 3. network name) -endpoint = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints = mesc.find_endpoints(chain_id=5) +endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) ``` ## Reference diff --git a/python/mesc/interface.py b/python/mesc/interface.py index f697aba..970e274 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -5,7 +5,6 @@ from typing_extensions import Any, Mapping, Sequence from .types import mesc_env_vars, Endpoint, RpcConfig from . import network_utils -from . import exceptions from . import load @@ -46,14 +45,13 @@ def get_default_endpoint( return get_endpoint_by_name(endpoint, config=config) -def get_endpoint_by_name(name: str, *, config: RpcConfig | None = None) -> Endpoint: +def get_endpoint_by_name( + name: str, *, config: RpcConfig | None = None +) -> Endpoint | None: """get MESC endpoint by name""" if config is None: config = load.read_config_data() - try: - return config['endpoints'][name] - except KeyError: - raise exceptions.MissingEndpoint('missing endpoint: ' + str(name)) + return config['endpoints'].get(name) def get_endpoint_by_network( diff --git a/rust/README.md b/rust/README.md index 1a20a47..d039942 100644 --- a/rust/README.md +++ b/rust/README.md @@ -59,7 +59,9 @@ use mesc::MescError; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; -type Result = Result, MescError>; + +// check whether mesc is enabled +let enabled: bool = mesc::is_mesc_enabled(); // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); @@ -74,7 +76,7 @@ let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: Result = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) diff --git a/rust/crates/mesc/src/interface.rs b/rust/crates/mesc/src/interface.rs index 729f6b3..ae76f0f 100644 --- a/rust/crates/mesc/src/interface.rs +++ b/rust/crates/mesc/src/interface.rs @@ -26,7 +26,7 @@ pub fn get_endpoint_by_network( } /// get endpoint by name -pub fn get_endpoint_by_name(name: &str) -> Result { +pub fn get_endpoint_by_name(name: &str) -> Result, MescError> { query::get_endpoint_by_name(&load_config_data()?, name) } diff --git a/rust/crates/mesc/src/query.rs b/rust/crates/mesc/src/query.rs index 149daeb..f6b8af9 100644 --- a/rust/crates/mesc/src/query.rs +++ b/rust/crates/mesc/src/query.rs @@ -14,12 +14,12 @@ pub fn get_default_endpoint( if let Some(profile) = profile { let name = config.profiles.get(profile).and_then(|p| p.default_endpoint.clone()); if let Some(name) = name { - return get_endpoint_by_name(config, name.as_str()).map(Some); + return get_endpoint_by_name(config, name.as_str()) } }; match &config.default_endpoint { - Some(name) => get_endpoint_by_name(config, name.as_str()).map(Some), + Some(name) => get_endpoint_by_name(config, name.as_str()), None => Ok(None), } } @@ -36,21 +36,21 @@ pub fn get_endpoint_by_network( if let Some(profile) = profile { let name = config.profiles.get(profile).and_then(|p| p.network_defaults.get(&chain_id)); if let Some(name) = name { - return get_endpoint_by_name(config, name).map(Some); + return get_endpoint_by_name(config, name) } }; // check if base configuration has a default endpoint for that chain_id match config.network_defaults.get(&chain_id) { - Some(name) => get_endpoint_by_name(config, name).map(Some), + Some(name) => get_endpoint_by_name(config, name), None => Ok(None), } } /// get endpoint by name -pub fn get_endpoint_by_name(config: &RpcConfig, name: &str) -> Result { +pub fn get_endpoint_by_name(config: &RpcConfig, name: &str) -> Result, MescError> { if let Some(endpoint) = config.endpoints.get(name) { - Ok(endpoint.clone()) + Ok(Some(endpoint.clone())) } else { Err(MescError::MissingEndpoint(name.to_string())) } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/endpoint.rs b/rust/crates/mesc_cli/src/cli/subcommands/endpoint.rs index b58377c..b94808e 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/endpoint.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/endpoint.rs @@ -6,7 +6,7 @@ use crate::{ pub(crate) fn endpoint_command(args: EndpointArgs) -> Result<(), MescCliError> { // get endpoint let endpoint = match (args.name, args.network, args.query) { - (Some(name), _, _) => mesc::get_endpoint_by_name(name.as_str()).map(Some), + (Some(name), _, _) => mesc::get_endpoint_by_name(name.as_str()), (None, Some(_), Some(_)) => { return Err(MescCliError::InvalidInput("specify either query or --network".to_string())) } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index 33c41e4..0cfac39 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -107,27 +107,30 @@ fn print_code(content: String, filetype: &str) { fn print_python_interface() { let interface = r#"import mesc +# check whether mesc is enabled +enabled: bool = mesc.is_mesc_enabled() + # get the default endpoint -endpoint = mesc.get_default_endpoint() +endpoint: Endpoint | None = mesc.get_default_endpoint() # get the default endpoint of a network -endpoint = mesc.get_endpoint_by_network(5) +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5) # get the default endpoint for a particular tool -endpoint = mesc.get_default_endpoint(profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_default_endpoint(profile='xyz_tool') # get the default endpoint of a network for a particular tool -endpoint = mesc.get_endpoint_by_network(5, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_network(5, profile='xyz_tool') # get an endpoint by name -endpoint = mesc.get_endpoint_by_name('local_goerli') +endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') # parse a user-provided string into a matching endpoint # (try 1. endpoint name, then 2. chain id, then 3. network name) -endpoint = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') +endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints = mesc.find_endpoints(chain_id=5)"#; +endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5)"#; print_code(interface.to_string(), "py") } @@ -138,7 +141,6 @@ use mesc::MescError; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; -type Result = Result, MescError>; // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); @@ -153,7 +155,7 @@ let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: Result = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup.rs index 52d7f2a..60bcba0 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup.rs @@ -835,10 +835,13 @@ fn modify_defaults(config: &mut RpcConfig) -> Result<(), MescCliError> { _ => return Ok(()), }; config.default_endpoint = Some(endpoint_name.clone()); - let endpoint = mesc::query::get_endpoint_by_name(config, endpoint_name.as_str())?; - if let Some(chain_id) = endpoint.chain_id { - config.network_defaults.insert(chain_id, endpoint_name); - }; + if let Some(endpoint) = + mesc::query::get_endpoint_by_name(config, endpoint_name.as_str())? + { + if let Some(chain_id) = endpoint.chain_id { + config.network_defaults.insert(chain_id, endpoint_name); + }; + } } Ok("Set the default endpoint for network") => { let prompt = "Set the default endpoint for which network?"; @@ -907,15 +910,17 @@ fn modify_defaults(config: &mut RpcConfig) -> Result<(), MescCliError> { Some(value) => value, _ => return Ok(()), }; - let endpoint = - mesc::query::get_endpoint_by_name(config, &default_endpoint)?; - if let Some(profile) = config.profiles.get_mut(&profile_name) { - profile.default_endpoint = Some(default_endpoint.clone()); - if let Some(chain_id) = endpoint.chain_id.clone() { - profile.network_defaults.insert(chain_id, default_endpoint); + if let Some(endpoint) = + mesc::query::get_endpoint_by_name(config, &default_endpoint)? + { + if let Some(profile) = config.profiles.get_mut(&profile_name) { + profile.default_endpoint = Some(default_endpoint.clone()); + if let Some(chain_id) = endpoint.chain_id.clone() { + profile.network_defaults.insert(chain_id, default_endpoint); + } + } else { + println!("profile not present"); } - } else { - println!("profile not present"); } } Ok("Set the profile's default endpoint for a network") => { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/url.rs b/rust/crates/mesc_cli/src/cli/subcommands/url.rs index 93d993c..997d245 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/url.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/url.rs @@ -3,7 +3,7 @@ use crate::{MescCliError, UrlArgs}; pub(crate) fn url_command(args: UrlArgs) -> Result<(), MescCliError> { // get endpoint let endpoint = match (args.name, args.network, args.query) { - (Some(name), _, _) => mesc::get_endpoint_by_name(name.as_str()).map(Some), + (Some(name), _, _) => mesc::get_endpoint_by_name(name.as_str()), (None, Some(_), Some(_)) => { return Err(MescCliError::InvalidInput("specify either query or --network".to_string())) } From e9bf98f6e2e6162ad7556a70a328915134076dc2 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 15 Jan 2024 16:18:13 -0800 Subject: [PATCH 22/85] add docs --- .gitignore | 1 + README.md | 4 +--- book/README.md | 22 +++++++++++++++++ book/book.toml | 6 +++++ book/src/SUMMARY.md | 29 ++++++++++++++++++++++ book/src/cli.md | 1 + book/src/creating_a_config.md | 1 + book/src/developer_resources.md | 1 + book/src/environment_variables.md | 1 + book/src/go.md | 1 + book/src/implementing_mesc.md | 16 +++++++++++++ book/src/integrating_mesc.md | 1 + book/src/mesc_libraries.md | 1 + book/src/mesc_overview.md | 15 ++++++++++++ book/src/metadata.md | 1 + book/src/overrides.md | 1 + book/src/profiles.md | 1 + book/src/python.md | 1 + book/src/quickstart.md | 40 +++++++++++++++++++++++++++++++ book/src/rust.md | 1 + book/src/setting_up_mesc.md | 1 + book/src/typescript.md | 1 + 22 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 book/README.md create mode 100644 book/book.toml create mode 100644 book/src/SUMMARY.md create mode 100644 book/src/cli.md create mode 100644 book/src/creating_a_config.md create mode 100644 book/src/developer_resources.md create mode 100644 book/src/environment_variables.md create mode 100644 book/src/go.md create mode 100644 book/src/implementing_mesc.md create mode 100644 book/src/integrating_mesc.md create mode 100644 book/src/mesc_libraries.md create mode 100644 book/src/mesc_overview.md create mode 100644 book/src/metadata.md create mode 100644 book/src/overrides.md create mode 100644 book/src/profiles.md create mode 100644 book/src/python.md create mode 100644 book/src/quickstart.md create mode 100644 book/src/rust.md create mode 100644 book/src/setting_up_mesc.md create mode 100644 book/src/typescript.md diff --git a/.gitignore b/.gitignore index 1ddbae0..2447ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ PITCH.md *.json __pycache__ python/dist +book/book diff --git a/README.md b/README.md index d81fb22..a0d1058 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # Multiple Endpoint Shared Configuration (MESC) Standard -MESC is a standard for how crypto tools configure their RPC endpoints. - -By following this specification, a user creates a single RPC configuration that can be shared by all crypto tools on their system. +MESC is a standard for how crypto tools configure their RPC endpoints. By following this specification, a user creates a single RPC configuration that can be shared by all crypto tools on their system. MESC has two main design goals: 1. make it easy to share RPC configuration data across tools, languages, and environments diff --git a/book/README.md b/book/README.md new file mode 100644 index 0000000..afa68bc --- /dev/null +++ b/book/README.md @@ -0,0 +1,22 @@ + +# MESC User Guide + +This is the user guide for MESC. See table of contents in [Summary](SUMMARY.md). + +## Usage + +To build: + +```sh +cargo install mdbook +mdbook build +``` + +To serve a live local copy of this guide in brower: + +```sh +mdbook serve +``` + +And open browser to `localhost:3000` + diff --git a/book/book.toml b/book/book.toml new file mode 100644 index 0000000..12c383a --- /dev/null +++ b/book/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["sslivkoff"] +language = "en" +multilingual = false +src = "src" +title = "MESC User Guide" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md new file mode 100644 index 0000000..120569e --- /dev/null +++ b/book/src/SUMMARY.md @@ -0,0 +1,29 @@ +# MESC User Guide + +- [MESC Overview](./mesc_overview.md) + + + +- [Basic MESC Usage]() + - [Quickstart](./quickstart.md) + - [Creating a config](./creating_a_config.md) + - [Environment variables](./environment_variables.md) + - [Profiles](./profiles.md) + - [Metadata](./metadata.md) + - [Overrides](./overrides.md) + + + +- [Developer Resources]() + - [Integrating MESC](./integrating_mesc.md) + - [Implementing MESC](./implementing_mesc.md) + + + +- [MESC Libraries]() + - [CLI](./cli.md) + - [Go](./go.md) + - [Python](./python.md) + - [Rust](./rust.md) + - [Typescript](./typescript.md) + diff --git a/book/src/cli.md b/book/src/cli.md new file mode 100644 index 0000000..3f213d4 --- /dev/null +++ b/book/src/cli.md @@ -0,0 +1 @@ +# CLI diff --git a/book/src/creating_a_config.md b/book/src/creating_a_config.md new file mode 100644 index 0000000..bd0786f --- /dev/null +++ b/book/src/creating_a_config.md @@ -0,0 +1 @@ +# Creating a config diff --git a/book/src/developer_resources.md b/book/src/developer_resources.md new file mode 100644 index 0000000..a67a443 --- /dev/null +++ b/book/src/developer_resources.md @@ -0,0 +1 @@ +# Developer Resources diff --git a/book/src/environment_variables.md b/book/src/environment_variables.md new file mode 100644 index 0000000..6888411 --- /dev/null +++ b/book/src/environment_variables.md @@ -0,0 +1 @@ +# Setting up environment variables diff --git a/book/src/go.md b/book/src/go.md new file mode 100644 index 0000000..452b575 --- /dev/null +++ b/book/src/go.md @@ -0,0 +1 @@ +# Go diff --git a/book/src/implementing_mesc.md b/book/src/implementing_mesc.md new file mode 100644 index 0000000..a8d6762 --- /dev/null +++ b/book/src/implementing_mesc.md @@ -0,0 +1,16 @@ +# Implementing MESC + +One of MESC's goals is to have an implementation for every programming language in the cryptocurrency ecosystem. + +If you are creating a new MESC implementation, you may find the following useful: + +1. The main functionality that a MESC implementation provides is the [Core MESC Interface](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#reference-implementation). This is a set of functions for reading whatever MESC data a user has configured on their system. + +2. The ability to **write** MESC configurations is useful, but should be considered a secondary goal. Users already have the ability to create MESC configurations either by 1) editing JSON by hand, 2) editing JSON programmatically, or 3) using the interactive [MESC cli tool](https://github.com/paradigmxyz/mesc/tree/main/cli). + +3. A MESC implementation's compliance to the specification can be checked using the language-agnostic MESC test suite. Passing the test suite means that an implementation is complete. More details on the test suite can be found [here](https://github.com/paradigmxyz/mesc/tree/main/tests). + +4. It is desirable to use the same names, types, and behaviors across each MESC implementation. This increases interoperability and makes MESC easier to learn and use. However it is also desirable to obey the common convetions of each programming language. Each MESC implementation must find a balance between language-agnostic conventions vs language-specific conventions. + +5. If parts of the MESC specification are confusing or difficult to implement, it may be helpful to look at existing implementations. These currently exist for [python](https://github.com/paradigmxyz/mesc/tree/main/python) and [rust](https://github.com/paradigmxyz/mesc/tree/main/rust). + diff --git a/book/src/integrating_mesc.md b/book/src/integrating_mesc.md new file mode 100644 index 0000000..0df363c --- /dev/null +++ b/book/src/integrating_mesc.md @@ -0,0 +1 @@ +# Integrating MESC diff --git a/book/src/mesc_libraries.md b/book/src/mesc_libraries.md new file mode 100644 index 0000000..69293ba --- /dev/null +++ b/book/src/mesc_libraries.md @@ -0,0 +1 @@ +# MESC Libraries diff --git a/book/src/mesc_overview.md b/book/src/mesc_overview.md new file mode 100644 index 0000000..53818cb --- /dev/null +++ b/book/src/mesc_overview.md @@ -0,0 +1,15 @@ +# MESC Overview + +To get started as quickly as possible, see [Quickstart](./quickstart.md). + +To integrate MESC into an existing tool, see [Integrating MESC](./integrating_mesc.md). + +To create a MESC implementation in a new programming language, see [Implementing MESC](./implementing_mesc.md). + +To see information about each existing MESC implementation, see: +- [cli](./cli.md) +- [go](./go.md) +- [python](./python.md) +- [rust](./rust.md) +- [typescript](./typescript.md) + diff --git a/book/src/metadata.md b/book/src/metadata.md new file mode 100644 index 0000000..3366648 --- /dev/null +++ b/book/src/metadata.md @@ -0,0 +1 @@ +# Metadata diff --git a/book/src/overrides.md b/book/src/overrides.md new file mode 100644 index 0000000..aea5e8c --- /dev/null +++ b/book/src/overrides.md @@ -0,0 +1 @@ +# Overrides diff --git a/book/src/profiles.md b/book/src/profiles.md new file mode 100644 index 0000000..682bf7f --- /dev/null +++ b/book/src/profiles.md @@ -0,0 +1 @@ +# Profiles diff --git a/book/src/python.md b/book/src/python.md new file mode 100644 index 0000000..4193ef4 --- /dev/null +++ b/book/src/python.md @@ -0,0 +1 @@ +# Python diff --git a/book/src/quickstart.md b/book/src/quickstart.md new file mode 100644 index 0000000..192f16c --- /dev/null +++ b/book/src/quickstart.md @@ -0,0 +1,40 @@ +# Quickstart + +The quickest way to use MESC is +1) create a `mesc.json` config file +2) set the `MESC_PATH` environment variable to the path of this file + +You can create a `mesc.json` either 1) by using the interactive [MESC cli tool](https://github.com/paradigmxyz/mesc/tree/main/cli) (install using `cargo install mesc_cli`) or 2) by modifying the template below: + +```json +{ + "mesc_version": "MESC 1.0", + "default_endpoint": "local_ethereum", + "network_defaults": { + "1": "local_ethereum" + }, + "network_names": {}, + "endpoints": { + "local_ethereum": { + "name": "local_ethereum", + "url": "http://localhost:8545", + "chain_id": "1", + "endpoint_metadata": {} + } + }, + "profiles": { + "xyz": { + "name": "xyz", + "default_endpoint": "local_ethereum", + "network_defaults": { + "1": "local_ethereum" + }, + "profile_metadata": {}, + "use_mesc": true + } + }, + "global_metadata": {} +} +``` + +Configuration should follow the MESC [specification](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md). diff --git a/book/src/rust.md b/book/src/rust.md new file mode 100644 index 0000000..2f1d5ef --- /dev/null +++ b/book/src/rust.md @@ -0,0 +1 @@ +# Rust diff --git a/book/src/setting_up_mesc.md b/book/src/setting_up_mesc.md new file mode 100644 index 0000000..a33fbf0 --- /dev/null +++ b/book/src/setting_up_mesc.md @@ -0,0 +1 @@ +# Basic MESC Usage diff --git a/book/src/typescript.md b/book/src/typescript.md new file mode 100644 index 0000000..42c9775 --- /dev/null +++ b/book/src/typescript.md @@ -0,0 +1 @@ +# Typescript From 7eeb70e602bd954d885ed1992b6705fe3d0ee1b2 Mon Sep 17 00:00:00 2001 From: Joshua Hyde Date: Mon, 15 Jan 2024 18:52:28 -0600 Subject: [PATCH 23/85] Initial Go spec implementation (#10) * Initial Go spec implementation * Return nil, not errors, when data is not found * Add IsMESCEnabled --- go/go.mod | 3 ++ go/pkg/mesc/endpoint/criteria/config.go | 34 +++++++++++++++ go/pkg/mesc/endpoint/resolution/config.go | 26 ++++++++++++ go/pkg/mesc/endpoints.go | 52 +++++++++++++++++++++++ go/pkg/mesc/model/chain_id.go | 13 ++++++ go/pkg/mesc/model/endpoint_metadata.go | 35 +++++++++++++++ go/pkg/mesc/model/profile.go | 13 ++++++ go/pkg/mesc/model/rpc_config.go | 14 ++++++ 8 files changed, 190 insertions(+) create mode 100644 go/go.mod create mode 100644 go/pkg/mesc/endpoint/criteria/config.go create mode 100644 go/pkg/mesc/endpoint/resolution/config.go create mode 100644 go/pkg/mesc/endpoints.go create mode 100644 go/pkg/mesc/model/chain_id.go create mode 100644 go/pkg/mesc/model/endpoint_metadata.go create mode 100644 go/pkg/mesc/model/profile.go create mode 100644 go/pkg/mesc/model/rpc_config.go diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 0000000..4cd8868 --- /dev/null +++ b/go/go.mod @@ -0,0 +1,3 @@ +module github.com/paradigmxyz/mesc/go + +go 1.20 diff --git a/go/pkg/mesc/endpoint/criteria/config.go b/go/pkg/mesc/endpoint/criteria/config.go new file mode 100644 index 0000000..776dd8c --- /dev/null +++ b/go/pkg/mesc/endpoint/criteria/config.go @@ -0,0 +1,34 @@ +package mesc + +import model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" + +// EndpointFindCriteriaConfig describes the criteria to be used with FindEndpoints +type EndpointFindCriteriaConfig struct { + chainID *model.ChainID + nameContains *string + urlContains *string +} + +// FindEndpointsCriteria provides a means of customizing the finding criteria for endpoints in FindEndpoints. +type FindEndpointsCriteria func(*EndpointFindCriteriaConfig) + +// HasChainID will find endpoints that contain endpoint metadata for the given chain ID. +func HasChainID(chainID model.ChainID) FindEndpointsCriteria { + return func(e *EndpointFindCriteriaConfig) { + e.chainID = &chainID + } +} + +// NameContains describes a criteria to find endpoints whose name contains the given substring. +func NameContains(name string) FindEndpointsCriteria { + return func(e *EndpointFindCriteriaConfig) { + e.nameContains = &name + } +} + +// URLContains describes a criteria to find endpoints whose URLs contain the given substring. +func URLContains(url string) FindEndpointsCriteria { + return func(e *EndpointFindCriteriaConfig) { + e.urlContains = &url + } +} diff --git a/go/pkg/mesc/endpoint/resolution/config.go b/go/pkg/mesc/endpoint/resolution/config.go new file mode 100644 index 0000000..1027c4b --- /dev/null +++ b/go/pkg/mesc/endpoint/resolution/config.go @@ -0,0 +1,26 @@ +package mesc + +import model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" + +// EndpointResolutionConfig describes configuration and context to be applied during endpoint resolution. +type EndpointResolutionConfig struct { + profile *string + rpcConfig *model.RPCConfig +} + +// EndpointResolutionOption describes a way of configuring the resolution of an endpoint +type EndpointResolutionOption func(*EndpointResolutionConfig) + +// WithProfile will configure endpoint resolution to resolve with the given profile enabled. +func WithProfile(profile string) EndpointResolutionOption { + return func(cfg *EndpointResolutionConfig) { + cfg.profile = &profile + } +} + +// WithRPCConfig will configure endpoint resolution to resolve from the given RPCConfig. +func WithRPCConfig(rpcConfig model.RPCConfig) EndpointResolutionOption { + return func(cfg *EndpointResolutionConfig) { + cfg.rpcConfig = &rpcConfig + } +} diff --git a/go/pkg/mesc/endpoints.go b/go/pkg/mesc/endpoints.go new file mode 100644 index 0000000..6b266a4 --- /dev/null +++ b/go/pkg/mesc/endpoints.go @@ -0,0 +1,52 @@ +package mesc + +import ( + "context" + "errors" + + criteria "github.com/paradigmxyz/mesc/go/pkg/mesc/endpoint/criteria" + resolution "github.com/paradigmxyz/mesc/go/pkg/mesc/endpoint/resolution" + model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +// FindEndpoints will find all endpoint metadata matching the given criteria. +// If no criteria is provided, then all endpoints will be returned. +// If no endpoints are found, then an empty slice of EndpointMetadata will be returned. +func FindEndpoints(ctx context.Context, findCriteria []criteria.FindEndpointsCriteria, options ...resolution.EndpointResolutionOption) ([]*model.EndpointMetadata, error) { + // TODO: implement + return nil, errors.New("not implemented") +} + +// GetDefaultEndpoint resolves the endpoint metadata, if available, for the default endpoint. +// This will return nil if no endpoint metadata can be resolved. +func GetDefaultEndpoint(ctx context.Context, options ...resolution.EndpointResolutionOption) (*model.EndpointMetadata, error) { + // TODO: implement + return nil, errors.New("not yet implemented") +} + +// GetEndpointByNetwork resolves the endpoint metadata, if available, for the given chain ID. +// This will return nil if no endpoint metadata can be resolved. +func GetEndpointByNetwork(ctx context.Context, chainID model.ChainID, options ...resolution.EndpointResolutionOption) (*model.EndpointMetadata, error) { + // TODO: implement + return nil, errors.New("not yet implemented") +} + +// GetEndpointByName resolves the endpoint metadata, if available, for the network for the given name. +// This will return nil if no endpoint metadata can be resolved. +func GetEndpointByName(ctx context.Context, name string, options ...resolution.EndpointResolutionOption) (*model.EndpointMetadata, error) { + // TODO: implement + return nil, errors.New("not yet implemented") +} + +// GetEndpointsByQuery resolves the endpoint metadata, if found, for the given query. +// This will return nil if no endpoint metadata can be resolved. +func GetEndpointsByQuery(ctx context.Context, query string, options ...resolution.EndpointResolutionOption) (*model.EndpointMetadata, error) { + // TODO: implement + return nil, errors.New("not yet implemented") +} + +// IsMESCEnabled determines if MESC is enabled. +func IsMESCEnabled(ctx context.Context) (bool, error) { + // TODO: implement + return false, errors.New("not yet implemented") +} diff --git a/go/pkg/mesc/model/chain_id.go b/go/pkg/mesc/model/chain_id.go new file mode 100644 index 0000000..2148a84 --- /dev/null +++ b/go/pkg/mesc/model/chain_id.go @@ -0,0 +1,13 @@ +package mesc + +import "errors" + +// ChainID is the definition of a representation of a chain ID, +// conforming to the format as described in the MESC specification. +type ChainID string + +// ToInt will parse an integer representation of the chain ID. +func (c ChainID) ToInt() (int64, error) { + // TODO: implement parsing of the chain ID per the MESC specification + return 0, errors.New("not implemented") +} diff --git a/go/pkg/mesc/model/endpoint_metadata.go b/go/pkg/mesc/model/endpoint_metadata.go new file mode 100644 index 0000000..f70abcc --- /dev/null +++ b/go/pkg/mesc/model/endpoint_metadata.go @@ -0,0 +1,35 @@ +package mesc + +const ( + rateLimitRequestsPerSecondKey = "rate_limit_rps" +) + +// EndpointMetadata describes metadata for an RPC endpoint. +type EndpointMetadata struct { + Name string // Name is the name of the endpoint + URL string // URL is the location of the endpoint + ChainID *ChainID // ChainID is the chain ID of the string + EndpointMetadata map[string]any // EndpointMetadata is a map of both well-defined endpoint metadata and custom metadata +} + +// GetRateLimitPerSecond gets the rate limit of requests per second that the endpoint will allow. +func (e EndpointMetadata) GetRateLimitPerSecond() (float64, bool) { + if e.EndpointMetadata == nil { + return 0.0, false + } + + rpsAny, hasRPS := e.EndpointMetadata[rateLimitRequestsPerSecondKey] + if !hasRPS { + return 0.0, false + } + + rpsFloat64, isFloat := rpsAny.(float64) + if isFloat { + return rpsFloat64, true + } + + return 0.0, false +} + +// TODO: implement other convenience methods for the other well-defined parameters here: +// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata diff --git a/go/pkg/mesc/model/profile.go b/go/pkg/mesc/model/profile.go new file mode 100644 index 0000000..e595945 --- /dev/null +++ b/go/pkg/mesc/model/profile.go @@ -0,0 +1,13 @@ +package mesc + +// Profile describes a profile to contextualize resolved endpoint metadata +type Profile struct { + Name string // Name is the name of the profile + DefaultEndpoint *ChainID // DefaultEndpoint contains the ChainID of the default network under this profile, if available + NetworkDefaults map[ChainID]string // NetworkDefaults maps ChainID values identifying networks to the name of the default endpoint of that network + ProfileMetadata map[string]any // ProfileMetadata is a combination of both well-defined and custom-defined metadata for this profile + UseMESC bool // UseMESC, if false, indicates that MESC resolution should not be used when this profile is enabled +} + +// TODO: implement helper methods resolving profile metadata, per the specification here: +// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata diff --git a/go/pkg/mesc/model/rpc_config.go b/go/pkg/mesc/model/rpc_config.go new file mode 100644 index 0000000..b13364a --- /dev/null +++ b/go/pkg/mesc/model/rpc_config.go @@ -0,0 +1,14 @@ +package mesc + +// RPCConfig describes a collection of RPC configurations +type RPCConfig struct { + MESCVersion string // MESCVersion describes the version of the MESC specification to which this adheres + DefaultEndpoint string // DefaultEndpoint is the name of the default endpoint to be used + NetworkDefaults map[ChainID]string // NetworkDefaults maps chain IDs to the names of the default network for each chain + Endpoints map[string]EndpointMetadata // Endpoints maps endpoint metadata by endpoint name + Profiles map[string]Profile // Profiles maps profiles by their profile names + GlobalMetadata map[string]any // GlobalMetadata contains metadata relevant across all profiles +} + +// TODO: implement helper methods resolving global metadata, per the specification here: +// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata From 2945fab9798743165270f7c890582544fe566939 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 11:12:04 -0800 Subject: [PATCH 24/85] add new input types and error types for file parsing --- rust/crates/mesc/src/load.rs | 14 ++++++++++---- rust/crates/mesc/src/types/errors.rs | 8 ++++++++ rust/crates/mesc/src/write.rs | 12 +++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/rust/crates/mesc/src/load.rs b/rust/crates/mesc/src/load.rs index c8e0d91..fa4f0f4 100644 --- a/rust/crates/mesc/src/load.rs +++ b/rust/crates/mesc/src/load.rs @@ -4,7 +4,7 @@ use std::{env, fs}; /// check whether mesc is enabled pub fn is_mesc_enabled() -> bool { if let Ok("DISABLED") = std::env::var("MESC_MODE").as_deref() { - return false + return false; }; let env_vars = [ "MESC_MODE", @@ -79,6 +79,9 @@ pub fn load_file_config(path: Option) -> Result { Some(path) => path, None => get_config_path()?, }; + if !std::path::Path::new(path.as_str()).exists() { + return Err(MescError::MissingConfigFile(path)); + }; let config_str = fs::read_to_string(path).map_err(MescError::IOError)?; serde_json::from_str(&config_str).map_err(|_| MescError::InvalidJson) } @@ -91,10 +94,13 @@ pub fn get_config_path() -> Result { } /// expand tilde's in path -pub fn expand_path(path: String) -> Result { - if let Some(subpath) = path.strip_prefix("~/") { +pub fn expand_path>(path: P) -> Result { + let path_str = + path.as_ref().to_str().ok_or(MescError::InvalidPath("Invalid path".to_string()))?; + + if let Some(subpath) = path_str.strip_prefix("~/") { Ok(format!("{}/{}", env::var("HOME")?, subpath)) } else { - Ok(path) + Ok(path_str.to_string()) } } diff --git a/rust/crates/mesc/src/types/errors.rs b/rust/crates/mesc/src/types/errors.rs index 4ed9312..a5f2f3c 100644 --- a/rust/crates/mesc/src/types/errors.rs +++ b/rust/crates/mesc/src/types/errors.rs @@ -23,6 +23,14 @@ pub enum MescError { #[error("Missing endpoint: {0}")] MissingEndpoint(String), + /// Error for missing invalid path + #[error("Invalid path: {0}")] + InvalidPath(String), + + /// Error for missing config file + #[error("Missing config file: {0}")] + MissingConfigFile(String), + /// Error wrapper for standard IO errors. #[error(transparent)] IOError(#[from] std::io::Error), diff --git a/rust/crates/mesc/src/write.rs b/rust/crates/mesc/src/write.rs index 867c875..8ecc328 100644 --- a/rust/crates/mesc/src/write.rs +++ b/rust/crates/mesc/src/write.rs @@ -1,15 +1,17 @@ use crate::{MescError, RpcConfig, TryIntoChainId}; -use std::fs::File; +use std::{fs::File, path::Path}; /// write config to file -pub fn write_config(config: RpcConfig, path: String) -> Result<(), MescError> { - if let Some(parent) = std::path::Path::new(&path).parent() { +pub fn write_config>(config: RpcConfig, path: P) -> Result<(), MescError> { + let path_ref = path.as_ref(); + + if let Some(parent) = path_ref.parent() { if !parent.exists() { - std::fs::create_dir_all(&path)? + std::fs::create_dir_all(parent)? }; } - let file = File::create(path)?; + let file = File::create(path_ref)?; Ok(serde_json::to_writer_pretty(file, &config)?) } From 77b8d9d9c45103e58e1071e93e2c9e605b78e98d Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 11:13:37 -0800 Subject: [PATCH 25/85] refactor setup subcommand --- rust/crates/mesc/src/overrides.rs | 14 + .../mesc_cli/src/cli/subcommands/setup.rs | 1088 ----------------- .../src/cli/subcommands/setup/command.rs | 229 ++++ .../subcommands/setup/config_modification.rs | 74 ++ .../src/cli/subcommands/setup/defaults.rs | 156 +++ .../src/cli/subcommands/setup/endpoints.rs | 207 ++++ .../cli/subcommands/setup/inquire_utils.rs | 25 + .../src/cli/subcommands/setup/metadata.rs | 139 +++ .../mesc_cli/src/cli/subcommands/setup/mod.rs | 12 + .../cli/subcommands/setup/network_names.rs | 96 ++ .../src/cli/subcommands/setup/selectors.rs | 238 ++++ .../src/cli/subcommands/setup/shell_config.rs | 258 ++++ .../src/cli/subcommands/setup/writing.rs | 77 ++ .../mesc_cli/src/cli/subcommands/status.rs | 56 +- rust/crates/mesc_cli/src/network.rs | 13 + 15 files changed, 1574 insertions(+), 1108 deletions(-) delete mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/defaults.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/mod.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/setup/writing.rs diff --git a/rust/crates/mesc/src/overrides.rs b/rust/crates/mesc/src/overrides.rs index a79b740..835c271 100644 --- a/rust/crates/mesc/src/overrides.rs +++ b/rust/crates/mesc/src/overrides.rs @@ -1,6 +1,20 @@ use crate::{ChainId, Endpoint, MescError, Profile, RpcConfig, TryIntoChainId}; use std::collections::HashMap; +/// get active overrides +pub fn get_active_overrides() -> Vec { + let overrides = [ + "MESC_NETWORK_NAMES", + "MESC_NETWORK_DEFAULTS", + "MESC_ENDPOINTS", + "MESC_DEFAULT_ENDPOINT", + "MESC_GLOBAL_METADATA", + "MESC_ENDPOINT_METADATA", + "MESC_PROFILES", + ]; + overrides.iter().filter_map(|v| std::env::var(v).ok()).collect() +} + /// apply overrides to config pub fn apply_overrides(config: &mut RpcConfig) -> Result<(), MescError> { if let Some(default_endpoint) = get_default_endpoint_override() { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup.rs deleted file mode 100644 index 60bcba0..0000000 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup.rs +++ /dev/null @@ -1,1088 +0,0 @@ -use crate::{print_defaults, MescCliError, SetupArgs}; -use inquire::{ - ui::{Attributes, Color, IndexPrefix, RenderConfig, StyleSheet, Styled}, - InquireError, -}; -use mesc::{ChainId, Endpoint, RpcConfig, TryIntoChainId}; -use std::collections::{HashMap, HashSet}; -use toolstr::Colorize; - -pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { - inquire::set_global_render_config(get_render_config()); - - if args.editor { - return edit_config_in_editor(args); - } - - let config_mode = mesc::load::get_config_mode()?; - match config_mode { - mesc::ConfigMode::Path => { - println!("MESC is enabled"); - println!(); - println!("config stored at: {}", mesc::load::get_config_path()?.bold()); - } - mesc::ConfigMode::Env => { - println!("MESC is enabled"); - println!(); - println!("config stored in MESC_ENV environment variable"); - } - mesc::ConfigMode::Disabled => { - println!("MESC is not enabled"); - } - }; - println!(); - - loop { - if mesc::is_mesc_enabled() { - match mesc::load::load_config_data() { - Ok(config) => return modify_existing_config(config, None).await, - Err(_) => { - println!("The current MESC config contains improper data"); - println!(); - let options = vec!["Fix the data manually", "Create a new config from scratch"]; - match inquire::Select::new("How to proceed?", options).prompt() { - Ok("Fix the data manually") => match config_mode { - mesc::ConfigMode::Path => { - let path = mesc::load::get_config_path()?; - edit::edit_file(path)? - } - _ => { - println!("Config data stored in MESC_ENV environment variable"); - println!(); - println!("Edit MESC_ENV in your terminal config files and then restart your terminal"); - } - }, - Ok("Create a new config from scratch") => return setup_new_config().await, - Err(InquireError::OperationCanceled) => { - println!("exiting"); - std::process::exit(1); - } - _ => println!("Improper selection"), - }; - return Ok(()); - } - } - } else if let Ok(path) = mesc::load::get_config_path() { - println!("a MESC config path has still been specified: {}", path.bold()); - - if std::path::Path::new(&path).exists() { - println!(); - match mesc::load::load_file_config(None) { - Ok(config) => { - println!("To enable MESC, select \"Setup environment\" below"); - println!(); - return modify_existing_config(config, None).await; - } - Err(_) => { - println!("This MESC config file contains improper data"); - let options = - vec!["Fix the data manually", "Create a new config from scratch"]; - match inquire::Select::new("How to proceed?", options).prompt() { - Ok("Fix the data manually") => edit::edit_file(path)?, - Ok("Create a new config from scratch") => { - return setup_new_config().await - } - Err(InquireError::OperationCanceled) => { - println!("exiting"); - std::process::exit(1); - } - _ => {} - }; - } - } - } else { - println!(); - return setup_new_config().await; - } - } else { - return setup_new_config().await; - } - } -} - -fn edit_config_in_editor(args: SetupArgs) -> Result<(), MescCliError> { - if let Some(path) = args.path { - edit::edit_file(path)? - } else if let Ok(mesc::ConfigMode::Path) = mesc::load::get_config_mode() { - let path = mesc::load::get_config_path()?; - edit::edit_file(path)? - } else { - return Err(MescCliError::Error("no file to edit".to_string())); - }; - Ok(()) -} - -async fn setup_new_config() -> Result<(), MescCliError> { - println!(" {}", "Creating new config...".bold()); - let mut write_mode = None; - let mut config = RpcConfig::default(); - setup_environment(&mut config, &mut write_mode)?; - if let Some(ConfigWriteMode::Path(path)) = write_mode.clone() { - if std::path::Path::new(&path).exists() { - println!(" Config file already exists, loading"); - config = mesc::load::load_file_config(Some(path))?; - } else { - mesc::write::write_config(config.clone(), path)?; - println!(" {}", "Empty configuration created".bold()); - } - } - - modify_existing_config(config, write_mode).await?; - - Ok(()) -} - -async fn modify_existing_config( - config: RpcConfig, - mut config_write_mode: Option, -) -> Result<(), MescCliError> { - let options = [ - "Setup environment", - "Add new endpoint", - "Modify endpoint", - "Modify defaults", - "Modify global metadata", - "Print config as JSON", - "Exit and save changes", - "Exit without saving", - ] - .to_vec(); - let original_config = config.clone(); - let mut valid_config = config.clone(); - let mut config = config.clone(); - // let mut config_write_mode: Option = None; - loop { - // modify config - let input = match inquire::Select::new("What do you want to do?", options.clone()) - .with_page_size(10) - .prompt() - { - Ok(input) => input, - Err(InquireError::OperationCanceled) => { - println!(" Exiting without saving"); - std::process::exit(0) - } - Err(e) => return Err(e.into()), - }; - match input { - "Setup environment" => setup_environment(&mut config, &mut config_write_mode)?, - "Add new endpoint" => add_endpoint(&mut config).await?, - "Modify endpoint" => modify_endpoint(&mut config).await?, - "Modify defaults" => modify_defaults(&mut config)?, - "Modify global metadata" => modify_global_metadata(&mut config).await?, - "Print config as JSON" => { - println!(); - println!("{}", colored_json::to_colored_json_auto(&config)?); - println!(); - } - "Exit and save changes" => break, - "Exit without saving" => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - - // validation - match config.validate() { - Ok(()) => {} - Err(e) => { - println!("Invalid data: {:?}", e); - println!("Reverting to previous config state"); - config = valid_config.clone(); - continue; - } - }; - - valid_config = config.clone(); - } - - // write file - if config != original_config { - if config_write_mode.is_none() { - config_write_mode = get_config_write_mode()?; - }; - if config_write_mode.is_none() { - println!(" No write mode selected"); - println!(" Not writing changes to disk"); - } else { - match &config_write_mode { - Some(write_mode) => match write_mode { - ConfigWriteMode::Path(path) => { - mesc::write::write_config(config, path.clone())?; - println!(" {} {}", "config written to".bold(), path.green()); - } - ConfigWriteMode::Env(_) => { - todo!("writing environment variables not supported yet") - } - }, - None => return Err(MescCliError::Error("could not obtain write mode".to_string())), - }; - } - } else { - println!(" {}", "No updates to save".bold()) - } - Ok(()) -} - -fn setup_environment( - _config: &mut RpcConfig, - config_write_mode: &mut Option, -) -> Result<(), MescCliError> { - if mesc::is_mesc_enabled() { - println!(); - println!(" MESC is already enabled"); - println!(" Using path {}", mesc::load::get_config_path()?.green().bold()); - println!(); - } else if let Some(config_write_mode) = config_write_mode { - match config_write_mode { - ConfigWriteMode::Path(path) => { - println!(" MESC not yet enabled, but will write config to {}", path.green().bold()) - } - ConfigWriteMode::Env(_) => { - println!(" ENV mode not yet available in the interactive cli") - } - }; - } else { - let options = - vec!["Store MESC config in a file", "Store MESC config in an environment variable"]; - let prompt = "How do you want to store your MESC config?"; - match inquire::Select::new(prompt, options).prompt() { - Ok("Store MESC config in a file") => { - let prompt = "Where should mesc.json file be saved? (enter a directory path)"; - let parent = match inquire::Text::new(prompt).prompt() { - Ok(parent) => { - let parent = if parent.trim().is_empty() { - ".".to_string() - } else { - mesc::load::expand_path(parent)? - }; - std::path::PathBuf::from(parent) - } - Err(InquireError::OperationCanceled) => return Ok(()), - Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - let path: String = parent.join("mesc.json").to_string_lossy().to_string(); - *config_write_mode = Some(ConfigWriteMode::Path(path.to_string())); - println!( - " Insert this line into your {} and {} files:", - "~/.bashrc".green().bold(), - "~/.profile".green().bold() - ); - println!(" {}{}", "MESC_PATH=".green().bold(), path.green().bold()); - println!(" Then restart your terminal shell"); - } - Ok("Store MESC config in an environment variable") => { - println!(" This is not available in the interactive MESC cli yet"); - } - Err(InquireError::OperationCanceled) => {} - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } - - Ok(()) -} - -#[derive(Clone)] -enum ConfigWriteMode { - /// file path of JSON config file - Path(String), - /// list of config files to write to - Env(Vec), -} - -fn get_config_write_mode() -> Result, MescCliError> { - if let Ok(path) = mesc::load::get_config_path() { - return Ok(Some(ConfigWriteMode::Path(path))); - }; - - let prompt = "How do you want to save the config?"; - let options = ["Save as path file", "Save as an environment variable"].to_vec(); - loop { - let write_mode = match inquire::Select::new(prompt, options.clone()).prompt() { - Ok("Save as path file") => { - let prompt = "Where should mesc.json file be saved? (enter a directory path)"; - let parent = match inquire::Text::new(prompt).prompt() { - Ok(parent) => { - let parent = if parent.trim().is_empty() { - ".".to_string() - } else { - mesc::load::expand_path(parent)? - }; - std::path::PathBuf::from(parent) - } - Err(InquireError::OperationCanceled) => return Ok(None), - Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - let path: String = parent.join("mesc.json").to_string_lossy().to_string(); - Some(ConfigWriteMode::Path(path.to_string())) - } - Ok("Save an environment variable") => { - println!("not supported yet"); - continue; - } - Err(InquireError::OperationCanceled) => return Ok(None), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - return Ok(write_mode); - } -} - -fn is_ip(url: &str) -> bool { - use std::net::{Ipv4Addr, Ipv6Addr}; - if url.is_empty() { - return false; - } - let domain = match url.split_once('/') { - Some((domain, _)) => domain, - None => url, - }; - let domain = domain.split(':').next().unwrap_or(""); - domain.parse::().is_ok() || domain.parse::().is_ok() -} - -async fn add_endpoint(config: &mut RpcConfig) -> Result<(), MescCliError> { - let url = match inquire::Text::new("New endpoint URL?").prompt() { - Ok(input) => input, - Err(InquireError::OperationCanceled) => return Ok(()), - Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - - // add transport protocol - let url = if !url.starts_with("http") & !url.starts_with("ws") & !url.ends_with(".ipc") { - if url.starts_with("localhost") | is_ip(&url) { - let url = format!("http://{}", url); - println!( - " Transport protocol not included. Defaulting to http: {}", - url.green().bold() - ); - url - } else { - let url = format!("https://{}", url); - println!( - " Transport protocol not included. Defaulting to https: {}", - url.green().bold() - ); - url - } - } else { - url - }; - - // get chain_id - println!(" Querying chain id..."); - let client = reqwest::Client::builder().timeout(std::time::Duration::from_secs(4)).build()?; - let chain_id = crate::rpc::request_chain_id(client, url.clone()).await; - let chain_id = match chain_id { - Ok(chain_id) => { - println!(" {} {}", "Using chain_id".bold(), chain_id.as_str().green()); - Some(chain_id) - } - _ => { - println!(" {}", "Could not detect chain id".red()); - select_chain_id("How to proceed?".to_string()).await? - } - }; - - // get name - let default_name = mesc::overrides::get_default_endpoint_name(&url, chain_id.clone()); - let mut input = inquire::Text::new("New endpoint name?"); - if let Some(default_name) = default_name.as_ref() { - input = input.with_default(default_name); - } - let name = match input.prompt() { - Ok(choice) => choice, - Err(InquireError::OperationCanceled) => return Ok(()), - Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - - // create endpoint - let endpoint = - Endpoint { url, name, chain_id, endpoint_metadata: std::collections::HashMap::new() }; - config.endpoints.insert(endpoint.name.clone(), endpoint); - println!(" {}", "New endpoint added".bold()); - Ok(()) -} - -async fn select_chain_id(prompt: String) -> Result, MescCliError> { - let options = vec![ - "Search known network names", - "Enter endpoint chain id manually", - "Do not use a chain id for this endpoint", - ]; - loop { - match inquire::Select::new(prompt.as_str(), options.clone()).prompt() { - Ok("Do not use a chain id for this endpoint") => return Ok(None), - Ok("Enter endpoint chain id manually") => { - match inquire::Text::new("Chain id?").prompt() { - Ok(text) => { - match text.try_into_chain_id() { - Ok(chain_id) => return Ok(Some(chain_id)), - _ => continue, - }; - } - Err(InquireError::OperationCanceled) => return Ok(None), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } - Ok("Search known network names") => { - println!( - " Fetching network names from {}...", - "https://chainid.network".green().bold() - ); - match select_chain_id_by_name().await { - Ok(Some(chain_id)) => return Ok(Some(chain_id)), - Ok(None) => return Ok(None), - _ => { - println!(" Exiting without saving"); - std::process::exit(0); - } - } - } - Err(InquireError::OperationCanceled) => return Ok(None), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } -} - -async fn modify_endpoint(config: &mut RpcConfig) -> Result<(), MescCliError> { - // select endpoint - let mut options: Vec = config.endpoints.clone().into_keys().collect(); - options.sort(); - let endpoint_name = match inquire::Select::new("Which endpoint to modify?", options).prompt() { - Ok(name) => name, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - let endpoint = match config.endpoints.get(&endpoint_name) { - Some(endpoint) => endpoint.clone(), - None => return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())), - }; - println!(" {}", "Current endpoint data:".bold(),); - println!(); - let colored = colored_json::to_colored_json_auto(&serde_json::to_value(&endpoint)?)?; - for line in colored.split('\n') { - println!(" {}", line); - } - println!(); - - // gather modifications - let halt_options: HashSet<&str> = vec!["Delete endpoint", "Done"].into_iter().collect(); - let mut option = query_modify_endpoint(endpoint_name.clone(), config, true).await?; - loop { - if halt_options.contains(option.as_str()) { - break; - } - option = query_modify_endpoint(endpoint_name.clone(), config, false).await?; - } - - // commit modifications - if option != "Delete endpoint" { - let new_endpoint = match config.endpoints.get(&endpoint_name) { - Some(endpoint) => endpoint.clone(), - None => return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())), - }; - if new_endpoint == endpoint { - println!(" Endpoint unmodified"); - } else { - println!(" {}", "New endpoint data:".bold(),); - println!(); - let colored = colored_json::to_colored_json_auto(&serde_json::to_value(endpoint)?)?; - for line in colored.split('\n') { - println!(" {}", line); - } - println!(); - } - } - - Ok(()) -} - -async fn query_modify_endpoint( - endpoint_name: String, - config: &mut RpcConfig, - first_change: bool, -) -> Result { - let options = [ - "Modify endpoint name", - "Modify endpoint url", - "Modify endpoint chain_id", - "Modify endpoint metadata", - "Delete endpoint", - "Print endpoint as JSON", - "Done", - ] - .to_vec(); - - let message = if first_change { "How to modify endpoint?" } else { "Any other modifications?" }; - - let option = match inquire::Select::new(message, options.clone()).prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - - match option { - "Modify endpoint name" => { - let new_name = match inquire::Text::new("New name?").prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - mesc::write::update_endpoint_name(config, endpoint_name.as_str(), new_name.as_str())?; - } - "Modify endpoint url" => { - let new_url = match inquire::Text::new("New url?").prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - if let Some(endpoint) = config.endpoints.get_mut(&endpoint_name) { - endpoint.url = new_url; - } - } - "Modify endpoint chain_id" => { - match select_chain_id("New chain_id?".to_string()).await { - Ok(Some(chain_id)) => mesc::write::update_endpoint_chain_id( - config, - endpoint_name.as_str(), - chain_id.clone(), - )?, - Ok(None) => return Ok("Done".to_string()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - } - "Modify endpoint metadata" => modify_endpoint_metadata(endpoint_name.as_str(), config)?, - "Delete endpoint" => { - mesc::write::delete_endpoint(config, endpoint_name.as_str())?; - println!("{} {}", "Deleted endpoint:".red(), endpoint_name.green()); - } - "Print endpoint as JSON" => { - let endpoint = match config.endpoints.get(&endpoint_name) { - Some(endpoint) => endpoint.clone(), - None => { - return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())) - } - }; - println!(" {}", "Current endpoint data:".bold(),); - println!(); - let colored = colored_json::to_colored_json_auto(&serde_json::to_value(endpoint)?)?; - for line in colored.split('\n') { - println!(" {}", line); - } - println!(); - } - "Done" => {} - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - - Ok(option.to_string()) -} - -fn modify_endpoint_metadata( - endpoint_name: &str, - config: &mut RpcConfig, -) -> Result<(), MescCliError> { - let endpoint = match config.endpoints.get_mut(endpoint_name) { - Some(endpoint) => endpoint, - None => { - return Err(MescCliError::InvalidInput(format!("missing endpoint: {}", endpoint_name))) - } - }; - let options = vec![ - "Add label", - "Remove label", - "Set ratelimit", - "Set api key", - "Edit raw JSON", - "Done editing metadata", - ]; - match inquire::Select::new("How to modify metadata?", options).prompt() { - Ok("Add label") => { - let new_label = match inquire::Text::new("What is the new label?").prompt() { - Ok(new_label) => new_label, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - if endpoint.endpoint_metadata.get_mut("labels").is_none() { - endpoint - .endpoint_metadata - .insert("labels".to_string(), serde_json::json!(Vec::::new())); - }; - let labels = endpoint.endpoint_metadata.get_mut("labels").unwrap(); - if let Some(array) = labels.as_array_mut() { - array.push(serde_json::Value::String(new_label)); - println!(" Added label") - } else { - println!("Incorrectly formatted data, labels is not a list"); - }; - } - Ok("Remove label") => { - match endpoint.endpoint_metadata.get_mut("labels") { - Some(serde_json::Value::Array(labels)) => { - let label_strings: Vec<&str> = - labels.iter().filter_map(|val| val.as_str()).collect(); - if label_strings.is_empty() { - println!("No labels for endpoint"); - return Ok(()); - }; - match inquire::Select::new("Which label to remove?", label_strings.clone()) - .prompt() - { - Ok(label) => { - if let Some(index) = - label_strings.iter().position(|test_label| test_label == &label) - { - labels.remove(index); - } else { - println!("Label not found."); - } - } - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } - Some(_) => { - println!("Incorrectly formatted data, labels is not a list"); - } - None => { - println!(" Endpoint does not have any labels") - } - }; - } - Ok("Set ratelimit") => { - let message = "What is the rate limit, in requests per second?"; - let value = match inquire::CustomType::::new(message) - .with_formatter(&|i| format!("{:.2}", i)) - .with_error_message("Please type a valid number") - .with_help_message(" Enter the number of requests per seconds") - .prompt() - { - Ok(value) => value, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - endpoint - .endpoint_metadata - .insert("rate_limit_rps".to_string(), serde_json::json!(value)); - } - Ok("Set api key") => { - let api_key = match inquire::Text::new("What is the api key?").prompt() { - Ok(api_key) => api_key, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - endpoint.endpoint_metadata.insert("api_key".to_string(), serde_json::json!(api_key)); - } - Ok("Edit raw JSON") => { - let edited = edit::edit(serde_json::to_string(&endpoint.endpoint_metadata)?)?; - let value: Result, serde_json::Error> = - serde_json::from_str(&edited); - endpoint.endpoint_metadata = value?; - } - Ok("Done editing metadata") => return Ok(()), - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - Ok(()) -} - -async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), MescCliError> { - let options = - vec!["Modify raw global metadata JSON", "Edit custom network names", "Back to main menu"]; - match inquire::Select::new("What do you want to do?", options).prompt() { - Ok("Modify raw global metadata JSON") => { - let old_metadata = serde_json::to_string(&config.global_metadata)?; - let new_metadata = edit::edit(&old_metadata)?; - if old_metadata == new_metadata { - println!(" {}", "Global metadata unchanged".bold()); - } else { - let value: Result, serde_json::Error> = - serde_json::from_str(&new_metadata); - config.global_metadata = value?; - println!(" {}", "Global metadata updated".bold()); - } - Ok(()) - } - Ok("Edit custom network names") => modify_custom_network_names(config).await, - Ok("Back to main menu") => Ok(()), - Err(InquireError::OperationCanceled) => Ok(()), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), - } -} - -async fn modify_custom_network_names(config: &mut RpcConfig) -> Result<(), MescCliError> { - print_custom_network_names(config); - - loop { - let options = if config.network_names.is_empty() { - vec![ - "Add custom network name", - "Print custom network names", - "Done editing custom names", - ] - } else { - vec![ - "Add custom network name", - "Edit custom network name", - "Remove custom network name", - "Print custom network names", - "Done editing custom names", - ] - }; - match inquire::Select::new("What do you want to do?", options).prompt() { - Ok("Add custom network name") => { - let name = match inquire::Text::new("Custom network name?").prompt() { - Ok(name) => name, - Err(InquireError::OperationCanceled) => continue, - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - loop { - match inquire::Text::new("What is the chain id?").prompt() { - Ok(chain_id) => match chain_id.try_into_chain_id() { - Ok(chain_id) => { - config.network_names.insert(name.clone(), chain_id); - println!(" Custom network name added"); - break; - } - _ => { - println!(" not a valid chain id"); - continue; - } - }, - Err(InquireError::OperationCanceled) => break, - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } - } - Ok("Edit custom network name") => match select_custom_network_name(config) { - Ok(Some(old_name)) => match inquire::Text::new("New name?").prompt() { - Ok(new_name) => match config.network_names.remove(&old_name) { - Some(chain_id) => { - config.network_names.insert(new_name, chain_id); - } - None => continue, - }, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }, - Ok(None) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }, - Ok("Remove custom network name") => match select_custom_network_name(config) { - Ok(Some(name)) => { - config.network_names.remove(&name); - println!(" Name removed"); - } - Ok(None) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }, - Ok("Print custom network names") => print_custom_network_names(config), - Ok("Done editing custom names") => return Ok(()), - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } -} - -fn print_custom_network_names(config: &RpcConfig) { - if config.network_names.is_empty() { - println!(" No custom network names currently being used"); - } else { - println!( - " {} custom network names currently being used:", - config.network_names.len().to_string().green().bold() - ); - for (network_name, chain_id) in config.network_names.iter() { - println!(" - {} = {}", network_name.bold(), chain_id.as_str().green().bold()); - } - }; -} - -fn select_custom_network_name(config: &RpcConfig) -> Result, MescCliError> { - let names: Vec<_> = config.network_names.keys().collect(); - if names.is_empty() { - return Ok(None); - } - match inquire::Select::new("Which custom name?", names).prompt() { - Ok(name) => Ok(Some(name.clone())), - Err(InquireError::OperationCanceled) => Ok(None), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), - } -} - -fn modify_defaults(config: &mut RpcConfig) -> Result<(), MescCliError> { - println!(" Current defaults:"); - println!(); - print_defaults(config)?; - println!(); - - let options = [ - "Set the default endpoint", - "Set the default endpoint for network", - "Add new profile", - "Modify existing profile", - "Print current defaults", - "Done modifying defaults", - ] - .to_vec(); - - loop { - match inquire::Select::new("Which defaults do you want to modify?", options.clone()) - .prompt() - { - Ok("Set the default endpoint") => { - let prompt = "Which endpoint should be the default?"; - let endpoint_name = match select_endpoint(config, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - config.default_endpoint = Some(endpoint_name.clone()); - if let Some(endpoint) = - mesc::query::get_endpoint_by_name(config, endpoint_name.as_str())? - { - if let Some(chain_id) = endpoint.chain_id { - config.network_defaults.insert(chain_id, endpoint_name); - }; - } - } - Ok("Set the default endpoint for network") => { - let prompt = "Set the default endpoint for which network?"; - let chain_id = match select_config_chain_id(config, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - let prompt = "What should be the default endpoint for this network?"; - let endpoint_name = match select_endpoint_of_network(config, &chain_id, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - config.network_defaults.insert(chain_id, endpoint_name); - } - Ok("Add new profile") => { - let name = match inquire::Text::new("Name?").prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - if config.profiles.contains_key(&name) { - println!(); - } else { - config.profiles.insert(name.clone(), mesc::Profile::new(name)); - println!(" profile added"); - } - } - Ok("Modify existing profile") => { - if config.profiles.is_empty() { - println!(" no profiles are currently configured"); - continue; - } - - let profile_name = match select_profile(config, "Which profile to modify?")? { - Some(value) => value, - _ => return Ok(()), - }; - let options = vec![ - "Set the profile's name", - "Set the profile's default endpoint", - "Set the profile's default endpoint for a network", - ]; - match inquire::Select::new("What to modify?", options).prompt() { - Ok("Set the profile's name") => { - let new_name = match inquire::Text::new("New name?").prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok(()), - _ => { - return Err(MescCliError::InvalidInput("invalid input".to_string())) - } - }; - if config.profiles.contains_key(&new_name) { - println!("profile with this name already exists"); - continue; - }; - if let Some(mut profile) = config.profiles.remove(&profile_name) { - profile.name = new_name.clone(); - config.profiles.insert(new_name, profile); - } else { - println!("profile not present"); - } - } - Ok("Set the profile's default endpoint") => { - let prompt = "Which endpoint to use as profile default?"; - let default_endpoint = match select_endpoint(config, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - if let Some(endpoint) = - mesc::query::get_endpoint_by_name(config, &default_endpoint)? - { - if let Some(profile) = config.profiles.get_mut(&profile_name) { - profile.default_endpoint = Some(default_endpoint.clone()); - if let Some(chain_id) = endpoint.chain_id.clone() { - profile.network_defaults.insert(chain_id, default_endpoint); - } - } else { - println!("profile not present"); - } - } - } - Ok("Set the profile's default endpoint for a network") => { - let prompt = "Set the profile's default endpoint for which network?"; - let chain_id = match select_config_chain_id(config, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - let prompt = "What should be the default endpoint for this network?"; - let endpoint_name = - match select_endpoint_of_network(config, &chain_id, prompt)? { - Some(value) => value, - _ => return Ok(()), - }; - if let Some(profile) = config.profiles.get_mut(&profile_name) { - profile.network_defaults.insert(chain_id, endpoint_name); - } else { - println!("profile not present"); - } - } - Err(InquireError::OperationCanceled) => return Ok(()), - _ => { - println!("invalid input"); - } - } - } - Ok("Print current defaults") => { - println!("Current defaults:"); - println!(); - print_defaults(config)?; - println!(); - } - Ok("Done modifying defaults") => return Ok(()), - Err(InquireError::OperationCanceled) => return Ok(()), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - } - } -} - -fn select_endpoint(config: &RpcConfig, prompt: &str) -> Result, MescCliError> { - let mut options: Vec = config.endpoints.clone().into_keys().collect(); - options.sort(); - match inquire::Select::new(prompt, options).prompt() { - Ok(answer) => Ok(Some(answer)), - Err(InquireError::OperationCanceled) => Ok(None), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), - } -} - -fn select_endpoint_of_network( - config: &RpcConfig, - chain_id: &ChainId, - prompt: &str, -) -> Result, MescCliError> { - let mut options: Vec = config - .endpoints - .clone() - .values() - .filter(|endpoint| endpoint.chain_id.as_ref() == Some(chain_id)) - .map(|endpoint| endpoint.name.clone()) - .collect(); - options.sort(); - match inquire::Select::new(prompt, options).prompt() { - Ok(answer) => Ok(Some(answer)), - Err(InquireError::OperationCanceled) => Ok(None), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), - } -} - -fn select_profile(config: &RpcConfig, prompt: &str) -> Result, MescCliError> { - let mut options: Vec<_> = config.profiles.keys().collect(); - options.sort(); - match inquire::Select::new(prompt, options).prompt() { - Ok(answer) => Ok(Some(answer.to_string())), - Err(InquireError::OperationCanceled) => Ok(None), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), - } -} - -fn select_config_chain_id( - config: &RpcConfig, - prompt: &str, -) -> Result, MescCliError> { - let mut chain_ids: HashSet = HashSet::new(); - for endpoint in config.endpoints.values() { - if let Some(chain_id) = endpoint.chain_id.as_ref() { - chain_ids.insert(chain_id.clone()); - } - } - let mut sorted_chain_ids: Vec = chain_ids.into_iter().collect(); - sorted_chain_ids.sort_by_key(|chain_id| chain_id.to_hex_256().unwrap_or("".to_string())); - let options: Vec = sorted_chain_ids - .iter() - .map(|chain_id| match mesc::directory::get_network_name(chain_id) { - Some(name) => format!("{}) {}", chain_id.as_str(), name), - None => chain_id.to_string(), - }) - .collect(); - let input = match inquire::Select::new(prompt, options.clone()).prompt() { - Ok(answer) => answer, - Err(InquireError::OperationCanceled) => return Ok(None), - _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), - }; - match options.iter().position(|x| x == &input) { - Some(index) => Ok(Some(sorted_chain_ids.remove(index))), - None => Err(MescCliError::Error("invalid input".to_string())), - } -} - -async fn select_chain_id_by_name() -> Result, MescCliError> { - let network_list = match crate::network::fetch_network_list().await { - Ok(mapping) => mapping, - Err(_) => { - println!(" could not retrieve network list"); - return Ok(None); - } - }; - let mut pairs: Vec<(ChainId, String)> = network_list.into_iter().collect(); - pairs.sort_by_key(|(chain_id, _)| { - chain_id.to_hex_256().unwrap_or(chain_id.as_str().to_string()) - }); - - let options: Vec<_> = - pairs.iter().map(|(chain_id, name)| format!("{}) {}", chain_id, name)).collect(); - let mut render_config = get_render_config(); - render_config.option_index_prefix = IndexPrefix::None; - match inquire::Select::new("Which network?", options.clone()) - .with_render_config(render_config) - .prompt() - { - Ok(answer) => match options.iter().position(|option| option == &answer) { - Some(index) => match pairs.get(index) { - Some((chain_id, _)) => Ok(Some(chain_id.clone())), - None => Ok(None), - }, - None => Err(MescCliError::InvalidInput("bad input".to_string())), - }, - Err(InquireError::OperationCanceled) => Ok(None), - _ => Err(MescCliError::Error("invalid input".to_string())), - } -} - -fn get_render_config() -> RenderConfig { - let highlight_color = Color::DarkGreen; - - let mut render_config = RenderConfig::default(); - render_config.prompt = StyleSheet::new().with_attr(Attributes::BOLD); - render_config.prompt_prefix = Styled::new("").with_fg(Color::LightRed); - render_config.answered_prompt_prefix = Styled::new("").with_fg(Color::LightRed); - render_config.placeholder = StyleSheet::new().with_fg(Color::LightRed); - render_config.selected_option = Some(StyleSheet::new().with_fg(highlight_color)); - render_config.highlighted_option_prefix = Styled::new("→").with_fg(highlight_color); - render_config.selected_checkbox = Styled::new("☑").with_fg(highlight_color); - render_config.scroll_up_prefix = Styled::new("⇞"); - render_config.scroll_down_prefix = Styled::new("⇟"); - render_config.unselected_checkbox = Styled::new("☐"); - render_config.option_index_prefix = IndexPrefix::Simple; - render_config.error_message = - render_config.error_message.with_prefix(Styled::new("❌").with_fg(Color::LightRed)); - render_config.answer = StyleSheet::new().with_attr(Attributes::BOLD).with_fg(highlight_color); - let grey = Color::Rgb { r: 100, g: 100, b: 100 }; - render_config.help_message = StyleSheet::new().with_fg(grey).with_attr(Attributes::ITALIC); - - render_config -} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs new file mode 100644 index 0000000..087e104 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -0,0 +1,229 @@ +use crate::{MescCliError, SetupArgs}; +use mesc::{MescError, RpcConfig}; +use toolstr::Colorize; + +use super::{config_modification::*, inquire_utils::*, selectors::*, shell_config::*, writing::*}; + +pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { + inquire::set_global_render_config(get_render_config()); + if args.editor { + edit_config_in_editor(args) + } else { + let mode = get_write_mode()?; + let config = load_config_data(&mode)?; + println!( + " Current config has {} endpoints and {} profiles", + config.endpoints.len().to_string().green(), + config.profiles.len().to_string().green() + ); + println!(); + modify_existing_config(config, Some(mode)).await + } +} + +/// edit MESC config in editor instead of interactive menus +fn edit_config_in_editor(args: SetupArgs) -> Result<(), MescCliError> { + if let Some(path) = args.path { + edit::edit_file(path)? + } else if let Ok(mesc::ConfigMode::Path) = mesc::load::get_config_mode() { + let path = mesc::load::get_config_path()?; + edit::edit_file(path)? + } else { + return Err(MescCliError::Error("no file to edit".to_string())); + }; + Ok(()) +} + +/// get write mode for config +fn get_write_mode() -> Result { + match ( + std::env::var("MESC_MODE").as_deref(), + std::env::var("MESC_PATH").as_deref(), + std::env::var("MESC_ENV").as_deref(), + !mesc::overrides::get_active_overrides().is_empty(), + ) { + (Ok("DISABLED"), _, _, _) => { + println!(" MESC is disabled because {}", "MESC_MODE=DISABLED".green().bold()); + println!( + " To enable MESC, set {} to {} or {} or unset it", + "MESC_MODE".green().bold(), + "PATH".green().bold(), + "ENV".green().bold() + ); + let config_mode = select_config_mode()?; + setup_mesc_mode_env_var(&config_mode)?; + setup_mesc_env_vars(&config_mode)?; + Ok(config_mode) + } + (Ok("PATH"), Ok(path), _, _) | (Err(_), Ok(path), _, _) => { + let path = mesc::load::expand_path(path)?; + println!(" MESC is {}", "enabled".green().bold()); + let print_path = + if let Ok(raw_path) = std::env::var("MESC_PATH") { raw_path } else { path.clone() }; + println!(" Using {}{}", "MESC_PATH=".green().bold(), print_path.green().bold()); + + Ok(ConfigWriteMode::Path(path.into())) + } + (Ok("PATH"), Err(_), _, _) => { + println!(" MESC is enabled"); + println!( + " Using {}, but {} is not set", + "MESC_MODE=PATH".green().bold(), + "MESC_PATH".green().bold() + ); + let path = select_config_path()?; + println!(" Using config path: {}", path.to_string_lossy().green().bold()); + setup_mesc_path_env_var(&path)?; + Ok(ConfigWriteMode::Path(path)) + } + (Ok("ENV"), _, Ok(_env), _) | (Err(_), Err(_), Ok(_env), _) => { + println!(" MESC is enabled"); + println!(" Using {}", "MESC_MODE=ENV".green().bold()); + Ok(ConfigWriteMode::Env(vec![])) + } + (Ok("ENV"), _, Err(_), _) => { + println!(" MESC is enabled"); + println!( + " Using {}, but {} is not set", + "MESC_MODE=ENV".green().bold(), + "MESC_ENV".green().bold() + ); + Ok(ConfigWriteMode::Env(vec![])) + } + (Ok(other), _, _, _) => { + eprintln!("Invaild value for {}: {}", "MESC_MODE".green().bold(), other.green().bold()); + eprintln!( + "Either 1) unset this variable, or 2) set it to one of {{PATH, ENV, DISABLED}}" + ); + Err(MescCliError::Error("invalid MESC_MODE".to_string())) + } + (Err(_), Err(_), Err(_), true) => { + println!(" MESC is only enabled because overrides are set:"); + for var_name in mesc::overrides::get_active_overrides().iter() { + println!("- {}", var_name.bold().green()) + } + println!( + " To enable MESC more permanently, set either {} or {}", + "MESC_PATH".green().bold(), + "MESC_ENV".green().bold() + ); + let mode = select_config_mode()?; + setup_mesc_env_vars(&mode)?; + Ok(mode) + } + (Err(_), Err(_), Err(_), false) => { + println!(" MESC is disabled because no MESC env vars are set"); + println!(" To enabled MESC, set one of the MESC env vars"); + let mode = select_config_mode()?; + setup_mesc_env_vars(&mode)?; + Ok(mode) + } + } +} + +/// load config data based on write mode +fn load_config_data(mode: &ConfigWriteMode) -> Result { + // attempt to load config data + let config = match mode { + ConfigWriteMode::Path(path) => { + // if path DNE that is ok, just start from scratch + // if invalid json, or other io error, ask to start from scratch break + let option_path = Some(path.to_string_lossy().into()); + match mesc::load::load_file_config(option_path) { + Ok(config) => Ok(config), + Err(MescError::MissingConfigFile(_)) => { + let config = RpcConfig::default(); + let prompt = "Config file does not exist, do you want to create one?"; + match inquire::Confirm::new(prompt).with_default(true).prompt() { + Ok(true) => { + mesc::write::write_config(config.clone(), path)?; + println!( + " Created blank config at {}", + path.to_string_lossy().bold().green() + ); + } + Ok(false) => { + println!(" Starting from blank config. Use \"Exit and save changes\" below to save"); + } + Err(_) => std::process::exit(1), + } + Ok(config) + } + Err(e) => Err(e), + } + } + ConfigWriteMode::Env(_) => { + // if env unset that is ok, just start from scratch + // if invalid json, ask to start from scratch, or break + match std::env::var("MESC_ENV") { + Ok(val) if !val.is_empty() => mesc::load::load_env_config(), + _ => { + println!(" {} var is empty, using blank config", "MESC_ENV".green().bold()); + Ok(RpcConfig::default()) + } + } + } + }; + + // create new config upon loading error + let config = match config { + Ok(config) => config, + Err(e) => { + eprintln!("Could not load config data: {}", format!("{}", e).red()); + let prompt = "How do you want to procede?"; + let options = vec!["Start a new config from scratch", "Exit setup"]; + match inquire::Select::new(prompt, options).prompt() { + Ok("Start a new config from scratch") => RpcConfig::default(), + _ => std::process::exit(1), + } + } + }; + + // ensure that config data is valid + let mut config = config.clone(); + loop { + match config.validate() { + Ok(()) => break, + Err(e) => { + eprintln!("Config data is not valid: {}", format!("{}", e).red()); + let prompt = "What do you want to do?"; + let options = + vec!["Create new config from scratch", "Edit the data manually", "Exit setup"]; + match inquire::Select::new(prompt, options).prompt() { + Ok("Create new config from scratch") => config = RpcConfig::default(), + Ok("Edit the data manually") => { + let new_config = edit::edit(serde_json::to_string(&config)?)?; + if let Ok(new_config) = serde_json::from_str(new_config.as_str()) { + config = new_config + } + } + Ok("Exit setup") | Ok(_) | Err(_) => std::process::exit(1), + } + } + }; + } + + Ok(config) +} + +fn setup_mesc_mode_env_var(mode: &ConfigWriteMode) -> Result<(), MescCliError> { + let value = match mode { + ConfigWriteMode::Path(_) => "PATH", + ConfigWriteMode::Env(_) => "ENV", + }; + modify_shell_config_var("MESC_MODE", value.to_string(), None)?; + Ok(()) +} + +fn setup_mesc_env_vars(mode: &ConfigWriteMode) -> Result<(), MescCliError> { + match mode { + ConfigWriteMode::Path(path) => setup_mesc_path_env_var(path), + ConfigWriteMode::Env(_) => Ok(()), + } +} + +fn setup_mesc_path_env_var(path: &std::path::Path) -> Result<(), MescCliError> { + let value = path.to_string_lossy().to_string(); + modify_shell_config_var("MESC_PATH", value, None)?; + Ok(()) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs new file mode 100644 index 0000000..7d564f5 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs @@ -0,0 +1,74 @@ +use crate::MescCliError; +use inquire::InquireError; +use mesc::RpcConfig; + +use super::{defaults::*, endpoints::*, metadata::*, writing::*}; +use toolstr::Colorize; + +pub(crate) async fn modify_existing_config( + config: RpcConfig, + config_write_mode: Option, +) -> Result<(), MescCliError> { + let options = [ + "Add new endpoint", + "Modify endpoint", + "Modify defaults", + "Modify global metadata", + "Print config as JSON", + "Exit and save changes", + "Exit without saving", + ] + .to_vec(); + let original_config = config.clone(); + let mut valid_config = config.clone(); + let mut config = config.clone(); + loop { + // modify config + match inquire::Select::new("What do you want to do?", options.clone()) + .with_page_size(10) + .prompt() + { + Ok("Add new endpoint") => add_endpoint(&mut config).await?, + Ok("Modify endpoint") => modify_endpoint(&mut config).await?, + Ok("Modify defaults") => modify_defaults(&mut config)?, + Ok("Modify global metadata") => modify_global_metadata(&mut config).await?, + Ok("Print config as JSON") => { + println!(); + println!("{}", colored_json::to_colored_json_auto(&config)?); + println!(); + } + Ok("Exit and save changes") => break, + Ok("Exit without saving") => return Ok(()), + Err(InquireError::OperationCanceled) => { + if config != original_config { + println!(" Exiting without saving"); + } else { + println!(" Exiting"); + } + std::process::exit(0) + } + Ok(_) | Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + + // validation + match config.validate() { + Ok(()) => {} + Err(e) => { + println!("Invalid data: {:?}", e); + println!("Reverting to previous config state"); + config = valid_config.clone(); + continue; + } + }; + + valid_config = config.clone(); + } + + // write file + if config != original_config { + write_config(config, config_write_mode)?; + } else { + println!(" {}", "No updates to save".bold()) + } + Ok(()) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/defaults.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/defaults.rs new file mode 100644 index 0000000..dfd2420 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/defaults.rs @@ -0,0 +1,156 @@ +use super::selectors::*; +use crate::{print_defaults, MescCliError}; +use inquire::InquireError; +use mesc::RpcConfig; + +pub(crate) fn modify_defaults(config: &mut RpcConfig) -> Result<(), MescCliError> { + println!(" Current defaults:"); + println!(); + print_defaults(config)?; + println!(); + + let options = [ + "Set the default endpoint", + "Set the default endpoint for network", + "Add new profile", + "Modify existing profile", + "Print current defaults", + "Done modifying defaults", + ] + .to_vec(); + + loop { + match inquire::Select::new("Which defaults do you want to modify?", options.clone()) + .prompt() + { + Ok("Set the default endpoint") => { + let prompt = "Which endpoint should be the default?"; + let endpoint_name = match select_endpoint(config, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + config.default_endpoint = Some(endpoint_name.clone()); + if let Some(endpoint) = + mesc::query::get_endpoint_by_name(config, endpoint_name.as_str())? + { + if let Some(chain_id) = endpoint.chain_id { + config.network_defaults.insert(chain_id, endpoint_name); + }; + } + } + Ok("Set the default endpoint for network") => { + let prompt = "Set the default endpoint for which network?"; + let chain_id = match select_config_chain_id(config, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + let prompt = "What should be the default endpoint for this network?"; + let endpoint_name = match select_endpoint_of_network(config, &chain_id, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + config.network_defaults.insert(chain_id, endpoint_name); + } + Ok("Add new profile") => { + let name = match inquire::Text::new("Name?").prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + if config.profiles.contains_key(&name) { + println!(); + } else { + config.profiles.insert(name.clone(), mesc::Profile::new(name)); + println!(" profile added"); + } + } + Ok("Modify existing profile") => { + if config.profiles.is_empty() { + println!(" no profiles are currently configured"); + continue; + } + + let profile_name = match select_profile(config, "Which profile to modify?")? { + Some(value) => value, + _ => return Ok(()), + }; + let options = vec![ + "Set the profile's name", + "Set the profile's default endpoint", + "Set the profile's default endpoint for a network", + ]; + match inquire::Select::new("What to modify?", options).prompt() { + Ok("Set the profile's name") => { + let new_name = match inquire::Text::new("New name?").prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => { + return Err(MescCliError::InvalidInput("invalid input".to_string())) + } + }; + if config.profiles.contains_key(&new_name) { + println!("profile with this name already exists"); + continue; + }; + if let Some(mut profile) = config.profiles.remove(&profile_name) { + profile.name = new_name.clone(); + config.profiles.insert(new_name, profile); + } else { + println!("profile not present"); + } + } + Ok("Set the profile's default endpoint") => { + let prompt = "Which endpoint to use as profile default?"; + let default_endpoint = match select_endpoint(config, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + if let Some(endpoint) = + mesc::query::get_endpoint_by_name(config, &default_endpoint)? + { + if let Some(profile) = config.profiles.get_mut(&profile_name) { + profile.default_endpoint = Some(default_endpoint.clone()); + if let Some(chain_id) = endpoint.chain_id.clone() { + profile.network_defaults.insert(chain_id, default_endpoint); + } + } else { + println!("profile not present"); + } + } + } + Ok("Set the profile's default endpoint for a network") => { + let prompt = "Set the profile's default endpoint for which network?"; + let chain_id = match select_config_chain_id(config, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + let prompt = "What should be the default endpoint for this network?"; + let endpoint_name = + match select_endpoint_of_network(config, &chain_id, prompt)? { + Some(value) => value, + _ => return Ok(()), + }; + if let Some(profile) = config.profiles.get_mut(&profile_name) { + profile.network_defaults.insert(chain_id, endpoint_name); + } else { + println!("profile not present"); + } + } + Err(InquireError::OperationCanceled) => return Ok(()), + _ => { + println!("invalid input"); + } + } + } + Ok("Print current defaults") => { + println!("Current defaults:"); + println!(); + print_defaults(config)?; + println!(); + } + Ok("Done modifying defaults") => return Ok(()), + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs new file mode 100644 index 0000000..30958fe --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs @@ -0,0 +1,207 @@ +use crate::{network::is_ip, MescCliError}; +use inquire::InquireError; +use mesc::{Endpoint, RpcConfig}; +use std::collections::{HashMap, HashSet}; +use toolstr::Colorize; + +use super::{metadata::*, selectors::*}; + +pub(crate) async fn add_endpoint(config: &mut RpcConfig) -> Result<(), MescCliError> { + let url = match inquire::Text::new("New endpoint URL?").prompt() { + Ok(input) => input, + Err(InquireError::OperationCanceled) => return Ok(()), + Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + + // add transport protocol + let url = if !url.starts_with("http") & !url.starts_with("ws") & !url.ends_with(".ipc") { + if url.starts_with("localhost") | is_ip(&url) { + let url = format!("http://{}", url); + println!( + " Transport protocol not included. Defaulting to http: {}", + url.green().bold() + ); + url + } else { + let url = format!("https://{}", url); + println!( + " Transport protocol not included. Defaulting to https: {}", + url.green().bold() + ); + url + } + } else { + url + }; + + // get chain_id + println!(" Querying chain id..."); + let client = reqwest::Client::builder().timeout(std::time::Duration::from_secs(4)).build()?; + let chain_id = crate::rpc::request_chain_id(client, url.clone()).await; + let chain_id = match chain_id { + Ok(chain_id) => { + println!(" {} {}", "Using chain_id".bold(), chain_id.as_str().green()); + Some(chain_id) + } + _ => { + println!(" {}", "Could not detect chain id".red()); + select_chain_id("How to proceed?".to_string()).await? + } + }; + + // get name + let default_name = mesc::overrides::get_default_endpoint_name(&url, chain_id.clone()); + let mut input = inquire::Text::new("New endpoint name?"); + if let Some(default_name) = default_name.as_ref() { + input = input.with_default(default_name); + } + let name = match input.prompt() { + Ok(choice) => choice, + Err(InquireError::OperationCanceled) => return Ok(()), + Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + + // create endpoint + let endpoint = Endpoint { url, name, chain_id, endpoint_metadata: HashMap::new() }; + config.endpoints.insert(endpoint.name.clone(), endpoint); + println!(" {}", "New endpoint added".bold()); + Ok(()) +} + +pub(crate) async fn modify_endpoint(config: &mut RpcConfig) -> Result<(), MescCliError> { + // select endpoint + let mut options: Vec = config.endpoints.clone().into_keys().collect(); + if options.is_empty() { + println!(" No endpoints to modify"); + return Ok(()) + } + options.sort(); + let endpoint_name = match inquire::Select::new("Which endpoint to modify?", options).prompt() { + Ok(name) => name, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + let endpoint = match config.endpoints.get(&endpoint_name) { + Some(endpoint) => endpoint.clone(), + None => return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())), + }; + println!(" {}", "Current endpoint data:".bold(),); + println!(); + let colored = colored_json::to_colored_json_auto(&serde_json::to_value(&endpoint)?)?; + for line in colored.split('\n') { + println!(" {}", line); + } + println!(); + + // gather modifications + let halt_options: HashSet<&str> = vec!["Delete endpoint", "Done"].into_iter().collect(); + let mut option = query_modify_endpoint(endpoint_name.clone(), config, true).await?; + loop { + if halt_options.contains(option.as_str()) { + break; + } + option = query_modify_endpoint(endpoint_name.clone(), config, false).await?; + } + + // commit modifications + if option != "Delete endpoint" { + let new_endpoint = match config.endpoints.get(&endpoint_name) { + Some(endpoint) => endpoint.clone(), + None => return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())), + }; + if new_endpoint == endpoint { + println!(" Endpoint unmodified"); + } else { + println!(" {}", "New endpoint data:".bold(),); + println!(); + let colored = colored_json::to_colored_json_auto(&serde_json::to_value(endpoint)?)?; + for line in colored.split('\n') { + println!(" {}", line); + } + println!(); + } + } + + Ok(()) +} + +pub(crate) async fn query_modify_endpoint( + endpoint_name: String, + config: &mut RpcConfig, + first_change: bool, +) -> Result { + let options = [ + "Modify endpoint name", + "Modify endpoint url", + "Modify endpoint chain_id", + "Modify endpoint metadata", + "Delete endpoint", + "Print endpoint as JSON", + "Done", + ] + .to_vec(); + + let message = if first_change { "How to modify endpoint?" } else { "Any other modifications?" }; + + let option = match inquire::Select::new(message, options.clone()).prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + + match option { + "Modify endpoint name" => { + let new_name = match inquire::Text::new("New name?").prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + mesc::write::update_endpoint_name(config, endpoint_name.as_str(), new_name.as_str())?; + } + "Modify endpoint url" => { + let new_url = match inquire::Text::new("New url?").prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok("Done".to_string()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + if let Some(endpoint) = config.endpoints.get_mut(&endpoint_name) { + endpoint.url = new_url; + } + } + "Modify endpoint chain_id" => { + match select_chain_id("New chain_id?".to_string()).await { + Ok(Some(chain_id)) => mesc::write::update_endpoint_chain_id( + config, + endpoint_name.as_str(), + chain_id.clone(), + )?, + Ok(None) => return Ok("Done".to_string()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + } + "Modify endpoint metadata" => modify_endpoint_metadata(endpoint_name.as_str(), config)?, + "Delete endpoint" => { + mesc::write::delete_endpoint(config, endpoint_name.as_str())?; + println!("{} {}", "Deleted endpoint:".red(), endpoint_name.green()); + } + "Print endpoint as JSON" => { + let endpoint = match config.endpoints.get(&endpoint_name) { + Some(endpoint) => endpoint.clone(), + None => { + return Err(MescCliError::InvalidInput("endpoint does not exist".to_string())) + } + }; + println!(" {}", "Current endpoint data:".bold(),); + println!(); + let colored = colored_json::to_colored_json_auto(&serde_json::to_value(endpoint)?)?; + for line in colored.split('\n') { + println!(" {}", line); + } + println!(); + } + "Done" => {} + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + + Ok(option.to_string()) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs new file mode 100644 index 0000000..789dfed --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs @@ -0,0 +1,25 @@ +use inquire::ui::{Attributes, Color, IndexPrefix, RenderConfig, StyleSheet, Styled}; + +pub(crate) fn get_render_config() -> RenderConfig { + let highlight_color = Color::DarkGreen; + + let mut render_config = RenderConfig::default(); + render_config.prompt = StyleSheet::new().with_attr(Attributes::BOLD); + render_config.prompt_prefix = Styled::new("").with_fg(Color::LightRed); + render_config.answered_prompt_prefix = Styled::new("").with_fg(Color::LightRed); + render_config.placeholder = StyleSheet::new().with_fg(Color::LightRed); + render_config.selected_option = Some(StyleSheet::new().with_fg(highlight_color)); + render_config.highlighted_option_prefix = Styled::new("→").with_fg(highlight_color); + render_config.selected_checkbox = Styled::new("☑").with_fg(highlight_color); + render_config.scroll_up_prefix = Styled::new("⇞"); + render_config.scroll_down_prefix = Styled::new("⇟"); + render_config.unselected_checkbox = Styled::new("☐"); + render_config.option_index_prefix = IndexPrefix::Simple; + render_config.error_message = + render_config.error_message.with_prefix(Styled::new("❌").with_fg(Color::LightRed)); + render_config.answer = StyleSheet::new().with_attr(Attributes::BOLD).with_fg(highlight_color); + let grey = Color::Rgb { r: 100, g: 100, b: 100 }; + render_config.help_message = StyleSheet::new().with_fg(grey).with_attr(Attributes::ITALIC); + + render_config +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs new file mode 100644 index 0000000..d6fa6d4 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs @@ -0,0 +1,139 @@ +use crate::MescCliError; +use inquire::InquireError; +use mesc::RpcConfig; +use std::collections::HashMap; +use toolstr::Colorize; + +use super::network_names::*; + +pub(crate) fn modify_endpoint_metadata( + endpoint_name: &str, + config: &mut RpcConfig, +) -> Result<(), MescCliError> { + let endpoint = match config.endpoints.get_mut(endpoint_name) { + Some(endpoint) => endpoint, + None => { + return Err(MescCliError::InvalidInput(format!("missing endpoint: {}", endpoint_name))) + } + }; + let options = vec![ + "Add label", + "Remove label", + "Set ratelimit", + "Set api key", + "Edit raw JSON", + "Done editing metadata", + ]; + match inquire::Select::new("How to modify metadata?", options).prompt() { + Ok("Add label") => { + let new_label = match inquire::Text::new("What is the new label?").prompt() { + Ok(new_label) => new_label, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + if endpoint.endpoint_metadata.get_mut("labels").is_none() { + endpoint + .endpoint_metadata + .insert("labels".to_string(), serde_json::json!(Vec::::new())); + }; + let labels = endpoint.endpoint_metadata.get_mut("labels").unwrap(); + if let Some(array) = labels.as_array_mut() { + array.push(serde_json::Value::String(new_label)); + println!(" Added label") + } else { + println!("Incorrectly formatted data, labels is not a list"); + }; + } + Ok("Remove label") => { + match endpoint.endpoint_metadata.get_mut("labels") { + Some(serde_json::Value::Array(labels)) => { + let label_strings: Vec<&str> = + labels.iter().filter_map(|val| val.as_str()).collect(); + if label_strings.is_empty() { + println!("No labels for endpoint"); + return Ok(()); + }; + match inquire::Select::new("Which label to remove?", label_strings.clone()) + .prompt() + { + Ok(label) => { + if let Some(index) = + label_strings.iter().position(|test_label| test_label == &label) + { + labels.remove(index); + } else { + println!("Label not found."); + } + } + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } + Some(_) => { + println!("Incorrectly formatted data, labels is not a list"); + } + None => { + println!(" Endpoint does not have any labels") + } + }; + } + Ok("Set ratelimit") => { + let message = "What is the rate limit, in requests per second?"; + let value = match inquire::CustomType::::new(message) + .with_formatter(&|i| format!("{:.2}", i)) + .with_error_message("Please type a valid number") + .with_help_message(" Enter the number of requests per seconds") + .prompt() + { + Ok(value) => value, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + endpoint + .endpoint_metadata + .insert("rate_limit_rps".to_string(), serde_json::json!(value)); + } + Ok("Set api key") => { + let api_key = match inquire::Text::new("What is the api key?").prompt() { + Ok(api_key) => api_key, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + endpoint.endpoint_metadata.insert("api_key".to_string(), serde_json::json!(api_key)); + } + Ok("Edit raw JSON") => { + let edited = edit::edit(serde_json::to_string(&endpoint.endpoint_metadata)?)?; + let value: Result, serde_json::Error> = + serde_json::from_str(&edited); + endpoint.endpoint_metadata = value?; + } + Ok("Done editing metadata") => return Ok(()), + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + Ok(()) +} + +pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), MescCliError> { + let options = + vec!["Modify raw global metadata JSON", "Edit custom network names", "Back to main menu"]; + match inquire::Select::new("What do you want to do?", options).prompt() { + Ok("Modify raw global metadata JSON") => { + let old_metadata = serde_json::to_string(&config.global_metadata)?; + let new_metadata = edit::edit(&old_metadata)?; + if old_metadata == new_metadata { + println!(" {}", "Global metadata unchanged".bold()); + } else { + let value: Result, serde_json::Error> = + serde_json::from_str(&new_metadata); + config.global_metadata = value?; + println!(" {}", "Global metadata updated".bold()); + } + Ok(()) + } + Ok("Edit custom network names") => modify_custom_network_names(config).await, + Ok("Back to main menu") => Ok(()), + Err(InquireError::OperationCanceled) => Ok(()), + _ => Err(MescCliError::InvalidInput("invalid input".to_string())), + } +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/mod.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/mod.rs new file mode 100644 index 0000000..80b49f4 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/mod.rs @@ -0,0 +1,12 @@ +mod command; +mod config_modification; +mod defaults; +mod endpoints; +mod inquire_utils; +mod metadata; +mod network_names; +mod selectors; +mod shell_config; +mod writing; + +pub(crate) use command::setup_command; diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs new file mode 100644 index 0000000..f8c1375 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs @@ -0,0 +1,96 @@ +use crate::MescCliError; +use inquire::InquireError; +use mesc::{RpcConfig, TryIntoChainId}; +use toolstr::Colorize; + +use super::selectors::*; + +pub(crate) async fn modify_custom_network_names( + config: &mut RpcConfig, +) -> Result<(), MescCliError> { + print_custom_network_names(config); + + loop { + let options = if config.network_names.is_empty() { + vec![ + "Add custom network name", + "Print custom network names", + "Done editing custom names", + ] + } else { + vec![ + "Add custom network name", + "Edit custom network name", + "Remove custom network name", + "Print custom network names", + "Done editing custom names", + ] + }; + match inquire::Select::new("What do you want to do?", options).prompt() { + Ok("Add custom network name") => { + let name = match inquire::Text::new("Custom network name?").prompt() { + Ok(name) => name, + Err(InquireError::OperationCanceled) => continue, + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + loop { + match inquire::Text::new("What is the chain id?").prompt() { + Ok(chain_id) => match chain_id.try_into_chain_id() { + Ok(chain_id) => { + config.network_names.insert(name.clone(), chain_id); + println!(" Custom network name added"); + break; + } + _ => { + println!(" not a valid chain id"); + continue; + } + }, + Err(InquireError::OperationCanceled) => break, + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } + } + Ok("Edit custom network name") => match select_custom_network_name(config) { + Ok(Some(old_name)) => match inquire::Text::new("New name?").prompt() { + Ok(new_name) => match config.network_names.remove(&old_name) { + Some(chain_id) => { + config.network_names.insert(new_name, chain_id); + } + None => continue, + }, + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }, + Ok(None) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }, + Ok("Remove custom network name") => match select_custom_network_name(config) { + Ok(Some(name)) => { + config.network_names.remove(&name); + println!(" Name removed"); + } + Ok(None) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }, + Ok("Print custom network names") => print_custom_network_names(config), + Ok("Done editing custom names") => return Ok(()), + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } +} + +fn print_custom_network_names(config: &RpcConfig) { + if config.network_names.is_empty() { + println!(" No custom network names currently being used"); + } else { + println!( + " {} custom network names currently being used:", + config.network_names.len().to_string().green().bold() + ); + for (network_name, chain_id) in config.network_names.iter() { + println!(" - {} = {}", network_name.bold(), chain_id.as_str().green().bold()); + } + }; +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs new file mode 100644 index 0000000..4996b2e --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs @@ -0,0 +1,238 @@ +use crate::MescCliError; +use inquire::{ui::IndexPrefix, InquireError}; +use mesc::{ChainId, RpcConfig, TryIntoChainId}; +use std::collections::HashSet; +use toolstr::Colorize; + +use super::{inquire_utils::*, writing::*}; + +pub(crate) async fn select_chain_id(prompt: String) -> Result, MescCliError> { + let options = vec![ + "Search known network names", + "Enter endpoint chain id manually", + "Do not use a chain id for this endpoint", + ]; + loop { + match inquire::Select::new(prompt.as_str(), options.clone()).prompt() { + Ok("Do not use a chain id for this endpoint") => return Ok(None), + Ok("Enter endpoint chain id manually") => { + match inquire::Text::new("Chain id?").prompt() { + Ok(text) => { + match text.try_into_chain_id() { + Ok(chain_id) => return Ok(Some(chain_id)), + _ => continue, + }; + } + Err(InquireError::OperationCanceled) => return Ok(None), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } + Ok("Search known network names") => { + println!( + " Fetching network names from {}...", + "https://chainid.network".green().bold() + ); + match select_chain_id_by_name().await { + Ok(Some(chain_id)) => return Ok(Some(chain_id)), + Ok(None) => return Ok(None), + _ => { + println!(" Exiting without saving"); + std::process::exit(0); + } + } + } + Err(InquireError::OperationCanceled) => return Ok(None), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + } + } +} + +pub(crate) async fn select_chain_id_by_name() -> Result, MescCliError> { + let network_list = match crate::network::fetch_network_list().await { + Ok(mapping) => mapping, + Err(_) => { + println!(" could not retrieve network list"); + return Ok(None); + } + }; + let mut pairs: Vec<(ChainId, String)> = network_list.into_iter().collect(); + pairs.sort_by_key(|(chain_id, _)| { + chain_id.to_hex_256().unwrap_or(chain_id.as_str().to_string()) + }); + + let options: Vec<_> = + pairs.iter().map(|(chain_id, name)| format!("{}) {}", chain_id, name)).collect(); + let mut render_config = get_render_config(); + render_config.option_index_prefix = IndexPrefix::None; + match inquire::Select::new("Which network?", options.clone()) + .with_render_config(render_config) + .prompt() + { + Ok(answer) => match options.iter().position(|option| option == &answer) { + Some(index) => match pairs.get(index) { + Some((chain_id, _)) => Ok(Some(chain_id.clone())), + None => Ok(None), + }, + None => Err(MescCliError::InvalidInput("bad input".to_string())), + }, + Err(InquireError::OperationCanceled) => Ok(None), + _ => Err(MescCliError::Error("invalid input".to_string())), + } +} + +pub(crate) fn select_custom_network_name( + config: &RpcConfig, +) -> Result, MescCliError> { + let names: Vec<_> = config.network_names.keys().collect(); + if names.is_empty() { + return Ok(None); + } + match inquire::Select::new("Which custom name?", names).prompt() { + Ok(name) => Ok(Some(name.clone())), + Err(InquireError::OperationCanceled) => Ok(None), + _ => Err(MescCliError::InvalidInput("invalid input".to_string())), + } +} + +pub(crate) fn select_endpoint( + config: &RpcConfig, + prompt: &str, +) -> Result, MescCliError> { + let mut options: Vec = config.endpoints.clone().into_keys().collect(); + options.sort(); + match inquire::Select::new(prompt, options).prompt() { + Ok(answer) => Ok(Some(answer)), + Err(InquireError::OperationCanceled) => Ok(None), + _ => Err(MescCliError::InvalidInput("invalid input".to_string())), + } +} + +pub(crate) fn select_endpoint_of_network( + config: &RpcConfig, + chain_id: &ChainId, + prompt: &str, +) -> Result, MescCliError> { + let mut options: Vec = config + .endpoints + .clone() + .values() + .filter(|endpoint| endpoint.chain_id.as_ref() == Some(chain_id)) + .map(|endpoint| endpoint.name.clone()) + .collect(); + options.sort(); + match inquire::Select::new(prompt, options).prompt() { + Ok(answer) => Ok(Some(answer)), + Err(InquireError::OperationCanceled) => Ok(None), + _ => Err(MescCliError::InvalidInput("invalid input".to_string())), + } +} + +pub(crate) fn select_profile( + config: &RpcConfig, + prompt: &str, +) -> Result, MescCliError> { + let mut options: Vec<_> = config.profiles.keys().collect(); + options.sort(); + match inquire::Select::new(prompt, options).prompt() { + Ok(answer) => Ok(Some(answer.to_string())), + Err(InquireError::OperationCanceled) => Ok(None), + _ => Err(MescCliError::InvalidInput("invalid input".to_string())), + } +} + +pub(crate) fn select_config_chain_id( + config: &RpcConfig, + prompt: &str, +) -> Result, MescCliError> { + let mut chain_ids: HashSet = HashSet::new(); + for endpoint in config.endpoints.values() { + if let Some(chain_id) = endpoint.chain_id.as_ref() { + chain_ids.insert(chain_id.clone()); + } + } + let mut sorted_chain_ids: Vec = chain_ids.into_iter().collect(); + sorted_chain_ids.sort_by_key(|chain_id| chain_id.to_hex_256().unwrap_or("".to_string())); + let options: Vec = sorted_chain_ids + .iter() + .map(|chain_id| match mesc::directory::get_network_name(chain_id) { + Some(name) => format!("{}) {}", chain_id.as_str(), name), + None => chain_id.to_string(), + }) + .collect(); + let input = match inquire::Select::new(prompt, options.clone()).prompt() { + Ok(answer) => answer, + Err(InquireError::OperationCanceled) => return Ok(None), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + match options.iter().position(|x| x == &input) { + Some(index) => Ok(Some(sorted_chain_ids.remove(index))), + None => Err(MescCliError::Error("invalid input".to_string())), + } +} + +pub(crate) fn select_config_mode() -> Result { + let prompt = "Do you want to store your MESC config in a file or in an env var?"; + let options = vec!["File (recommended)", "Environment Variable"]; + match inquire::Select::new(prompt, options).prompt() { + Ok("File (recommended)") => Ok(ConfigWriteMode::Path(select_config_path()?)), + Ok("Environment Variable") => Ok(ConfigWriteMode::Env(vec![])), + Ok(_) | Err(_) => { + eprintln!("Aborting setup"); + std::process::exit(1); + } + } +} + +pub(crate) fn select_config_path() -> Result { + loop { + let prompt = "Where to save MESC config file?"; + match inquire::Text::new(prompt).with_default("~/mesc.json").prompt() { + Ok(path) => { + let path = mesc::load::expand_path(path)?; + let path = std::path::Path::new(path.as_str()); + if path.exists() { + if path.is_file() { + match path.extension().map(|ext| ext.to_string_lossy()) { + Some(ext) if ext == "json" => return Ok(path.to_path_buf()), + _ => { + let prompt = "Use file even without a .json file extension?"; + if let Ok(true) = + inquire::Confirm::new(prompt).with_default(false).prompt() + { + return Ok(path.to_path_buf()); + } + } + } + } else if path.is_dir() { + let path = path.join("mesc.json"); + println!("Treating as a directory, will save to {}", path.display()); + return Ok(path); + } else { + println!("Not a valid file path"); + } + } else { + match path.extension() { + Some(ext) if ext == "json" => return Ok(path.to_path_buf()), + Some(_) => { + let prompt = "Use file even without a .json file extension?"; + if let Ok(true) = + inquire::Confirm::new(prompt).with_default(false).prompt() + { + return Ok(path.to_path_buf()); + } + } + None => { + let path = path.join("mesc.json"); + println!("Treating as a directory, will save to {}", path.display()); + return Ok(path); + } + } + } + } + Err(_) => { + eprintln!("Aborting setup"); + std::process::exit(1); + } + } + } +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs new file mode 100644 index 0000000..7c73ffa --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs @@ -0,0 +1,258 @@ +use crate::MescCliError; + +use std::{ + fs::{File, OpenOptions}, + io::{BufRead, BufReader, Write}, + path::{Path, PathBuf}, +}; +use toolstr::Colorize; + +#[derive(Hash, PartialEq, Eq)] +pub(crate) struct Mention { + pub(crate) path: PathBuf, + pub(crate) env_var: String, + pub(crate) simple_value: Option, + pub(crate) line: String, +} + +pub(crate) fn get_shell_config_paths() -> Result, MescCliError> { + let home_dir = + std::env::var("HOME").map_err(|_| MescCliError::Error("home dir not found".to_string()))?; + let home_path = PathBuf::from(home_dir); + let candidates = vec![ + home_path.join(".bashrc"), + home_path.join(".profile"), + home_path.join(".bash_profile"), + ]; + Ok(candidates) +} + +/// return list of modified files +pub(crate) fn modify_shell_config_var( + var_name: &str, + value: String, + paths: Option>, +) -> Result, MescCliError> { + // decide where to look + let shell_configs = match paths { + Some(paths) => paths, + None => get_shell_config_paths()?, + }; + + // detect where env var is currently defined + let mut not_set: Vec = Vec::new(); + let mut complex_mentions: Vec = Vec::new(); + let mut set_already: Vec = Vec::new(); + let mut set_wrong: Vec = Vec::new(); + for path in shell_configs.into_iter() { + let mentions = find_env_var_mentions(var_name, &path)?; + if mentions.is_empty() { + not_set.push(path) + } else if mentions.iter().all(|m| m.simple_value.is_none()) { + complex_mentions.push(path) + } else if mentions.iter().all(|m| m.simple_value == Some(value.clone())) { + set_already.push(path) + } else { + set_wrong.push(path) + } + } + + println!("NOT_SET {:?}", not_set); + println!("COMPLEX_MENTIONS {:?}", complex_mentions); + println!("SET_ALREADY {:?}", set_already); + println!("SET_WRONG {:?}", set_wrong); + + // modify shell configs accordingly + match (not_set.len(), complex_mentions.len(), set_wrong.len(), set_already.len()) { + (0, 0, 0, 0) => { + println!(" No shell config files specified"); + Ok(vec![]) + } + (n_not_set, n_set_complex, n_set_wrong, n_set_already) => { + println!(" Need to set {} in order to use this file", "MESC_PATH".green().bold()); + if n_set_already > 0 { + println!( + " {} is already set to the desired value in {} shell config files", + var_name.bold().green(), + n_set_already.to_string().green().bold() + ); + for (i, path) in set_already.iter().enumerate() { + println!(" {}. {}", i + 1, path.to_string_lossy().green().bold()); + } + } + if n_set_complex > 0 { + println!(" {} is already set in a complex, non-standard way for {} shell config files. You must edit these files manually: {:?}", var_name.green().bold(), n_set_complex.to_string().green().bold(), get_file_names(&complex_mentions)); + for (i, path) in complex_mentions.iter().enumerate() { + println!(" {}. {}", i + 1, path.to_string_lossy().green().bold()); + } + } + if n_not_set + n_set_wrong > 0 { + let to_change: Vec<_> = not_set.into_iter().chain(set_wrong).collect(); + edit_shell_config_files_to_value(var_name, value, to_change) + } else { + Ok(vec![]) + } + } + } +} + +fn edit_shell_config_files_to_value( + var_name: &str, + value: String, + to_edit: Vec, +) -> Result, MescCliError> { + println!( + " {} can be automatically updated for {} shell config files:", + var_name.bold().green(), + format!("{}", to_edit.len()).green().bold(), + ); + for (i, path) in to_edit.iter().enumerate() { + println!(" {}. {}", i + 1, path.to_string_lossy().green().bold()); + } + let mut to_edit: std::collections::HashSet = to_edit.into_iter().collect(); + + let prompt = "What do you want to do?"; + let options = vec![ + "Edit these files automatically (recommended)", + "Edit these files manually in editor", + "Choose a subset of these files", + "Ignore this for now", + "Exit setup", + ]; + let original_to_edit = to_edit.clone(); + let edited = loop { + match inquire::Select::new(prompt, options.clone()).prompt() { + Ok("Edit these files automatically (recommended)") => { + for path in to_edit.iter() { + replace_mentions(path, var_name, &value)? + } + break to_edit.into_iter().collect(); + } + Ok("Edit these files manually in editor") => { + for path in to_edit.iter() { + edit::edit_file(path)?; + } + break to_edit.into_iter().collect(); + } + Ok("Choose a subset of these files") => { + to_edit = match inquire::MultiSelect::new( + "Select which files to edit", + original_to_edit + .clone() + .into_iter() + .map(|x| x.to_string_lossy().to_string()) + .collect(), + ) + .prompt() + { + Ok(paths) => { + println!(" Selected {} files", paths.len().to_string().bold().green()); + paths.iter().map(|p| PathBuf::from(p.to_string())).collect() + } + Err(_) => continue, + } + } + Ok("Ignore this for now") => break vec![], + Ok("Exit setup") | Ok(_) | Err(_) => std::process::exit(0), + }; + }; + + match edited.len() { + 0 => println!(" {} not updated in any shell config files", var_name.green().bold()), + 1 => println!(" {} updated in 1 config file", var_name.green().bold()), + n => println!(" Edited {} config files", n.to_string().green().bold()), + }; + + Ok(edited) +} + +/// Find mentions of environment variable in path +pub(crate) fn find_env_var_mentions( + env_var: &str, + path: &PathBuf, +) -> Result, MescCliError> { + let mut mentions: Vec = Vec::new(); + if path.exists() { + let file = File::open(path)?; + let reader = BufReader::new(file); + for line in reader.lines() { + let line = line?; + if line.trim_start().starts_with('#') { + continue; + } + if let Some(value) = extract_simple_value(&line, env_var) { + mentions.push(Mention { + path: path.clone(), + env_var: env_var.to_string(), + simple_value: Some(value), + line: line.clone(), + }); + } else if line.contains(env_var) { + mentions.push(Mention { + path: path.clone(), + env_var: env_var.to_string(), + simple_value: None, + line, + }); + } + } + } + Ok(mentions) +} + +/// Helper function to extract the simple value from a line, if present +fn extract_simple_value(line: &str, env_var: &str) -> Option { + if line.starts_with(&format!("export {}=", env_var)) { + line.split_once('=').map(|(_, value)| value.to_string()) + } else { + None + } +} + +/// Helper function to get a list of file names from a list of paths +fn get_file_names(paths: &[PathBuf]) -> Vec { + paths + .iter() + .filter_map(|path| path.file_name()) + .filter_map(|os_str| os_str.to_str()) + .map(|str_slice| str_slice.to_owned()) + .collect() +} + +/// Replace mentions of an environment variable in a file with a new value +pub(crate) fn replace_mentions>( + path: P, + env_var: &str, + new_value: &str, +) -> Result<(), MescCliError> { + let path = path.as_ref(); + let file = File::open(path)?; + let reader = BufReader::new(file); + + let mut lines: Vec = Vec::new(); + let mut modified = false; + + for line in reader.lines() { + let line = line?; + if line.starts_with(&format!("export {}=", env_var)) { + lines.push(format!("export {}={}", env_var, new_value)); + modified = true; + } else { + lines.push(line); + } + } + if !modified { + lines.push("".to_string()); + lines.push(format!("export {}={}", env_var, new_value)); + modified = true; + } + + if modified { + let mut file = OpenOptions::new().write(true).truncate(true).open(path)?; + for line in lines { + writeln!(file, "{}", line)?; + } + } + + Ok(()) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/writing.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/writing.rs new file mode 100644 index 0000000..e85cfd0 --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/writing.rs @@ -0,0 +1,77 @@ +use crate::MescCliError; +use inquire::InquireError; +use mesc::RpcConfig; +use toolstr::Colorize; + +#[derive(Clone)] +pub(crate) enum ConfigWriteMode { + /// file path of JSON config file + Path(std::path::PathBuf), + /// list of config files to write to + Env(Vec), +} + +pub(crate) fn write_config( + config: RpcConfig, + config_write_mode: Option, +) -> Result<(), MescCliError> { + let config_write_mode = match config_write_mode { + Some(config_write_mode) => Some(config_write_mode), + None => get_config_write_mode()?, + }; + if config_write_mode.is_none() { + println!(" No write mode selected"); + println!(" Not writing changes to disk"); + } else { + match &config_write_mode { + Some(write_mode) => match write_mode { + ConfigWriteMode::Path(path) => { + mesc::write::write_config(config, path.clone())?; + println!(" {} {}", "config written to".bold(), path.to_string_lossy().green()); + } + ConfigWriteMode::Env(_) => { + todo!("writing environment variables not supported yet") + } + }, + None => return Err(MescCliError::Error("could not obtain write mode".to_string())), + }; + }; + Ok(()) +} + +pub(crate) fn get_config_write_mode() -> Result, MescCliError> { + if let Ok(path) = mesc::load::get_config_path() { + return Ok(Some(ConfigWriteMode::Path(path.into()))); + }; + + let prompt = "How do you want to save the config?"; + let options = ["Save as path file", "Save as an environment variable"].to_vec(); + loop { + let write_mode = match inquire::Select::new(prompt, options.clone()).prompt() { + Ok("Save as path file") => { + let prompt = "Where should mesc.json file be saved? (enter a directory path)"; + let parent = match inquire::Text::new(prompt).prompt() { + Ok(parent) => { + let parent = if parent.trim().is_empty() { + ".".to_string() + } else { + mesc::load::expand_path(parent)? + }; + std::path::PathBuf::from(parent) + } + Err(InquireError::OperationCanceled) => return Ok(None), + Err(_) => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + let path: String = parent.join("mesc.json").to_string_lossy().to_string(); + Some(ConfigWriteMode::Path(path.into())) + } + Ok("Save an environment variable") => { + println!("not supported yet"); + continue; + } + Err(InquireError::OperationCanceled) => return Ok(None), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), + }; + return Ok(write_mode); + } +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/status.rs b/rust/crates/mesc_cli/src/cli/subcommands/status.rs index 3dfae8c..03815af 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/status.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/status.rs @@ -46,33 +46,41 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { values.push("false".to_string()); if let MescError::IOError(ref e) = e { if let std::io::ErrorKind::NotFound = e.kind() { - println!("config file not found"); + println!("{}", "config file not found".red()); + println!(); } else { - println!("could not load config: {:?}", e); + println!("{}", format!("could not load config: {:?}", e).red()); + println!(); + keys.push("config found"); + values.push(format!("{}", "false".to_string().red())); } } else { - println!("could not load config: {:?}", e); + println!("{}", format!("could not load config: {:?}", e).red()); + println!(); }; - return Err(e.into()); + None } Ok(config) => { - keys.push("config found"); - values.push("true".to_string()); - config + values.push(format!("{}", "true".to_string().green())); + Some(config) } }; // validate config keys.push("config valid"); - match config.validate() { - Ok(()) => { - values.push("true".to_string()); - } - Err(e) => { - values.push("false".to_string()); - println!("{:?}", e); - } - }; + if let Some(config) = config.clone() { + match config.validate() { + Ok(()) => { + values.push(format!("{}", "true".to_string().green())); + } + Err(e) => { + values.push(format!("{}", "false".to_string().red())); + println!("{:?}", e); + } + }; + } else { + values.push("[no config]".to_string()); + } let format = toolstr::TableFormat::default(); let column_formats = vec![ @@ -80,7 +88,7 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { toolstr::ColumnFormatShorthand::new() .name("v") .left_justify() - .font_style("".green().bold()), + .font_style("".bold().green()), ]; let format = toolstr::TableFormat { include_header_row: false, @@ -103,8 +111,12 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { println!(); toolstr::print_header("Configured Endpoints", &theme); println!(); - let endpoints: Vec<_> = config.endpoints.clone().into_values().collect(); - print_endpoints(&endpoints, args.reveal)?; + if let Some(ref config) = config.clone() { + let endpoints: Vec<_> = config.endpoints.clone().into_values().collect(); + print_endpoints(&endpoints, args.reveal)?; + } else { + println!("[no config]"); + } }; // print defaults @@ -113,7 +125,11 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { println!(); toolstr::print_header("Default Endpoints", &theme); println!(); - print_defaults(&config)?; + if let Some(config) = config.clone() { + print_defaults(&config)?; + } else { + println!("[no config]"); + } }; Ok(()) diff --git a/rust/crates/mesc_cli/src/network.rs b/rust/crates/mesc_cli/src/network.rs index a61eef3..2118e67 100644 --- a/rust/crates/mesc_cli/src/network.rs +++ b/rust/crates/mesc_cli/src/network.rs @@ -73,6 +73,19 @@ pub(crate) async fn get_node_network_info( }) } +pub(crate) fn is_ip(url: &str) -> bool { + use std::net::{Ipv4Addr, Ipv6Addr}; + if url.is_empty() { + return false; + } + let domain = match url.split_once('/') { + Some((domain, _)) => domain, + None => url, + }; + let domain = domain.split(':').next().unwrap_or(""); + domain.parse::().is_ok() || domain.parse::().is_ok() +} + fn get_ip_address(url: &str) -> Result { let parsed_url = url::Url::parse(url) .map_err(|_| MescCliError::UrlError("could not parse url".to_string()))?; From 7e92b0a367dd87effca9e8ddb48bfc97e77dab43 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 12:46:46 -0800 Subject: [PATCH 26/85] build out metadata setup modifiers --- .../src/cli/subcommands/setup/command.rs | 16 ++- .../subcommands/setup/config_modification.rs | 7 +- .../src/cli/subcommands/setup/metadata.rs | 110 ++++++++++++++---- .../src/cli/subcommands/setup/selectors.rs | 9 ++ 4 files changed, 116 insertions(+), 26 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs index 087e104..b933d87 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -11,10 +11,22 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { } else { let mode = get_write_mode()?; let config = load_config_data(&mode)?; + let endpoint_word = if config.endpoints.len() == 1 { + "endpoint" + } else { + "endpoints" + }; + let profile_word = if config.profiles.len() == 1 { + "profile" + } else { + "profiles" + }; println!( - " Current config has {} endpoints and {} profiles", + " Current config has {} {} and {} {}", config.endpoints.len().to_string().green(), - config.profiles.len().to_string().green() + endpoint_word, + config.profiles.len().to_string().green(), + profile_word, ); println!(); modify_existing_config(config, Some(mode)).await diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs index 7d564f5..d259e1f 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs @@ -4,6 +4,7 @@ use mesc::RpcConfig; use super::{defaults::*, endpoints::*, metadata::*, writing::*}; use toolstr::Colorize; +use super::network_names::*; pub(crate) async fn modify_existing_config( config: RpcConfig, @@ -13,7 +14,8 @@ pub(crate) async fn modify_existing_config( "Add new endpoint", "Modify endpoint", "Modify defaults", - "Modify global metadata", + "Modify metadata", + "Modify network names", "Print config as JSON", "Exit and save changes", "Exit without saving", @@ -31,7 +33,8 @@ pub(crate) async fn modify_existing_config( Ok("Add new endpoint") => add_endpoint(&mut config).await?, Ok("Modify endpoint") => modify_endpoint(&mut config).await?, Ok("Modify defaults") => modify_defaults(&mut config)?, - Ok("Modify global metadata") => modify_global_metadata(&mut config).await?, + Ok("Modify metadata") => modify_global_metadata(&mut config).await?, + Ok("Modify network names") => modify_custom_network_names(&mut config).await?, Ok("Print config as JSON") => { println!(); println!("{}", colored_json::to_colored_json_auto(&config)?); diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs index d6fa6d4..dc41392 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs @@ -4,7 +4,7 @@ use mesc::RpcConfig; use std::collections::HashMap; use toolstr::Colorize; -use super::network_names::*; +use super::selectors::*; pub(crate) fn modify_endpoint_metadata( endpoint_name: &str, @@ -20,7 +20,7 @@ pub(crate) fn modify_endpoint_metadata( "Add label", "Remove label", "Set ratelimit", - "Set api key", + "Set API key", "Edit raw JSON", "Done editing metadata", ]; @@ -93,8 +93,8 @@ pub(crate) fn modify_endpoint_metadata( .endpoint_metadata .insert("rate_limit_rps".to_string(), serde_json::json!(value)); } - Ok("Set api key") => { - let api_key = match inquire::Text::new("What is the api key?").prompt() { + Ok("Set API key") => { + let api_key = match inquire::Text::new("What is the API key?").prompt() { Ok(api_key) => api_key, Err(InquireError::OperationCanceled) => return Ok(()), _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), @@ -115,25 +115,91 @@ pub(crate) fn modify_endpoint_metadata( } pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), MescCliError> { - let options = - vec!["Modify raw global metadata JSON", "Edit custom network names", "Back to main menu"]; - match inquire::Select::new("What do you want to do?", options).prompt() { - Ok("Modify raw global metadata JSON") => { - let old_metadata = serde_json::to_string(&config.global_metadata)?; - let new_metadata = edit::edit(&old_metadata)?; - if old_metadata == new_metadata { - println!(" {}", "Global metadata unchanged".bold()); - } else { - let value: Result, serde_json::Error> = - serde_json::from_str(&new_metadata); - config.global_metadata = value?; - println!(" {}", "Global metadata updated".bold()); + loop { + let options = vec![ + "Modify global metadata as JSON", + "Modify profile metadata as JSON", + "Modify endpoint metadata", + "Print global metadata", + "Print profiles metadata", + "Back to main menu", + ]; + match inquire::Select::new("What do you want to do?", options).prompt() { + Ok("Modify global metadata as JSON") => { + let old_metadata = serde_json::to_string(&config.global_metadata)?; + let new_metadata = edit::edit(&old_metadata)?; + if old_metadata == new_metadata { + println!(" {}", "Global metadata unchanged".bold()); + } else { + let value: Result, serde_json::Error> = + serde_json::from_str(&new_metadata); + match value { + Ok(value) => { + config.global_metadata = value; + println!(" {}", "Global metadata updated".bold()); + }, + Err(_) => { + println!(" {}", "Invalid JSON, ignoring".red().bold()) + } + } + } } - Ok(()) + Ok("Modify profile metadata as JSON") => { + if config.profiles.is_empty() { + println!(" No profiles in config"); + } else if let Some(profile_name) = select_profile(config, "Which profile?")? { + if let Some(profile) = config.profiles.get(&profile_name) { + let old_metadata = serde_json::to_string(&profile.profile_metadata)?; + let new_metadata = edit::edit(&old_metadata)?; + if old_metadata == new_metadata { + println!(" {}", "Profile metadata unchanged".bold()); + } else { + let value: Result, serde_json::Error> = + serde_json::from_str(&new_metadata); + match value { + Ok(value) => { + config.global_metadata = value; + println!(" {}", "Profile metadata updated".bold()); + }, + Err(_) => { + println!(" {}", "Invalid JSON, ignoring".red().bold()) + } + } + } + } + } else { + return Ok(()) + } + }, + Ok("Modify endpoint metadata") => { + if config.endpoints.is_empty() { + println!(" No endpoints in config"); + } else if let Some(endpoint) = select_endpoint(config, "Which endpoint?")? { + modify_endpoint_metadata(endpoint.as_str(), config)?; + } else { + return Ok(()) + } + }, + Ok("Print global metadata") => { + println!(); + println!("{}", colored_json::to_colored_json_auto(&config.global_metadata)?); + println!(); + }, + Ok("Print profiles metadata") => { + if config.profiles.is_empty() { + println!(" No profiles in config"); + } else { + println!(); + for (profile_name, profile) in config.profiles.iter() { + println!("profile: {}:", profile_name.bold().white()); + println!("{}", colored_json::to_colored_json_auto(&profile.profile_metadata)?); + println!(); + } + } + }, + Ok("Back to main menu") => return Ok(()), + Err(InquireError::OperationCanceled) => return Ok(()), + _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), } - Ok("Edit custom network names") => modify_custom_network_names(config).await, - Ok("Back to main menu") => Ok(()), - Err(InquireError::OperationCanceled) => Ok(()), - _ => Err(MescCliError::InvalidInput("invalid input".to_string())), } } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs index 4996b2e..4cf1dfe 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs @@ -99,6 +99,9 @@ pub(crate) fn select_endpoint( prompt: &str, ) -> Result, MescCliError> { let mut options: Vec = config.endpoints.clone().into_keys().collect(); + if options.is_empty() { + return Ok(None) + } options.sort(); match inquire::Select::new(prompt, options).prompt() { Ok(answer) => Ok(Some(answer)), @@ -119,6 +122,9 @@ pub(crate) fn select_endpoint_of_network( .filter(|endpoint| endpoint.chain_id.as_ref() == Some(chain_id)) .map(|endpoint| endpoint.name.clone()) .collect(); + if options.is_empty() { + return Ok(None) + } options.sort(); match inquire::Select::new(prompt, options).prompt() { Ok(answer) => Ok(Some(answer)), @@ -132,6 +138,9 @@ pub(crate) fn select_profile( prompt: &str, ) -> Result, MescCliError> { let mut options: Vec<_> = config.profiles.keys().collect(); + if options.is_empty() { + return Ok(None) + } options.sort(); match inquire::Select::new(prompt, options).prompt() { Ok(answer) => Ok(Some(answer.to_string())), From 5963ca628114a10025e7045b4994478e33b041cf Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 12:51:24 -0800 Subject: [PATCH 27/85] rust format --- .../src/cli/subcommands/setup/command.rs | 12 ++-------- .../subcommands/setup/config_modification.rs | 3 +-- .../src/cli/subcommands/setup/metadata.rs | 23 +++++++++++-------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs index b933d87..74727b5 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -11,16 +11,8 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { } else { let mode = get_write_mode()?; let config = load_config_data(&mode)?; - let endpoint_word = if config.endpoints.len() == 1 { - "endpoint" - } else { - "endpoints" - }; - let profile_word = if config.profiles.len() == 1 { - "profile" - } else { - "profiles" - }; + let endpoint_word = if config.endpoints.len() == 1 { "endpoint" } else { "endpoints" }; + let profile_word = if config.profiles.len() == 1 { "profile" } else { "profiles" }; println!( " Current config has {} {} and {} {}", config.endpoints.len().to_string().green(), diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs index d259e1f..eb31ac6 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs @@ -2,9 +2,8 @@ use crate::MescCliError; use inquire::InquireError; use mesc::RpcConfig; -use super::{defaults::*, endpoints::*, metadata::*, writing::*}; +use super::{defaults::*, endpoints::*, metadata::*, network_names::*, writing::*}; use toolstr::Colorize; -use super::network_names::*; pub(crate) async fn modify_existing_config( config: RpcConfig, diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs index dc41392..bd2e4f4 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs @@ -137,7 +137,7 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), Ok(value) => { config.global_metadata = value; println!(" {}", "Global metadata updated".bold()); - }, + } Err(_) => { println!(" {}", "Invalid JSON, ignoring".red().bold()) } @@ -154,13 +154,15 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), if old_metadata == new_metadata { println!(" {}", "Profile metadata unchanged".bold()); } else { - let value: Result, serde_json::Error> = - serde_json::from_str(&new_metadata); + let value: Result< + HashMap, + serde_json::Error, + > = serde_json::from_str(&new_metadata); match value { Ok(value) => { config.global_metadata = value; println!(" {}", "Profile metadata updated".bold()); - }, + } Err(_) => { println!(" {}", "Invalid JSON, ignoring".red().bold()) } @@ -170,7 +172,7 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), } else { return Ok(()) } - }, + } Ok("Modify endpoint metadata") => { if config.endpoints.is_empty() { println!(" No endpoints in config"); @@ -179,12 +181,12 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), } else { return Ok(()) } - }, + } Ok("Print global metadata") => { println!(); println!("{}", colored_json::to_colored_json_auto(&config.global_metadata)?); println!(); - }, + } Ok("Print profiles metadata") => { if config.profiles.is_empty() { println!(" No profiles in config"); @@ -192,11 +194,14 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), println!(); for (profile_name, profile) in config.profiles.iter() { println!("profile: {}:", profile_name.bold().white()); - println!("{}", colored_json::to_colored_json_auto(&profile.profile_metadata)?); + println!( + "{}", + colored_json::to_colored_json_auto(&profile.profile_metadata)? + ); println!(); } } - }, + } Ok("Back to main menu") => return Ok(()), Err(InquireError::OperationCanceled) => return Ok(()), _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), From 6c199726680c2e29721f2bb48ba01bf1953800bf Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 12:50:19 -0800 Subject: [PATCH 28/85] add setup help --- .../mesc_cli/src/cli/subcommands/help.rs | 58 ++++++++++++++++++- .../subcommands/setup/config_modification.rs | 3 + 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index 0cfac39..75cdc1e 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -9,6 +9,7 @@ pub(crate) fn help_command(args: HelpArgs) -> Result<(), MescCliError> { "python" => print_python_interface(), "rust" => print_rust_interface(), "schema" => print_schema()?, + "setup" => print_setup_help(), _ => println!("Unknown help topic: {}", topic), }, None => Cli::command().print_help().map_err(|e| { @@ -19,15 +20,50 @@ pub(crate) fn help_command(args: HelpArgs) -> Result<(), MescCliError> { Ok(()) } +fn print_help_topic(topic: &str) -> Result<(), MescCliError> { + match topic { + "env" => print_env_help(), + "python" => print_python_interface(), + "rust" => print_rust_interface(), + "schema" => print_schema()?, + "setup" => print_setup_help(), + _ => println!("Unknown help topic: {}", topic), + } + Ok(()) +} + pub(crate) fn get_help_topics() -> Vec<(String, String)> { vec![ - ("env".to_string(), "Description of environmental variables".to_string()), - ("python".to_string(), "Print python interface".to_string()), - ("rust".to_string(), "Print rust interface".to_string()), + ("env".to_string(), "Environmental variables".to_string()), + ("python".to_string(), "Python interface".to_string()), + ("rust".to_string(), "Rust interface".to_string()), ("schema".to_string(), "Schemas of configs, endpoints, and profiles".to_string()), + ("setup".to_string(), "How to set up MESC".to_string()), ] } +pub(crate) fn print_interactive_help() -> Result<(), MescCliError> { + println!(); + print_setup_help(); + println!(); + let topics = get_help_topics(); + let mut options: Vec<_> = topics.iter().map(|(t, _)| t.as_str()).collect(); + options.push("Return to main menu"); + loop { + let prompt = "Print help about other MESC topics?"; + match inquire::Select::new(prompt, options.clone()).prompt() { + Ok("Return to main menu") => return Ok(()), + Ok(topic) => { + println!(); + print_help_topic(topic)?; + println!() + }, + Err(inquire::InquireError::OperationCanceled) => return Ok(()), + Err(e) => return Err(e.into()), + } + } +} + fn print_env_help() { let messages = vec![ ( @@ -298,3 +334,19 @@ fn print_schema() -> Result<(), MescCliError> { Ok(()) } + +fn print_setup_help() { + println!( + r#"A basic MESC setup requires two steps: +1. create a {} configuration file +2. set the {} environment variable to the path of this file + +The {} command can interactively perform both steps + +{} can also be used to create and modify configuration data"#, + "mesc.json".white().bold(), + "MESC_PATH".white().bold(), + "mesc setup".white().bold(), + "mesc setup".white().bold() + ) +} diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs index eb31ac6..a2e468e 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/config_modification.rs @@ -3,6 +3,7 @@ use inquire::InquireError; use mesc::RpcConfig; use super::{defaults::*, endpoints::*, metadata::*, network_names::*, writing::*}; +use crate::cli::subcommands::help::print_interactive_help; use toolstr::Colorize; pub(crate) async fn modify_existing_config( @@ -16,6 +17,7 @@ pub(crate) async fn modify_existing_config( "Modify metadata", "Modify network names", "Print config as JSON", + "Print help information", "Exit and save changes", "Exit without saving", ] @@ -39,6 +41,7 @@ pub(crate) async fn modify_existing_config( println!("{}", colored_json::to_colored_json_auto(&config)?); println!(); } + Ok("Print help information") => print_interactive_help()?, Ok("Exit and save changes") => break, Ok("Exit without saving") => return Ok(()), Err(InquireError::OperationCanceled) => { From 952bc069ae80c141814124fc7f23a88f4f731526 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 13:39:33 -0800 Subject: [PATCH 29/85] update network names --- python/mesc/network_names.py | 32 ++++++++++++++++++++++----- rust/crates/mesc/src/network_names.rs | 32 ++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index 63e613c..c61e015 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -134,6 +134,7 @@ network_names = { '126': 'oy', '127': 'factory_127', '128': 'huobi_eco', + '129': 'protojumbo_testnet', '131': 'engram_testnet', '134': 'iexec', '135': 'alyx_testnet', @@ -195,7 +196,7 @@ network_names = { '246': 'energy_web', '248': 'oasys', '250': 'fantom_opera', - '252': 'frax', + '252': 'fraxtal', '255': 'kroma', '256': 'huobi_eco_testnet', '258': 'setheum', @@ -229,6 +230,8 @@ network_names = { '365': 'theta_testnet', '369': 'pulse', '371': 'consta_testnet', + '380': 'zkamoeba_testnet', + '381': 'zkamoeba', '385': 'lisinski', '399': 'nativ3', '400': 'hyperon_testnet', @@ -260,6 +263,7 @@ network_names = { '558': 'tao', '568': 'doge_testnet', '570': 'rollux', + '571': 'meta', '588': 'metis_stardust_testnet', '592': 'astar', '595': 'acala_mandala_testnet_tc9', @@ -268,11 +272,13 @@ network_names = { '599': 'metis_goerli_testnet', '600': 'meshnyan_testnet', '601': 'vine_testnet', + '612': 'eiob', '614': 'graphlinq_block', '634': 'avocado', '647': 'sx_testnet', '648': 'endurance', - '653': 'kali', + '653': 'kali_testnet', + '654': 'kali', '666': 'pixie_testnet', '667': 'laos_arrakis', '668': 'junca', @@ -298,6 +304,7 @@ network_names = { '800': 'lucid_block', '803': 'haic', '808': 'portal_fantasy_test', + '810': 'haven1_testnet', '813': 'qitmeer', '814': 'fire_zkevm', '818': 'beone', @@ -419,7 +426,7 @@ network_names = { '1442': 'polygon_zkevm_testnet', '1452': 'gil_testnet', '1455': 'ctex_scan_block', - '1501': 'bevm', + '1501': 'bevm_canary', '1506': 'sherpax', '1507': 'sherpax_testnet', '1515': 'beagle_messaging', @@ -527,7 +534,7 @@ network_names = { '2458': 'hybrid_testnet', '2468': 'hybrid', '2484': 'unicorn_ultra_nebulas_testnet', - '2522': 'frax_testnet', + '2522': 'fraxtal_testnet', '2559': 'kortho', '2569': 'techpay', '2606': 'pocrnet', @@ -571,6 +578,7 @@ network_names = { '3701': 'xpla_testnet', '3737': 'crossbell', '3797': 'alvey', + '3799': 'tangle_testnet', '3885': 'fire_zkevm_ghostrider', '3888': 'kaly', '3889': 'kaly_testnet', @@ -596,6 +604,7 @@ network_names = { '4181': 'phi_v1', '4201': 'lukso_testnet', '4242': 'nexi', + '4243': 'nexi_v2', '4328': 'bobafuji_testnet', '4337': 'beam', '4400': 'credit', @@ -649,6 +658,7 @@ network_names = { '6661': 'cybria', '6666': 'cybria_testnet', '6688': 'irishub', + '6701': 'paxb', '6779': 'compverse', '6789': 'gold', '6969': 'tomb', @@ -675,6 +685,7 @@ network_names = { '7777': 'rise_of_the_warbots_testnet', '7860': 'maal_testnet', '7878': 'hazlor_testnet', + '7887': 'kinto', '7895': 'ardenium_athena', '7979': 'dos', '8000': 'teleport', @@ -727,6 +738,7 @@ network_names = { '9170': 'rinia_testnet_old', '9223': 'codefin', '9339': 'dogcoin_testnet', + '9395': 'evoke', '9527': 'rangers_protocol_testnet_robin', '9528': 'qeasyweb3_testnet', '9559': 'neonlink_testnet', @@ -814,6 +826,7 @@ network_names = { '20001': 'camelark', '20729': 'callisto_testnet', '20736': 'p12', + '20765': 'jono11_subnet', '21337': 'cennznet_azalea', '21816': 'om', '21912': 'bsl', @@ -829,6 +842,7 @@ network_names = { '23888': 'blast_testnet', '24484': 'web', '24734': 'mintme.com', + '25186': 'liquidlayer', '25888': 'hammer', '25925': 'bitkub_testnet', '26026': 'ferrum_testnet', @@ -842,7 +856,9 @@ network_names = { '31223': 'cloudtx', '31224': 'cloudtx_testnet', '31337': 'go_testnet', + '31414': 'evoke_testnet', '31415': 'filecoin___wallaby_testnet', + '32001': 'w3gamez_holesky_testnet', '32520': 'bitgert', '32659': 'fusion', '32769': 'zilliqa_evm', @@ -879,6 +895,7 @@ network_names = { '44444': 'fren', '44787': 'celo_alfajores_testnet', '45000': 'autobahn', + '45510': 'deelance', '46688': 'fusion_testnet', '47805': 'rei', '49049': 'wireshape_floripa_testnet', @@ -965,6 +982,7 @@ network_names = { '91002': 'nautilus_trition', '91715': 'combo_testnet', '92001': 'lambda_testnet', + '93572': 'liquidlayer_testnet', '96970': 'mantis_testnet_hexapod', '97288': 'boba_bnb_old', '99099': 'eliberty_testnet', @@ -997,12 +1015,14 @@ network_names = { '111111': 'siberium', '112358': 'meta_one', '123456': 'adil_devnet', + '128123': 'etherlink_testnet', '131419': 'etnds', '142857': 'icplaza', '167004': 'taiko_alpha_2_testnet', '167005': 'taiko_grimsvotn_l2', '167006': 'taiko_eldfell_l3', '167007': 'taiko_jolnir_l2', + '167008': 'taiko_katla_l2', '188710': 'bitica', '188881': 'condor_test', '200101': 'milkomeda_c1_testnet', @@ -1079,6 +1099,7 @@ network_names = { '827431': 'curve', '846000': '4goodnetwork', '855456': 'dodao', + '879151': 'blocx', '888888': 'vision', '900000': 'posi_shard_0', '910000': 'posi_testnet_shard_0', @@ -1095,6 +1116,7 @@ network_names = { '1337702': 'kintsugi', '1337802': 'kiln', '1337803': 'zhejiang', + '1731313': 'turkey_demo_dev', '2021398': 'debank_testnet', '2099156': 'plian_main', '2206132': 'platon_dev_testnet2', @@ -1134,6 +1156,7 @@ network_names = { '22052002': 'excelon', '27082017': 'excoincial_volta_testnet', '27082022': 'excoincial', + '28122024': 'ancient8_testnet', '28945486': 'auxilium', '29032022': 'fla', '31415926': 'filecoin___local_testnet', @@ -1183,7 +1206,6 @@ network_names = { '1666900001': 'harmony_devnet_shard_1', '2021121117': 'datahopper', '2046399126': 'skale_europa_hub', - '2863311531': 'ancient8_testnet', '3125659152': 'pirl', '4216137055': 'oneledger_testnet_frankenstein', '11297108099': 'palm_testnet', diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index 288aa72..9ed2043 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -139,6 +139,7 @@ pub fn get_network_names() -> HashMap { ("126", "oy"), ("127", "factory_127"), ("128", "huobi_eco"), + ("129", "protojumbo_testnet"), ("131", "engram_testnet"), ("134", "iexec"), ("135", "alyx_testnet"), @@ -200,7 +201,7 @@ pub fn get_network_names() -> HashMap { ("246", "energy_web"), ("248", "oasys"), ("250", "fantom_opera"), - ("252", "frax"), + ("252", "fraxtal"), ("255", "kroma"), ("256", "huobi_eco_testnet"), ("258", "setheum"), @@ -234,6 +235,8 @@ pub fn get_network_names() -> HashMap { ("365", "theta_testnet"), ("369", "pulse"), ("371", "consta_testnet"), + ("380", "zkamoeba_testnet"), + ("381", "zkamoeba"), ("385", "lisinski"), ("399", "nativ3"), ("400", "hyperon_testnet"), @@ -265,6 +268,7 @@ pub fn get_network_names() -> HashMap { ("558", "tao"), ("568", "doge_testnet"), ("570", "rollux"), + ("571", "meta"), ("588", "metis_stardust_testnet"), ("592", "astar"), ("595", "acala_mandala_testnet_tc9"), @@ -273,11 +277,13 @@ pub fn get_network_names() -> HashMap { ("599", "metis_goerli_testnet"), ("600", "meshnyan_testnet"), ("601", "vine_testnet"), + ("612", "eiob"), ("614", "graphlinq_block"), ("634", "avocado"), ("647", "sx_testnet"), ("648", "endurance"), - ("653", "kali"), + ("653", "kali_testnet"), + ("654", "kali"), ("666", "pixie_testnet"), ("667", "laos_arrakis"), ("668", "junca"), @@ -303,6 +309,7 @@ pub fn get_network_names() -> HashMap { ("800", "lucid_block"), ("803", "haic"), ("808", "portal_fantasy_test"), + ("810", "haven1_testnet"), ("813", "qitmeer"), ("814", "fire_zkevm"), ("818", "beone"), @@ -424,7 +431,7 @@ pub fn get_network_names() -> HashMap { ("1442", "polygon_zkevm_testnet"), ("1452", "gil_testnet"), ("1455", "ctex_scan_block"), - ("1501", "bevm"), + ("1501", "bevm_canary"), ("1506", "sherpax"), ("1507", "sherpax_testnet"), ("1515", "beagle_messaging"), @@ -532,7 +539,7 @@ pub fn get_network_names() -> HashMap { ("2458", "hybrid_testnet"), ("2468", "hybrid"), ("2484", "unicorn_ultra_nebulas_testnet"), - ("2522", "frax_testnet"), + ("2522", "fraxtal_testnet"), ("2559", "kortho"), ("2569", "techpay"), ("2606", "pocrnet"), @@ -576,6 +583,7 @@ pub fn get_network_names() -> HashMap { ("3701", "xpla_testnet"), ("3737", "crossbell"), ("3797", "alvey"), + ("3799", "tangle_testnet"), ("3885", "fire_zkevm_ghostrider"), ("3888", "kaly"), ("3889", "kaly_testnet"), @@ -601,6 +609,7 @@ pub fn get_network_names() -> HashMap { ("4181", "phi_v1"), ("4201", "lukso_testnet"), ("4242", "nexi"), + ("4243", "nexi_v2"), ("4328", "bobafuji_testnet"), ("4337", "beam"), ("4400", "credit"), @@ -654,6 +663,7 @@ pub fn get_network_names() -> HashMap { ("6661", "cybria"), ("6666", "cybria_testnet"), ("6688", "irishub"), + ("6701", "paxb"), ("6779", "compverse"), ("6789", "gold"), ("6969", "tomb"), @@ -680,6 +690,7 @@ pub fn get_network_names() -> HashMap { ("7777", "rise_of_the_warbots_testnet"), ("7860", "maal_testnet"), ("7878", "hazlor_testnet"), + ("7887", "kinto"), ("7895", "ardenium_athena"), ("7979", "dos"), ("8000", "teleport"), @@ -732,6 +743,7 @@ pub fn get_network_names() -> HashMap { ("9170", "rinia_testnet_old"), ("9223", "codefin"), ("9339", "dogcoin_testnet"), + ("9395", "evoke"), ("9527", "rangers_protocol_testnet_robin"), ("9528", "qeasyweb3_testnet"), ("9559", "neonlink_testnet"), @@ -819,6 +831,7 @@ pub fn get_network_names() -> HashMap { ("20001", "camelark"), ("20729", "callisto_testnet"), ("20736", "p12"), + ("20765", "jono11_subnet"), ("21337", "cennznet_azalea"), ("21816", "om"), ("21912", "bsl"), @@ -834,6 +847,7 @@ pub fn get_network_names() -> HashMap { ("23888", "blast_testnet"), ("24484", "web"), ("24734", "mintme.com"), + ("25186", "liquidlayer"), ("25888", "hammer"), ("25925", "bitkub_testnet"), ("26026", "ferrum_testnet"), @@ -847,7 +861,9 @@ pub fn get_network_names() -> HashMap { ("31223", "cloudtx"), ("31224", "cloudtx_testnet"), ("31337", "go_testnet"), + ("31414", "evoke_testnet"), ("31415", "filecoin___wallaby_testnet"), + ("32001", "w3gamez_holesky_testnet"), ("32520", "bitgert"), ("32659", "fusion"), ("32769", "zilliqa_evm"), @@ -884,6 +900,7 @@ pub fn get_network_names() -> HashMap { ("44444", "fren"), ("44787", "celo_alfajores_testnet"), ("45000", "autobahn"), + ("45510", "deelance"), ("46688", "fusion_testnet"), ("47805", "rei"), ("49049", "wireshape_floripa_testnet"), @@ -970,6 +987,7 @@ pub fn get_network_names() -> HashMap { ("91002", "nautilus_trition"), ("91715", "combo_testnet"), ("92001", "lambda_testnet"), + ("93572", "liquidlayer_testnet"), ("96970", "mantis_testnet_hexapod"), ("97288", "boba_bnb_old"), ("99099", "eliberty_testnet"), @@ -1002,12 +1020,14 @@ pub fn get_network_names() -> HashMap { ("111111", "siberium"), ("112358", "meta_one"), ("123456", "adil_devnet"), + ("128123", "etherlink_testnet"), ("131419", "etnds"), ("142857", "icplaza"), ("167004", "taiko_alpha_2_testnet"), ("167005", "taiko_grimsvotn_l2"), ("167006", "taiko_eldfell_l3"), ("167007", "taiko_jolnir_l2"), + ("167008", "taiko_katla_l2"), ("188710", "bitica"), ("188881", "condor_test"), ("200101", "milkomeda_c1_testnet"), @@ -1084,6 +1104,7 @@ pub fn get_network_names() -> HashMap { ("827431", "curve"), ("846000", "4goodnetwork"), ("855456", "dodao"), + ("879151", "blocx"), ("888888", "vision"), ("900000", "posi_shard_0"), ("910000", "posi_testnet_shard_0"), @@ -1100,6 +1121,7 @@ pub fn get_network_names() -> HashMap { ("1337702", "kintsugi"), ("1337802", "kiln"), ("1337803", "zhejiang"), + ("1731313", "turkey_demo_dev"), ("2021398", "debank_testnet"), ("2099156", "plian_main"), ("2206132", "platon_dev_testnet2"), @@ -1139,6 +1161,7 @@ pub fn get_network_names() -> HashMap { ("22052002", "excelon"), ("27082017", "excoincial_volta_testnet"), ("27082022", "excoincial"), + ("28122024", "ancient8_testnet"), ("28945486", "auxilium"), ("29032022", "fla"), ("31415926", "filecoin___local_testnet"), @@ -1188,7 +1211,6 @@ pub fn get_network_names() -> HashMap { ("1666900001", "harmony_devnet_shard_1"), ("2021121117", "datahopper"), ("2046399126", "skale_europa_hub"), - ("2863311531", "ancient8_testnet"), ("3125659152", "pirl"), ("4216137055", "oneledger_testnet_frankenstein"), ("11297108099", "palm_testnet"), From 0cdd87347235c77851fac819cb091457bf886e39 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 13:57:18 -0800 Subject: [PATCH 30/85] fix status subcommand --- rust/crates/mesc_cli/src/cli/subcommands/help.rs | 2 +- rust/crates/mesc_cli/src/cli/subcommands/status.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index 75cdc1e..f13b1c2 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -57,7 +57,7 @@ pub(crate) fn print_interactive_help() -> Result<(), MescCliError> { println!(); print_help_topic(topic)?; println!() - }, + } Err(inquire::InquireError::OperationCanceled) => return Ok(()), Err(e) => return Err(e.into()), } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/status.rs b/rust/crates/mesc_cli/src/cli/subcommands/status.rs index 03815af..35f47f4 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/status.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/status.rs @@ -61,6 +61,7 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { None } Ok(config) => { + keys.push("config found"); values.push(format!("{}", "true".to_string().green())); Some(config) } @@ -94,7 +95,7 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { include_header_row: false, indent: 4, column_formats: Some(column_formats), - column_delimiter: " ".to_string(), + column_delimiter: " ".to_string(), ..format }; let mut table = toolstr::Table::default(); @@ -132,5 +133,14 @@ pub(crate) fn status_command(args: StatusArgs) -> Result<(), MescCliError> { } }; + if !args.verbose { + println!(); + println!( + "use {} or {} to print additional information", + "-v".bold().white(), + "--verbose".bold().white() + ) + } + Ok(()) } From 5cb1086c237f2b38c3a3095466823f3d64a62052 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Thu, 25 Jan 2024 21:27:34 -0800 Subject: [PATCH 31/85] add mesc set subcommand --- rust/crates/mesc_cli/src/cli/args.rs | 57 ++- .../mesc_cli/src/cli/subcommands/import.rs | 5 + .../mesc_cli/src/cli/subcommands/mod.rs | 2 + .../mesc_cli/src/cli/subcommands/set.rs | 341 ++++++++++++++++++ 4 files changed, 393 insertions(+), 12 deletions(-) create mode 100644 rust/crates/mesc_cli/src/cli/subcommands/set.rs diff --git a/rust/crates/mesc_cli/src/cli/args.rs b/rust/crates/mesc_cli/src/cli/args.rs index e1d3c1b..5d08e2c 100644 --- a/rust/crates/mesc_cli/src/cli/args.rs +++ b/rust/crates/mesc_cli/src/cli/args.rs @@ -7,6 +7,7 @@ pub(crate) async fn run_cli() -> Result<(), MescCliError> { match Cli::parse().command { Commands::Setup(args) => setup_command(args).await, Commands::Import(args) => import_command(args).await, + Commands::Set(args) => set_command(args).await, Commands::Status(args) => status_command(args), Commands::Ls(args) => ls_command(args), Commands::Defaults(args) => defaults_command(args), @@ -43,26 +44,30 @@ pub(crate) struct Cli { /// Define your subcommands as an enum #[derive(Subcommand)] pub(crate) enum Commands { - /// Create new config or modify existing config + /// Create or modify config interactively Setup(SetupArgs), - /// Import a config from file or external source + /// Modify config by importing from file or other source Import(ImportArgs), - /// Print status of configuration - Status(StatusArgs), - /// Print list of endpoints - Ls(LsArgs), - /// Print list of defaults - Defaults(DefaultsArgs), + /// Modify config by setting specific values + /// + /// This command is idempotent + Set(SetArgs), /// Ping endpoints and fetch metadata Ping(PingArgs), + /// Print list of defaults + Defaults(DefaultsArgs), /// Print endpoint Endpoint(EndpointArgs), - /// Print metadata - Metadata(MetadataArgs), - /// Print endpoint URL - Url(UrlArgs), /// Print help Help(HelpArgs), + /// Print list of endpoints + Ls(LsArgs), + /// Print metadata + Metadata(MetadataArgs), + /// Print status of configuration + Status(StatusArgs), + /// Print endpoint URL + Url(UrlArgs), } /// Arguments for the `setup` subcommand @@ -105,6 +110,34 @@ pub(crate) struct ImportArgs { pub(crate) output_path: Option, } +/// Arguments for the `set` subcommand +#[derive(Parser)] +pub(crate) struct SetArgs { + /// key to set + #[clap()] + pub(crate) key: Option, + + /// value to set + #[clap()] + pub(crate) value: Option, + + /// space-separated list of keys + #[clap(long)] + pub(crate) keys: Option>, + + /// space-separated list of values (must match --keys) + #[clap(long)] + pub(crate) values: Option>, + + /// delete specified key(s) instead of setting them + #[clap(long)] + pub(crate) delete: bool, + + /// config path to use [default: MESC_PATH] + #[clap(long)] + pub(crate) path: Option, +} + /// Arguments for the `status` subcommand #[derive(Parser)] pub(crate) struct StatusArgs { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/import.rs b/rust/crates/mesc_cli/src/cli/subcommands/import.rs index 4c6a3c0..b56c530 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/import.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/import.rs @@ -1,7 +1,12 @@ use crate::{ImportArgs, MescCliError}; use mesc::RpcConfig; +#[allow(unreachable_code)] +#[allow(unused_variables)] pub(crate) async fn import_command(args: ImportArgs) -> Result<(), MescCliError> { + println!("import command under construction, try again later"); + return Ok(()); + // get output path let output_path = match (args.output_path, std::env::var("MESC_PATH")) { (Some(path), _) => path, diff --git a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs index 0f642fc..dcbe01e 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/mod.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/mod.rs @@ -5,6 +5,7 @@ mod import; mod ls; mod metadata; mod ping; +mod set; mod setup; mod status; mod url; @@ -16,6 +17,7 @@ pub(crate) use import::*; pub(crate) use ls::*; pub(crate) use metadata::*; pub(crate) use ping::*; +pub(crate) use set::*; pub(crate) use setup::*; pub(crate) use status::*; pub(crate) use url::*; diff --git a/rust/crates/mesc_cli/src/cli/subcommands/set.rs b/rust/crates/mesc_cli/src/cli/subcommands/set.rs new file mode 100644 index 0000000..b7b73ec --- /dev/null +++ b/rust/crates/mesc_cli/src/cli/subcommands/set.rs @@ -0,0 +1,341 @@ +use crate::{MescCliError, SetArgs}; +use mesc::{RpcConfig, TryIntoChainId}; +use serde_json::{Map, Value}; +use std::collections::HashMap; +use toolstr::Colorize; + +pub(crate) async fn set_command(args: SetArgs) -> Result<(), MescCliError> { + // load old config data + let path = match (args.path.clone(), mesc::load::get_config_mode()) { + (Some(path), _) => path, + (_, Ok(mesc::ConfigMode::Path)) => mesc::load::get_config_path()?, + _ => { + eprintln!("to use set, must be in MESC_MODE=PATH or use the --path argument"); + std::process::exit(1); + } + }; + let mut config = match mesc::load::load_file_config(Some(path.clone())) { + Ok(data) => data, + Err(e) => { + eprintln!("could not load MESC config: {}", e); + std::process::exit(1); + } + }; + let old_config = config.clone(); + + // decide what to edit + let kv_pairs = determine_kv_pairs(&args)?; + let n_kv_pairs = kv_pairs.len(); + + // edit + for (key, value) in kv_pairs.into_iter() { + if let Some(value) = value { + set_config_value(&mut config, key, value)? + } else { + delete_config_value(&mut config, key)? + } + } + + // check that new config is valid + if let Err(e) = config.validate() { + eprintln!("Aborting because these updated resulted in an invalid config: {}", e); + std::process::exit(1); + } + + // write new file + if config != old_config { + mesc::write::write_config(config, path)?; + if n_kv_pairs == 1 { + println!("Applied {} update to config", n_kv_pairs.to_string().green().bold()); + } else { + println!("Applied {} updates to config", n_kv_pairs.to_string().green().bold()); + } + } else { + println!("Updates did not change the content of the config"); + } + + Ok(()) +} + +fn determine_kv_pairs(args: &SetArgs) -> Result)>, MescCliError> { + let kv_pairs = match ( + args.key.clone(), + args.value.clone(), + args.keys.clone(), + args.values.clone(), + args.delete, + ) { + (None, _, None, _, _) => { + return Err(MescCliError::InvalidInput("specify one of key or --keys".to_string())) + } + (Some(_), _, Some(_), _, _) => { + return Err(MescCliError::InvalidInput("cannot specify both key and --keys".to_string())) + } + (_, None, _, None, false) => { + return Err(MescCliError::InvalidInput("specify value or --values".to_string())) + } + (_, Some(_), _, Some(_), _) => { + return Err(MescCliError::InvalidInput( + "cannot specify both value and --values".to_string(), + )) + } + (_, Some(_), _, _, true) | (_, _, _, Some(_), true) => { + return Err(MescCliError::InvalidInput( + "cannot specify value or --values when using --delete".to_string(), + )) + } + (_, _, None, Some(_), false) => { + return Err(MescCliError::InvalidInput( + "must specify --keys when using --values".to_string(), + )) + } + (Some(key), Some(value), None, None, false) => vec![(key, Some(value))], + (Some(key), None, None, None, true) => vec![(key, None)], + (None, None, Some(keys), Some(values), false) => { + keys.into_iter().zip(values.into_iter().map(Some)).collect() + } + (None, None, Some(keys), None, true) => keys.into_iter().map(|k| (k, None)).collect(), + (None, Some(value), Some(keys), None, false) => { + keys.into_iter().map(|k| (k, Some(value.clone()))).collect() + } + }; + Ok(kv_pairs) +} + +fn set_config_value( + config: &mut RpcConfig, + key: String, + value: String, +) -> Result<(), MescCliError> { + let parts = key.split("\\.").flat_map(|part| part.split('.')).collect::>(); + match parts.as_slice() { + ["mesc_version"] => config.mesc_version = value, + ["default_endpoint"] => config.default_endpoint = Some(value), + ["endpoints", endpoint_name] => { + config + .endpoints + .insert(endpoint_name.to_string(), serde_json::from_str(value.as_str())?); + } + ["endpoints", endpoint_name, rest @ ..] => { + let rest = rest.to_vec(); + if (rest.len() == 1) & (rest[0] == "name") { + mesc::write::update_endpoint_name(config, endpoint_name, value.as_str())?; + return Ok(()); + } + if let Some(endpoint) = config.endpoints.get_mut(*endpoint_name) { + match rest.as_slice() { + ["url"] => endpoint.url = value, + ["chain_id"] => endpoint.chain_id = Some(value.try_into_chain_id()?), + ["endpoint_metadata", location @ ..] => { + set_metadata_entry(&mut endpoint.endpoint_metadata, location, value)?; + } + _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), + } + }; + } + ["network_defaults", chain_id] => { + config.network_defaults.insert(chain_id.try_into_chain_id()?, value); + } + ["network_names", network_name] => { + config.network_names.insert(network_name.to_string(), value.try_into_chain_id()?); + } + ["profiles", profile_name] => { + config.profiles.insert(profile_name.to_string(), serde_json::from_str(value.as_str())?); + } + ["profiles", profile_name, rest @ ..] => { + let rest = rest.to_vec(); + if let Some(profile) = config.profiles.get_mut(*profile_name) { + match rest.as_slice() { + ["name"] => profile.name = value, + ["default_endpoint"] => profile.default_endpoint = Some(value), + ["network_defaults", chain_id] => { + profile.network_defaults.insert(chain_id.try_into_chain_id()?, value); + } + ["profile_metadata", location @ ..] => { + set_metadata_entry(&mut profile.profile_metadata, location, value)?; + } + ["use_mesc"] => match value.parse::() { + Ok(as_bool) => profile.use_mesc = as_bool, + Err(_) => { + return Err(MescCliError::InvalidInput( + "use_mesc must be a bool value".to_string(), + )) + } + }, + _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), + } + } + } + ["global_metadata", location @ ..] => { + set_metadata_entry(&mut config.global_metadata, location, value)?; + } + _ => return Err(MescCliError::InvalidInput(format!("cannot delete key: {}", key))), + }; + Ok(()) +} + +fn delete_config_value(config: &mut RpcConfig, key: String) -> Result<(), MescCliError> { + let parts = key.split("\\.").flat_map(|part| part.split('.')).collect::>(); + match parts.as_slice() { + ["mesc_version"] => { + return Err(MescCliError::InvalidInput("cannot delete mesc_version".to_string())) + } + ["default_endpoint"] => config.default_endpoint = None, + ["endpoints", endpoint_name] => { + config.endpoints.remove(endpoint_name.to_string().as_str()); + } + ["endpoints", endpoint_name, rest @ ..] => { + let rest = rest.to_vec(); + if let Some(endpoint) = config.endpoints.get_mut(*endpoint_name) { + match rest.as_slice() { + ["name"] => { + return Err(MescCliError::InvalidInput( + "cannot delete endpoint name".to_string(), + )) + } + ["url"] => { + return Err(MescCliError::InvalidInput( + "cannot delete endpoint url".to_string(), + )) + } + ["chain_id"] => { + endpoint.chain_id = None; + } + ["endpoint_metadata", location @ ..] => { + delete_metadata_entry(&mut endpoint.endpoint_metadata, location)?; + } + _ => { + return Err(MescCliError::InvalidInput(format!( + "cannot delete key: {}", + key + ))) + } + } + } + } + ["network_defaults", chain_id] => { + config.network_defaults.remove(&chain_id.try_into_chain_id()?); + } + ["network_names", network_name] => { + config.network_names.remove(*network_name); + } + ["profiles", profile_name] => { + config.profiles.remove(*profile_name); + } + ["profiles", profile_name, rest @ ..] => { + let rest = rest.to_vec(); + if let Some(profile) = config.profiles.get_mut(*profile_name) { + match rest.as_slice() { + ["name"] => { + return Err(MescCliError::InvalidInput( + "cannot delete profile name".to_string(), + )) + } + ["default_endpoint"] => profile.default_endpoint = None, + ["network_defaults", chain_id] => { + profile.network_defaults.remove(&chain_id.try_into_chain_id()?); + } + ["profile_metadata", location @ ..] => { + delete_metadata_entry(&mut profile.profile_metadata, location)?; + } + ["use_mesc"] => { + return Err(MescCliError::InvalidInput( + "cannot delete profile use_mesc".to_string(), + )) + } + _ => { + return Err(MescCliError::InvalidInput(format!( + "cannot delete key: {}", + key + ))) + } + } + } + } + ["global_metadata", location @ ..] => { + delete_metadata_entry(&mut config.global_metadata, location)?; + } + _ => return Err(MescCliError::InvalidInput(format!("cannot delete key: {}", key))), + }; + Ok(()) +} + +fn set_metadata_entry( + metadata: &mut HashMap, + location: &[&str], + json_content: String, +) -> Result<(), MescCliError> { + if location.is_empty() { + return Err(MescCliError::InvalidInput("must specify metadata path to set".to_string())); + } + + let parsed_value = serde_json::from_str(&json_content) + .map_err(|e| MescCliError::InvalidInput(format!("Failed to parse JSON content: {}", e)))?; + + if location.len() == 1 { + metadata.insert(location[0].to_string(), parsed_value); + return Ok(()); + } + + let mut current_value = + metadata.entry(location[0].to_string()).or_insert_with(|| Value::Object(Map::new())); + + for &key in &location[1..location.len() - 1] { + current_value = match current_value { + Value::Object(map) => { + map.entry(key.to_string()).or_insert_with(|| Value::Object(Map::new())) + } + _ => return Err(MescCliError::InvalidInput(format!("Invalid path: {}", key))), + }; + } + + if let Some(last_key) = location.last() { + if let Value::Object(map) = current_value { + map.insert(last_key.to_string(), parsed_value); + } else { + return Err(MescCliError::InvalidInput("Target is not an object".to_string())); + } + } + + Ok(()) +} + +fn delete_metadata_entry( + metadata: &mut HashMap, + location: &[&str], +) -> Result<(), MescCliError> { + if location.is_empty() { + return Err(MescCliError::InvalidInput("must specify metadata path to delete".to_string())); + } + + if location.len() == 1 { + metadata.remove(location[0]); + return Ok(()); + } + + let mut current_value = match metadata.get_mut(location[0]) { + Some(value) => value, + None => return Ok(()), + }; + + for &key in &location[1..location.len() - 1] { + current_value = match current_value { + Value::Null => return Ok(()), + Value::Object(map) => match map.get_mut(key) { + Some(value) => value, + None => return Ok(()), + }, + _ => return Err(MescCliError::InvalidInput(format!("Invalid path: {}", key))), + }; + } + + if let Some(last_key) = location.last() { + if let Value::Object(map) = current_value { + map.remove(*last_key); + } else { + return Err(MescCliError::InvalidInput("Target is not an object".to_string())); + } + } + + Ok(()) +} From 144ea440d2bdc405768c229ed2ed8b3cc7294cd3 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Fri, 26 Jan 2024 18:57:08 -0800 Subject: [PATCH 32/85] replace custom test runner with pytest --- python/mesc/interface.py | 2 + tests/README.md | 31 +++- tests/conftest.py | 18 +++ tests/generate.py | 2 +- tests/generated/.gitkeep | 0 tests/run.py | 302 --------------------------------------- tests/test.py | 204 ++++++++++++++++++++++++++ 7 files changed, 250 insertions(+), 309 deletions(-) create mode 100644 tests/conftest.py delete mode 100644 tests/generated/.gitkeep delete mode 100755 tests/run.py create mode 100644 tests/test.py diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 970e274..6e63cfe 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -51,6 +51,8 @@ def get_endpoint_by_name( """get MESC endpoint by name""" if config is None: config = load.read_config_data() + if not isinstance(name, str): + raise Exception('invalid type for name query, it must be a str') return config['endpoints'].get(name) diff --git a/tests/README.md b/tests/README.md index 28c6a34..49534e4 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,17 +6,36 @@ These tests measure the degree to which a MESC implementation is compliant with These tests are language-agnostic, allowing the same tests to be run against each MESC implementation. ## Usage -1. `generate.py` generates tests in the `generated/` directory -2. `run.py adapters/` runs the tests for the given adapter + +1. Install `pytest` (and `pytest-xdist` for parallel testing): +`pip install pytest pytest-xdist` + + +2. Then run one of the following commands: + +|description | command | +| --- | --- | +| run tests | `pytest test.py` | +| run test in parallel (much faster) | `pytest test.py -n auto` | +| run tests in debug mode (helpful for debugging) | `pytest test.py --pdb` | +| run tests for just one adapter | `pytest test.py --adapters adapters/python` | + ## Adapters -Each MESC implementation has an adapter that allows running the tests using the test runner. +Each MESC implementation has an adapter that receives a test as input and prints the result as output. Adapters are located in the [adapters](https://github.com/paradigmxyz/mesc/tree/main/tests/adapters) directory. To make a custom adapter: -1. adapter should be a script that takes a JSON `Query` as its single argument -2. the adapter should run the query and output the result as JSON -3. if the config loading or the query fails, simply output the word `FAIL` +1. adapter should be a script that takes a JSON [`MescQuery`](https://github.com/paradigmxyz/mesc/blob/5cb1086c237f2b38c3a3095466823f3d64a62052/python/mesc/types.py#L115) as its single argument +2. the adapter should run the query, and then print the result as JSON +3. if the config loading or the query fails, simply print the word `FAIL` The adapter should never crash upon failure, just print the word `FAIL` + +## Files +- `adapters/` contains a test adapter for each MESC implementation +- `conftest.py` configuration file for pytest +- `generate.py` generates all of the MESC test cases +- `test.py` packages MESC tests into form usable by pypi + diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..4093dd1 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,18 @@ +from __future__ import annotations + +from _pytest.config.argparsing import Parser +from _pytest.fixtures import FixtureRequest +import pytest + + +def pytest_addoption(parser: Parser) -> None: + parser.addoption("--adapter", action="append") + + +@pytest.fixture +def adapter(request: FixtureRequest) -> str: + adapter = request.config.getoption("adapter") + if isinstance(adapter, str): + return adapter + else: + raise Exception("must use str adapter") diff --git a/tests/generate.py b/tests/generate.py index ba57530..856191e 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -9,7 +9,7 @@ import time from typing import Any, TypeVar, Sequence from mesc import RpcConfig, Profile, Endpoint -from mesc.types import EndpointQuery, MultiEndpointQuery, GlobalMetadataQuery, MescQuery +from mesc.types import MescQuery blank_config: RpcConfig = { "mesc_version": "MESC 1.0", diff --git a/tests/generated/.gitkeep b/tests/generated/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/run.py b/tests/run.py deleted file mode 100755 index 7fa5d0b..0000000 --- a/tests/run.py +++ /dev/null @@ -1,302 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import contextlib -import os -import json -import shutil -import subprocess -import sys -import tempfile -from typing import Any, Callable, ContextManager, Generator, Mapping, MutableSequence - -from mesc.types import EndpointQuery, MultiEndpointQuery, RpcConfig - - -# tests are in form [test_name, env, config, query, result, should_succeed] -Test = tuple[ - str, - dict[str, str], - RpcConfig, - None | EndpointQuery | MultiEndpointQuery, - Any, - bool, -] - - -class OutputDoesNotMatch(Exception): - pass - - -class FailedQuery(Exception): - pass - - -def get_setups() -> ( - Mapping[str, Callable[[RpcConfig], ContextManager[Mapping[str, str]]]] -): - return { - "path": setup_config_path, - "env": setup_config_env_var, - } - - -@contextlib.contextmanager -def setup_config_path(config: RpcConfig) -> Generator[Mapping[str, str], None, None]: - temp_dir = tempfile.mkdtemp() - temp_path = os.path.join(temp_dir, "config.json") - with open(temp_path, "w") as f: - json.dump(config, f) - try: - yield {"MESC_MODE": "PATH", "MESC_PATH": temp_path} - finally: - shutil.rmtree(temp_dir) - - -@contextlib.contextmanager -def setup_config_env_var(config: RpcConfig) -> Generator[Mapping[str, str], None, None]: - config_data = json.dumps(config) - try: - yield {"MESC_MODE": "ENV", "MESC_ENV": config_data} - finally: - pass - - -def parse_args() -> Mapping[str, Any]: - parser = argparse.ArgumentParser() - parser.add_argument("adapters", help="path to adapter", nargs="+") - parser.add_argument( - "--verbose", help="print extra error output", action="store_true" - ) - parser.add_argument("--halt", help="halt on first error", action="store_true") - parser.add_argument( - "--generated-path", - help="path to generated tests", - default="./generated/tests.json", - ) - parser.add_argument('--index', help='test indices to run', nargs='+') - args = parser.parse_args() - - return { - "adapters": args.adapters, - "generated_path": args.generated_path, - "verbose": args.verbose, - "halt": args.halt, - 'index': args.index, - } - - -def run_test( - test: Test, - adapter: str, - setup_name: str, - setup_env: Mapping[str, str], - halt: bool, - verbose: bool, - successes: MutableSequence[tuple[str, str, str]], - failures: MutableSequence[tuple[str, str, str, str]], - index: int, -) -> None: - test_name, test_env, config, query, target_result, should_succeed = test - - # run command - try: - # create env - env = {} - env["PATH"] = os.environ["PATH"] - env.update(setup_env) - env.update(test_env) - - cmd = [adapter, json.dumps(query)] - output = subprocess.check_output([sys.executable] + cmd, env=env) - except Exception: - if halt: - sys.exit() - message = "adapter broken, test failed to complete" - failures.append((adapter, setup_name, test_name, message)) - return - - # parse output - try: - actual_result = json.loads(output.decode("utf-8").strip()) - if not json_equal(actual_result, target_result): - raise OutputDoesNotMatch("") - if should_succeed: - successes.append((adapter, setup_name, test_name)) - else: - message = "success when expecting failure" - failures.append((adapter, setup_name, test_name, message)) - if verbose: - print(message) - print_summary( - config=config, - env=env, - test_name=test_name, - query=query, - output=output, - target_result=target_result, - exception=None, - successes=successes, - failures=failures, - index=index, - ) - if halt: - sys.exit() - else: - return - except Exception as exception: - if should_succeed: - if verbose: - print_summary( - config=config, - env=env, - test_name=test_name, - query=query, - output=output, - target_result=target_result, - exception=exception, - successes=successes, - failures=failures, - index=index, - ) - if halt: - sys.exit() - if len(output) == 0: - message = "no output" - elif output.decode("utf-8").startswith("FAIL"): - message = "QueryFailed:" - else: - message = str(type(exception).__name__) + ": " + str(exception.args[0]) - failures.append((adapter, setup_name, test_name, message)) - else: - successes.append((adapter, setup_name, test_name)) - - -def print_summary( - config: Any, - env: Mapping[str, str], - test_name: str, - query: Any, - output: Any, - target_result: Any, - exception: Exception | None, - successes: MutableSequence[tuple[str, str, str]], - failures: MutableSequence[tuple[str, str, str, str]], - index: int, -) -> None: - print("CONFIG", json.dumps(config, sort_keys=True, indent=4)) - print( - "ENV:", - json.dumps( - {k: v for k, v in env.items() if k != "PATH"}, - sort_keys=True, - indent=4, - ), - ) - print("QUERY:", query) - try: - print( - "OUTPUT:", - json.dumps(json.loads(output.decode("utf-8")), indent=4, sort_keys=True), - ) - except Exception: - print("OUTPUT:", output.decode("utf-8").strip()) - print("EXPECTED:", json.dumps(target_result, indent=4, sort_keys=True)) - print("EXCEPTION:", type(exception), exception) - print("TEST_NAME:", test_name) - print("INDEX:", index) - - -def json_equal(lhs: Any, rhs: Any) -> bool: - return cannonical_json(lhs) == cannonical_json(rhs) - - -def cannonical_json(data: Any): - if isinstance(data, list): - data = sorted(cannonical_json(item) for item in data) - return json.dumps(data, sort_keys=True) - - -if __name__ == "__main__": - # load data - args = parse_args() - adapters = args["adapters"] - setups = get_setups() - with open(args["generated_path"], "r") as f: - tests = json.load(f) - - # store successes as (adapter, test_name, setup_name) - successes: MutableSequence[tuple[str, str, str]] = [] - - # store failures as (adapter, test_name, setup_name, error) - failures: MutableSequence[tuple[str, str, str, str]] = [] - - # run tests - if len(adapters) == 1: - word = 'adapter' - else: - word = 'adapters' - print( - "testing", - len(tests), - "queries in", - len(setups), - "modes for", - len(adapters), - word - ) - index = -1 - for adapter in adapters: - for test in tests: - for setup_name, setup in setups.items(): - with setup(test[2]) as setup_env: - index += 1 - if args['index'] is not None and str(index) not in args['index']: - continue - run_test( - adapter=adapter, - test=test, - setup_name=setup_name, - setup_env=setup_env, - halt=args["halt"], - verbose=args["verbose"], - successes=successes, - failures=failures, - index=index, - ) - - # summary - print() - print(len(successes), "/", len(adapters) * len(setups) * len(tests), "tests successful") - n_failures = len(failures) - if n_failures == 0: - print() - print("SUCCESS") - else: - print() - print(n_failures, "total failures:") - - try: - import toolstr - - labels = ["adapter", "mode", "test", "error"] - rows = [list(row) for row in failures] - for row in rows: - row[0] = row[0].split("/")[-1] - row[2] = row[2].replace(", ", "\n") - row[3] = row[3] - column_justify = {"error": "left"} - toolstr.print_multiline_table( - rows, - separate_all_rows=False, - compact=3, - labels=labels, - add_row_index=True, - max_table_width=shutil.get_terminal_size().columns, - column_justify=column_justify, - ) - except ImportError: - for failure in failures: - print("-", failure) - print() - print("FAILURE") diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..0492bc9 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,204 @@ +from __future__ import annotations + +import contextlib +import os +import json +import shutil +import subprocess +import sys +import tempfile +from typing import ( + Any, + Callable, + ContextManager, + Generator, + Mapping, + cast, +) +import pytest + +import generate +from mesc.types import EndpointQuery, MultiEndpointQuery, RpcConfig + + +# tests are in form [test_name, env, config, query, result, should_succeed] +Test = tuple[ + str, + dict[str, str], + RpcConfig, + None | EndpointQuery | MultiEndpointQuery, + Any, + bool, +] + + +class AdapterFailure(Exception): + pass + + +class OutputDoesNotMatch(Exception): + pass + + +class QueryFailed(Exception): + pass + + +class QueryShouldHaveFailed(Exception): + pass + + +def get_setups() -> ( + list[tuple[str, Callable[[RpcConfig], ContextManager[Mapping[str, str]]]]] +): + return [ + ("path", setup_config_path), + ("env", setup_config_env_var), + ] + + +@contextlib.contextmanager +def setup_config_path(config: RpcConfig) -> Generator[Mapping[str, str], None, None]: + temp_dir = tempfile.mkdtemp() + temp_path = os.path.join(temp_dir, "config.json") + with open(temp_path, "w") as f: + json.dump(config, f) + try: + yield {"MESC_MODE": "PATH", "MESC_PATH": temp_path} + finally: + shutil.rmtree(temp_dir) + + +@contextlib.contextmanager +def setup_config_env_var(config: RpcConfig) -> Generator[Mapping[str, str], None, None]: + config_data = json.dumps(config) + try: + yield {"MESC_MODE": "ENV", "MESC_ENV": config_data} + finally: + pass + + +tests = generate.generate_tests() + + +@pytest.mark.parametrize("setup", get_setups()) +@pytest.mark.parametrize("test", tests, ids=[test[0] for test in tests]) +def test_mesc_output( + setup: tuple[str, Callable[[RpcConfig], ContextManager[Mapping[str, str]]]], + test: Test, + adapter: str, +) -> None: + # load inputs + if adapter in ["", None]: + raise AdapterFailure("must specify adapter") + test_name, test_env, config, query, target_result, should_succeed = test + setup_name, f_setup = setup + + # run query + env = {} + with f_setup(test[2]) as setup_env: + try: + env["PATH"] = os.environ["PATH"] + env.update(setup_env) + env.update(test_env) + cmd = [adapter, json.dumps(query)] + output = subprocess.check_output([sys.executable] + cmd, env=env) + except Exception: + raise AdapterFailure("adapter broken, test failed to complete") + + # package error data for printing + error_data = dict( + config=config, + env=env, + test_name=test_name, + query=query, + output=output, + target_result=target_result, + ) + + # decode output as json + decode_exception: Exception | None = None + try: + actual_result = json.loads(output.decode("utf-8").strip()) + output_decodable = True + except Exception as e: + actual_result = None + output_decodable = False + decode_exception = e + + # assert whether output is correct + if not output_decodable: + if should_succeed: + # failure case: output could not be decoded + print_error_summary(**error_data) + if len(output) == 0: + message = "no output" + elif output.decode("utf-8").startswith("FAIL"): + message = "QueryFailed:" + else: + exception = cast(Exception, decode_exception) + message = str(type(exception).__name__) + ": " + str(exception.args) + raise QueryFailed(message, adapter, setup_name, test_name) + else: + # working properly + pass + else: + if json_equal(actual_result, target_result): + if should_succeed: + # working properly + pass + else: + # failure case: incorrect query output + print_error_summary(**error_data) + raise OutputDoesNotMatch( + "output does not match", adapter, setup_name, test_name + ) + else: + if should_succeed: + # failure case: query should have failed + print_error_summary(**error_data) + raise QueryShouldHaveFailed( + "success when expecting failure", adapter, setup_name, test_name + ) + else: + # working properly + pass + + +def json_equal(lhs: Any, rhs: Any) -> bool: + return cannonical_json(lhs) == cannonical_json(rhs) + + +def cannonical_json(data: Any) -> str: + if isinstance(data, list): + data = sorted(cannonical_json(item) for item in data) + return json.dumps(data, sort_keys=True) + + +def print_error_summary( + config: Any, + env: Mapping[str, str], + test_name: str, + query: Any, + output: Any, + target_result: Any, +) -> None: + print("CONFIG", json.dumps(config, sort_keys=True, indent=4)) + print( + "ENV:", + json.dumps( + {k: v for k, v in env.items() if k != "PATH"}, + sort_keys=True, + indent=4, + ), + ) + print("QUERY:", query) + try: + print( + "OUTPUT:", + json.dumps(json.loads(output.decode("utf-8")), indent=4, sort_keys=True), + ) + except Exception: + print("OUTPUT:", output.decode("utf-8").strip()) + print("EXPECTED:", json.dumps(target_result, indent=4, sort_keys=True)) + print("TEST_NAME:", test_name) From d408c69de4e980e1031c6fd4d89cdcd5a925ef07 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Fri, 26 Jan 2024 20:03:04 -0800 Subject: [PATCH 33/85] allow using specific subset of test adapters using --adapters --- tests/README.md | 13 +++++++------ tests/conftest.py | 19 ++++++++----------- tests/{test.py => test_mesc.py} | 0 3 files changed, 15 insertions(+), 17 deletions(-) rename tests/{test.py => test_mesc.py} (100%) diff --git a/tests/README.md b/tests/README.md index 49534e4..6bda5e8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -10,15 +10,16 @@ These tests are language-agnostic, allowing the same tests to be run against eac 1. Install `pytest` (and `pytest-xdist` for parallel testing): `pip install pytest pytest-xdist` +2. Go into the `mesc/tests` directory -2. Then run one of the following commands: +3. Then run one of these commands: |description | command | | --- | --- | -| run tests | `pytest test.py` | -| run test in parallel (much faster) | `pytest test.py -n auto` | -| run tests in debug mode (helpful for debugging) | `pytest test.py --pdb` | -| run tests for just one adapter | `pytest test.py --adapters adapters/python` | +| run tests | `pytest` | +| run test in parallel (much faster) | `pytest -n auto` | +| run tests in debug mode (helpful for debugging) | `pytest --pdb` | +| run tests using specific adapters only | `pytest --adapters adapters/python` | ## Adapters @@ -37,5 +38,5 @@ The adapter should never crash upon failure, just print the word `FAIL` - `adapters/` contains a test adapter for each MESC implementation - `conftest.py` configuration file for pytest - `generate.py` generates all of the MESC test cases -- `test.py` packages MESC tests into form usable by pypi +- `test_mesc.py` packages MESC tests into form usable by pypi diff --git a/tests/conftest.py b/tests/conftest.py index 4093dd1..a6d3f97 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,18 +1,15 @@ from __future__ import annotations - from _pytest.config.argparsing import Parser -from _pytest.fixtures import FixtureRequest -import pytest +from _pytest.python import Metafunc + +default_adapters = ["adapters/python", "adapters/cli"] def pytest_addoption(parser: Parser) -> None: - parser.addoption("--adapter", action="append") + parser.addoption("--adapters", action="store", nargs="+", default=default_adapters) -@pytest.fixture -def adapter(request: FixtureRequest) -> str: - adapter = request.config.getoption("adapter") - if isinstance(adapter, str): - return adapter - else: - raise Exception("must use str adapter") +def pytest_generate_tests(metafunc: Metafunc) -> None: + if "adapter" in metafunc.fixturenames: + adapters = metafunc.config.getoption("adapters") + metafunc.parametrize("adapter", adapters, scope="function") diff --git a/tests/test.py b/tests/test_mesc.py similarity index 100% rename from tests/test.py rename to tests/test_mesc.py From 87b79f499ad072eabf7424ea943ef313b43384fb Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 17:54:09 -0800 Subject: [PATCH 34/85] revamp docs --- book/src/SUMMARY.md | 23 +++++------- book/src/cli.md | 2 +- book/src/creating_a_config.md | 1 - book/src/developer_resources.md | 7 ++++ book/src/environment_variables.md | 1 - book/src/go.md | 2 +- book/src/integrating_mesc.md | 59 +++++++++++++++++++++++++++++++ book/src/libraries.md | 14 ++++++++ book/src/mesc_libraries.md | 1 - book/src/mesc_overview.md | 22 +++++++----- book/src/mesc_tests.md | 2 ++ book/src/metadata.md | 42 ++++++++++++++++++++++ book/src/overrides.md | 57 +++++++++++++++++++++++++++++ book/src/profiles.md | 31 ++++++++++++++++ book/src/python.md | 2 +- book/src/queries.md | 17 +++++++++ book/src/quickstart.md | 19 ++++++++-- book/src/roadmap.md | 6 ++++ book/src/rust.md | 2 +- book/src/setting_up_mesc.md | 1 - book/src/setup.md | 29 +++++++++++++++ book/src/typescript.md | 2 +- book/src/using_mesc.md | 7 ++++ book/src/what_is_mesc.md | 24 +++++++++++++ book/src/why_mesc.md | 16 +++++++++ cli/README.md | 23 ++++++++---- rust/README.md | 2 ++ tests/README.md | 15 ++++---- 28 files changed, 381 insertions(+), 48 deletions(-) delete mode 100644 book/src/creating_a_config.md delete mode 100644 book/src/environment_variables.md create mode 100644 book/src/libraries.md delete mode 100644 book/src/mesc_libraries.md create mode 100644 book/src/mesc_tests.md create mode 100644 book/src/queries.md create mode 100644 book/src/roadmap.md delete mode 100644 book/src/setting_up_mesc.md create mode 100644 book/src/setup.md create mode 100644 book/src/using_mesc.md create mode 100644 book/src/what_is_mesc.md create mode 100644 book/src/why_mesc.md diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 120569e..4b2cf0e 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -1,26 +1,21 @@ # MESC User Guide - [MESC Overview](./mesc_overview.md) - - - -- [Basic MESC Usage]() - [Quickstart](./quickstart.md) - - [Creating a config](./creating_a_config.md) - - [Environment variables](./environment_variables.md) + - [What is MESC?](./what_is_mesc.md) + - [Why MESC?](./why_mesc.md) + - [Roadmap](./roadmap.md) +- [Using MESC](./using_mesc.md) + - [Setting up MESC](./setup.md) - [Profiles](./profiles.md) - [Metadata](./metadata.md) - [Overrides](./overrides.md) - - - -- [Developer Resources]() + - [Queries](./queries.md) +- [Developer Resources](./developer_resources.md) - [Integrating MESC](./integrating_mesc.md) - [Implementing MESC](./implementing_mesc.md) - - - -- [MESC Libraries]() + - [MESC Tests](./mesc_tests.md) +- [MESC Libraries](./libraries.md) - [CLI](./cli.md) - [Go](./go.md) - [Python](./python.md) diff --git a/book/src/cli.md b/book/src/cli.md index 3f213d4..f7a9c1c 100644 --- a/book/src/cli.md +++ b/book/src/cli.md @@ -1 +1 @@ -# CLI +{{#include ../../cli/README.md}} diff --git a/book/src/creating_a_config.md b/book/src/creating_a_config.md deleted file mode 100644 index bd0786f..0000000 --- a/book/src/creating_a_config.md +++ /dev/null @@ -1 +0,0 @@ -# Creating a config diff --git a/book/src/developer_resources.md b/book/src/developer_resources.md index a67a443..a6ce921 100644 --- a/book/src/developer_resources.md +++ b/book/src/developer_resources.md @@ -1 +1,8 @@ # Developer Resources + +The MESC specification and its reference implementations are developed in the [github repository](https://github.com/paradigmxyz/mesc). +- For information about integrating MESC into an existing tool, see [Integrating MESC](./integrating_mesc.md). +- For information about implementing a new MESC client, see [Implementing MESC](./implementing_mesc.md). +- For information about running MESC tests, see [MESC Test README](https://github.com/paradigmxyz/mesc/tree/main/tests). +- For information about building these docs, see [here](https://github.com/paradigmxyz/mesc/tree/main/book). + diff --git a/book/src/environment_variables.md b/book/src/environment_variables.md deleted file mode 100644 index 6888411..0000000 --- a/book/src/environment_variables.md +++ /dev/null @@ -1 +0,0 @@ -# Setting up environment variables diff --git a/book/src/go.md b/book/src/go.md index 452b575..18dfaa7 100644 --- a/book/src/go.md +++ b/book/src/go.md @@ -1 +1 @@ -# Go +{{#include ../../go/README.md}} diff --git a/book/src/integrating_mesc.md b/book/src/integrating_mesc.md index 0df363c..c448103 100644 --- a/book/src/integrating_mesc.md +++ b/book/src/integrating_mesc.md @@ -1 +1,60 @@ # Integrating MESC + +MESC is designed to be easy to integrate into any existing tool in a backward-compatible manner. + +MESC integration patterns can be designed so that they only affect users that have opted-in to MESC, while leaving other users unaffected. + +Examples below are shown in python but work nearly identically for each language. + +## Workflow for getting the default RPC endpoint + +Let's say that an existing tool named `xyz` currently gets its default RPC endpoint from an environment variable `ETH_RPC_URL` like so: + +```python +def get_default_rpc_url() -> str | None: + return os.environ.get('ETH_RPC_URL') +``` + +MESC can be integrated using a few lines of code: + +```python +import mesc + +def get_default_rpc_url() -> str | None: + if mesc.is_mesc_enabled(): + endpoint = mesc.get_default_endpoint(profile='xyz') + if endpoint is not None: + return endpoint['url'] + return os.environ.get('ETH_RPC_URL') +``` + +This new function loads the MESC default endpoint for users that have opted-in to MESC. But it falls back to using `ETH_RPC_URL` if MESC is not enabled or MESC does not have a default endpoint set. + +Using `profile='xyz'` is optional, but it allows users to set custom settings for the `xyz` tool instead of using the global settings. + +## Workflow for letting users select an RPC endpoint + +Let's say that an existing tool named `xyz` currently lets users choose an RPC endpoint using an `-r` input argument. Users might use the tool in a similar manner to `xyz -r https://eth.llamarpc.com` or `xyz -r localhost:8545`. + +If we add an extra parsing step for the user input, we can allow the user to select from any endpoint inside the MESC configuration by name, by network name, or by chain id. Using a pattern like this: + +```python +def get_endpoint_url(user_input: str) -> str: + if mesc.is_mesc_enabled(): + endpoint = mesc.get_endpoint_by_query(user_input) + if endpoint is not None: + return endpoint['url'] + return user_input + +# ... + +url = get_endpoint_url(user_input) +``` + +Then users will be able to do any of the following + +- `xyz -r localhost:8545` (use a url) +- `xyz -r llamanodes_goerli` (use the endpoint named `llamanodes_goerli`) +- `xyz -r 5` (use the default endpoint for network with chain id `5`) +- `xyz -r goerli` (use the default endpoint for the network named `goerli`) + diff --git a/book/src/libraries.md b/book/src/libraries.md new file mode 100644 index 0000000..f6450d7 --- /dev/null +++ b/book/src/libraries.md @@ -0,0 +1,14 @@ +# MESC Libraries + +MESC aims to have an implementation for every common langauge in the cryptocurrency ecosystem. + +Implementations currently exist for: +- [CLI](./cli.md) +- [Go](./go.md) +- [Python](./python.md) +- [Rust](./rust.md) +- [Typescript](./typescript.md) + + +If you want to create a MESC implementation for a new language, see [implementing MESC](./implementing_mesc.md). + diff --git a/book/src/mesc_libraries.md b/book/src/mesc_libraries.md deleted file mode 100644 index 69293ba..0000000 --- a/book/src/mesc_libraries.md +++ /dev/null @@ -1 +0,0 @@ -# MESC Libraries diff --git a/book/src/mesc_overview.md b/book/src/mesc_overview.md index 53818cb..5a29926 100644 --- a/book/src/mesc_overview.md +++ b/book/src/mesc_overview.md @@ -1,15 +1,19 @@ # MESC Overview -To get started as quickly as possible, see [Quickstart](./quickstart.md). +To **get started quickly**, see [Quickstart](./quickstart.md). -To integrate MESC into an existing tool, see [Integrating MESC](./integrating_mesc.md). +To learn **what MESC is**, see [What is MESC?](./what_is_mesc.md). -To create a MESC implementation in a new programming language, see [Implementing MESC](./implementing_mesc.md). +To learn the **motivation** behind MESC, see [Why MESC?](./why_mesc.md). -To see information about each existing MESC implementation, see: -- [cli](./cli.md) -- [go](./go.md) -- [python](./python.md) -- [rust](./rust.md) -- [typescript](./typescript.md) +To **integrate** MESC into an existing tool, see [Integrating MESC](./integrating_mesc.md). + +To **implement** MESC in a new programming language, see [Implementing MESC](./implementing_mesc.md). + +For information about existing MESC implementations, see: +- [CLI](./cli.md) +- [Go](./go.md) +- [Python](./python.md) +- [Rust](./rust.md) +- [Typescript](./typescript.md) diff --git a/book/src/mesc_tests.md b/book/src/mesc_tests.md new file mode 100644 index 0000000..ed1ae05 --- /dev/null +++ b/book/src/mesc_tests.md @@ -0,0 +1,2 @@ + +{{#include ../../tests/README.md}} diff --git a/book/src/metadata.md b/book/src/metadata.md index 3366648..095816f 100644 --- a/book/src/metadata.md +++ b/book/src/metadata.md @@ -1 +1,43 @@ # Metadata + +In a MESC configuration, the `global_metadata`, `profile_metadata`, and `endpoint_metadata` fields allow for optional or idiosyncratic metadata to be stored alongside the core RPC data. + +Tools using MESC can choose to ignore these fields. + + +## Metadata fields + +Contents of MESC metadata is only loosely specified. This is intentional to allow for some degree of future-proofing. It enables MESC to handle use-cases that are either unanticipated or highly-specific to a given tool. + + +## Examples + +**Endpoint metadata** + +| key | value type | description | examples | +| --- | --- | --- | --- | +| `rate_limit_rps` | `int` or `float` | ratelimit in requests per second | `250` | +| `rate_limit_cups` | `int` or `float` | ratelimit in CUPS | `1000` | +| `rate_limit_per_method` | `Mapping[str, int or float]` | ratelimit in RPS for each method | `{"trace_block": 200}` | +| `api_key` | `str` | api key | `a2798f237a2398rf7` | +| `jwt_secret` | `str` | jwt secret | | +| `host` | `str` | name of provider host | `"llamanodes"`, `"alchemy"`, `"quicknode"`, `"localhost"` +| `ecosystem` | `str` | ecosystem of chain, (e.g. relates mainnets to testnets) | `"ethereum"`, `"polygon"` | +| `node_client` | `str` | versioned node client | `erigon/2.48.1/linux-amd64/go1.20.5` `reth/v0.1.0-alpha.10-7b781eb60/x86_64-unknown-linux-gnu` | +| `namespaces` | `Sequence[str]` | RPC name spaces enabled for endpoint | `["eth", "trace, "debug"]` +| `explorer` | `str` | block explorer url | `https://etherscan.io` +| `location` | `str` | geographic region | `Paris, France` | +| `cloud_region` | `str` | cloud provider region | `aws-us-east-1a` | +| `labels` | `Sequence[str]` | tags | `private_mempool`, `cache`, `archive`, `consensus_layer`, `execution_layer`, `validator`, `ephemeral` | + +**Global Metadata** and **Profile Metadata** + +| key | value type | description | examples | +| --- | --- | --- | --- | +| `last_modified_by` | `str` | versioned tool used to create configuration | `mesc__1.0` | +| `last_modified_time` | `int` | timestamp of config modification | `1700200462` | +| `creation_time` | `int` | timestamp of config creation | `1700200462` | +| `api_keys` | `Mapping[str, str]` | API keys to RPC-related services | `{"etherscan": "abc123"}` | +| `groups` | `Mapping[str, Sequence[str]]` | groupings of endpoints, mapping of group name to list of endpoint names | `{"load_balancer": ["alchemy_optimism", "quicknode_optimism"]}` | +| `conceal` | `bool` | whether tool should avoid casually revealing private RPC url's unprompted | `true` | + diff --git a/book/src/overrides.md b/book/src/overrides.md index aea5e8c..d4fec9d 100644 --- a/book/src/overrides.md +++ b/book/src/overrides.md @@ -1 +1,58 @@ # Overrides + +Overrides are a way to quickly modify a MESC configuration without needing to modify any files. + +Each override is an environment variable that overrides a specific MESC configuration key. + +Each override uses a syntax that is quick and easy to write by hand. + +## Example usage + +The `MESC_DEFAULT_ENDPOINT` override changes the default endpoint. + +#### Use in a script + +Sometimes it might be useful tweak a MESC config for a shell script. This can be achieved by inserting the MESC overrides into the script: + +```bash +#!/usr/bin/env bash + +export MESC_DEFAULT_ENDPOINT=local_goerli + +# ...rest of scriptt that does RPC things +``` + +#### Prepending syntax + +Adding `VAR_NAME=VAR_VALUE` before a cli command will set an environment variable for just that command. + +So if before the default url is this: + +```bash +mesc url +> https://eth.llamarpc.com +``` + +Adding the override before the command will change the default url: + +```bash +MESC_DEFAULT_ENDPOINT=local_goerli mesc url +> localhost:8545 +``` + +This syntax works for any cli program, not just the `mesc` cli tool. + +## List of overrides + +Every type of information within a MESC configuration can be modified using overrides: + +| override variable | value syntax | example | +| --- | --- | --- | +| `MESC_DEFAULT_ENDPOINT` | url, endpoint name, or network name | `localhost:9999` | +| `MESC_NETWORK_DEFAULTS` | space-separated pairs of `=` | `5=alchemy_optimism 1=local_mainnet` | +| `MESC_NETWORK_NAMES` | space-separated pairs of `=` | `zora=7777777` | +| `MESC_ENDPOINTS` | space-separated items of `[[:]=]` | `alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545` | +| `MESC_PROFILES` | space-separated pairs of `.[.` | `foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism` | +| `MESC_GLOBAL_METADATA` | JSON formatted global metadata | `{}` | +| `MESC_ENDPOINT_METADATA` | JSON mapping of `{"endpoint_name": {}}` | `{}` | + diff --git a/book/src/profiles.md b/book/src/profiles.md index 682bf7f..d942943 100644 --- a/book/src/profiles.md +++ b/book/src/profiles.md @@ -1 +1,32 @@ # Profiles + +Profiles are a way for each tool to customize its own MESC settings. + +Profiles allow each tool to: +- set its own default endpoint +- set its own default endpoints for each network +- override global metadata with its own metadata +- avoid using MESC for that tool without disabling MESC globally + +## Profiles are an optional feature + +If a MESC query does not specify a profile, the global configuration values are used. + +If a MESC query specifies a profile, but that profile does not exist or does not specify the relevant information, MESC will fallback to using global configuration values. + +## Setting up a profile + +The easiest way to create a profile is by using the interactive `mesc` cli tool, using the `mesc setup` subcommand. + +Alternatively, you can manually add a new `Profile` to the `profiles` key inside your `mesc.json`. The following is a template `Profile`: + +```json +{ + "name": "PROFILE_NAME", + "default_endpoint": null, + "network_defaults": {}, + "profile_metadata": {}, + "use_mesc": true +} +``` + diff --git a/book/src/python.md b/book/src/python.md index 4193ef4..6bb05a2 100644 --- a/book/src/python.md +++ b/book/src/python.md @@ -1 +1 @@ -# Python +{{#include ../../python/README.md}} diff --git a/book/src/queries.md b/book/src/queries.md new file mode 100644 index 0000000..71803e4 --- /dev/null +++ b/book/src/queries.md @@ -0,0 +1,17 @@ +# Querying MESC data + +Each MESC implementation provides the same set of 6 functions for querying MESC data. + +The behavior of these functions is the same across languages. + +| function | output type | description | example call | +| --- | --- | --- | --- | +| `is_mesc_enabled()` | `bool` | return whether MESC is enabled | `is_mesc_enabled()` | +| `get_default_endpoint()` | `Endpoint` or `None` | get default MESC endpoint | `get_default_endpoint(profile='xyz')` | +| `get_endpoint_by_network()` | `Endpoint` or `None` | get default endpoint for network | `get_endpoint_by_network(5, profile='xyz')` | +| `get_endpoint_by_name()` | `Endpoint` or `None` | get endpoint by name | `get_endpoint_by_name('local_goerli')` | +| `get_endpoint_by_query()` | `Endpoint` or `None` | get endpoint for user input query | `get_endpoint_by_query(user_str, profile='xyz')` | +| `find_endpoints()` | `list[Endpoint]` | find endpoint that match input criteria | `find_endpoints(chain_id=5)` | + +The `profile` argument is optional for each function (it allows users to customize the settings for each tool, see [Profiles](./profiles.md) for details). + diff --git a/book/src/quickstart.md b/book/src/quickstart.md index 192f16c..e35db21 100644 --- a/book/src/quickstart.md +++ b/book/src/quickstart.md @@ -4,7 +4,11 @@ The quickest way to use MESC is 1) create a `mesc.json` config file 2) set the `MESC_PATH` environment variable to the path of this file -You can create a `mesc.json` either 1) by using the interactive [MESC cli tool](https://github.com/paradigmxyz/mesc/tree/main/cli) (install using `cargo install mesc_cli`) or 2) by modifying the template below: +## Creating a config file + +You can create a `mesc.json` by one of two ways: +1) use the interactive [MESC cli tool](https://github.com/paradigmxyz/mesc/tree/main/cli) (install using `cargo install mesc_cli` and run `mesc setup`) +2) modify the template below: ```json { @@ -37,4 +41,15 @@ You can create a `mesc.json` either 1) by using the interactive [MESC cli tool]( } ``` -Configuration should follow the MESC [specification](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md). +The structure of the config must follow the MESC [specification](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md). + +## Setting environment variables + +The typical way to set environment variables is in your shell configuration files: `~/.bashrc`, `~.profile`, and/or `~/.bash_profile`. Including this line in those files will enable MESC: + +```bash +export MESC_PATH=/path/to/your/mesc.json +``` + +You can avoid editing these files yourself by running the MESC setup tool (`mesc setup`) as specified above. It will give you the option to automatically edit your shell files. + diff --git a/book/src/roadmap.md b/book/src/roadmap.md new file mode 100644 index 0000000..c52dd8d --- /dev/null +++ b/book/src/roadmap.md @@ -0,0 +1,6 @@ +# Roadmap + +Once the MESC specification reaches version 1.0, it will become ossified forever. This will maximize forward- and backward-compatibility between MESC integrations. + +Client libraries for reading or writing MESC configurations might continue development, but the underlying MESC specification will not change. + diff --git a/book/src/rust.md b/book/src/rust.md index 2f1d5ef..f3b12a4 100644 --- a/book/src/rust.md +++ b/book/src/rust.md @@ -1 +1 @@ -# Rust +{{#include ../../rust/README.md}} diff --git a/book/src/setting_up_mesc.md b/book/src/setting_up_mesc.md deleted file mode 100644 index a33fbf0..0000000 --- a/book/src/setting_up_mesc.md +++ /dev/null @@ -1 +0,0 @@ -# Basic MESC Usage diff --git a/book/src/setup.md b/book/src/setup.md new file mode 100644 index 0000000..c86b195 --- /dev/null +++ b/book/src/setup.md @@ -0,0 +1,29 @@ + +# Setting up MESC + +## Basic setup + +MESC becomes enabled by setting one or more environment variables. + +In the simplest case, only one variable necessary: `MESC_PATH` is set to the path of a `mesc.json` config file. + +As described in the [quickstart](./quickstart.md), the `mesc.json` file is usually created using either 1) the interactive `mesc setup` command, or 2) copying from a starter template. The quickstart guide also describes how to set environment variables in your terminal shell. + +## Alternative setup without a `mesc.json` + +Sometimes it is convenient to configure a system without editing any files (e.g. inside a container, or on a network drive, or in a low-privilege environment). + +This can be accomplished with MESC by setting the `MESC_ENV` variable instead of the `MESC_PATH` variable. `MESC_ENV` should simply contain the JSON content of a MESC configuration. + +If both `MESC_PATH` and `MESC_ENV` are set, you can select which one to use by setting `MESC_MODE` to either `PATH` or `ENV`. `MESC_PATH` takes precedence over `MESC_ENV` if `MESC_MODE` is not set. + +## Disabling MESC + +MESC can be disabled by either 1) unsetting all `MESC_*` variables, or 2) setting `MESC_MODE=DISABLED`. + +If MESC is disabled, the `is_mesc_disabled()` function will return `false` and all MESC querying functions will return an error (depending on language). + +## Overrides + +MESC also uses environment variables for overrides. See the [overrides](overrides.md) section for details. + diff --git a/book/src/typescript.md b/book/src/typescript.md index 42c9775..3a765c6 100644 --- a/book/src/typescript.md +++ b/book/src/typescript.md @@ -1 +1 @@ -# Typescript +{{#include ../../typescript/README.md}} diff --git a/book/src/using_mesc.md b/book/src/using_mesc.md new file mode 100644 index 0000000..cd9223a --- /dev/null +++ b/book/src/using_mesc.md @@ -0,0 +1,7 @@ +# Using MESC + +- To set MESC up, see [Setup up MESC](./setting_up_mesc.md) +- To use different MESC settings for different tools, see [Profiles](./profiles.md) +- To use MESC for tracking miscellaneous metadata, see [Metadata](./metadata.md) +- To quickly override MESC settings without editing files, see [Overrides](./overrides.md) + diff --git a/book/src/what_is_mesc.md b/book/src/what_is_mesc.md new file mode 100644 index 0000000..4a2d7e6 --- /dev/null +++ b/book/src/what_is_mesc.md @@ -0,0 +1,24 @@ +# What is MESC? + +MESC is a standardized approach for configuring RPC endpoints. Using MESC, a user creates a single RPC config that is shared by all RPC tools on their system. + +## Design Goals + +MESC has two main design goals: + +1. make it easy to share RPC configuration data across tools, languages, and environments +2. make it easy to manage the configuration of a large number of RPC endpoints + +MESC also has many secondary goals. It aims to be a solution that: +- allows specifying multiple providers for multiple chains +- allows selection of a default endpoint for each chain +- allows using either environment variables or config files +- is a single source of truth across multiple tools +- is OS-agnostic, using no OS-specific features +- is language-agnostic, using no language-specific features +- is backwards compatible with previous solutions + +## MESC is opt-in + +MESC is an **opt-in** standard: MESC is only enabled if a user has set a MESC-specific environment variable in their environment. This maximizes backward-compatiblity for existing tools that want to integrate MESC: If a user has not opted-in to MESC then simply fall back to the existing configuration method. + diff --git a/book/src/why_mesc.md b/book/src/why_mesc.md new file mode 100644 index 0000000..c86b43c --- /dev/null +++ b/book/src/why_mesc.md @@ -0,0 +1,16 @@ +# Why MESC? + +Between mainnet, testnets, chainforks, rollups, and alternative L1's, modern crypto tools must manage the configuration of multiple RPC endpoints. This configuration process is not standardized across tools. + +The most common approach for configuring RPC endpoint information is the `ETH_RPC_URL` environment variable (dapptools, forge, heimdall, checkthechain). However, this is not a formal standard and many tools use other approaches. Furthermore, using `ETH_RPC_URL` can only specify a single provider for a single chain, and it cannot specify any provider metadata beyond the url. + +Instead it would be desirable to have a solution that: +- allows specifying multiple providers for multiple chains +- allows selection of a default endpoint for each chain +- allows using either environment variables or config files +- is a single source of truth across multiple tools +- is OS-agnostic, using no OS-specific features +- is language-agnostic, using no language-specific features +- is backwards compatible with previous solutions + +MESC aims to satisfy all of these constraints. diff --git a/cli/README.md b/cli/README.md index 4e5d422..3d11a65 100644 --- a/cli/README.md +++ b/cli/README.md @@ -71,25 +71,36 @@ mesc endpoint goerli --json ## Reference +Show in terminal by typing `mesc --help`: + ``` -Utility for creating and managing MESC RPC configurations +command line interface for creating, loading, and modifying MESC configuration data Usage: mesc Commands: - setup Create new configuration or modify existing configuration - status Print status of configuration - ls Print list of endpoints - defaults Print list of defaults + setup Create or modify config interactively + import Modify config by importing from file or other source + set Modify config by setting specific values ping Ping endpoints and fetch metadata + defaults Print list of defaults endpoint Print endpoint + help Print help + ls Print list of endpoints metadata Print metadata + status Print status of configuration url Print endpoint URL - help Print this message or the help of the given subcommand(s) Options: -h, --help Print help -V, --version Print version + +Help topics: (print these with mesc help ) + env Environmental variables + python Python interface + rust Rust interface + schema Schemas of configs, endpoints, and profiles + setup How to set up MESC ``` - If an endpoint is omitted, use the default endpoint diff --git a/rust/README.md b/rust/README.md index d039942..609f9fe 100644 --- a/rust/README.md +++ b/rust/README.md @@ -46,6 +46,8 @@ pub struct Profile { pub name: String, pub default_endpoint: Option, pub network_defaults: HashMap, + pub profile_metadata: HashMap, + pub use_mesc: bool, } #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Hash)] diff --git a/tests/README.md b/tests/README.md index 6bda5e8..22de1d8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,25 +1,24 @@ # MESC Tests -These tests measure the degree to which a MESC implementation is compliant with the MESC specification. +A standard set of tests is used to check whether each MESC implementation is compliant with the MESC specification. -These tests are language-agnostic, allowing the same tests to be run against each MESC implementation. +These tests are language-agnostic and can be run against each MESC implementation. ## Usage -1. Install `pytest` (and `pytest-xdist` for parallel testing): -`pip install pytest pytest-xdist` +1. Install `pytest` with `pytest-xdist`: `pip install pytest pytest-xdist` -2. Go into the `mesc/tests` directory +2. Go to the tests directory: `cd $MESC_REPO/mesc/tests` -3. Then run one of these commands: +3. Run one of these commands: |description | command | | --- | --- | | run tests | `pytest` | -| run test in parallel (much faster) | `pytest -n auto` | +| run test in parallel mode (much faster) | `pytest -n auto` | | run tests in debug mode (helpful for debugging) | `pytest --pdb` | -| run tests using specific adapters only | `pytest --adapters adapters/python` | +| run tests for specific adapters only | `pytest --adapters adapters/python adapters/cli` | ## Adapters From 955bb9069fb541f067f29501808931a36f532b31 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 18:04:51 -0800 Subject: [PATCH 35/85] rename docs folder --- .gitignore | 2 +- {book => docs}/README.md | 2 +- {book => docs}/book.toml | 0 {book => docs}/src/SUMMARY.md | 0 {book => docs}/src/cli.md | 0 {book => docs}/src/developer_resources.md | 0 {book => docs}/src/go.md | 0 {book => docs}/src/implementing_mesc.md | 0 {book => docs}/src/integrating_mesc.md | 0 {book => docs}/src/libraries.md | 0 {book => docs}/src/mesc_overview.md | 0 {book => docs}/src/mesc_tests.md | 0 {book => docs}/src/metadata.md | 0 {book => docs}/src/overrides.md | 0 {book => docs}/src/profiles.md | 0 {book => docs}/src/python.md | 0 {book => docs}/src/queries.md | 0 {book => docs}/src/quickstart.md | 0 {book => docs}/src/roadmap.md | 0 {book => docs}/src/rust.md | 0 {book => docs}/src/setup.md | 0 {book => docs}/src/typescript.md | 0 {book => docs}/src/using_mesc.md | 0 {book => docs}/src/what_is_mesc.md | 0 {book => docs}/src/why_mesc.md | 0 25 files changed, 2 insertions(+), 2 deletions(-) rename {book => docs}/README.md (92%) rename {book => docs}/book.toml (100%) rename {book => docs}/src/SUMMARY.md (100%) rename {book => docs}/src/cli.md (100%) rename {book => docs}/src/developer_resources.md (100%) rename {book => docs}/src/go.md (100%) rename {book => docs}/src/implementing_mesc.md (100%) rename {book => docs}/src/integrating_mesc.md (100%) rename {book => docs}/src/libraries.md (100%) rename {book => docs}/src/mesc_overview.md (100%) rename {book => docs}/src/mesc_tests.md (100%) rename {book => docs}/src/metadata.md (100%) rename {book => docs}/src/overrides.md (100%) rename {book => docs}/src/profiles.md (100%) rename {book => docs}/src/python.md (100%) rename {book => docs}/src/queries.md (100%) rename {book => docs}/src/quickstart.md (100%) rename {book => docs}/src/roadmap.md (100%) rename {book => docs}/src/rust.md (100%) rename {book => docs}/src/setup.md (100%) rename {book => docs}/src/typescript.md (100%) rename {book => docs}/src/using_mesc.md (100%) rename {book => docs}/src/what_is_mesc.md (100%) rename {book => docs}/src/why_mesc.md (100%) diff --git a/.gitignore b/.gitignore index 2447ba9..c0f4a86 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ PITCH.md *.json __pycache__ python/dist -book/book +docs/book diff --git a/book/README.md b/docs/README.md similarity index 92% rename from book/README.md rename to docs/README.md index afa68bc..d0ff07f 100644 --- a/book/README.md +++ b/docs/README.md @@ -1,7 +1,7 @@ # MESC User Guide -This is the user guide for MESC. See table of contents in [Summary](SUMMARY.md). +This is the user guide for MESC. See table of contents in [Summary](src/SUMMARY.md). ## Usage diff --git a/book/book.toml b/docs/book.toml similarity index 100% rename from book/book.toml rename to docs/book.toml diff --git a/book/src/SUMMARY.md b/docs/src/SUMMARY.md similarity index 100% rename from book/src/SUMMARY.md rename to docs/src/SUMMARY.md diff --git a/book/src/cli.md b/docs/src/cli.md similarity index 100% rename from book/src/cli.md rename to docs/src/cli.md diff --git a/book/src/developer_resources.md b/docs/src/developer_resources.md similarity index 100% rename from book/src/developer_resources.md rename to docs/src/developer_resources.md diff --git a/book/src/go.md b/docs/src/go.md similarity index 100% rename from book/src/go.md rename to docs/src/go.md diff --git a/book/src/implementing_mesc.md b/docs/src/implementing_mesc.md similarity index 100% rename from book/src/implementing_mesc.md rename to docs/src/implementing_mesc.md diff --git a/book/src/integrating_mesc.md b/docs/src/integrating_mesc.md similarity index 100% rename from book/src/integrating_mesc.md rename to docs/src/integrating_mesc.md diff --git a/book/src/libraries.md b/docs/src/libraries.md similarity index 100% rename from book/src/libraries.md rename to docs/src/libraries.md diff --git a/book/src/mesc_overview.md b/docs/src/mesc_overview.md similarity index 100% rename from book/src/mesc_overview.md rename to docs/src/mesc_overview.md diff --git a/book/src/mesc_tests.md b/docs/src/mesc_tests.md similarity index 100% rename from book/src/mesc_tests.md rename to docs/src/mesc_tests.md diff --git a/book/src/metadata.md b/docs/src/metadata.md similarity index 100% rename from book/src/metadata.md rename to docs/src/metadata.md diff --git a/book/src/overrides.md b/docs/src/overrides.md similarity index 100% rename from book/src/overrides.md rename to docs/src/overrides.md diff --git a/book/src/profiles.md b/docs/src/profiles.md similarity index 100% rename from book/src/profiles.md rename to docs/src/profiles.md diff --git a/book/src/python.md b/docs/src/python.md similarity index 100% rename from book/src/python.md rename to docs/src/python.md diff --git a/book/src/queries.md b/docs/src/queries.md similarity index 100% rename from book/src/queries.md rename to docs/src/queries.md diff --git a/book/src/quickstart.md b/docs/src/quickstart.md similarity index 100% rename from book/src/quickstart.md rename to docs/src/quickstart.md diff --git a/book/src/roadmap.md b/docs/src/roadmap.md similarity index 100% rename from book/src/roadmap.md rename to docs/src/roadmap.md diff --git a/book/src/rust.md b/docs/src/rust.md similarity index 100% rename from book/src/rust.md rename to docs/src/rust.md diff --git a/book/src/setup.md b/docs/src/setup.md similarity index 100% rename from book/src/setup.md rename to docs/src/setup.md diff --git a/book/src/typescript.md b/docs/src/typescript.md similarity index 100% rename from book/src/typescript.md rename to docs/src/typescript.md diff --git a/book/src/using_mesc.md b/docs/src/using_mesc.md similarity index 100% rename from book/src/using_mesc.md rename to docs/src/using_mesc.md diff --git a/book/src/what_is_mesc.md b/docs/src/what_is_mesc.md similarity index 100% rename from book/src/what_is_mesc.md rename to docs/src/what_is_mesc.md diff --git a/book/src/why_mesc.md b/docs/src/why_mesc.md similarity index 100% rename from book/src/why_mesc.md rename to docs/src/why_mesc.md From fa7295b04026946a54fd4c57bcdd46ff5b926f1b Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 18:15:15 -0800 Subject: [PATCH 36/85] add docs build action --- .github/workflows/deploy-docs.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/deploy-docs.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000..f3de976 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,28 @@ +name: Deploy docs to GitHub Pages + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Install mdBook + run: cargo install mdbook + - name: Build mdBook + run: mdbook build docs + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/book + From f88f05cbf20bc111d5b6188bd8e64c22afdb99ab Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 18:19:28 -0800 Subject: [PATCH 37/85] deploy docs to special branch --- .github/workflows/deploy-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index f3de976..62ade45 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -25,4 +25,6 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/book + publish_branch: gh-pages + keep_files: false From 1db40dbeddc0a5d33ff04a3924ba63bf24a9f80b Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 18:30:05 -0800 Subject: [PATCH 38/85] add badges to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a0d1058..de006b3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Multiple Endpoint Shared Configuration (MESC) Standard +![Specification](https://img.shields.io/badge/Spec-blueviolet) +![Documentation](https://img.shields.io/badge/Docs-green) + + MESC is a standard for how crypto tools configure their RPC endpoints. By following this specification, a user creates a single RPC configuration that can be shared by all crypto tools on their system. MESC has two main design goals: From f48ff39bc25ac6f7b88604915959e97f8cb57d70 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sat, 27 Jan 2024 18:33:59 -0800 Subject: [PATCH 39/85] add links to README badges --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de006b3..79f1ded 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # Multiple Endpoint Shared Configuration (MESC) Standard -![Specification](https://img.shields.io/badge/Spec-blueviolet) -![Documentation](https://img.shields.io/badge/Docs-green) - +[![Specification](https://img.shields.io/badge/Spec-blueviolet)](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md) +[![issues - badge-generator](https://img.shields.io/badge/Docs-green)](https://paradigmxyz.github.io/mesc) MESC is a standard for how crypto tools configure their RPC endpoints. By following this specification, a user creates a single RPC configuration that can be shared by all crypto tools on their system. From 363377b64802ec4575ca96808f5520dfac1b545c Mon Sep 17 00:00:00 2001 From: omahs <73983677+omahs@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:29:35 +0800 Subject: [PATCH 40/85] fix typos (#14) * fix typo * fix typo * fix typo --- docs/src/implementing_mesc.md | 2 +- docs/src/libraries.md | 2 +- docs/src/overrides.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/implementing_mesc.md b/docs/src/implementing_mesc.md index a8d6762..1991675 100644 --- a/docs/src/implementing_mesc.md +++ b/docs/src/implementing_mesc.md @@ -10,7 +10,7 @@ If you are creating a new MESC implementation, you may find the following useful 3. A MESC implementation's compliance to the specification can be checked using the language-agnostic MESC test suite. Passing the test suite means that an implementation is complete. More details on the test suite can be found [here](https://github.com/paradigmxyz/mesc/tree/main/tests). -4. It is desirable to use the same names, types, and behaviors across each MESC implementation. This increases interoperability and makes MESC easier to learn and use. However it is also desirable to obey the common convetions of each programming language. Each MESC implementation must find a balance between language-agnostic conventions vs language-specific conventions. +4. It is desirable to use the same names, types, and behaviors across each MESC implementation. This increases interoperability and makes MESC easier to learn and use. However it is also desirable to obey the common conventions of each programming language. Each MESC implementation must find a balance between language-agnostic conventions vs language-specific conventions. 5. If parts of the MESC specification are confusing or difficult to implement, it may be helpful to look at existing implementations. These currently exist for [python](https://github.com/paradigmxyz/mesc/tree/main/python) and [rust](https://github.com/paradigmxyz/mesc/tree/main/rust). diff --git a/docs/src/libraries.md b/docs/src/libraries.md index f6450d7..8028beb 100644 --- a/docs/src/libraries.md +++ b/docs/src/libraries.md @@ -1,6 +1,6 @@ # MESC Libraries -MESC aims to have an implementation for every common langauge in the cryptocurrency ecosystem. +MESC aims to have an implementation for every common language in the cryptocurrency ecosystem. Implementations currently exist for: - [CLI](./cli.md) diff --git a/docs/src/overrides.md b/docs/src/overrides.md index d4fec9d..3f33383 100644 --- a/docs/src/overrides.md +++ b/docs/src/overrides.md @@ -19,7 +19,7 @@ Sometimes it might be useful tweak a MESC config for a shell script. This can be export MESC_DEFAULT_ENDPOINT=local_goerli -# ...rest of scriptt that does RPC things +# ...rest of script that does RPC things ``` #### Prepending syntax From 88434ba5518dd346fb884f6895184728ea717c4c Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 13:06:14 -0800 Subject: [PATCH 41/85] update tests (#15) --- README.md | 2 +- python/mesc/interface.py | 19 +- python/mesc/types.py | 8 +- rust/README.md | 8 +- rust/crates/mesc/src/interface.rs | 6 +- rust/crates/mesc/src/query.rs | 43 +- rust/crates/mesc/src/types/queries.rs | 2 + rust/crates/mesc_cli/src/cli/args.rs | 14 +- .../mesc_cli/src/cli/subcommands/help.rs | 8 +- .../mesc_cli/src/cli/subcommands/metadata.rs | 32 +- rust/crates/mesc_cli/src/metadata.rs | 2 +- tests/README.md | 7 +- tests/adapters/cli | 9 +- tests/adapters/python | 2 +- tests/generate.py | 370 ++++++++++++------ tests/test_mesc.py | 8 +- 16 files changed, 389 insertions(+), 151 deletions(-) mode change 100644 => 100755 tests/test_mesc.py diff --git a/README.md b/README.md index 79f1ded..89cefad 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); // get an endpoint by name -let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 6e63cfe..9602135 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -68,7 +68,7 @@ def get_endpoint_by_network( # get global default for network if chain_id is None: - raise ValueError('chain_id must be a str') + raise ValueError('chain_id must be a str or int') chain_id = str(chain_id) network_defaults = config['network_defaults'] default_name = network_defaults.get(chain_id) @@ -162,6 +162,19 @@ def find_endpoints( return endpoints -def get_global_metadata() -> Mapping[str, Any]: +def get_global_metadata( + *, profile: str | None = None, config: RpcConfig | None = None +) -> Mapping[str, Any]: """return MESC global metadata""" - return load.read_config_data()['global_metadata'] + + if config is None: + config = load.read_config_data() + + if profile is not None: + profile_data = config['profiles'].get(profile) + if profile_data is not None: + if not profile_data['use_mesc']: + return {} + return dict(config['global_metadata'], **profile_data['profile_metadata']) + + return config['global_metadata'] diff --git a/python/mesc/types.py b/python/mesc/types.py index 380822b..c936aeb 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing_extensions import Any, MutableMapping, TypedDict, Literal, Sequence +from typing_extensions import Any, MutableMapping, TypedDict, Literal mesc_env_vars = [ @@ -94,7 +94,7 @@ class EndpointNameQuery(TypedDict): class EndpointNetworkQuery(TypedDict): profile: str | None - chain_id: str + chain_id: str | int class UserInputQuery(TypedDict): @@ -105,11 +105,11 @@ class UserInputQuery(TypedDict): class MultiEndpointQuery(TypedDict, total=False): name_contains: str | None url_contains: str | None - chain_id: str | None + chain_id: str | int | None class GlobalMetadataQuery(TypedDict, total=False): - path: Sequence[str] | None + profile: str | None class MescQuery(TypedDict): diff --git a/rust/README.md b/rust/README.md index 609f9fe..f34211f 100644 --- a/rust/README.md +++ b/rust/README.md @@ -72,17 +72,17 @@ let endpoint: OptionalResult = mesc::get_default_endpoint(None); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); // get the default network for a particular tool -let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); +let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, Some("xyz_tool")); // get an endpoint by name -let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) -let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); diff --git a/rust/crates/mesc/src/interface.rs b/rust/crates/mesc/src/interface.rs index ae76f0f..2de8e3d 100644 --- a/rust/crates/mesc/src/interface.rs +++ b/rust/crates/mesc/src/interface.rs @@ -44,6 +44,8 @@ pub fn find_endpoints(query: MultiEndpointQuery) -> Result, MescEr } /// get global metadata -pub fn get_global_metadata() -> Result, MescError> { - query::get_global_metadata(&load_config_data()?) +pub fn get_global_metadata( + profile: Option<&str>, +) -> Result, MescError> { + query::get_global_metadata(&load_config_data()?, profile) } diff --git a/rust/crates/mesc/src/query.rs b/rust/crates/mesc/src/query.rs index f6b8af9..1e48523 100644 --- a/rust/crates/mesc/src/query.rs +++ b/rust/crates/mesc/src/query.rs @@ -12,9 +12,13 @@ pub fn get_default_endpoint( ) -> Result, MescError> { // if using a profile, check if that profile has a default endpoint for chain_id if let Some(profile) = profile { - let name = config.profiles.get(profile).and_then(|p| p.default_endpoint.clone()); - if let Some(name) = name { - return get_endpoint_by_name(config, name.as_str()) + if let Some(profile_data) = config.profiles.get(profile) { + if !profile_data.use_mesc { + return Ok(None) + } + if let Some(endpoint_name) = profile_data.default_endpoint.as_deref() { + return get_endpoint_by_name(config, endpoint_name) + } } }; @@ -34,9 +38,13 @@ pub fn get_endpoint_by_network( // if using a profile, check if that profile has a default endpoint for chain_id if let Some(profile) = profile { - let name = config.profiles.get(profile).and_then(|p| p.network_defaults.get(&chain_id)); - if let Some(name) = name { - return get_endpoint_by_name(config, name) + if let Some(profile_data) = config.profiles.get(profile) { + if !profile_data.use_mesc { + return Ok(None) + } + if let Some(endpoint_name) = profile_data.network_defaults.get(&chain_id) { + return get_endpoint_by_name(config, endpoint_name) + } } }; @@ -62,6 +70,14 @@ pub fn get_endpoint_by_query( query: &str, profile: Option<&str>, ) -> Result, MescError> { + if let Some(profile) = profile { + if let Some(profile_data) = config.profiles.get(profile) { + if !profile_data.use_mesc { + return Ok(None) + } + } + } + // by endpoint name if let Some(endpoint) = config.endpoints.get(query) { return Ok(Some(endpoint.clone())); @@ -109,6 +125,19 @@ pub fn find_endpoints( /// get global metadata pub fn get_global_metadata( config: &RpcConfig, + profile: Option<&str>, ) -> Result, MescError> { - Ok(config.global_metadata.clone()) + let mut metadata = config.global_metadata.clone(); + + // load profile metadata + if let Some(profile) = profile { + if let Some(profile_data) = config.profiles.get(profile) { + if !profile_data.use_mesc { + return Ok(HashMap::new()) + } + metadata.extend(profile_data.profile_metadata.clone()) + } + } + + Ok(metadata) } diff --git a/rust/crates/mesc/src/types/queries.rs b/rust/crates/mesc/src/types/queries.rs index e5dddeb..866bbda 100644 --- a/rust/crates/mesc/src/types/queries.rs +++ b/rust/crates/mesc/src/types/queries.rs @@ -115,6 +115,8 @@ pub struct UserInputQuery { /// GlobalMetadataQuery #[derive(Debug, Clone)] pub struct GlobalMetadataQuery { + /// profile + pub profile: Option, /// path pub path: Option>, } diff --git a/rust/crates/mesc_cli/src/cli/args.rs b/rust/crates/mesc_cli/src/cli/args.rs index 5d08e2c..7cbcee8 100644 --- a/rust/crates/mesc_cli/src/cli/args.rs +++ b/rust/crates/mesc_cli/src/cli/args.rs @@ -245,7 +245,19 @@ pub(crate) struct EndpointArgs { /// Arguments for the `metadata` subcommand #[derive(Parser)] -pub(crate) struct MetadataArgs {} +pub(crate) struct MetadataArgs { + /// print metadata of endpoint + #[clap(long)] + pub(crate) endpoint: Option, + + /// print metadata of profile merged with global metadata + #[clap(long)] + pub(crate) profile: Option, + + /// print metadata of profile not merged with global metadata + #[clap(long)] + pub(crate) profile_only: Option, +} /// Arguments for the `url` subcommand #[derive(Parser)] diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index f13b1c2..53f54a5 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -185,17 +185,17 @@ let endpoint: OptionalResult = mesc::get_default_endpoint(None); let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); // get the default network for a particular tool -let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); +let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, Some("xyz_tool")); // get an endpoint by name -let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_query"); +let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) -let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); diff --git a/rust/crates/mesc_cli/src/cli/subcommands/metadata.rs b/rust/crates/mesc_cli/src/cli/subcommands/metadata.rs index c14bd41..fda0f5b 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/metadata.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/metadata.rs @@ -1,7 +1,33 @@ use crate::{MescCliError, MetadataArgs}; -pub(crate) fn metadata_command(_args: MetadataArgs) -> Result<(), MescCliError> { +pub(crate) fn metadata_command(args: MetadataArgs) -> Result<(), MescCliError> { let config = mesc::load::load_config_data()?; - println!("{}", serde_json::to_string_pretty(&config.global_metadata)?); - Ok(()) + match (args.endpoint, args.profile, args.profile_only) { + (None, None, None) => { + println!("{}", serde_json::to_string_pretty(&config.global_metadata)?); + Ok(()) + } + (Some(endpoint), None, None) => { + if let Some(endpoint) = config.endpoints.get(endpoint.as_str()) { + println!("{}", serde_json::to_string_pretty(&endpoint.endpoint_metadata)?); + Ok(()) + } else { + Err(MescCliError::Error("endpoint not found".to_string())) + } + } + (None, Some(profile), None) => { + let metadata = mesc::get_global_metadata(Some(profile.as_str()))?; + println!("{}", serde_json::to_string_pretty(&metadata)?); + Ok(()) + } + (None, None, Some(profile)) => { + if let Some(profile) = config.profiles.get(profile.as_str()) { + println!("{}", serde_json::to_string_pretty(&profile.profile_metadata)?); + Ok(()) + } else { + Err(MescCliError::Error("profile not found".to_string())) + } + } + _ => Err(MescCliError::Error("cannot specify more than one metadata type".to_string())), + } } diff --git a/rust/crates/mesc_cli/src/metadata.rs b/rust/crates/mesc_cli/src/metadata.rs index ba2a500..8533746 100644 --- a/rust/crates/mesc_cli/src/metadata.rs +++ b/rust/crates/mesc_cli/src/metadata.rs @@ -30,7 +30,7 @@ pub(crate) fn get_theme_font_style(id: &str) -> Result } fn get_cli_theme() -> Result, MescCliError> { - let global_metadata = mesc::get_global_metadata()?; + let global_metadata = mesc::get_global_metadata(Some("mesc_cli"))?; let path: Vec<&str> = vec![]; let cli_theme: HashMap = match global_metadata.get("cli_theme") { Some(value) => get_value_at(value, &path)?, diff --git a/tests/README.md b/tests/README.md index 22de1d8..82841a9 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,9 +1,7 @@ # MESC Tests -A standard set of tests is used to check whether each MESC implementation is compliant with the MESC specification. - -These tests are language-agnostic and can be run against each MESC implementation. +A language-agnostic set of tests is used to check whether each MESC implementation is compliant with the MESC specification. ## Usage @@ -18,8 +16,11 @@ These tests are language-agnostic and can be run against each MESC implementatio | run tests | `pytest` | | run test in parallel mode (much faster) | `pytest -n auto` | | run tests in debug mode (helpful for debugging) | `pytest --pdb` | +| run tests only tests that previously failed | `pytest --lf` | | run tests for specific adapters only | `pytest --adapters adapters/python adapters/cli` | +By default, tests will run for all MESC implementations. If you do not have all of these implementations installed, you will need to use `--adapters` to select only the subset that that you have installed. + ## Adapters diff --git a/tests/adapters/cli b/tests/adapters/cli index d648eff..11db74b 100755 --- a/tests/adapters/cli +++ b/tests/adapters/cli @@ -15,7 +15,9 @@ def run_query(query: MescQuery) -> str: name = cast(str, query["fields"]["name"]) # type: ignore cmd = ["mesc", "endpoint", "--json", "--name", name] elif query["query_type"] == "endpoint_by_network": - chain_id = cast(str, query["fields"]["chain_id"]) # type: ignore + chain_id = query["fields"]["chain_id"] + if isinstance(chain_id, int): + chain_id = str(chain_id) cmd = ["mesc", "endpoint", "--json", "--network", chain_id] elif query["query_type"] == "user_input": user_input = query["fields"]["user_input"] # type: ignore @@ -30,7 +32,10 @@ def run_query(query: MescQuery) -> str: cmd.append(query['fields']['url_contains']) if query["fields"].get('chain_id') is not None: cmd.append('--network') - cmd.append(query['fields']['chain_id']) + chain_id = query["fields"]["chain_id"] + if isinstance(chain_id, int): + chain_id = str(chain_id) + cmd.append(chain_id) elif query['query_type'] == 'global_metadata': cmd = ["mesc", "metadata"] else: diff --git a/tests/adapters/python b/tests/adapters/python index 85bbd25..d6e451a 100755 --- a/tests/adapters/python +++ b/tests/adapters/python @@ -25,7 +25,7 @@ def run_query(query: EndpointQuery) -> Endpoint | Sequence[Endpoint] | None: multi_endpoint_fields = cast(mesc.types.MultiEndpointQuery, query['fields']) return mesc.find_endpoints(**multi_endpoint_fields) elif query["query_type"] == "global_metadata": - return mesc.get_global_metadata() + return mesc.get_global_metadata(**query['fields']) else: raise Exception("invalid query type: " + str(query["query_type"])) diff --git a/tests/generate.py b/tests/generate.py index 856191e..d659e6a 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -3,9 +3,6 @@ from __future__ import annotations import copy -import json -import os -import time from typing import Any, TypeVar, Sequence from mesc import RpcConfig, Profile, Endpoint @@ -94,14 +91,24 @@ full_config: RpcConfig = { "1": "llamanodes_ethereum", "10": "llamanodes_optimism", }, - "profile_metadata": {}, + "profile_metadata": { + "sample_key": "profile_value", + }, "use_mesc": True, }, + "not_using_mesc": { + "name": "not_using_mesc", + "default_endpoint": None, + "network_defaults": {}, + "profile_metadata": {}, + "use_mesc": False, + }, }, "global_metadata": { "api_keys": { "etherscan": "abc123", }, + "sample_key": "global_value", }, } @@ -128,9 +135,47 @@ def generate_tests() -> list[Test]: generators = [ create_basic_query_tests, create_override_tests, - create_invalid_tests, + create_invalid_query_tests, + create_invalid_config_tests, ] - return [test for generator in generators for test in generator()] + + tests = [test for generator in generators for test in generator()] + + # for tests that query with null profile, also query with non-existent profile + for test in list(tests): + query = test[3] + if ( + query is not None + and "profile" in query.get("fields", {}) + and query["fields"].get("profile") is None + ): + new_test = copy.deepcopy(test) + new_test[3]["fields"]["profile"] = "unknown_profile" # type: ignore + + new_test = (new_test[0] + ", unknown_profile",) + new_test[1:] + tests.append(new_test) + + # every query should return None or empty when a profile has use_mesc=True + for test in list(tests): + query = test[3] + target_output = test[4] + if ( + query is not None + and "profile" in query.get("fields", {}) + and query["fields"].get("profile") is None + and target_output is not None + ): + new_test = copy.deepcopy(test) + new_test[3]["fields"]["profile"] = "not_using_mesc" # type: ignore + if query["query_type"] == "global_metadata": + expected: dict | None = {} + else: + expected = None + new_test = new_test[0:4] + (expected,) + new_test[5:] + new_test = (new_test[0] + ", profile not_using_mesc",) + new_test[1:] + tests.append(new_test) + + return tests T = TypeVar("T") @@ -239,6 +284,17 @@ def create_basic_query_tests() -> list[Test]: full_config["endpoints"]["local_goerli"], True, ), + ( + "query endpoint chain_id by int", + {}, + full_config, + { + "query_type": "endpoint_by_network", + "fields": {"chain_id": 1, "profile": None}, + }, + full_config["endpoints"]["local_ethereum"], + True, + ), ( "get endpoint by network", {}, @@ -353,9 +409,20 @@ def create_basic_query_tests() -> list[Test]: full_config["endpoints"]["local_goerli"], True, ), + ( + "get endpoint by user query, dne", + {}, + full_config, + { + "query_type": "user_input", + "fields": {"user_input": "this_query_has_no_results", "profile": None}, + }, + None, + True, + ), ] - # get endpoint by user query, profile blank + # get endpoint by user query, with default profile tests += [ ( "get endpoint by user query, endpoint name", @@ -423,6 +490,17 @@ def create_basic_query_tests() -> list[Test]: full_config["endpoints"]["local_goerli"], True, ), + ( + "get endpoint by user query, dne", + {}, + full_config, + { + "query_type": "user_input", + "fields": {"user_input": "this_query_has_no_results", "profile": "abc"}, + }, + None, + True, + ), ] # get endpoint by user query, profile full @@ -482,16 +560,33 @@ def create_basic_query_tests() -> list[Test]: full_config["endpoints"]["llamanodes_ethereum"], True, ), - # ( - # "get endpoint by user query, custom network name", - # full_config, - # {"query_type": "user_input", "fields": {"user_input": "testnet", "profile": "xyz"}}, - # full_config['endpoints']['llamanodes_goerli'], - # ), + ( + "get endpoint by user query, custom network name", + {}, + full_config, + { + "query_type": "user_input", + "fields": {"user_input": "testnet", "profile": "xyz"}, + }, + full_config["endpoints"]["local_goerli"], + True, + ), + ( + "get endpoint by user query, dne", + {}, + full_config, + { + "query_type": "user_input", + "fields": {"user_input": "this_query_has_no_results", "profile": "xyz"}, + }, + None, + True, + ), ] # test querying by known network names for chain_id, network_name in known_networks.items(): + # with a default endpoint network_endpoint = copy.deepcopy(blank_endpoint) network_endpoint["chain_id"] = chain_id network_config = copy.deepcopy(full_config) @@ -510,6 +605,23 @@ def create_basic_query_tests() -> list[Test]: ) tests.append(test) + # without a default endpoint + network_config = copy.deepcopy(full_config) + if chain_id in network_config["network_defaults"]: + del network_config["network_defaults"][chain_id] + test_without: Test = ( + "test querying " + network_name + " by name", + {}, + network_config, + { + "query_type": "user_input", + "fields": {"user_input": network_name, "profile": None}, + }, + None, + True, + ) + tests.append(test_without) + # test multi-endpoint queries tests += [ ( @@ -524,6 +636,14 @@ def create_basic_query_tests() -> list[Test]: ], True, ), + ( + "empty fuzzy name query", + {}, + full_config, + {"query_type": "multi_endpoint", "fields": {"name_contains": "yyyyyy"}}, + [], + True, + ), ( "fuzzy url query", {}, @@ -535,6 +655,14 @@ def create_basic_query_tests() -> list[Test]: ], True, ), + ( + "fuzzy url query", + {}, + full_config, + {"query_type": "multi_endpoint", "fields": {"url_contains": "yyyyyy"}}, + [], + True, + ), ( "chain_id query", {}, @@ -546,21 +674,125 @@ def create_basic_query_tests() -> list[Test]: ], True, ), + ( + "chain_id int query", + {}, + full_config, + {"query_type": "multi_endpoint", "fields": {"chain_id": 1}}, + [ + full_config["endpoints"]["local_ethereum"], + full_config["endpoints"]["llamanodes_ethereum"], + ], + True, + ), + ( + "empty chain_id query", + {}, + full_config, + {"query_type": "multi_endpoint", "fields": {"chain_id": "1111"}}, + [], + True, + ), ] - # for tests that query with null profile, also query with non-existent profile - for test in list(tests): - query = test[3] - if "profile" in query.get("fields", {}) and query["fields"]["profile"] is None: # type: ignore - new_test = copy.deepcopy(test) - new_test[3]["fields"]["profile"] = "unknown_profile" # type: ignore - tests.append(new_test) + # test fetching metadata + tests += [ + ( + "get full global metadata, no profile", + {}, + full_config, + {"query_type": "global_metadata", "fields": {"profile": None}}, + full_config["global_metadata"], + True, + ), + ( + "get full global metadata, irrelevant profile", + {}, + full_config, + {"query_type": "global_metadata", "fields": {"profile": "abc"}}, + full_config["global_metadata"], + True, + ), + ( + "get full global metadata, merged with profile", + {}, + full_config, + {"query_type": "global_metadata", "fields": {"profile": "xyz"}}, + dict( + full_config["global_metadata"], + **full_config["profiles"]["xyz"]["profile_metadata"], + ), + True, + ), + ] return tests -# [name, env, config] -def create_invalid_tests() -> list[Test]: +def create_invalid_query_tests() -> list[Test]: + invalid_queries: Sequence[tuple[str, Any]] = [ + ( + "query default endpoint with int profile", + {"query_type": "default_endpoint", "fields": {"profile": 1}}, + ), + ( + "query endpoint name by null", + {"query_type": "endpoint_by_name", "fields": {"name": None}}, + ), + ( + "query endpoint name by int", + {"query_type": "endpoint_by_name", "fields": {"name": 1}}, + ), + ( + "query endpoint chain_id by null", + { + "query_type": "endpoint_by_network", + "fields": {"chain_id": None, "profile": None}, + }, + ), + ( + "query endpoint chain_id by int profile", + { + "query_type": "endpoint_by_network", + "fields": {"chain_id": "1", "profile": 1}, + }, + ), + ( + "query user input by null", + { + "query_type": "user_input", + "fields": {"user_input": None, "profile": None}, + }, + ), + ( + "query user input by bool", + { + "query_type": "user_input", + "fields": {"user_input": True, "profile": None}, + }, + ), + ( + "query user input by int profile", + {"query_type": "user_input", "fields": {"user_input": True, "profile": 1}}, + ), + ] + + tests = [] + for test_name, query in invalid_queries: + test: Test = ( + test_name, + {}, + full_config, + query, + None, + False, + ) + tests.append(test) + + return tests + + +def create_invalid_config_tests() -> list[Test]: tests: list[Test] = [] # unknown default endpoint @@ -591,75 +823,6 @@ def create_invalid_tests() -> list[Test]: ), ) - # invalid queries - invalid_queries: Sequence[tuple[str, Any]] = [ - ( - "query default endpoint with int profile", - {"query_type": "default_endpoint", "fields": {"profile": 1}}, - ), - ( - "query endpoint name by non-existent name", - {"query_type": "default_endpoint", "fields": {"profile": 1}}, - ), - ( - "query endpoint name by null", - {"query_type": "endpoint_by_name", "fields": {"name": None}}, - ), - ( - "query endpoint name by int", - {"query_type": "endpoint_by_name", "fields": {"name": 1}}, - ), - ( - "query endpoint chain_id by null", - { - "query_type": "endpoint_by_network", - "fields": {"chain_id": None, "profile": None}, - }, - ), - ( - "query endpoint chain_id by int", - { - "query_type": "endpoint_by_network", - "fields": {"chain_id": 1, "profile": None}, - }, - ), - ( - "query endpoint chain_id by int profile", - { - "query_type": "endpoint_by_network", - "fields": {"chain_id": "1", "profile": 1}, - }, - ), - ( - "query user input by null", - { - "query_type": "user_input", - "fields": {"user_input": None, "profile": None}, - }, - ), - ( - "query user input by bool", - { - "query_type": "user_input", - "fields": {"user_input": True, "profile": None}, - }, - ), - ( - "query user input by int profile", - {"query_type": "user_input", "fields": {"user_input": True, "profile": 1}}, - ), - ] - for test_name, query in invalid_queries: - test: Test = ( - test_name, - {}, - full_config, - query, - None, - False, - ) - tests.append(test) - # incorrect types tests invalid_type_tests = [ ( @@ -836,7 +999,7 @@ def create_invalid_tests() -> list[Test]: ), ] for test_name, config in invalid_type_tests: - test = ( + test: Test = ( test_name, {}, config, @@ -929,7 +1092,6 @@ def create_invalid_tests() -> list[Test]: return tests -# [name, env, config, query, result] def create_override_tests() -> list[Test]: tests: list[Test] = [] @@ -1200,15 +1362,15 @@ def create_override_tests() -> list[Test]: "override global metadata, change existing key", {"MESC_GLOBAL_METADATA": '{"api_keys": {"etherscan": "new_key"}}'}, full_config, - {"query_type": "global_metadata", "fields": {"path": None}}, - {"api_keys": {"etherscan": "new_key"}}, + {"query_type": "global_metadata", "fields": {}}, + dict(full_config["global_metadata"], api_keys={"etherscan": "new_key"}), True, ), ( "override global metadata, add new key", {"MESC_GLOBAL_METADATA": '{"some_new_key": "value"}'}, full_config, - {"query_type": "global_metadata", "fields": {"path": None}}, + {"query_type": "global_metadata", "fields": {}}, dict(full_config["global_metadata"], some_new_key="value"), True, ), @@ -1216,7 +1378,7 @@ def create_override_tests() -> list[Test]: "override global metadata blank", {"MESC_GLOBAL_METADATA": ""}, full_config, - {"query_type": "global_metadata", "fields": {"path": None}}, + {"query_type": "global_metadata", "fields": {}}, full_config["global_metadata"], True, ), @@ -1282,17 +1444,3 @@ def create_override_tests() -> list[Test]: pass return tests - - -if __name__ == "__main__": - start_time = time.time() - tests = generate_tests() - duration = time.time() - start_time - print("generated", len(tests), "tests in", "%.3f" % duration, "seconds") - - path = "generated/tests.json" - os.makedirs(os.path.dirname(path), exist_ok=True) - with open(path, "w") as f: - json.dump(tests, f) - print() - print("saved to", path) diff --git a/tests/test_mesc.py b/tests/test_mesc.py old mode 100644 new mode 100755 index 0492bc9..d972a57 --- a/tests/test_mesc.py +++ b/tests/test_mesc.py @@ -150,15 +150,15 @@ def test_mesc_output( else: # failure case: incorrect query output print_error_summary(**error_data) - raise OutputDoesNotMatch( - "output does not match", adapter, setup_name, test_name + raise QueryShouldHaveFailed( + "success when expecting failure", adapter, setup_name, test_name ) else: if should_succeed: # failure case: query should have failed print_error_summary(**error_data) - raise QueryShouldHaveFailed( - "success when expecting failure", adapter, setup_name, test_name + raise OutputDoesNotMatch( + "output does not match", adapter, setup_name, test_name ) else: # working properly From fbc22f947eef2b2f4ab83a2ed0e3d3944c41953c Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 13:49:44 -0800 Subject: [PATCH 42/85] Add github ci for tests (#16) * add github ci * update typing annotations * more typing annotations * update rust test action * update adapters * stop using local toolstr * revert to older type annotation syntax * do not require python mesc to be installed to run test suite * require Test type only for type annotations * Test type only necessary for type annotations --- .github/workflows/python-tests.yml | 25 +++++++++++++++++++++ .github/workflows/rust-tests.yml | 36 ++++++++++++++++++++++++++++++ rust/crates/mesc_cli/Cargo.toml | 2 +- tests/adapters/cli | 7 +++++- tests/adapters/python | 10 +++++---- tests/generate.py | 25 ++++++++++++--------- tests/test_mesc.py | 24 +++++++++++--------- 7 files changed, 102 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/python-tests.yml create mode 100644 .github/workflows/rust-tests.yml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000..67e5403 --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -0,0 +1,25 @@ +name: Python Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + pip install -e ./python + pip install pytest pytest-xdist + + - name: Run Python tests + run: | + cd tests + pytest --adapters adapters/python + diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml new file mode 100644 index 0000000..688dc9c --- /dev/null +++ b/.github/workflows/rust-tests.yml @@ -0,0 +1,36 @@ +name: Rust Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Build and Install Rust Project + run: | + cd rust + cargo install --path crates/mesc_cli + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' # Specify your required Python version + + - name: Install Python dependencies for testing + run: | + pip install pytest pytest-xdist + + - name: Run Rust tests + run: | + cd tests + pytest --adapters adapters/cli diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 4245bfc..29fde7e 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -25,5 +25,5 @@ serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { version = "1.32.0", features = ["full"] } -toolstr = { version = "0.1.3", path = "../../../../toolstr/toolstr-rust/crates/toolstr" } +toolstr = { version = "0.1.3" } url = "2.2.2" diff --git a/tests/adapters/cli b/tests/adapters/cli index 11db74b..5875665 100755 --- a/tests/adapters/cli +++ b/tests/adapters/cli @@ -1,11 +1,16 @@ #!/usr/bin/env python3 +from __future__ import annotations + import argparse import json import os import subprocess +import typing from typing import cast -from mesc.types import MescQuery + +if typing.TYPE_CHECKING: + from mesc.types import MescQuery def run_query(query: MescQuery) -> str: diff --git a/tests/adapters/python b/tests/adapters/python index d6e451a..3635a59 100755 --- a/tests/adapters/python +++ b/tests/adapters/python @@ -1,14 +1,16 @@ #!/usr/bin/env python3 +from __future__ import annotations + import argparse import json -from typing import Sequence, cast +from typing import Sequence, cast, Union from mesc.types import Endpoint, EndpointQuery import mesc -def run_query(query: EndpointQuery) -> Endpoint | Sequence[Endpoint] | None: +def run_query(query: EndpointQuery) -> Union[Endpoint, Sequence[Endpoint], None]: if query["query_type"] == "default_endpoint": default_fields = cast(mesc.types.DefaultEndpointQuery, query["fields"]) return mesc.get_default_endpoint(**default_fields) @@ -22,10 +24,10 @@ def run_query(query: EndpointQuery) -> Endpoint | Sequence[Endpoint] | None: user_input_fields = cast(mesc.types.UserInputQuery, query["fields"]) return mesc.get_endpoint_by_query(**user_input_fields) elif query["query_type"] == "multi_endpoint": - multi_endpoint_fields = cast(mesc.types.MultiEndpointQuery, query['fields']) + multi_endpoint_fields = cast(mesc.types.MultiEndpointQuery, query["fields"]) return mesc.find_endpoints(**multi_endpoint_fields) elif query["query_type"] == "global_metadata": - return mesc.get_global_metadata(**query['fields']) + return mesc.get_global_metadata(**query["fields"]) else: raise Exception("invalid query type: " + str(query["query_type"])) diff --git a/tests/generate.py b/tests/generate.py index d659e6a..ed9a009 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -3,10 +3,12 @@ from __future__ import annotations import copy -from typing import Any, TypeVar, Sequence +from typing import Any, TypeVar, Sequence, Union +import typing -from mesc import RpcConfig, Profile, Endpoint -from mesc.types import MescQuery +if typing.TYPE_CHECKING: + from mesc import RpcConfig, Profile, Endpoint + from mesc.types import MescQuery blank_config: RpcConfig = { "mesc_version": "MESC 1.0", @@ -120,14 +122,15 @@ known_networks = { } # tests are in form [test_name, env, config, query, result, should_succeed] -Test = tuple[ - str, - dict[str, str], - RpcConfig, - None | MescQuery, - Any, - bool, -] +if typing.TYPE_CHECKING: + Test = tuple[ + str, + dict[str, str], + RpcConfig, + Union[None, MescQuery], + Any, + bool, + ] def generate_tests() -> list[Test]: diff --git a/tests/test_mesc.py b/tests/test_mesc.py index d972a57..e1d3f02 100755 --- a/tests/test_mesc.py +++ b/tests/test_mesc.py @@ -14,22 +14,26 @@ from typing import ( Generator, Mapping, cast, + Union, ) import pytest import generate -from mesc.types import EndpointQuery, MultiEndpointQuery, RpcConfig +import typing -# tests are in form [test_name, env, config, query, result, should_succeed] -Test = tuple[ - str, - dict[str, str], - RpcConfig, - None | EndpointQuery | MultiEndpointQuery, - Any, - bool, -] +if typing.TYPE_CHECKING: + from mesc.types import RpcConfig, MescQuery + + # tests are in form [test_name, env, config, query, result, should_succeed] + Test = tuple[ + str, + dict[str, str], + RpcConfig, + Union[None, MescQuery], + Any, + bool, + ] class AdapterFailure(Exception): From 24c6c3fd11dc874a1ff9ee9df774b8092e7b0129 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 14:08:38 -0800 Subject: [PATCH 43/85] Update README.md --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 89cefad..e201b71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ # Multiple Endpoint Shared Configuration (MESC) Standard [![Specification](https://img.shields.io/badge/Spec-blueviolet)](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md) -[![issues - badge-generator](https://img.shields.io/badge/Docs-green)](https://paradigmxyz.github.io/mesc) +[![issues - badge-generator](https://img.shields.io/badge/Docs-blueviolet)](https://paradigmxyz.github.io/mesc) +[![Rust Tests](https://github.com/paradigmxyz/mesc/workflows/Rust%20Tests/badge.svg)](https://github.com/paradigmxyz/mesc/tree/main/tests) +[![Python Tests](https://github.com/paradigmxyz/mesc/workflows/Python%20Tests/badge.svg)](https://github.com/paradigmxyz/mesc/tree/main/tests) + MESC is a standard for how crypto tools configure their RPC endpoints. By following this specification, a user creates a single RPC configuration that can be shared by all crypto tools on their system. @@ -12,6 +15,8 @@ MESC has two main design goals: MESC is formally defined in [SPECIFICATION.md](./SPECIFICATION.md). +Additional information can be found in the [MESC Documentation](https://paradigmxyz.github.io/mesc/). + ### Contents - [Reference Implementations](#reference-implementations) - [Quickstart](#quickstart) @@ -33,18 +38,19 @@ These implementations provide a consistent language-agnostic interface while sti ## Quickstart -The interactive [`mesc`](./cli) CLI tool makes it easy to create and manage a MESC configuration. -1. Install: `cargo install mesc_cli` -2. Create config interactively: `mesc setup` +The quickest way to use MESC is: +1. create a `mesc.json` config file +2. set the `MESC_PATH` environment variable to the path of this file -To create a MESC config manually: -1) Create a JSON file (can use [the example](./SPECIFICATION.md#example-rpcconfig) from the spec as a template). -2) Set `MESC_PATH` to the path of this JSON file. +These steps can be performed automatically using the interactive [`mesc`](./cli) CLI tool: +1. Install: `cargo install mesc_cli` +2. Perform interactive setup: `mesc setup` ## Tutorial -Below is a brief tutorial on MESC. For more detail, see [SPECIFICATION.md](./SPECIFICATION.md). +Below is a brief tutorial on MESC. For more detail, see the MESC [Specification](./SPECIFICATION.md) and [Documentation](https://paradigmxyz.github.io/mesc). +Topics: - [Tracked Information](#tracked-information) - [Common Interface](#common-interface) - [Typical Usage](#typical-usage) From 1bef23a54670df21a7e14247cdb166f05f400a3e Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 14:46:40 -0800 Subject: [PATCH 44/85] add more tests --- rust/Cargo.lock | 4 ++ tests/generate.py | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 804b0b8..c2aeaa7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2895,6 +2895,8 @@ dependencies = [ [[package]] name = "toolstr" version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af0deafe22b11f8422063fc8bf7aeeaeaf291fc644fc2926917774e9c5eea394" dependencies = [ "chrono", "polars", @@ -2907,6 +2909,8 @@ dependencies = [ [[package]] name = "toolstr_colored" version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d335176ed9b133b9d9e226656f2f486f84ebac50250c598246ac6d6d512ac05" dependencies = [ "lazy_static", "windows-sys 0.48.0", diff --git a/tests/generate.py b/tests/generate.py index ed9a009..e16981a 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -811,6 +811,18 @@ def create_invalid_config_tests() -> list[Test]: False, ) ) + config = copy.deepcopy(full_config) + config['profiles']['abc']["default_endpoint"] = "random_unknown" + tests.append( + ( + "unknown default endpoint", + {}, + config, + None, + None, + False, + ) + ) # unknown network defaults config = copy.deepcopy(full_config) @@ -825,6 +837,75 @@ def create_invalid_config_tests() -> list[Test]: False, ), ) + config = copy.deepcopy(full_config) + config['profiles']['abc']["network_defaults"]["10"] = "random_unknown" + tests.append( + ( + "unknown network defaults", + {}, + config, + None, + None, + False, + ), + ) + + # endpoint name doesn't match + config = copy.deepcopy(blank_config) + config['endpoints'] = {'other_name': blank_endpoint} + tests.append( + ( + "unknown network defaults", + {}, + # dict(blank_config, endpoints={'other_name': blank_endpoint}), + config, + None, + None, + False, + ), + ) + + # profile name doesn't match + config = copy.deepcopy(blank_config) + config['profiles'] = {'other_name': blank_profile} + tests.append( + ( + "unknown network defaults", + {}, + config, + None, + None, + False, + ), + ) + + # global default endpoint of network doesn't actually use that network + config = copy.deepcopy(full_config) + config['endpoints']['local_ethereum']['chain_id'] = '4' + tests.append( + ( + "global default endpoint of network doesn't actually use that network", + {}, + config, + None, + None, + False, + ), + ) + + # profile default endpoint of network doesn't actually use that network + config = copy.deepcopy(full_config) + config['endpoints']['llamanodes_ethereum']['chain_id'] = '4' + tests.append( + ( + "global default endpoint of network doesn't actually use that network", + {}, + config, + None, + None, + False, + ), + ) # incorrect types tests invalid_type_tests = [ @@ -992,6 +1073,38 @@ def create_invalid_config_tests() -> list[Test]: None, ), ), + ( + "profile profile_metadata is null", + set_path_value( + copy.deepcopy(full_config), + ["profiles", "xyz", "profile_metadata"], + None, + ), + ), + ( + "profile profile_metadata is int", + set_path_value( + copy.deepcopy(full_config), + ["profiles", "xyz", "profile_metadata"], + 1, + ), + ), + ( + "profile use_mesc is null", + set_path_value( + copy.deepcopy(full_config), + ["profiles", "xyz", "use_mesc"], + None, + ), + ), + ( + "profile use_mesc is int", + set_path_value( + copy.deepcopy(full_config), + ["profiles", "xyz", "use_mesc"], + 1, + ), + ), ( "global metadata is int", set_path_value(copy.deepcopy(full_config), ["global_metadata"], 1), From d697e502e805ec1b2b0203bf59d560288dbfa033 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 15:07:52 -0800 Subject: [PATCH 45/85] update specification --- SPECIFICATION.md | 11 +++++++---- docs/src/queries.md | 5 +++-- python/README.md | 6 +++++- rust/README.md | 4 ++++ rust/crates/mesc_cli/src/cli/subcommands/help.rs | 14 +++++++++++--- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 503395a..2aab993 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -112,10 +112,10 @@ MESC is built using three key-value data schemas: | `use_mesc` | `bool` | whether to disable MESC when this profile is selected Requirements: -- All keys of `RpcConfig` and `Endpoint` are required. No additional keys should be present, except within `global_metadata`, `profile_metadata`, and `endpoint_metadata`. +- All keys of `RpcConfig` and `Endpoint` are required. No additional keys must be present, except within `global_metadata`, `profile_metadata`, and `endpoint_metadata`. - Every endpoint name specified in `RpcConfig.default_endpoint` and in `RpcConfig.network_defaults` must exist in `RpcConfig.endpoints`. - These key-value structures can be easily represented in JSON and in most common programming languages. -- Each `chain_id` should be represented using either a decimal string or a hex string. Strings are used because chain id's can be 256 bits and most languages do not have native 256 bit integer types. For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. +- EVM `chain_id`'s must be represented using either a decimal string or a hex string. Strings are used because chain id's can be 256 bits and most programming languages do not have native 256 bit integer types. For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. - Names of endpoints, networks, and profiles should be composed of characters that are either alphanumeric, dashes, underscores, or periods. Names should be at least 1 character long. ##### Metadata @@ -207,7 +207,7 @@ These overrides use a simple syntax that is intended to be easily written by hum When a user specifies an endpoint, as in `-r `, a MESC library must resolve this input into an endpoint URL. It is generally preferable to allow this user query to be a URL, an endpoint name, a network name, or a chain_id. -MESC data should be searched in the following order: +MESC data must be searched in the following order: 1. endpoint names 2. chain_id 3. network name @@ -358,7 +358,10 @@ endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) +endpoints: Sequence[Endpoint] = mesc.find_endpoints(chain_id=5) + +# get non-endpoint metadata +metadata: Mapping[str, Any] = mesc.get_global_metadata(profile='xyz_tool') ``` A reference implementation is provided in the supplemental files of this repository. diff --git a/docs/src/queries.md b/docs/src/queries.md index 71803e4..e909e03 100644 --- a/docs/src/queries.md +++ b/docs/src/queries.md @@ -1,6 +1,6 @@ # Querying MESC data -Each MESC implementation provides the same set of 6 functions for querying MESC data. +Each MESC implementation provides the same set of 7 functions for querying MESC data. The behavior of these functions is the same across languages. @@ -11,7 +11,8 @@ The behavior of these functions is the same across languages. | `get_endpoint_by_network()` | `Endpoint` or `None` | get default endpoint for network | `get_endpoint_by_network(5, profile='xyz')` | | `get_endpoint_by_name()` | `Endpoint` or `None` | get endpoint by name | `get_endpoint_by_name('local_goerli')` | | `get_endpoint_by_query()` | `Endpoint` or `None` | get endpoint for user input query | `get_endpoint_by_query(user_str, profile='xyz')` | -| `find_endpoints()` | `list[Endpoint]` | find endpoint that match input criteria | `find_endpoints(chain_id=5)` | +| `find_endpoints()` | `Sequence[Endpoint]` | find endpoint that match input criteria | `find_endpoints(chain_id=5)` | +| `get_global_metadata()` | `Mapping[str, Any]` | get non-endpoint metadata | `get_global_metadata(profile='xyz')` | The `profile` argument is optional for each function (it allows users to customize the settings for each tool, see [Profiles](./profiles.md) for details). diff --git a/python/README.md b/python/README.md index d1d9f1a..987274e 100644 --- a/python/README.md +++ b/python/README.md @@ -24,6 +24,7 @@ pip install ./ ## Example Usage ```python +from typing import Any, Mapping, Sequence import mesc # check whether mesc is enabled @@ -49,7 +50,10 @@ endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) +endpoints: Sequence[Endpoint] = mesc.find_endpoints(chain_id=5) + +# get non-endpoint metadata +metadata: Mapping[str, Any] = mesc.get_global_metadata(profile='xyz_tool') ``` ## Reference diff --git a/rust/README.md b/rust/README.md index f34211f..bc38369 100644 --- a/rust/README.md +++ b/rust/README.md @@ -61,6 +61,7 @@ use mesc::MescError; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; +type MetadataResult = Result, MescError> // check whether mesc is enabled let enabled: bool = mesc::is_mesc_enabled(); @@ -87,4 +88,7 @@ let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_t // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); let endpoints: MultiResult = mesc::find_endpoints(query); + +// get non-endpoint metadata +let metadata: MetadataResult = mesc::get_global_metadata(Some("xyz_tool")); ``` diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index 53f54a5..f768f1e 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -141,7 +141,8 @@ fn print_code(content: String, filetype: &str) { } fn print_python_interface() { - let interface = r#"import mesc + let interface = r#"from typing import Any, Mapping, Sequence +import mesc # check whether mesc is enabled enabled: bool = mesc.is_mesc_enabled() @@ -166,7 +167,10 @@ endpoint: Endpoint | None = mesc.get_endpoint_by_name('local_goerli') endpoint: Endpoint | None = mesc.get_endpoint_by_query(user_str, profile='xyz_tool') # find all endpoints matching given criteria -endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5)"#; +endpoints: Sequence[Endpoint] = mesc.find_endpoints(chain_id=5) + +# get non-endpoint metadata +metadata: Mapping[str, Any] = mesc.get_global_metadata(profile='xyz_tool')"#; print_code(interface.to_string(), "py") } @@ -177,6 +181,7 @@ use mesc::MescError; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; +type MetadataResult = Result, MescError> // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); @@ -199,7 +204,10 @@ let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_t // find all endpoints matching given criteria let query = mesc::MultiEndpointQuery::new().chain_id(5); -let endpoints: MultiResult = mesc::find_endpoints(query);"#; +let endpoints: MultiResult = mesc::find_endpoints(query); + +// get non-endpoint metadata +let metadata: MetadataResult = mesc::get_global_metadata(Some("xyz_tool"));"#; print_code(interface.to_string(), "rs") } From bdcb4429b390e6beb0f60561f3888148cb0574aa Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 20:10:49 -0800 Subject: [PATCH 46/85] update why_mesc.md --- docs/src/why_mesc.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/src/why_mesc.md b/docs/src/why_mesc.md index c86b43c..822a786 100644 --- a/docs/src/why_mesc.md +++ b/docs/src/why_mesc.md @@ -14,3 +14,13 @@ Instead it would be desirable to have a solution that: - is backwards compatible with previous solutions MESC aims to satisfy all of these constraints. + + +## As a developer, why should I integrate MESC into my tools? + +- **Easier Onboarding**. As soon as a user installs your tool, they will be able to use your tool with all of their configured networks. This eliminates one of the major setup steps for most RPC consuming tools. +- **Interoperability**. If you maintain multiple tools, or your tool has components in multiple languages, MESC will create a single, shared source of truth across all of these tool components. +- **Safety and Robustness**. MESC is thoroughly tested against a large number of config-related edge cases. In many cases it will be safer to user MESC than to create a configuration system from scratch. +- **Minimize maintenance burden**. Leaning on MESC to handle configuration means there is one less thing you need to maintain. You can spend your time on other things. +- **Developer Features**. If you need to develop or test your tool with multiple endpoints, the `mesc` CLI tools contains many useful developer features for managing endpoints. +- **Go config-free**. In some cases, adopting MESC means that your tool no longer needs its own config. You can store your tool's config data in MESC's metadata and then just use MESC for all config IO. From e6cb41b4ea2bb88c1e8fb09537fa6a1ac5cca29c Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 20:11:43 -0800 Subject: [PATCH 47/85] fix decimal vs hex equivalence --- SPECIFICATION.md | 2 +- python/mesc/interface.py | 17 ++- python/mesc/network_utils.py | 29 +++++ python/mesc/validation.py | 32 +++++- rust/crates/mesc/src/interface.rs | 2 +- rust/crates/mesc/src/query.rs | 43 ++++++-- rust/crates/mesc/src/types/chain_ids.rs | 54 +++++++-- tests/generate.py | 140 ++++++++++++++++++++++-- 8 files changed, 280 insertions(+), 39 deletions(-) diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 2aab993..e031e9e 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -115,7 +115,7 @@ Requirements: - All keys of `RpcConfig` and `Endpoint` are required. No additional keys must be present, except within `global_metadata`, `profile_metadata`, and `endpoint_metadata`. - Every endpoint name specified in `RpcConfig.default_endpoint` and in `RpcConfig.network_defaults` must exist in `RpcConfig.endpoints`. - These key-value structures can be easily represented in JSON and in most common programming languages. -- EVM `chain_id`'s must be represented using either a decimal string or a hex string. Strings are used because chain id's can be 256 bits and most programming languages do not have native 256 bit integer types. For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. +- EVM `chain_id`'s must be represented using either a decimal string or a `0x`-prefixed hex string. Strings are used because chain id's can be 256 bits and most programming languages do not have native 256 bit integer types. For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. - Names of endpoints, networks, and profiles should be composed of characters that are either alphanumeric, dashes, underscores, or periods. Names should be at least 1 character long. ##### Metadata diff --git a/python/mesc/interface.py b/python/mesc/interface.py index 9602135..e02055c 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -71,15 +71,18 @@ def get_endpoint_by_network( raise ValueError('chain_id must be a str or int') chain_id = str(chain_id) network_defaults = config['network_defaults'] - default_name = network_defaults.get(chain_id) + default_name = network_utils.get_by_chain_id(network_defaults, chain_id) # get profile default for network - if profile and profile in config['profiles']: + if profile is not None and profile in config['profiles']: if not config['profiles'][profile]['use_mesc']: return None - name = config['profiles'][profile]['network_defaults'].get( - chain_id, default_name + name = network_utils.get_by_chain_id( + config['profiles'][profile]['network_defaults'], + chain_id, ) + if name is None: + name = default_name else: name = default_name @@ -143,8 +146,12 @@ def find_endpoints( if chain_id is not None: if isinstance(chain_id, int): chain_id = str(chain_id) + chain_id = network_utils.chain_id_to_standard_hex(chain_id) endpoints = [ - endpoint for endpoint in endpoints if endpoint['chain_id'] == chain_id + endpoint + for endpoint in endpoints + if endpoint['chain_id'] is not None + and network_utils.chain_id_to_standard_hex(endpoint['chain_id']) == chain_id ] # check name_contains diff --git a/python/mesc/network_utils.py b/python/mesc/network_utils.py index ed1adc7..c0544e5 100644 --- a/python/mesc/network_utils.py +++ b/python/mesc/network_utils.py @@ -1,5 +1,6 @@ from __future__ import annotations +import typing from .types import RpcConfig from . import network_names @@ -31,3 +32,31 @@ def network_name_to_chain_id( return chain_id else: return None + + +def chain_id_to_standard_hex(chain_id: str) -> str | None: + if chain_id.startswith('0x'): + if len(chain_id) > 2: + as_hex = chain_id + else: + try: + as_hex = hex(int(chain_id)) + except ValueError: + return None + + return '0x' + as_hex[2:].lstrip('0') + + +T = typing.TypeVar('T') + + +def get_by_chain_id(mapping: typing.Mapping[str, T], chain_id: str) -> T | None: + if chain_id in mapping: + return mapping[chain_id] + + standard_mapping = {chain_id_to_standard_hex(k): v for k, v in mapping.items()} + return standard_mapping.get(chain_id_to_standard_hex(chain_id)) + + +def chain_ids_equal(lhs: str, rhs: str) -> bool: + return chain_id_to_standard_hex(lhs) == chain_id_to_standard_hex(rhs) diff --git a/python/mesc/validation.py b/python/mesc/validation.py index c79bbf9..9ed0f16 100644 --- a/python/mesc/validation.py +++ b/python/mesc/validation.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing_extensions import Any +from typing import Sequence from .exceptions import InvalidConfig from .types import rpc_config_types, endpoint_types, profile_types @@ -100,7 +101,9 @@ def validate(config: Any) -> None: # default endpoints of each network actually use that specified network for chain_id, endpoint_name in config['network_defaults'].items(): - if chain_id != config['endpoints'][endpoint_name]['chain_id']: + if not network_utils.chain_ids_equal( + chain_id, config['endpoints'][endpoint_name]['chain_id'] + ): raise InvalidConfig( 'Endpoint is set as the default endpoint of network ' + chain_id @@ -109,7 +112,9 @@ def validate(config: Any) -> None: ) for profile_name, profile in config['profiles'].items(): for chain_id, endpoint_name in profile['network_defaults'].items(): - if chain_id != config['endpoints'][endpoint_name]['chain_id']: + if not network_utils.chain_ids_equal( + chain_id, config['endpoints'][endpoint_name]['chain_id'] + ): raise InvalidConfig( 'Endpoint is set as the default endpoint of network ' + chain_id @@ -165,7 +170,28 @@ def validate(config: Any) -> None: ) # no duplicate default network entries using decimal vs hex - pass + ensure_no_chain_id_collisions( + list(config['network_defaults'].keys()), 'network defaults' + ) + for profile_name, profile in config['profiles'].items(): + ensure_no_chain_id_collisions( + list(config['network_defaults'].keys()), 'profile ' + profile_name + ) + + +def ensure_no_chain_id_collisions(chain_ids: Sequence[str], name: str) -> None: + hex_numbers = set() + for chain_id in chain_ids: + as_hex = network_utils.chain_id_to_standard_hex(chain_id) + if as_hex in hex_numbers: + raise Exception( + 'chain_id collision, ' + + str(name) + + ' has multiple decimal/hex values for chain_id: ' + + str(chain_id) + ) + else: + hex_numbers.add(as_hex) def _check_type( diff --git a/rust/crates/mesc/src/interface.rs b/rust/crates/mesc/src/interface.rs index 2de8e3d..21e20c1 100644 --- a/rust/crates/mesc/src/interface.rs +++ b/rust/crates/mesc/src/interface.rs @@ -18,7 +18,7 @@ pub fn get_default_endpoint(profile: Option<&str>) -> Result, M } /// get endpoint by network -pub fn get_endpoint_by_network( +pub fn get_endpoint_by_network( chain_id: T, profile: Option<&str>, ) -> Result, MescError> { diff --git a/rust/crates/mesc/src/query.rs b/rust/crates/mesc/src/query.rs index 1e48523..57c1984 100644 --- a/rust/crates/mesc/src/query.rs +++ b/rust/crates/mesc/src/query.rs @@ -1,7 +1,7 @@ use crate::{ directory, types::{Endpoint, MescError, RpcConfig}, - MultiEndpointQuery, TryIntoChainId, + ChainId, MultiEndpointQuery, TryIntoChainId, }; use std::collections::HashMap; @@ -10,14 +10,14 @@ pub fn get_default_endpoint( config: &RpcConfig, profile: Option<&str>, ) -> Result, MescError> { - // if using a profile, check if that profile has a default endpoint for chain_id + // if using a profile, check if that profile has a default endpoint if let Some(profile) = profile { if let Some(profile_data) = config.profiles.get(profile) { if !profile_data.use_mesc { - return Ok(None) + return Ok(None); } if let Some(endpoint_name) = profile_data.default_endpoint.as_deref() { - return get_endpoint_by_name(config, endpoint_name) + return get_endpoint_by_name(config, endpoint_name); } } }; @@ -29,7 +29,7 @@ pub fn get_default_endpoint( } /// get endpoint by network -pub fn get_endpoint_by_network( +pub fn get_endpoint_by_network( config: &RpcConfig, chain_id: T, profile: Option<&str>, @@ -40,21 +40,40 @@ pub fn get_endpoint_by_network( if let Some(profile) = profile { if let Some(profile_data) = config.profiles.get(profile) { if !profile_data.use_mesc { - return Ok(None) + return Ok(None); } if let Some(endpoint_name) = profile_data.network_defaults.get(&chain_id) { - return get_endpoint_by_name(config, endpoint_name) + return get_endpoint_by_name(config, endpoint_name); } } }; // check if base configuration has a default endpoint for that chain_id - match config.network_defaults.get(&chain_id) { - Some(name) => get_endpoint_by_name(config, name), + match get_by_chain_id(&config.network_defaults, chain_id)? { + Some(name) => get_endpoint_by_name(config, name.as_str()), None => Ok(None), } } +fn get_by_chain_id( + mapping: &HashMap, + chain_id: T, +) -> Result, MescError> { + let chain_id = chain_id.try_into_chain_id()?; + if let Some(value) = mapping.get(&chain_id) { + Ok(Some(value.clone())) + } else { + let standard_chain_id = chain_id.to_hex_256()?; + let results: Result, _> = mapping + .iter() + .map(|(k, v)| k.to_hex_256().map(|hex| (hex, v.clone()))) + .collect::, _>>() // Collect into a Result, Error> + .map(|pairs| pairs.into_iter().collect::>()); + let standard_mapping = results?; + Ok(standard_mapping.get(&standard_chain_id).cloned()) + } +} + /// get endpoint by name pub fn get_endpoint_by_name(config: &RpcConfig, name: &str) -> Result, MescError> { if let Some(endpoint) = config.endpoints.get(name) { @@ -73,7 +92,7 @@ pub fn get_endpoint_by_query( if let Some(profile) = profile { if let Some(profile_data) = config.profiles.get(profile) { if !profile_data.use_mesc { - return Ok(None) + return Ok(None); } } } @@ -108,7 +127,7 @@ pub fn find_endpoints( let mut candidates: Vec = config.endpoints.clone().into_values().collect(); if let Some(chain_id) = query.chain_id { - candidates.retain(|endpoint| endpoint.chain_id.as_ref() == Some(&chain_id)) + candidates.retain(|endpoint| endpoint.chain_id.as_ref() == Some(&chain_id)); } if let Some(name) = query.name_contains { @@ -133,7 +152,7 @@ pub fn get_global_metadata( if let Some(profile) = profile { if let Some(profile_data) = config.profiles.get(profile) { if !profile_data.use_mesc { - return Ok(HashMap::new()) + return Ok(HashMap::new()); } metadata.extend(profile_data.profile_metadata.clone()) } diff --git a/rust/crates/mesc/src/types/chain_ids.rs b/rust/crates/mesc/src/types/chain_ids.rs index 6b0c4be..09bd4a5 100644 --- a/rust/crates/mesc/src/types/chain_ids.rs +++ b/rust/crates/mesc/src/types/chain_ids.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; /// ChainId is a string representation of an integer chain id /// - TryFrom conversions allow specifying as String, &str, uint, or binary data -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Hash)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq)] pub struct ChainId(String); impl ChainId { @@ -23,12 +23,14 @@ impl ChainId { /// convert to hex representation, zero-padded to 256 bits pub fn to_hex_256(&self) -> Result { let ChainId(chain_id) = self; - if chain_id.starts_with("0x") { - Ok(chain_id.clone()) + if let Some(stripped) = chain_id.strip_prefix("0x") { + Ok(format!("0x{:0>64}", stripped)) } else { - match chain_id.parse::() { - Ok(number) => Ok(format!("0x{:016x}", number)), - Err(_) => Err(MescError::IntegrityError("bad chain_id".to_string())), + match chain_id.parse::() { + Ok(number) => Ok(format!("0x{:064x}", number)), + Err(_) => { + Err(MescError::InvalidChainId("cannot convert chain_id to hex".to_string())) + } } } } @@ -40,12 +42,42 @@ impl ChainId { } } +impl std::hash::Hash for ChainId { + fn hash(&self, state: &mut H) { + match self.to_hex_256() { + Ok(as_hex) => { + as_hex.hash(state); + } + _ => { + let ChainId(contents) = self; + contents.hash(state); + } + } + } +} + impl PartialOrd for ChainId { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } +impl PartialEq for ChainId { + fn eq(&self, other: &Self) -> bool { + let self_string: String = match self.to_hex() { + Ok(s) => s[2..].to_string(), + Err(_) => return self == other, + }; + let other_string = match other.to_hex() { + Ok(s) => s[2..].to_string(), + Err(_) => return self == other, + }; + let self_str = format!("{:0>79}", self_string); + let other_str = format!("{:0>79}", other_string); + self_str.eq(&other_str) + } +} + impl Ord for ChainId { fn cmp(&self, other: &Self) -> std::cmp::Ordering { let self_string: String = match self.to_hex() { @@ -96,7 +128,10 @@ impl TryIntoChainId for ChainId { impl TryIntoChainId for String { fn try_into_chain_id(self) -> Result { - if !self.is_empty() && self.chars().all(|c| c.is_ascii_digit()) { + if !self.is_empty() && + (self.chars().all(|c| c.is_ascii_digit()) || + (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) + { Ok(ChainId(self)) } else { Err(MescError::InvalidChainId(self)) @@ -106,7 +141,10 @@ impl TryIntoChainId for String { impl TryIntoChainId for &str { fn try_into_chain_id(self) -> Result { - if self.chars().all(|c| c.is_ascii_digit()) { + if !self.is_empty() && + (self.chars().all(|c| c.is_ascii_digit()) || + (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) + { Ok(ChainId(self.to_string())) } else { Err(MescError::InvalidChainId(self.to_string())) diff --git a/tests/generate.py b/tests/generate.py index e16981a..99c0c73 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -68,7 +68,7 @@ full_config: RpcConfig = { "llamanodes_ethereum": { "name": "llamanodes_ethereum", "url": "https://eth.llamarpc.com", - "chain_id": "1", + "chain_id": "0x01", "endpoint_metadata": {}, }, "llamanodes_optimism": { @@ -77,6 +77,12 @@ full_config: RpcConfig = { "chain_id": "10", "endpoint_metadata": {}, }, + "llamanodes_base": { + "name": "llamanodes_base", + "url": "https://base.llamarpc.com", + "chain_id": "0x2105", + "endpoint_metadata": {}, + }, }, "profiles": { "abc": { @@ -90,8 +96,9 @@ full_config: RpcConfig = { "name": "xyz", "default_endpoint": "llamanodes_ethereum", "network_defaults": { - "1": "llamanodes_ethereum", + "0x00001": "llamanodes_ethereum", "10": "llamanodes_optimism", + "8453": "llamanodes_base", }, "profile_metadata": { "sample_key": "profile_value", @@ -144,6 +151,64 @@ def generate_tests() -> list[Test]: tests = [test for generator in generators for test in generator()] + # for queries that specify chain_id, also specify hexadecimal chain_id + for test in list(tests): + query = test[3] + if query is not None and "profile" in query.get("fields", {}): + if query["fields"].get("chain_id") is not None: + # version without leading zeros + chain_id = query["fields"]["chain_id"] # type: ignore + as_hex = hex(int(chain_id)) # type: ignore + new_test = copy.deepcopy(test) + new_test[3]["fields"]["chain_id"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + + # version with 1 extra leading zero + chain_id = query["fields"]["chain_id"] # type: ignore + as_hex = "0x" + "0" + hex(int(chain_id))[2:] # type: ignore + new_test = copy.deepcopy(test) + new_test[3]["fields"]["chain_id"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + + # version with 4 extra leading zeros + chain_id = query["fields"]["chain_id"] # type: ignore + as_hex = "0x" + "0000" + hex(int(chain_id))[2:] # type: ignore + new_test = copy.deepcopy(test) + new_test[3]["fields"]["chain_id"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + + if ( + query["fields"].get("user_input") is not None + and isinstance(query["fields"]["user_input"], str) # type: ignore + and query["fields"]["user_input"].isdecimal() # type: ignore + ): + # version without leading zeros + chain_id = query["fields"]["user_input"] # type: ignore + as_hex = hex(int(chain_id)) + new_test = copy.deepcopy(test) + new_test[3]["fields"]["user_input"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + + # version with 1 extra leading zero + chain_id = query["fields"]["user_input"] # type: ignore + as_hex = "0x" + "0" + hex(int(chain_id))[2:] + new_test = copy.deepcopy(test) + new_test[3]["fields"]["user_input"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + + # version with 4 extra leading zeros + chain_id = query["fields"]["user_input"] # type: ignore + as_hex = "0x" + "0000" + hex(int(chain_id))[2:] + new_test = copy.deepcopy(test) + new_test[3]["fields"]["user_input"] = as_hex # type: ignore + new_test = (new_test[0] + ", hex chain_id",) + new_test[1:] + tests.append(new_test) + # for tests that query with null profile, also query with non-existent profile for test in list(tests): query = test[3] @@ -154,7 +219,6 @@ def generate_tests() -> list[Test]: ): new_test = copy.deepcopy(test) new_test[3]["fields"]["profile"] = "unknown_profile" # type: ignore - new_test = (new_test[0] + ", unknown_profile",) + new_test[1:] tests.append(new_test) @@ -309,6 +373,28 @@ def create_basic_query_tests() -> list[Test]: None, True, ), + ( + "get endpoint by network, base", + {}, + full_config, + { + "query_type": "endpoint_by_network", + "fields": {"chain_id": "8453", "profile": None}, + }, + None, + True, + ), + ( + "get endpoint by network, base, profile", + {}, + full_config, + { + "query_type": "endpoint_by_network", + "fields": {"chain_id": "8453", "profile": "xyz"}, + }, + full_config["endpoints"]["llamanodes_base"], + True, + ), ( "get endpoint by network profile fallback", {}, @@ -655,6 +741,7 @@ def create_basic_query_tests() -> list[Test]: [ full_config["endpoints"]["llamanodes_ethereum"], full_config["endpoints"]["llamanodes_optimism"], + full_config["endpoints"]["llamanodes_base"], ], True, ), @@ -812,7 +899,7 @@ def create_invalid_config_tests() -> list[Test]: ) ) config = copy.deepcopy(full_config) - config['profiles']['abc']["default_endpoint"] = "random_unknown" + config["profiles"]["abc"]["default_endpoint"] = "random_unknown" tests.append( ( "unknown default endpoint", @@ -838,7 +925,7 @@ def create_invalid_config_tests() -> list[Test]: ), ) config = copy.deepcopy(full_config) - config['profiles']['abc']["network_defaults"]["10"] = "random_unknown" + config["profiles"]["abc"]["network_defaults"]["10"] = "random_unknown" tests.append( ( "unknown network defaults", @@ -852,7 +939,7 @@ def create_invalid_config_tests() -> list[Test]: # endpoint name doesn't match config = copy.deepcopy(blank_config) - config['endpoints'] = {'other_name': blank_endpoint} + config["endpoints"] = {"other_name": blank_endpoint} tests.append( ( "unknown network defaults", @@ -867,7 +954,7 @@ def create_invalid_config_tests() -> list[Test]: # profile name doesn't match config = copy.deepcopy(blank_config) - config['profiles'] = {'other_name': blank_profile} + config["profiles"] = {"other_name": blank_profile} tests.append( ( "unknown network defaults", @@ -881,7 +968,7 @@ def create_invalid_config_tests() -> list[Test]: # global default endpoint of network doesn't actually use that network config = copy.deepcopy(full_config) - config['endpoints']['local_ethereum']['chain_id'] = '4' + config["endpoints"]["local_ethereum"]["chain_id"] = "4" tests.append( ( "global default endpoint of network doesn't actually use that network", @@ -895,7 +982,7 @@ def create_invalid_config_tests() -> list[Test]: # profile default endpoint of network doesn't actually use that network config = copy.deepcopy(full_config) - config['endpoints']['llamanodes_ethereum']['chain_id'] = '4' + config["endpoints"]["llamanodes_ethereum"]["chain_id"] = "4" tests.append( ( "global default endpoint of network doesn't actually use that network", @@ -907,6 +994,41 @@ def create_invalid_config_tests() -> list[Test]: ), ) + # conflicting chain_ids in global network defaults + config = copy.deepcopy(full_config) + config["network_defaults"]["8453"] = "llamanodes_base" + config["network_defaults"]["0x2105"] = "llamanodes_base" + tests.append( + ( + "conflicting chain_ids in global network defaults", + {}, + config, + None, + None, + False, + ), + ) + + # conflicting chain_ids in profile network defaults + for profile_name, profile_data in full_config["profiles"].items(): + config = copy.deepcopy(full_config) + config["profiles"][profile_name]["network_defaults"]["8453"] = "llamanodes_base" + config["profiles"][profile_name]["network_defaults"][ + "0x2105" + ] = "llamanodes_base" + tests.append( + ( + "conflicting chain_ids in profile " + + profile_name + + " network defaults", + {}, + config, + None, + None, + False, + ), + ) + # incorrect types tests invalid_type_tests = [ ( From 67dcf691fb4fd5fccd21d161af1665f397fe4d50 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 20:53:45 -0800 Subject: [PATCH 48/85] remove .bash_profile from default shell config targets --- rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs index 7c73ffa..aad4254 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs @@ -22,7 +22,6 @@ pub(crate) fn get_shell_config_paths() -> Result, MescCliError> { let candidates = vec![ home_path.join(".bashrc"), home_path.join(".profile"), - home_path.join(".bash_profile"), ]; Ok(candidates) } From c15995a6147baef48b6c52d8652d0ccf9e918659 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 20:58:31 -0800 Subject: [PATCH 49/85] create shell configs that do not exist --- .../src/cli/subcommands/setup/shell_config.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs index aad4254..1704455 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs @@ -19,10 +19,7 @@ pub(crate) fn get_shell_config_paths() -> Result, MescCliError> { let home_dir = std::env::var("HOME").map_err(|_| MescCliError::Error("home dir not found".to_string()))?; let home_path = PathBuf::from(home_dir); - let candidates = vec![ - home_path.join(".bashrc"), - home_path.join(".profile"), - ]; + let candidates = vec![home_path.join(".bashrc"), home_path.join(".profile")]; Ok(candidates) } @@ -56,11 +53,6 @@ pub(crate) fn modify_shell_config_var( } } - println!("NOT_SET {:?}", not_set); - println!("COMPLEX_MENTIONS {:?}", complex_mentions); - println!("SET_ALREADY {:?}", set_already); - println!("SET_WRONG {:?}", set_wrong); - // modify shell configs accordingly match (not_set.len(), complex_mentions.len(), set_wrong.len(), set_already.len()) { (0, 0, 0, 0) => { @@ -225,6 +217,10 @@ pub(crate) fn replace_mentions>( new_value: &str, ) -> Result<(), MescCliError> { let path = path.as_ref(); + + if !path.exists() { + let _file = File::create(path)?; + } let file = File::open(path)?; let reader = BufReader::new(file); From 3121581277bdbe47b0cfd24622a0099ffc4566dd Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 21:25:09 -0800 Subject: [PATCH 50/85] print notice about restarting shell after updating config files --- .../src/cli/subcommands/setup/command.rs | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs index 74727b5..d6a890f 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -1,6 +1,7 @@ use crate::{MescCliError, SetupArgs}; use mesc::{MescError, RpcConfig}; use toolstr::Colorize; +use std::path::PathBuf; use super::{config_modification::*, inquire_utils::*, selectors::*, shell_config::*, writing::*}; @@ -9,7 +10,7 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { if args.editor { edit_config_in_editor(args) } else { - let mode = get_write_mode()?; + let (mode, shell_config_modified) = get_write_mode()?; let config = load_config_data(&mode)?; let endpoint_word = if config.endpoints.len() == 1 { "endpoint" } else { "endpoints" }; let profile_word = if config.profiles.len() == 1 { "profile" } else { "profiles" }; @@ -21,7 +22,12 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { profile_word, ); println!(); - modify_existing_config(config, Some(mode)).await + let result = modify_existing_config(config, Some(mode)).await; + if shell_config_modified { + println!(); + println!("{}", "Shell config files were modified. Restart shell to load these files.".magenta()) + } + result } } @@ -39,7 +45,7 @@ fn edit_config_in_editor(args: SetupArgs) -> Result<(), MescCliError> { } /// get write mode for config -fn get_write_mode() -> Result { +fn get_write_mode() -> Result<(ConfigWriteMode, bool), MescCliError> { match ( std::env::var("MESC_MODE").as_deref(), std::env::var("MESC_PATH").as_deref(), @@ -55,9 +61,9 @@ fn get_write_mode() -> Result { "ENV".green().bold() ); let config_mode = select_config_mode()?; - setup_mesc_mode_env_var(&config_mode)?; - setup_mesc_env_vars(&config_mode)?; - Ok(config_mode) + let modified_first = setup_mesc_mode_env_var(&config_mode)?; + let modified_second = setup_mesc_env_vars(&config_mode)?; + Ok((config_mode, !modified_first.is_empty() || !modified_second.is_empty())) } (Ok("PATH"), Ok(path), _, _) | (Err(_), Ok(path), _, _) => { let path = mesc::load::expand_path(path)?; @@ -65,8 +71,7 @@ fn get_write_mode() -> Result { let print_path = if let Ok(raw_path) = std::env::var("MESC_PATH") { raw_path } else { path.clone() }; println!(" Using {}{}", "MESC_PATH=".green().bold(), print_path.green().bold()); - - Ok(ConfigWriteMode::Path(path.into())) + Ok((ConfigWriteMode::Path(path.into()), false)) } (Ok("PATH"), Err(_), _, _) => { println!(" MESC is enabled"); @@ -77,13 +82,13 @@ fn get_write_mode() -> Result { ); let path = select_config_path()?; println!(" Using config path: {}", path.to_string_lossy().green().bold()); - setup_mesc_path_env_var(&path)?; - Ok(ConfigWriteMode::Path(path)) + let modified_files = setup_mesc_path_env_var(&path)?; + Ok((ConfigWriteMode::Path(path), !modified_files.is_empty())) } (Ok("ENV"), _, Ok(_env), _) | (Err(_), Err(_), Ok(_env), _) => { println!(" MESC is enabled"); println!(" Using {}", "MESC_MODE=ENV".green().bold()); - Ok(ConfigWriteMode::Env(vec![])) + Ok((ConfigWriteMode::Env(vec![]), false)) } (Ok("ENV"), _, Err(_), _) => { println!(" MESC is enabled"); @@ -92,7 +97,7 @@ fn get_write_mode() -> Result { "MESC_MODE=ENV".green().bold(), "MESC_ENV".green().bold() ); - Ok(ConfigWriteMode::Env(vec![])) + Ok((ConfigWriteMode::Env(vec![]), false)) } (Ok(other), _, _, _) => { eprintln!("Invaild value for {}: {}", "MESC_MODE".green().bold(), other.green().bold()); @@ -112,15 +117,15 @@ fn get_write_mode() -> Result { "MESC_ENV".green().bold() ); let mode = select_config_mode()?; - setup_mesc_env_vars(&mode)?; - Ok(mode) + let modified_files = setup_mesc_env_vars(&mode)?; + Ok((mode, !modified_files.is_empty())) } (Err(_), Err(_), Err(_), false) => { println!(" MESC is disabled because no MESC env vars are set"); println!(" To enabled MESC, set one of the MESC env vars"); let mode = select_config_mode()?; - setup_mesc_env_vars(&mode)?; - Ok(mode) + let modified_files = setup_mesc_env_vars(&mode)?; + Ok((mode, !modified_files.is_empty())) } } } @@ -210,24 +215,22 @@ fn load_config_data(mode: &ConfigWriteMode) -> Result { Ok(config) } -fn setup_mesc_mode_env_var(mode: &ConfigWriteMode) -> Result<(), MescCliError> { +fn setup_mesc_mode_env_var(mode: &ConfigWriteMode) -> Result, MescCliError> { let value = match mode { ConfigWriteMode::Path(_) => "PATH", ConfigWriteMode::Env(_) => "ENV", }; - modify_shell_config_var("MESC_MODE", value.to_string(), None)?; - Ok(()) + modify_shell_config_var("MESC_MODE", value.to_string(), None) } -fn setup_mesc_env_vars(mode: &ConfigWriteMode) -> Result<(), MescCliError> { +fn setup_mesc_env_vars(mode: &ConfigWriteMode) -> Result, MescCliError> { match mode { ConfigWriteMode::Path(path) => setup_mesc_path_env_var(path), - ConfigWriteMode::Env(_) => Ok(()), + ConfigWriteMode::Env(_) => Ok(vec![]), } } -fn setup_mesc_path_env_var(path: &std::path::Path) -> Result<(), MescCliError> { +fn setup_mesc_path_env_var(path: &std::path::Path) -> Result, MescCliError> { let value = path.to_string_lossy().to_string(); - modify_shell_config_var("MESC_PATH", value, None)?; - Ok(()) + modify_shell_config_var("MESC_PATH", value, None) } From a0302fe16c0a60d82cf387ea30121b08849456ca Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 21:31:16 -0800 Subject: [PATCH 51/85] update docs with note about ssl installation reqs --- README.md | 2 ++ docs/src/quickstart.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index e201b71..2e4d456 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ These steps can be performed automatically using the interactive [`mesc`](./cli) 1. Install: `cargo install mesc_cli` 2. Perform interactive setup: `mesc setup` +Installing the `mesc` cli on some linux distributions may require installing ssl libraries (e.g. `sudo apt-get install pkg-config libssl-dev` on ubunutu) + ## Tutorial Below is a brief tutorial on MESC. For more detail, see the MESC [Specification](./SPECIFICATION.md) and [Documentation](https://paradigmxyz.github.io/mesc). diff --git a/docs/src/quickstart.md b/docs/src/quickstart.md index e35db21..cbe0e65 100644 --- a/docs/src/quickstart.md +++ b/docs/src/quickstart.md @@ -43,6 +43,8 @@ You can create a `mesc.json` by one of two ways: The structure of the config must follow the MESC [specification](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md). +Installing the `mesc` cli on some linux distributions may require installing ssl libraries (e.g. `sudo apt-get install pkg-config libssl-dev` on ubunutu) + ## Setting environment variables The typical way to set environment variables is in your shell configuration files: `~/.bashrc`, `~.profile`, and/or `~/.bash_profile`. Including this line in those files will enable MESC: From de4e784c87cdbe61a649f541d7d0510a231fe54d Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 21:45:28 -0800 Subject: [PATCH 52/85] bump to 0.2.0 --- python/mesc/__init__.py | 2 +- rust/Cargo.lock | 517 +++++++++++++------------------- rust/Cargo.toml | 2 +- rust/crates/mesc_cli/Cargo.toml | 2 +- 4 files changed, 214 insertions(+), 309 deletions(-) diff --git a/python/mesc/__init__.py b/python/mesc/__init__.py index 9e34f3b..dd6349d 100644 --- a/python/mesc/__init__.py +++ b/python/mesc/__init__.py @@ -11,7 +11,7 @@ from .interface import ( ) from .types import Endpoint, Profile, RpcConfig -__version__ = '0.1.4' +__version__ = '0.2.0' __all__ = ( 'Endpoint', diff --git a/rust/Cargo.lock b/rust/Cargo.lock index c2aeaa7..80168c7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "getrandom", @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -106,30 +106,30 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -176,18 +176,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "atoi_simd" -version = "0.15.5" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccfc14f5c3e34de57539a7ba9c18ecde3d9bbde48d232ea1da3e468adb307fd0" +checksum = "9ae037714f313c1353189ead58ef9eec30a8e8dc101b2622d461418fd59e28a9" [[package]] name = "autocfg" @@ -228,9 +228,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bat" @@ -286,9 +286,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "brotli" @@ -341,9 +341,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" dependencies = [ "bytemuck_derive", ] @@ -356,7 +356,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -389,23 +389,23 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] name = "clap" -version = "4.4.8" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", @@ -413,9 +413,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -433,7 +433,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -485,15 +485,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -532,56 +532,46 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crossterm" @@ -605,7 +595,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "crossterm_winapi", "libc", "parking_lot", @@ -638,9 +628,9 @@ checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "edit" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c562aa71f7bc691fde4c6bf5f93ae5a5298b617c2eb44c76c87832299a17fbb4" +checksum = "f364860e764787163c8c8f58231003839be31276e821e2ad2092ddf496b1aa09" dependencies = [ "tempfile", "which", @@ -676,7 +666,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -787,9 +777,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -802,9 +792,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -812,15 +802,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -829,38 +819,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -876,9 +866,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -910,7 +900,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -919,7 +909,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "libgit2-sys", "log", @@ -961,9 +951,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -1016,9 +1006,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1028,11 +1018,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1048,9 +1038,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1071,9 +1061,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1086,7 +1076,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", @@ -1108,9 +1098,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1141,9 +1131,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1186,9 +1176,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" @@ -1201,9 +1191,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -1280,9 +1270,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libgit2-sys" @@ -1304,9 +1294,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" dependencies = [ "cc", "libc", @@ -1331,9 +1321,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -1386,18 +1376,9 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mesc" -version = "0.1.4" +version = "0.2.0" dependencies = [ "serde", "serde_json", @@ -1406,7 +1387,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.1.4" +version = "0.2.0" dependencies = [ "bat", "clap", @@ -1442,9 +1423,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", @@ -1560,18 +1541,18 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "onig" @@ -1597,11 +1578,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.61" +version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -1618,7 +1599,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1629,9 +1610,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.97" +version = "0.9.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", @@ -1707,9 +1688,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "planus" @@ -1790,7 +1771,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae73d5b8e55decde670caba1cc82b61f14bfb9a72503198f0997d657a98dcfd6" dependencies = [ "ahash", - "bitflags 2.4.1", + "bitflags 2.4.2", "bytemuck", "chrono", "comfy-table", @@ -1891,7 +1872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3555f759705be6dd0d3762d16a0b8787b2dc4da73b57465f3b2bf1a070ba8f20" dependencies = [ "ahash", - "bitflags 2.4.1", + "bitflags 2.4.2", "glob", "once_cell", "polars-arrow", @@ -2087,9 +2068,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -2105,9 +2086,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -2154,9 +2135,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" dependencies = [ "either", "rayon-core", @@ -2164,9 +2145,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -2183,29 +2164,29 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +checksum = "c4846d4c50d1721b1a3bef8af76924eef20d5e723647333798c1b519b3a9473f" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -2215,9 +2196,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -2238,9 +2219,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64", "bytes", @@ -2300,11 +2281,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.26" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -2319,9 +2300,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "safemem" @@ -2340,11 +2321,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2378,9 +2359,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "seq-macro" @@ -2390,29 +2371,29 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -2433,9 +2414,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.29" +version = "0.9.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129" +checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e" dependencies = [ "indexmap", "itoa", @@ -2497,9 +2478,9 @@ dependencies = [ [[package]] name = "simd-json" -version = "0.13.4" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a3720326b20bf5b95b72dbbd133caae7e0dcf71eae8f6e6656e71a7e5c9aaa" +checksum = "2faf8f101b9bc484337a6a6b0409cf76c139f2fb70a9e3aee6b6774be7bfbf76" dependencies = [ "ahash", "getrandom", @@ -2530,9 +2511,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "smartstring" @@ -2551,16 +2532,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.5" @@ -2635,7 +2606,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2651,9 +2622,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2734,22 +2705,22 @@ checksum = "cfb5fa503293557c5158bd215fdc225695e567a77e453f5d4452a50a193969bd" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -2766,22 +2737,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2840,9 +2811,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2852,7 +2823,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -2865,7 +2836,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2941,7 +2912,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2981,15 +2952,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3058,9 +3029,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-trait" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea87257cfcbedcb9444eda79c59fdfea71217e6305afee8ee33f500375c2ac97" +checksum = "dad8db98c1e677797df21ba03fca7d3bf9bec3ca38db930954e4fe6e1ea27eb4" dependencies = [ "float-cmp", "halfbrown", @@ -3107,9 +3078,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3117,24 +3088,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -3144,9 +3115,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3154,28 +3125,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -3195,9 +3166,9 @@ dependencies = [ [[package]] name = "wild" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d01931a94d5a115a53f95292f51d316856b68a035618eb831bbba593a30b67" +checksum = "a3131afc8c575281e1e80f36ed6a092aa502c08b18ed7524e86fbbb12bb410e1" dependencies = [ "glob", ] @@ -3235,20 +3206,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.0", ] [[package]] @@ -3269,21 +3231,6 @@ dependencies = [ "windows-targets 0.52.0", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -3314,12 +3261,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -3332,12 +3273,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -3350,12 +3285,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -3368,12 +3297,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -3386,12 +3309,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -3404,12 +3321,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -3422,12 +3333,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -3452,9 +3357,9 @@ dependencies = [ [[package]] name = "xxhash-rust" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9828b178da53440fa9c766a3d2f73f7cf5d0ac1fe3980c1e5018d899fd19e07b" +checksum = "53be06678ed9e83edb1745eb72efc0bbcd7b5c3c35711a860906aed827a13d61" [[package]] name = "yaml-rust" @@ -3473,22 +3378,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.30" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306dca4455518f1f31635ec308b6b3e4eb1b11758cefafc782827d0aa7acb5c7" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.30" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be912bf68235a88fbefd1b73415cb218405958d1655b2ece9035a19920bdf6ba" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1505d0d..f5e759d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.1.4" +version = "0.2.0" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 29fde7e..3c25d1c 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -19,7 +19,7 @@ edit = "0.1.4" futures = "0.3.29" inquire = "0.6.2" ipgeolocate = "0.3.6" -mesc = { version = "0.1.4", path = "../mesc" } +mesc = { version = "0.2.0", path = "../mesc" } reqwest = { version = "0.11.22", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } From 73f04c482f98517b8d3548fa50ff0b50b5857c04 Mon Sep 17 00:00:00 2001 From: Joshua Hyde Date: Sun, 28 Jan 2024 23:56:20 -0600 Subject: [PATCH 53/85] Add, verify JSON deserialization for Go implementation (#11) * Initial implementation; need to implement profile and global metadata testing * Fill out profile methods * Finish tests * Add Go build action * Add testing file * Add linting build step * Remove unneeded doc * Remove inapplicable TODO for RPCConfig --- .github/workflows/go.yml | 42 ++++++ SPECIFICATION.md | 2 +- go/README.md | 20 ++- go/go.mod | 14 ++ go/go.sum | 34 +++++ go/pkg/mesc/endpoint/criteria/config.go | 26 ++-- .../io/serialization/example.test_json | 62 +++++++++ go/pkg/mesc/endpoint/io/serialization/json.go | 130 ++++++++++++++++++ .../endpoint/io/serialization/json_test.go | 82 +++++++++++ .../serialization/serialization_suite_test.go | 13 ++ go/pkg/mesc/endpoint/resolution/config.go | 18 +-- go/pkg/mesc/endpoints.go | 4 +- go/pkg/mesc/model/chain_id.go | 27 +++- go/pkg/mesc/model/chain_id_test.go | 30 ++++ go/pkg/mesc/model/endpoint_metadata.go | 115 ++++++++++++---- go/pkg/mesc/model/metadata.go | 82 +++++++++++ go/pkg/mesc/model/model_suite_test.go | 13 ++ go/pkg/mesc/model/profile.go | 117 ++++++++++++++-- go/pkg/mesc/model/rpc_config.go | 18 ++- 19 files changed, 774 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/go.yml create mode 100644 go/go.sum create mode 100644 go/pkg/mesc/endpoint/io/serialization/example.test_json create mode 100644 go/pkg/mesc/endpoint/io/serialization/json.go create mode 100644 go/pkg/mesc/endpoint/io/serialization/json_test.go create mode 100644 go/pkg/mesc/endpoint/io/serialization/serialization_suite_test.go create mode 100644 go/pkg/mesc/model/chain_id_test.go create mode 100644 go/pkg/mesc/model/metadata.go create mode 100644 go/pkg/mesc/model/model_suite_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..bff1271 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,42 @@ +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.x' + + - name: Build + working-directory: ./go + run: go build -v ./... + + - name: Test + working-directory: ./go + run: go test -v ./... + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54 + working-directory: ./go diff --git a/SPECIFICATION.md b/SPECIFICATION.md index e031e9e..41a1336 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -133,7 +133,7 @@ The `global_metadata`, `profile_metadata`, and `endpoint_metadata` fields allow | `host` | `str` | name of provider host | `"llamanodes"`, `"alchemy"`, `"quicknode"`, `"localhost"` | `ecosystem` | `str` | ecosystem of chain, (e.g. relates mainnets to testnets) | `"ethereum"`, `"polygon"` | | `node_client` | `str` | versioned node client | `erigon/2.48.1/linux-amd64/go1.20.5` `reth/v0.1.0-alpha.10-7b781eb60/x86_64-unknown-linux-gnu` | -| `namespaces` | `Sequence[str]` | RPC name spaces enabled for endpoint | `["eth", "trace, "debug"]` +| `namespaces` | `Sequence[str]` | RPC name spaces enabled for endpoint | `["eth", "trace", "debug"]` | `explorer` | `str` | block explorer url | `https://etherscan.io` | `location` | `str` | geographic region | `Paris, France` | | `cloud_region` | `str` | cloud provider region | `aws-us-east-1a` | diff --git a/go/README.md b/go/README.md index bf54c21..1e8d807 100644 --- a/go/README.md +++ b/go/README.md @@ -1,3 +1,21 @@ # Go MESC Implementation -[WIP] +This is a reference implementation of the Go MESC standard. + +## Installation + +To use this project within your Golang project, execute the following within your project: + +``` +go get github.com/paradigmxyz/mesc/go +``` + +## Example Usage + +// TODO: pending doc + +## Reference + +Refer to the function signatures defined in [endpoints.go](pkg/mesc/endpoints.go) for the list of available functions. + +Models are available in the [model](pkg/mesc/model) package. \ No newline at end of file diff --git a/go/go.mod b/go/go.mod index 4cd8868..d3617f1 100644 --- a/go/go.mod +++ b/go/go.mod @@ -1,3 +1,17 @@ module github.com/paradigmxyz/mesc/go go 1.20 + +require ( + github.com/go-logr/logr v1.3.0 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect + github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/onsi/gomega v1.31.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.16.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go/go.sum b/go/go.sum new file mode 100644 index 0000000..71b2f92 --- /dev/null +++ b/go/go.sum @@ -0,0 +1,34 @@ +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= +github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/pkg/mesc/endpoint/criteria/config.go b/go/pkg/mesc/endpoint/criteria/config.go index 776dd8c..cc72bac 100644 --- a/go/pkg/mesc/endpoint/criteria/config.go +++ b/go/pkg/mesc/endpoint/criteria/config.go @@ -1,12 +1,12 @@ package mesc -import model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +import "github.com/paradigmxyz/mesc/go/pkg/mesc/model" // EndpointFindCriteriaConfig describes the criteria to be used with FindEndpoints type EndpointFindCriteriaConfig struct { - chainID *model.ChainID - nameContains *string - urlContains *string + chainID *model.ChainID + nameContains *string + urlContains *string } // FindEndpointsCriteria provides a means of customizing the finding criteria for endpoints in FindEndpoints. @@ -14,21 +14,21 @@ type FindEndpointsCriteria func(*EndpointFindCriteriaConfig) // HasChainID will find endpoints that contain endpoint metadata for the given chain ID. func HasChainID(chainID model.ChainID) FindEndpointsCriteria { - return func(e *EndpointFindCriteriaConfig) { - e.chainID = &chainID - } + return func(e *EndpointFindCriteriaConfig) { + e.chainID = &chainID + } } // NameContains describes a criteria to find endpoints whose name contains the given substring. func NameContains(name string) FindEndpointsCriteria { - return func(e *EndpointFindCriteriaConfig) { - e.nameContains = &name - } + return func(e *EndpointFindCriteriaConfig) { + e.nameContains = &name + } } // URLContains describes a criteria to find endpoints whose URLs contain the given substring. func URLContains(url string) FindEndpointsCriteria { - return func(e *EndpointFindCriteriaConfig) { - e.urlContains = &url - } + return func(e *EndpointFindCriteriaConfig) { + e.urlContains = &url + } } diff --git a/go/pkg/mesc/endpoint/io/serialization/example.test_json b/go/pkg/mesc/endpoint/io/serialization/example.test_json new file mode 100644 index 0000000..80505ab --- /dev/null +++ b/go/pkg/mesc/endpoint/io/serialization/example.test_json @@ -0,0 +1,62 @@ +{ + "mesc_version": "MESC 1.0", + "default_endpoint": "local_ethereum", + "network_defaults": { + "1": "local_ethereum" + }, + "network_names": { + "local_ethereum": "1" + }, + "endpoints": { + "local_ethereum": { + "name": "local_ethereum", + "url": "http://localhost:8545", + "chain_id": "1", + "endpoint_metadata": { + "rate_limit_rps": 250, + "rate_limit_cups": 1000, + "rate_limit_per_method": { + "trace_block": 200 + }, + "api_key": "a2798f237a2398rf7", + "jwt_secret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.dyt0CoTl4WoVjAHI9Q_CwSKhl6d_9rhM3NrXuJttkao", + "host": "local", + "ecosystem": "ethereum", + "node_client": "reth/v0.1.0-alpha.10-7b781eb60/x86_64-unknown-linux-gnu", + "namespaces": ["eth", "trace", "debug"], + "explorer": "https://etherscan.io", + "location": "Paris, France", + "cloud_region": "aws-us-east-1a", + "labels": ["private_mempool", "cache", "archive"] + } + } + }, + "profiles": { + "xyz": { + "name": "xyz", + "default_endpoint": "local_ethereum", + "network_defaults": { + "1": "local_ethereum" + }, + "profile_metadata": { + "last_modified_by": "mesc__1.0", + "last_modified_time": 1705870535, + "creation_time": 1700200462, + "api_keys": { + "etherscan": "abc123" + }, + "groups": { + "load_balancer": [ + "alchemy_optimism", + "quicknode_optimism" + ] + }, + "conceal": true + }, + "use_mesc": true + } + }, + "global_metadata": { + "example_global_metadatum": "example-global-value" + } +} \ No newline at end of file diff --git a/go/pkg/mesc/endpoint/io/serialization/json.go b/go/pkg/mesc/endpoint/io/serialization/json.go new file mode 100644 index 0000000..c0062de --- /dev/null +++ b/go/pkg/mesc/endpoint/io/serialization/json.go @@ -0,0 +1,130 @@ +package serialization + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +// DeserializeJSON deserializes the JSON contained within the given io.Reader into a model.RPCConfig object. +// This does not apply any validations prescribed by the MESC specification. +func DeserializeJSON(reader io.Reader) (*model.RPCConfig, error) { + var jsonConfig *jsonRPCConfig + if decodeErr := json.NewDecoder(reader).Decode(&jsonConfig); decodeErr != nil { + return nil, fmt.Errorf("failed to decode MESC JSON: %w", decodeErr) + } + + return jsonConfig.toModel(), nil +} + +func toOptionalChainID(v *string) *model.ChainID { + if v == nil { + return nil + } + + asModel := model.ChainID(*v) + return &asModel +} + +func toChainIDMap[V any](source map[string]V) map[model.ChainID]V { + if source == nil { + return nil + } + + copy := make(map[model.ChainID]V, len(source)) + for chainID, value := range source { + copy[model.ChainID(chainID)] = value + } + + return copy +} + +func toMappedChainID[K comparable](source map[K]string) map[K]model.ChainID { + if source == nil { + return nil + } + + copy := make(map[K]model.ChainID, len(source)) + for key, chainID := range source { + copy[key] = model.ChainID(chainID) + } + + return copy +} + +type jsonRPCConfig struct { + MESCVersion string `json:"mesc_version"` + DefaultEndpoint *string `json:"default_endpoint"` + NetworkDefaults map[string]string `json:"network_defaults"` + NetworkNames map[string]string `json:"network_names"` + Endpoints map[string]*jsonEndpoint + Profiles map[string]*jsonProfile + GlobalMetadata map[string]any `json:"global_metadata"` +} + +func (j *jsonRPCConfig) toModel() *model.RPCConfig { + networkDefaults := toChainIDMap(j.NetworkDefaults) + networkNames := toMappedChainID(j.NetworkNames) + + rpcConfig := &model.RPCConfig{ + MESCVersion: j.MESCVersion, + DefaultEndpoint: j.DefaultEndpoint, + NetworkDefaults: networkDefaults, + NetworkNames: networkNames, + GlobalMetadata: j.GlobalMetadata, + } + + if jsonEndpoints := j.Endpoints; jsonEndpoints != nil { + modelEndpoints := make(map[string]model.EndpointMetadata, len(jsonEndpoints)) + for endpointName, jsonEndpoint := range jsonEndpoints { + modelEndpoints[endpointName] = jsonEndpoint.toModel() + } + rpcConfig.Endpoints = modelEndpoints + } + + if jsonProfiles := j.Profiles; jsonProfiles != nil { + modelProfiles := make(map[string]model.Profile, len(jsonProfiles)) + for profileName, jsonProfile := range jsonProfiles { + modelProfiles[profileName] = jsonProfile.toModel() + } + rpcConfig.Profiles = modelProfiles + } + + return rpcConfig +} + +type jsonEndpoint struct { + Name string + URL string + ChainID *string `json:"chain_id"` + EndpointMetadata map[string]any `json:"endpoint_metadata"` +} + +func (j *jsonEndpoint) toModel() model.EndpointMetadata { + return model.EndpointMetadata{ + Name: j.Name, + URL: j.URL, + ChainID: toOptionalChainID(j.ChainID), + EndpointMetadata: j.EndpointMetadata, + } +} + +type jsonProfile struct { + Name string + DefaultEndpoint *string `json:"default_endpoint"` + NetworkDefaults map[string]string `json:"network_defaults"` + ProfileMetadata map[string]any `json:"profile_metadata"` + UseMESC bool `json:"use_mesc"` +} + +func (j *jsonProfile) toModel() model.Profile { + return model.Profile{ + Name: j.Name, + DefaultEndpoint: j.DefaultEndpoint, + NetworkDefaults: toChainIDMap(j.NetworkDefaults), + ProfileMetadata: j.ProfileMetadata, + UseMESC: j.UseMESC, + } +} diff --git a/go/pkg/mesc/endpoint/io/serialization/json_test.go b/go/pkg/mesc/endpoint/io/serialization/json_test.go new file mode 100644 index 0000000..5ec32db --- /dev/null +++ b/go/pkg/mesc/endpoint/io/serialization/json_test.go @@ -0,0 +1,82 @@ +package serialization_test + +import ( + "bytes" + _ "embed" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/onsi/gomega/types" + + "github.com/paradigmxyz/mesc/go/pkg/mesc/endpoint/io/serialization" + "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +//go:embed example.test_json +var exampleJSON string + +var _ = Describe("JSON Deserialization", func() { + It("successfully deserializes the example JSON", func() { + jsonReader := bytes.NewBufferString(exampleJSON) + rpcConfig, err := serialization.DeserializeJSON(jsonReader) + Expect(err).ToNot(HaveOccurred(), "deserializing the JSON should not fail") + + Expect(rpcConfig.MESCVersion).To(Equal("MESC 1.0"), "the MESC version should be deserialized correctly") + Expect(rpcConfig.DefaultEndpoint).ToNot(BeNil(), "there should be a default endpoint") + Expect(*rpcConfig.DefaultEndpoint).To(Equal("local_ethereum"), "the default endpoint should be correct") + Expect(rpcConfig.NetworkDefaults).To(HaveKeyWithValue(model.ChainID("1"), "local_ethereum"), "the network defaults should be deserialized") + Expect(rpcConfig.NetworkNames).To(HaveKeyWithValue("local_ethereum", model.ChainID("1")), "the network names should be deserialized") + Expect(rpcConfig.GlobalMetadata).To(And(HaveLen(1), HaveKeyWithValue("example_global_metadatum", "example-global-value")), "the global metadata should have been read in") + + // verify endpoints + Expect(rpcConfig.Endpoints).To(And(HaveLen(1), HaveKey("local_ethereum")), "the local_ethereum endpoint should be deserialized") + ethereumEndpoint := rpcConfig.Endpoints["local_ethereum"] + Expect(ethereumEndpoint.Name).To(Equal("local_ethereum"), "the endpoint name should be deserialized") + Expect(ethereumEndpoint.URL).To(Equal("http://localhost:8545"), "the endpoint URL should be deserialized") + Expect(ethereumEndpoint.ChainID).ToNot(BeNil(), "the chain ID should be present on the endpoint metadata") + Expect(*ethereumEndpoint.ChainID).To(Equal(model.ChainID("1")), "the chain ID should be deserialized") + // The actual verification of the metadata contents follows this by exercising helper methods + Expect(ethereumEndpoint.EndpointMetadata).To(HaveLen(13), "there should be 13 endpoint metadata elements") + + expectMatches("rate limit RPS", ethereumEndpoint.GetRateLimitRPS, BeNumerically("==", 250)) + expectMatches("rate limit CUPS", ethereumEndpoint.GetRateLimitCUPS, BeNumerically("==", 1000)) + expectMatches("method rate limit", func() (float64, bool) { + return ethereumEndpoint.GetMethodRateLimit("trace_block") + }, BeNumerically("==", 200)) + expectMatches("API key", ethereumEndpoint.GetAPIKey, Equal("a2798f237a2398rf7")) + expectMatches("JWT secret", ethereumEndpoint.GetJWTSecret, ContainSubstring("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9")) + expectMatches("host", ethereumEndpoint.GetHost, Equal("local")) + expectMatches("ecosystem", ethereumEndpoint.GetEcosystem, Equal("ethereum")) + expectMatches("node client", ethereumEndpoint.GetNodeClient, Equal("reth/v0.1.0-alpha.10-7b781eb60/x86_64-unknown-linux-gnu")) + expectMatches("namespaces", ethereumEndpoint.GetNamespaces, ConsistOf([]string{"debug", "eth", "trace"})) + expectMatches("explorer", ethereumEndpoint.GetExplorer, Equal("https://etherscan.io")) + expectMatches("location", ethereumEndpoint.GetLocation, Equal("Paris, France")) + expectMatches("cloud region", ethereumEndpoint.GetCloudRegion, Equal("aws-us-east-1a")) + expectMatches("labels", ethereumEndpoint.GetLabels, ConsistOf([]string{"archive", "cache", "private_mempool"})) + + // verify profiles + Expect(rpcConfig.Profiles).To(And(HaveLen(1), HaveKey("xyz")), "the xyz profile should be read in") + xyzProfile := rpcConfig.Profiles["xyz"] + Expect(xyzProfile.Name).To(Equal("xyz"), "the profile name should be correct") + Expect(xyzProfile.DefaultEndpoint).ToNot(BeNil(), "the profile should have a default endpoint") + Expect(*xyzProfile.DefaultEndpoint).To(Equal("local_ethereum"), "the profile should have the correct default endpoint") + Expect(xyzProfile.NetworkDefaults).To(And(HaveLen(1), HaveKeyWithValue(model.ChainID("1"), "local_ethereum")), "the profile should have the correct network defaults") + Expect(xyzProfile.UseMESC).To(BeTrue(), "the profile should have MESC enabled") + expectMatches("last modified by", xyzProfile.GetLastModifiedBy, Equal("mesc__1.0")) + expectMatches("last modified time", xyzProfile.GetLastModifiedTime, BeTemporally("==", time.Unix(1705870535, 0))) + expectMatches("creation time", xyzProfile.GetCreationTime, BeTemporally("==", time.Unix(1700200462, 0))) + expectMatches("API keys", xyzProfile.GetAPIKeys, And(HaveLen(1), HaveKeyWithValue("etherscan", "abc123"))) + expectMatches("load balancer groups", func() ([]string, bool) { + loadBalancerGroups, hasGroup := xyzProfile.GetEndpointNamesForGrouping("load_balancer") + return loadBalancerGroups, hasGroup + }, ConsistOf([]string{"alchemy_optimism", "quicknode_optimism"})) + expectMatches("conceal", xyzProfile.Conceal, BeTrue()) + }) +}) + +func expectMatches[V any](valueDescriptor string, getter func() (V, bool), valueMatcher types.GomegaMatcher) { + actualValue, hasValue := getter() + Expect(hasValue).To(BeTrue(), "%s should be present", valueDescriptor) + Expect(actualValue).To(valueMatcher, "%s should match", valueDescriptor) +} diff --git a/go/pkg/mesc/endpoint/io/serialization/serialization_suite_test.go b/go/pkg/mesc/endpoint/io/serialization/serialization_suite_test.go new file mode 100644 index 0000000..b933e64 --- /dev/null +++ b/go/pkg/mesc/endpoint/io/serialization/serialization_suite_test.go @@ -0,0 +1,13 @@ +package serialization_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestSerialization(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Serialization Suite") +} diff --git a/go/pkg/mesc/endpoint/resolution/config.go b/go/pkg/mesc/endpoint/resolution/config.go index 1027c4b..ccd1e60 100644 --- a/go/pkg/mesc/endpoint/resolution/config.go +++ b/go/pkg/mesc/endpoint/resolution/config.go @@ -1,11 +1,11 @@ package mesc -import model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +import "github.com/paradigmxyz/mesc/go/pkg/mesc/model" // EndpointResolutionConfig describes configuration and context to be applied during endpoint resolution. type EndpointResolutionConfig struct { - profile *string - rpcConfig *model.RPCConfig + profile *string + rpcConfig *model.RPCConfig } // EndpointResolutionOption describes a way of configuring the resolution of an endpoint @@ -13,14 +13,14 @@ type EndpointResolutionOption func(*EndpointResolutionConfig) // WithProfile will configure endpoint resolution to resolve with the given profile enabled. func WithProfile(profile string) EndpointResolutionOption { - return func(cfg *EndpointResolutionConfig) { - cfg.profile = &profile - } + return func(cfg *EndpointResolutionConfig) { + cfg.profile = &profile + } } // WithRPCConfig will configure endpoint resolution to resolve from the given RPCConfig. func WithRPCConfig(rpcConfig model.RPCConfig) EndpointResolutionOption { - return func(cfg *EndpointResolutionConfig) { - cfg.rpcConfig = &rpcConfig - } + return func(cfg *EndpointResolutionConfig) { + cfg.rpcConfig = &rpcConfig + } } diff --git a/go/pkg/mesc/endpoints.go b/go/pkg/mesc/endpoints.go index 6b266a4..2277a98 100644 --- a/go/pkg/mesc/endpoints.go +++ b/go/pkg/mesc/endpoints.go @@ -33,7 +33,9 @@ func GetEndpointByNetwork(ctx context.Context, chainID model.ChainID, options .. // GetEndpointByName resolves the endpoint metadata, if available, for the network for the given name. // This will return nil if no endpoint metadata can be resolved. -func GetEndpointByName(ctx context.Context, name string, options ...resolution.EndpointResolutionOption) (*model.EndpointMetadata, error) { +// If the given RPC config is non-nil, it will be used to determine the endpoint. +// If the given RPC config is nil, then the RPC config will be resolved according to the MESC specification. +func GetEndpointByName(ctx context.Context, name string, rpcConfig *model.RPCConfig) (*model.EndpointMetadata, error) { // TODO: implement return nil, errors.New("not yet implemented") } diff --git a/go/pkg/mesc/model/chain_id.go b/go/pkg/mesc/model/chain_id.go index 2148a84..ff7499a 100644 --- a/go/pkg/mesc/model/chain_id.go +++ b/go/pkg/mesc/model/chain_id.go @@ -1,6 +1,10 @@ -package mesc +package model -import "errors" +import ( + "fmt" + "strconv" + "strings" +) // ChainID is the definition of a representation of a chain ID, // conforming to the format as described in the MESC specification. @@ -8,6 +12,21 @@ type ChainID string // ToInt will parse an integer representation of the chain ID. func (c ChainID) ToInt() (int64, error) { - // TODO: implement parsing of the chain ID per the MESC specification - return 0, errors.New("not implemented") + asString := string(c) + if strings.HasPrefix(asString, "0x") { + parsedInt, parseErr := strconv.ParseInt(asString[2:], 16, 64) + if parseErr != nil { + return 0, fmt.Errorf("failed to parse chain ID '%s' as a hex value: %w", asString, parseErr) + } + + return parsedInt, nil + } + + // Try to just parse it as a ten-base digit + parsedInt, parseErr := strconv.ParseInt(asString, 10, 64) + if parseErr != nil { + return 0, fmt.Errorf("failed to parse chain ID '%s' as a ten-base value: %w", asString, parseErr) + } + + return parsedInt, nil } diff --git a/go/pkg/mesc/model/chain_id_test.go b/go/pkg/mesc/model/chain_id_test.go new file mode 100644 index 0000000..eab44fd --- /dev/null +++ b/go/pkg/mesc/model/chain_id_test.go @@ -0,0 +1,30 @@ +package model_test + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +var _ = Describe("ChainID", func() { + Context("ToInt", func() { + When("the chain ID is expressed as a ten-base number", func() { + It("successfully parses the integer", func() { + chainID := model.ChainID("512") + asInt, err := chainID.ToInt() + Expect(err).ToNot(HaveOccurred(), "parsing the integer should not fail") + Expect(asInt).To(BeNumerically("==", 512), "the parsed integer should be correct") + }) + }) + + When("the chain ID is expressed as a hexadecimal number", func() { + It("successfully parses the integer", func() { + chainID := model.ChainID("0xddb99ac060e2") + asInt, err := chainID.ToInt() + Expect(err).ToNot(HaveOccurred(), "parsing the integer should not fail") + Expect(asInt).To(BeNumerically("==", 243789234987234), "the parsed integer should be correct") + }) + }) + }) +}) diff --git a/go/pkg/mesc/model/endpoint_metadata.go b/go/pkg/mesc/model/endpoint_metadata.go index f70abcc..0428a9b 100644 --- a/go/pkg/mesc/model/endpoint_metadata.go +++ b/go/pkg/mesc/model/endpoint_metadata.go @@ -1,35 +1,94 @@ -package mesc - -const ( - rateLimitRequestsPerSecondKey = "rate_limit_rps" -) +package model // EndpointMetadata describes metadata for an RPC endpoint. type EndpointMetadata struct { - Name string // Name is the name of the endpoint - URL string // URL is the location of the endpoint - ChainID *ChainID // ChainID is the chain ID of the string - EndpointMetadata map[string]any // EndpointMetadata is a map of both well-defined endpoint metadata and custom metadata + Name string // Name is the name of the endpoint + URL string // URL is the location of the endpoint + ChainID *ChainID // ChainID is the chain ID of the string + EndpointMetadata map[string]any // EndpointMetadata is a map of both well-defined endpoint metadata and custom metadata } -// GetRateLimitPerSecond gets the rate limit of requests per second that the endpoint will allow. -func (e EndpointMetadata) GetRateLimitPerSecond() (float64, bool) { - if e.EndpointMetadata == nil { - return 0.0, false - } - - rpsAny, hasRPS := e.EndpointMetadata[rateLimitRequestsPerSecondKey] - if !hasRPS { - return 0.0, false - } - - rpsFloat64, isFloat := rpsAny.(float64) - if isFloat { - return rpsFloat64, true - } - - return 0.0, false +// GetAPIKey gets the API key in the endpoint metadata, if present. +func (e EndpointMetadata) GetAPIKey() (string, bool) { + return getMetadataString(apiKeyKey, e.EndpointMetadata) } -// TODO: implement other convenience methods for the other well-defined parameters here: -// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata +// GetCloudRegion gets the cloud region from the endpoint metadata, if present. +func (e EndpointMetadata) GetCloudRegion() (string, bool) { + return getMetadataString(cloudRegionKey, e.EndpointMetadata) +} + +// GetEcosystem gets the ecosystem in the endpoint metadata, if present. +func (e EndpointMetadata) GetEcosystem() (string, bool) { + return getMetadataString(ecosystemKey, e.EndpointMetadata) +} + +// GetExplorer gets the URL of the explorer from the endpoint metadata, if present. +func (e EndpointMetadata) GetExplorer() (string, bool) { + return getMetadataString(explorerKey, e.EndpointMetadata) +} + +// GetHost gets the host from the endpoint metadata, if present. +func (e EndpointMetadata) GetHost() (string, bool) { + return getMetadataString(hostKey, e.EndpointMetadata) +} + +// GetJWTSecret gets the JWT secret from the endpoint metadata, if present. +func (e EndpointMetadata) GetJWTSecret() (string, bool) { + return getMetadataString(jwtSecretkey, e.EndpointMetadata) +} + +// GetLabels gets the labels from the endpoint metadata, if present. +func (e EndpointMetadata) GetLabels() ([]string, bool) { + return getMetadataStringSlice(labelsKey, e.EndpointMetadata) +} + +// GetLocation gets the location from the endpoint metadata, if present. +func (e EndpointMetadata) GetLocation() (string, bool) { + return getMetadataString(locationKey, e.EndpointMetadata) +} + +// GetMethodRateLimit gets the rate limit, if present, of requests per second for the given RPC method name. +func (e EndpointMetadata) GetMethodRateLimit(methodName string) (float64, bool) { + rateLimitPerMethodAny, hasRateLimits := getMetadataAny(rateLimitPerMethodKey, e.EndpointMetadata) + if !hasRateLimits { + return 0.0, false + } + + rateLimitPerMethodMap, isMap := rateLimitPerMethodAny.(map[string]any) + if !isMap { + return 0.0, false + } + + rateLimitAny, hasRateLimit := rateLimitPerMethodMap[methodName] + if !hasRateLimit { + return 0.0, false + } + + rateLimitFloat, isFloat := rateLimitAny.(float64) + if !isFloat { + return 0.0, false + } + + return rateLimitFloat, true +} + +// GetNamespaces gets the method namespaces defined in the endpoint metadata, if present. +func (e EndpointMetadata) GetNamespaces() ([]string, bool) { + return getMetadataStringSlice(namespacesKey, e.EndpointMetadata) +} + +// GetNodeClient gets the node client information in the metadata, if present. +func (e EndpointMetadata) GetNodeClient() (string, bool) { + return getMetadataString(nodeClientKey, e.EndpointMetadata) +} + +// GetRateLimitCUPS gets the rate limit in compute units per second that the endpoint will allow. +func (e EndpointMetadata) GetRateLimitCUPS() (float64, bool) { + return getMetadataFloat64(rateLimitComputeUnitsPerSecondKey, e.EndpointMetadata) +} + +// GetRateLimitRPS gets the rate limit of requests per second that the endpoint will allow. +func (e EndpointMetadata) GetRateLimitRPS() (float64, bool) { + return getMetadataFloat64(rateLimitRequestsPerSecondKey, e.EndpointMetadata) +} diff --git a/go/pkg/mesc/model/metadata.go b/go/pkg/mesc/model/metadata.go new file mode 100644 index 0000000..63ff447 --- /dev/null +++ b/go/pkg/mesc/model/metadata.go @@ -0,0 +1,82 @@ +package model + +const ( + apiKeyKey = "api_key" + apiKeysKey = "api_keys" + cloudRegionKey = "cloud_region" + concealKey = "conceal" + creationTimeKey = "creation_time" + ecosystemKey = "ecosystem" + explorerKey = "explorer" + groupsKey = "groups" + hostKey = "host" + jwtSecretkey = "jwt_secret" + labelsKey = "labels" + lastModifiedByKey = "last_modified_by" + lastModifiedTimeKey = "last_modified_time" + locationKey = "location" + namespacesKey = "namespaces" + nodeClientKey = "node_client" + rateLimitComputeUnitsPerSecondKey = "rate_limit_cups" + rateLimitPerMethodKey = "rate_limit_per_method" + rateLimitRequestsPerSecondKey = "rate_limit_rps" +) + +func getMetadataAny(parameterName string, metadata map[string]any) (any, bool) { + if metadata == nil { + return nil, false + } + + metadatumAny, hasMetadatum := metadata[parameterName] + return metadatumAny, hasMetadatum +} + +func getMetadataFloat64(parameterName string, metadata map[string]any) (float64, bool) { + metadatumAny, hasMetadatum := getMetadataAny(parameterName, metadata) + if !hasMetadatum { + return 0.0, false + } + + metadatumFloat, isFloat := metadatumAny.(float64) + if !isFloat { + return 0.0, false + } + + return metadatumFloat, true +} + +func getMetadataString(parameterName string, metadata map[string]any) (string, bool) { + metadatumAny, hasMetadatum := getMetadataAny(parameterName, metadata) + if !hasMetadatum { + return "", false + } + + metadatumString, isString := metadatumAny.(string) + if !isString { + return "", false + } + + return metadatumString, true +} + +func getMetadataStringSlice(parameterName string, metadata map[string]any) ([]string, bool) { + metadatumAny, hasMetadatum := getMetadataAny(parameterName, metadata) + if !hasMetadatum { + return nil, false + } + + metadatumAnySlice, isAnySlice := metadatumAny.([]any) + if !isAnySlice { + return nil, false + } + + stringSlice := make([]string, len(metadatumAnySlice)) + for metadatumIndex, metadatumAny := range metadatumAnySlice { + metadatumString, isString := metadatumAny.(string) + if !isString { + return nil, false + } + stringSlice[metadatumIndex] = metadatumString + } + return stringSlice, true +} diff --git a/go/pkg/mesc/model/model_suite_test.go b/go/pkg/mesc/model/model_suite_test.go new file mode 100644 index 0000000..64ce08a --- /dev/null +++ b/go/pkg/mesc/model/model_suite_test.go @@ -0,0 +1,13 @@ +package model_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestModel(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Model Suite") +} diff --git a/go/pkg/mesc/model/profile.go b/go/pkg/mesc/model/profile.go index e595945..f5a38f1 100644 --- a/go/pkg/mesc/model/profile.go +++ b/go/pkg/mesc/model/profile.go @@ -1,13 +1,114 @@ -package mesc +package model + +import ( + "fmt" + "time" +) // Profile describes a profile to contextualize resolved endpoint metadata type Profile struct { - Name string // Name is the name of the profile - DefaultEndpoint *ChainID // DefaultEndpoint contains the ChainID of the default network under this profile, if available - NetworkDefaults map[ChainID]string // NetworkDefaults maps ChainID values identifying networks to the name of the default endpoint of that network - ProfileMetadata map[string]any // ProfileMetadata is a combination of both well-defined and custom-defined metadata for this profile - UseMESC bool // UseMESC, if false, indicates that MESC resolution should not be used when this profile is enabled + Name string // Name is the name of the profile + DefaultEndpoint *string // DefaultEndpoint contains the ChainID of the default network under this profile, if available + NetworkDefaults map[ChainID]string // NetworkDefaults maps ChainID values identifying networks to the name of the default endpoint of that network + ProfileMetadata map[string]any // ProfileMetadata is a combination of both well-defined and custom-defined metadata for this profile + UseMESC bool // UseMESC, if false, indicates that MESC resolution should not be used when this profile is enabled } -// TODO: implement helper methods resolving profile metadata, per the specification here: -// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata +// Conceal gets, from the profile metadata, whether tools should avoid casually revealing the RPC URLs without prompting. +func (p Profile) Conceal() (bool, bool) { + concealAny, hasConceal := getMetadataAny(concealKey, p.ProfileMetadata) + if !hasConceal { + return false, false + } + + concealBool, isBool := concealAny.(bool) + if !isBool { + return false, false + } + + return concealBool, true +} + +// GetAPIKeys gets from the profile metadata the provided API keys, if present. +func (p Profile) GetAPIKeys() (map[string]string, bool) { + apiKeysAny, hasAPIKeys := getMetadataAny(apiKeysKey, p.ProfileMetadata) + if !hasAPIKeys { + return nil, false + } + + apiKeysMapToAny, isMap := apiKeysAny.(map[string]any) + if !isMap { + return nil, false + } + + apiKeys := make(map[string]string, len(apiKeysMapToAny)) + for serviceName, apiKeyAny := range apiKeysMapToAny { + apiKeyString, isString := apiKeyAny.(string) + if !isString { + return nil, false + } + apiKeys[serviceName] = apiKeyString + } + + return apiKeys, true +} + +// GetEndpointNamesForGrouping gets from the profile metadata the endpoint names that are found in the given grouping, if present. +func (p Profile) GetEndpointNamesForGrouping(grouping string) ([]string, bool) { + groupsAny, hasGroupsAny := getMetadataAny(groupsKey, p.ProfileMetadata) + if !hasGroupsAny { + return nil, false + } + + groupsMap, isMap := groupsAny.(map[string]any) + if !isMap { + return nil, false + } + + groupedEndpointsAny, hasGroup := groupsMap[grouping] + if !hasGroup { + fmt.Println("does not have grouping") + return nil, false + } + + groupedEndpointsAnySlice, isSlice := groupedEndpointsAny.([]any) + if !isSlice { + return nil, false + } + + stringSlice := make([]string, len(groupedEndpointsAnySlice)) + for anyIndex, anyEndpoint := range groupedEndpointsAnySlice { + endpointString, isString := anyEndpoint.(string) + if !isString { + return nil, false + } + stringSlice[anyIndex] = endpointString + } + + return stringSlice, true +} + +// GetCreationTime gets from the metadata the date and time at which the profile was created, present. +func (p Profile) GetCreationTime() (time.Time, bool) { + floatTime, hasFloat := getMetadataFloat64(creationTimeKey, p.ProfileMetadata) + if !hasFloat { + return time.Time{}, false + } + + return time.Unix(int64(floatTime), 0), true +} + +// GetLastModifiedBy gets from the metadata the versioned identifier of the tool used to create the configuration, if present. +func (p Profile) GetLastModifiedBy() (string, bool) { + return getMetadataString(lastModifiedByKey, p.ProfileMetadata) +} + +// GetLastModifiedTime gets from the metadata the date and time when this profile was last modified, if present. +func (p Profile) GetLastModifiedTime() (time.Time, bool) { + floatTime, hasFloat := getMetadataFloat64(lastModifiedTimeKey, p.ProfileMetadata) + if !hasFloat { + return time.Time{}, false + } + + return time.Unix(int64(floatTime), 0), true +} diff --git a/go/pkg/mesc/model/rpc_config.go b/go/pkg/mesc/model/rpc_config.go index b13364a..c773443 100644 --- a/go/pkg/mesc/model/rpc_config.go +++ b/go/pkg/mesc/model/rpc_config.go @@ -1,14 +1,12 @@ -package mesc +package model // RPCConfig describes a collection of RPC configurations type RPCConfig struct { - MESCVersion string // MESCVersion describes the version of the MESC specification to which this adheres - DefaultEndpoint string // DefaultEndpoint is the name of the default endpoint to be used - NetworkDefaults map[ChainID]string // NetworkDefaults maps chain IDs to the names of the default network for each chain - Endpoints map[string]EndpointMetadata // Endpoints maps endpoint metadata by endpoint name - Profiles map[string]Profile // Profiles maps profiles by their profile names - GlobalMetadata map[string]any // GlobalMetadata contains metadata relevant across all profiles + MESCVersion string // MESCVersion describes the version of the MESC specification to which this adheres + DefaultEndpoint *string // DefaultEndpoint is the name of the default endpoint to be used; if nil, then there is no named default endpoint + NetworkDefaults map[ChainID]string // NetworkDefaults maps chain IDs to the names of the default network for each chain + NetworkNames map[string]ChainID // NetworkNames maps network names to chain ID values + Endpoints map[string]EndpointMetadata // Endpoints maps endpoint metadata by endpoint name + Profiles map[string]Profile // Profiles maps profiles by their profile names + GlobalMetadata map[string]any // GlobalMetadata contains metadata relevant across all profiles } - -// TODO: implement helper methods resolving global metadata, per the specification here: -// https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#metadata From cd50d84805cd1e061afaeefebace3993bda5eb42 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Sun, 28 Jan 2024 22:26:29 -0800 Subject: [PATCH 54/85] update network name list and add note abot generation to docs --- docs/src/implementing_mesc.md | 9 ++++++++- python/mesc/network_names.py | 12 +++++++++++- rust/crates/mesc/src/network_names.rs | 12 +++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/src/implementing_mesc.md b/docs/src/implementing_mesc.md index 1991675..97bc6c7 100644 --- a/docs/src/implementing_mesc.md +++ b/docs/src/implementing_mesc.md @@ -4,7 +4,7 @@ One of MESC's goals is to have an implementation for every programming language If you are creating a new MESC implementation, you may find the following useful: -1. The main functionality that a MESC implementation provides is the [Core MESC Interface](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#reference-implementation). This is a set of functions for reading whatever MESC data a user has configured on their system. +1. The main functionality that a MESC implementation provides is the [core MESC interface](https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#reference-implementation). This is a set of functions for reading whatever MESC data a user has configured on their system. 2. The ability to **write** MESC configurations is useful, but should be considered a secondary goal. Users already have the ability to create MESC configurations either by 1) editing JSON by hand, 2) editing JSON programmatically, or 3) using the interactive [MESC cli tool](https://github.com/paradigmxyz/mesc/tree/main/cli). @@ -14,3 +14,10 @@ If you are creating a new MESC implementation, you may find the following useful 5. If parts of the MESC specification are confusing or difficult to implement, it may be helpful to look at existing implementations. These currently exist for [python](https://github.com/paradigmxyz/mesc/tree/main/python) and [rust](https://github.com/paradigmxyz/mesc/tree/main/rust). + +## Implementation Checklist + +1. Implement the [core MESC interface](https://paradigmxyz.github.io/mesc/queries.html) functions. These functions should have the same behavior in each implementation. +2. Create an adapter to run the [MESC test suite](https://github.com/paradigmxyz/mesc/tree/main/tests). Passing these tests means the implementation is fully compliant with the MESC specification. +3. Add an entry to the [generate_network_names.py](https://github.com/paradigmxyz/mesc/blob/main/python/generate_network_names.py) script. This script creates a native language code file for mapping between network names and chain id's using the standard [ethereum-lists/chains](https://github.com/ethereum-lists/chains) repository. + diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index c61e015..e074245 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -134,7 +134,7 @@ network_names = { '126': 'oy', '127': 'factory_127', '128': 'huobi_eco', - '129': 'protojumbo_testnet', + '129': 'innovator', '131': 'engram_testnet', '134': 'iexec', '135': 'alyx_testnet', @@ -219,6 +219,7 @@ network_names = { '314': 'filecoin', '321': 'kcc', '322': 'kcc_testnet', + '323': 'cosvm', '324': 'zksync', '333': 'web3q', '335': 'dfk_test', @@ -665,6 +666,7 @@ network_names = { '6999': 'polysmart', '7000': 'zeta', '7001': 'zeta_athens_3_testnet', + '7007': 'bst', '7027': 'ella_the_heart', '7070': 'planq', '7100': 'nume', @@ -734,6 +736,7 @@ network_names = { '9000': 'evmos_testnet', '9001': 'evmos', '9012': 'berylbit', + '9024': 'nexa_block', '9100': 'genesis_coin', '9170': 'rinia_testnet_old', '9223': 'codefin', @@ -814,6 +817,7 @@ network_names = { '17000': 'holesky', '17001': 'redstone_holesky_testnet', '17171': 'g8', + '17172': 'eclipse_subnet', '17180': 'palette_testnet', '17777': 'eos_evm', '18000': 'frontier_of_dreams_testnet', @@ -822,11 +826,13 @@ network_names = { '18181': 'g8_testnet', '18686': 'mxc_zkevm', '19011': 'home_verse', + '19527': 'magnet', '19845': 'btcix', '20001': 'camelark', '20729': 'callisto_testnet', '20736': 'p12', '20765': 'jono11_subnet', + '21133': 'all_about_healthy', '21337': 'cennznet_azalea', '21816': 'om', '21912': 'bsl', @@ -959,6 +965,7 @@ network_names = { '78432': 'conduit_subnet', '79879': 'gold_testnet', '80001': 'mumbai', + '80085': 'bera_artio', '81041': 'nordek', '81341': 'amana_testnet', '81342': 'amana_mixnet', @@ -1107,6 +1114,7 @@ network_names = { '920000': 'posi_devnet_shard_0', '920001': 'posi_devnet_shard_1', '923018': 'fncy_testnet', + '955081': 'jono12_subnet', '955305': 'eluvio_content_fabric', '988207': 'ecrox', '1127469': 'tiltyard_subnet', @@ -1170,6 +1178,7 @@ network_names = { '68840142': 'frame_testnet', '88888888': 't.e.a.m_block', '99415706': 'joys_digital_testnet', + '168587773': 'blast_sepolia_testnet', '192837465': 'gather', '222000222': 'kanazawa', '245022926': 'neon_evm_devnet', @@ -1183,6 +1192,7 @@ network_names = { '476158412': 'skale_europa_hub_testnet', '486217935': 'gather_devnet', '503129905': 'skale_nebula_hub_testnet', + '888888888': 'ancient8', '999999999': 'zora_sepolia_testnet', '1122334455': 'ipos', '1146703430': 'cyberdecknet', diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index 9ed2043..ae3c7c5 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -139,7 +139,7 @@ pub fn get_network_names() -> HashMap { ("126", "oy"), ("127", "factory_127"), ("128", "huobi_eco"), - ("129", "protojumbo_testnet"), + ("129", "innovator"), ("131", "engram_testnet"), ("134", "iexec"), ("135", "alyx_testnet"), @@ -224,6 +224,7 @@ pub fn get_network_names() -> HashMap { ("314", "filecoin"), ("321", "kcc"), ("322", "kcc_testnet"), + ("323", "cosvm"), ("324", "zksync"), ("333", "web3q"), ("335", "dfk_test"), @@ -670,6 +671,7 @@ pub fn get_network_names() -> HashMap { ("6999", "polysmart"), ("7000", "zeta"), ("7001", "zeta_athens_3_testnet"), + ("7007", "bst"), ("7027", "ella_the_heart"), ("7070", "planq"), ("7100", "nume"), @@ -739,6 +741,7 @@ pub fn get_network_names() -> HashMap { ("9000", "evmos_testnet"), ("9001", "evmos"), ("9012", "berylbit"), + ("9024", "nexa_block"), ("9100", "genesis_coin"), ("9170", "rinia_testnet_old"), ("9223", "codefin"), @@ -819,6 +822,7 @@ pub fn get_network_names() -> HashMap { ("17000", "holesky"), ("17001", "redstone_holesky_testnet"), ("17171", "g8"), + ("17172", "eclipse_subnet"), ("17180", "palette_testnet"), ("17777", "eos_evm"), ("18000", "frontier_of_dreams_testnet"), @@ -827,11 +831,13 @@ pub fn get_network_names() -> HashMap { ("18181", "g8_testnet"), ("18686", "mxc_zkevm"), ("19011", "home_verse"), + ("19527", "magnet"), ("19845", "btcix"), ("20001", "camelark"), ("20729", "callisto_testnet"), ("20736", "p12"), ("20765", "jono11_subnet"), + ("21133", "all_about_healthy"), ("21337", "cennznet_azalea"), ("21816", "om"), ("21912", "bsl"), @@ -964,6 +970,7 @@ pub fn get_network_names() -> HashMap { ("78432", "conduit_subnet"), ("79879", "gold_testnet"), ("80001", "mumbai"), + ("80085", "bera_artio"), ("81041", "nordek"), ("81341", "amana_testnet"), ("81342", "amana_mixnet"), @@ -1112,6 +1119,7 @@ pub fn get_network_names() -> HashMap { ("920000", "posi_devnet_shard_0"), ("920001", "posi_devnet_shard_1"), ("923018", "fncy_testnet"), + ("955081", "jono12_subnet"), ("955305", "eluvio_content_fabric"), ("988207", "ecrox"), ("1127469", "tiltyard_subnet"), @@ -1175,6 +1183,7 @@ pub fn get_network_names() -> HashMap { ("68840142", "frame_testnet"), ("88888888", "t.e.a.m_block"), ("99415706", "joys_digital_testnet"), + ("168587773", "blast_sepolia_testnet"), ("192837465", "gather"), ("222000222", "kanazawa"), ("245022926", "neon_evm_devnet"), @@ -1188,6 +1197,7 @@ pub fn get_network_names() -> HashMap { ("476158412", "skale_europa_hub_testnet"), ("486217935", "gather_devnet"), ("503129905", "skale_nebula_hub_testnet"), + ("888888888", "ancient8"), ("999999999", "zora_sepolia_testnet"), ("1122334455", "ipos"), ("1146703430", "cyberdecknet"), From 4686402938cf9124a50dc0e868c1e30b444bd8e7 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 00:05:50 -0800 Subject: [PATCH 55/85] initial binary release workflow (#17) --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26f1aa7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ + +name: Release + +on: + workflow_dispatch: + +jobs: + build: + name: Build on ${{ matrix.os }} for ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + arch: [amd64, arm64] + include: + - os: ubuntu-latest + arch: arm64 + target: aarch64-unknown-linux-gnu + - os: macos-latest + arch: arm64 + target: aarch64-apple-darwin + exclude: + - os: windows-latest + arch: arm64 + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install Dependencies (Ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install pkg-config libssl-dev + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + + - name: Build Binary + run: | + cd rust + cargo build --release --target ${{ matrix.target }} --path crates/mesc_cli + + - name: Publish Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v1 + with: + files: | + rust/target/${{ matrix.target }}/release/mesc_cli* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + From 0ca6980bbd78baf4bec084c6eb544e53b9caee42 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 09:54:28 -0800 Subject: [PATCH 56/85] mention new implementation in roadmap --- docs/src/roadmap.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/roadmap.md b/docs/src/roadmap.md index c52dd8d..e2b7a37 100644 --- a/docs/src/roadmap.md +++ b/docs/src/roadmap.md @@ -1,6 +1,6 @@ # Roadmap -Once the MESC specification reaches version 1.0, it will become ossified forever. This will maximize forward- and backward-compatibility between MESC integrations. +Once the MESC specification reaches version 1.0, it will become ossified forever. This will maximize forward- and backward-compatibility between MESC integrations. Client libraries for reading or writing MESC configurations might continue development, but the underlying MESC specification will not change. -Client libraries for reading or writing MESC configurations might continue development, but the underlying MESC specification will not change. +MESC currently has implementations for CLI, python, and rust. Implementations for go and typescript are coming soon. If there is another language you have interest in bringing MESC to an additional programming language or environment, feel free to share on the [issue tracker](https://github.com/paradigmxyz/mesc). From df9045c0446b11034064bdb45dcc1c8c5368d814 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 09:54:40 -0800 Subject: [PATCH 57/85] add code for gif demos --- .gitignore | 1 + docs/demos/autocomplete.tape | 29 +++++++++++++++++++++ docs/demos/basics.tape | 50 ++++++++++++++++++++++++++++++++++++ docs/demos/tests.tape | 15 +++++++++++ 4 files changed, 95 insertions(+) create mode 100644 docs/demos/autocomplete.tape create mode 100644 docs/demos/basics.tape create mode 100644 docs/demos/tests.tape diff --git a/.gitignore b/.gitignore index c0f4a86..45cae29 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ PITCH.md __pycache__ python/dist docs/book +*.gif diff --git a/docs/demos/autocomplete.tape b/docs/demos/autocomplete.tape new file mode 100644 index 0000000..b5c808b --- /dev/null +++ b/docs/demos/autocomplete.tape @@ -0,0 +1,29 @@ +Output autocomplete.gif +Set FontSize 26 +Set Width 900 +Set Height 450 + +# setup +Hide +Type "mesc setup" +Enter +Sleep 500ms +Enter +Type "f" +Enter +Sleep 1 +Enter +Show + +Sleep 1.5s +Type@250ms "arbi" +Sleep 3s +Backspace 4 +Sleep 1s +Type@250ms "opti" +Sleep 3s +Backspace 4 +Sleep 1s +Type@250ms "zora" +Sleep 3s +Enter diff --git a/docs/demos/basics.tape b/docs/demos/basics.tape new file mode 100644 index 0000000..0c93223 --- /dev/null +++ b/docs/demos/basics.tape @@ -0,0 +1,50 @@ +Output basics.gif +Set FontSize 26 +Set Width 1200 +Set Height 800 + +# start mesc setup +Type "mesc setup" +Sleep 400ms +Enter +Sleep 2000ms + +# scroll through the options +Down +Sleep 250ms +Down +Sleep 250ms +Down +Sleep 1000ms +Up +Sleep 250ms +Up +Sleep 250ms +Up +Sleep 500ms + +# start the endpoint add process +Enter +Sleep 2000ms +Type "https://eth.llamarpc.com" +Enter +Sleep 3500ms + +# go through the add options +Enter +Sleep 2000ms + + +# save and exit +Up +Sleep 1500ms +Up +Sleep 1500ms +Enter +Sleep 2500ms + +# perform ping +Type "mesc ping" +Enter +Sleep 6000ms + diff --git a/docs/demos/tests.tape b/docs/demos/tests.tape new file mode 100644 index 0000000..6c4042e --- /dev/null +++ b/docs/demos/tests.tape @@ -0,0 +1,15 @@ +Output tests.gif +Set FontSize 19 +Set Width 1200 +Set Height 800 + + +Hide +Type "cd ~/repos/mesc/tests" +Enter +Type "clear" +Enter +Show +Type "pytest -n 8" +Enter +Sleep 25s From 545f46574c76190a580f613e0dc2a7f3609a30f2 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 09:58:13 -0800 Subject: [PATCH 58/85] add image to main readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2e4d456..741471f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ MESC is formally defined in [SPECIFICATION.md](./SPECIFICATION.md). Additional information can be found in the [MESC Documentation](https://paradigmxyz.github.io/mesc/). +![basics](https://github.com/paradigmxyz/mesc/assets/7907648/2f84d90b-9cfd-42fd-89f1-bd35949e1c14) + + ### Contents - [Reference Implementations](#reference-implementations) - [Quickstart](#quickstart) From a11ec77e9b0f20859b391401fc975d4bd375bb4d Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 10:10:30 -0800 Subject: [PATCH 59/85] move gif to cli readme page --- README.md | 2 -- cli/README.md | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 741471f..ac26bba 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ MESC is formally defined in [SPECIFICATION.md](./SPECIFICATION.md). Additional information can be found in the [MESC Documentation](https://paradigmxyz.github.io/mesc/). -![basics](https://github.com/paradigmxyz/mesc/assets/7907648/2f84d90b-9cfd-42fd-89f1-bd35949e1c14) - ### Contents - [Reference Implementations](#reference-implementations) diff --git a/cli/README.md b/cli/README.md index 3d11a65..0ce1e2a 100644 --- a/cli/README.md +++ b/cli/README.md @@ -13,6 +13,8 @@ The most important cli subcommands: View help for each subcommand by typing `mesc [SUBCOMMAND] --help` +![basics](https://github.com/paradigmxyz/mesc/assets/7907648/2f84d90b-9cfd-42fd-89f1-bd35949e1c14) + ## Contents - [Installation](#installation) - [Example Usage](#example-usage) From 5e4ec2c1ae5a1495ec6a6e70cf2c9be9dd42bd08 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 11:56:58 -0800 Subject: [PATCH 60/85] add edit button to doc pages --- docs/book.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/book.toml b/docs/book.toml index 12c383a..e406d1f 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -4,3 +4,6 @@ language = "en" multilingual = false src = "src" title = "MESC User Guide" + +[output.html] +edit-url-template="https://github.com/paradigmxyz/mesc/edit/main/docs/{path}" From 629aaf5d4c1a8852386c1dad4cbe01cc10b591bb Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 29 Jan 2024 12:03:33 -0800 Subject: [PATCH 61/85] feat(docs): Add GitHub URL and edit link (#19) * Add GitHub URL and edit link * chore: update typescript casing --- docs/book.toml | 4 +++- docs/src/SUMMARY.md | 3 +-- docs/src/libraries.md | 3 +-- docs/src/mesc_overview.md | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/book.toml b/docs/book.toml index e406d1f..b2c8396 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -4,6 +4,8 @@ language = "en" multilingual = false src = "src" title = "MESC User Guide" +description = "A specification for how crypto tools configure their RPC endpoints" [output.html] -edit-url-template="https://github.com/paradigmxyz/mesc/edit/main/docs/{path}" +git-repository-url = "https://github.com/paradigmxyz/mesc" +edit-url-template = "https://github.com/paradigmxyz/mesc/edit/main/docs/{path}" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 4b2cf0e..199505f 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -20,5 +20,4 @@ - [Go](./go.md) - [Python](./python.md) - [Rust](./rust.md) - - [Typescript](./typescript.md) - + - [TypeScript](./typescript.md) diff --git a/docs/src/libraries.md b/docs/src/libraries.md index 8028beb..f40a501 100644 --- a/docs/src/libraries.md +++ b/docs/src/libraries.md @@ -7,8 +7,7 @@ Implementations currently exist for: - [Go](./go.md) - [Python](./python.md) - [Rust](./rust.md) -- [Typescript](./typescript.md) +- [TypeScript](./typescript.md) If you want to create a MESC implementation for a new language, see [implementing MESC](./implementing_mesc.md). - diff --git a/docs/src/mesc_overview.md b/docs/src/mesc_overview.md index 5a29926..dfb3f51 100644 --- a/docs/src/mesc_overview.md +++ b/docs/src/mesc_overview.md @@ -15,5 +15,4 @@ For information about existing MESC implementations, see: - [Go](./go.md) - [Python](./python.md) - [Rust](./rust.md) -- [Typescript](./typescript.md) - +- [TypeScript](./typescript.md) From cab1b4b046d296fa2980c20a6748822c5e2a2b4f Mon Sep 17 00:00:00 2001 From: 0xTaylor <53136615+x676f64@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:08:41 -0800 Subject: [PATCH 62/85] Correcting typo in git clone URL for Python (#18) This corrects a typo in the install from source instructions for Python --- python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index 987274e..a33b06e 100644 --- a/python/README.md +++ b/python/README.md @@ -16,7 +16,7 @@ It has no external dependencies. ### From Source ``` -git clone https://github/paradigmxyz/mesc +git clone https://github.com/paradigmxyz/mesc cd mesc pip install ./ ``` From e5990884a8948a57cf283f4708f722b777af8ccb Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Mon, 29 Jan 2024 13:09:33 -0800 Subject: [PATCH 63/85] add note about acronym --- docs/src/what_is_mesc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/what_is_mesc.md b/docs/src/what_is_mesc.md index 4a2d7e6..7859f80 100644 --- a/docs/src/what_is_mesc.md +++ b/docs/src/what_is_mesc.md @@ -1,6 +1,6 @@ # What is MESC? -MESC is a standardized approach for configuring RPC endpoints. Using MESC, a user creates a single RPC config that is shared by all RPC tools on their system. +MESC (Multiple Endpoint Shared Configuration) is a standardized approach for configuring RPC endpoints. Using MESC, a user creates a single RPC config that is shared by all RPC tools on their system. ## Design Goals From b4b4b915d0f0bfd0d968f12a7a69700534809241 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 30 Jan 2024 01:20:48 -0800 Subject: [PATCH 64/85] import python type annotations only when type checking for import times --- python/mesc/__init__.py | 43 +++++++---- python/mesc/interface.py | 8 +- python/mesc/load.py | 16 ++-- python/mesc/network_utils.py | 4 +- python/mesc/overrides.py | 7 +- python/mesc/types.py | 142 +++++++++++++++++------------------ python/mesc/validation.py | 7 +- tests/generate.py | 2 +- 8 files changed, 130 insertions(+), 99 deletions(-) diff --git a/python/mesc/__init__.py b/python/mesc/__init__.py index dd6349d..5d6e603 100644 --- a/python/mesc/__init__.py +++ b/python/mesc/__init__.py @@ -9,19 +9,34 @@ from .interface import ( find_endpoints, get_global_metadata, ) -from .types import Endpoint, Profile, RpcConfig + +import typing + +if typing.TYPE_CHECKING: + from .types import Endpoint, Profile, RpcConfig + + __all__ = ( + 'Endpoint', + 'Profile', + 'RpcConfig', + 'is_mesc_enabled', + 'get_default_endpoint', + 'get_endpoint_by_name', + 'get_endpoint_by_network', + 'get_endpoint_by_query', + 'find_endpoints', + 'get_global_metadata', + ) + +else: + __all__ = ( + 'is_mesc_enabled', + 'get_default_endpoint', + 'get_endpoint_by_name', + 'get_endpoint_by_network', + 'get_endpoint_by_query', + 'find_endpoints', + 'get_global_metadata', + ) __version__ = '0.2.0' - -__all__ = ( - 'Endpoint', - 'Profile', - 'RpcConfig', - 'is_mesc_enabled', - 'get_default_endpoint', - 'get_endpoint_by_name', - 'get_endpoint_by_network', - 'get_endpoint_by_query', - 'find_endpoints', - 'get_global_metadata', -) diff --git a/python/mesc/interface.py b/python/mesc/interface.py index e02055c..684c7c7 100644 --- a/python/mesc/interface.py +++ b/python/mesc/interface.py @@ -1,12 +1,16 @@ from __future__ import annotations import os -from typing_extensions import Any, Mapping, Sequence +import typing -from .types import mesc_env_vars, Endpoint, RpcConfig +from .types import mesc_env_vars from . import network_utils from . import load +if typing.TYPE_CHECKING: + from typing_extensions import Any, Mapping, Sequence + from .types import Endpoint, RpcConfig + def is_mesc_enabled() -> bool: """MESC is enabled if two criteria are met: diff --git a/python/mesc/load.py b/python/mesc/load.py index a08184c..baa4af3 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -1,13 +1,17 @@ from __future__ import annotations + import json import os -from typing_extensions import cast, overload, Literal, Any +import typing -from .types import RpcConfig from . import exceptions from . import overrides from . import validation +if typing.TYPE_CHECKING: + from typing_extensions import cast, Literal, Any + from .types import RpcConfig + def read_config_data() -> RpcConfig: """read MESC config according to MESC environment variables""" @@ -40,12 +44,12 @@ def read_config_data() -> RpcConfig: return cast(RpcConfig, config) -@overload +@typing.overload def read_env_config(*, validate: Literal[False]) -> Any: ... -@overload +@typing.overload def read_env_config(*, validate: Literal[True]) -> RpcConfig: ... @@ -73,12 +77,12 @@ def read_env_config(*, validate: bool = True) -> RpcConfig | Any: return config -@overload +@typing.overload def read_file_config(*, path: str | None = None, validate: Literal[False]) -> Any: ... -@overload +@typing.overload def read_file_config(*, path: str | None = None, validate: Literal[True]) -> RpcConfig: ... diff --git a/python/mesc/network_utils.py b/python/mesc/network_utils.py index c0544e5..cf7e13e 100644 --- a/python/mesc/network_utils.py +++ b/python/mesc/network_utils.py @@ -1,9 +1,11 @@ from __future__ import annotations import typing -from .types import RpcConfig from . import network_names +if typing.TYPE_CHECKING: + from .types import RpcConfig + def is_chain_id(chain_id: str) -> bool: """return True if input is a valid chain_id""" diff --git a/python/mesc/overrides.py b/python/mesc/overrides.py index 5da1571..bb7a632 100644 --- a/python/mesc/overrides.py +++ b/python/mesc/overrides.py @@ -4,10 +4,13 @@ import copy import json import os import re -from typing_extensions import Any, Mapping, MutableMapping +import typing from . import interface, network_utils, exceptions -from .types import RpcConfig, Endpoint, Profile + +if typing.TYPE_CHECKING: + from typing_extensions import Any, Mapping, MutableMapping + from .types import RpcConfig, Endpoint, Profile def apply_env_overrides(config: RpcConfig | None) -> RpcConfig: diff --git a/python/mesc/types.py b/python/mesc/types.py index c936aeb..58fa905 100644 --- a/python/mesc/types.py +++ b/python/mesc/types.py @@ -1,6 +1,9 @@ from __future__ import annotations -from typing_extensions import Any, MutableMapping, TypedDict, Literal +import typing + +if typing.TYPE_CHECKING: + from typing_extensions import Any, MutableMapping, TypedDict, Literal mesc_env_vars = [ @@ -17,29 +20,29 @@ mesc_env_vars = [ ] -class Endpoint(TypedDict): - name: str - url: str - chain_id: str | None - endpoint_metadata: MutableMapping[str, Any] +if typing.TYPE_CHECKING: + class Endpoint(TypedDict): + name: str + url: str + chain_id: str | None + endpoint_metadata: MutableMapping[str, Any] -class Profile(TypedDict): - name: str - default_endpoint: str | None - network_defaults: MutableMapping[str, str] - profile_metadata: MutableMapping[str, Any] - use_mesc: bool + class Profile(TypedDict): + name: str + default_endpoint: str | None + network_defaults: MutableMapping[str, str] + profile_metadata: MutableMapping[str, Any] + use_mesc: bool - -class RpcConfig(TypedDict): - mesc_version: str - default_endpoint: str | None - endpoints: MutableMapping[str, Endpoint] - network_defaults: MutableMapping[str, str] - network_names: MutableMapping[str, str] - profiles: MutableMapping[str, Profile] - global_metadata: MutableMapping[str, Any] + class RpcConfig(TypedDict): + mesc_version: str + default_endpoint: str | None + endpoints: MutableMapping[str, Endpoint] + network_defaults: MutableMapping[str, str] + network_names: MutableMapping[str, str] + profiles: MutableMapping[str, Profile] + global_metadata: MutableMapping[str, Any] endpoint_types: dict[str, type | tuple[type, ...]] = { @@ -71,61 +74,58 @@ rpc_config_types: dict[str, type | tuple[type, ...]] = { # # query types # +if typing.TYPE_CHECKING: -class EndpointQuery(TypedDict): - query_type: Literal[ - 'default_endpoint', - 'endpoint_by_name', - 'endpoint_by_network', - 'user_input', - ] - fields: ( - DefaultEndpointQuery | EndpointNameQuery | EndpointNetworkQuery | UserInputQuery - ) + class EndpointQuery(TypedDict): + query_type: Literal[ + 'default_endpoint', + 'endpoint_by_name', + 'endpoint_by_network', + 'user_input', + ] + fields: ( + DefaultEndpointQuery + | EndpointNameQuery + | EndpointNetworkQuery + | UserInputQuery + ) + class DefaultEndpointQuery(TypedDict): + profile: str | None -class DefaultEndpointQuery(TypedDict): - profile: str | None + class EndpointNameQuery(TypedDict): + name: str + class EndpointNetworkQuery(TypedDict): + profile: str | None + chain_id: str | int -class EndpointNameQuery(TypedDict): - name: str + class UserInputQuery(TypedDict): + profile: str | None + user_input: str + class MultiEndpointQuery(TypedDict, total=False): + name_contains: str | None + url_contains: str | None + chain_id: str | int | None -class EndpointNetworkQuery(TypedDict): - profile: str | None - chain_id: str | int + class GlobalMetadataQuery(TypedDict, total=False): + profile: str | None - -class UserInputQuery(TypedDict): - profile: str | None - user_input: str - - -class MultiEndpointQuery(TypedDict, total=False): - name_contains: str | None - url_contains: str | None - chain_id: str | int | None - - -class GlobalMetadataQuery(TypedDict, total=False): - profile: str | None - - -class MescQuery(TypedDict): - query_type: Literal[ - 'default_endpoint', - 'endpoint_by_name', - 'endpoint_by_network', - 'user_input', - 'multi_endpoint', - 'global_metadata', - ] - fields: ( - DefaultEndpointQuery - | EndpointNameQuery - | EndpointNetworkQuery - | UserInputQuery - | MultiEndpointQuery - | GlobalMetadataQuery - ) + class MescQuery(TypedDict): + query_type: Literal[ + 'default_endpoint', + 'endpoint_by_name', + 'endpoint_by_network', + 'user_input', + 'multi_endpoint', + 'global_metadata', + ] + fields: ( + DefaultEndpointQuery + | EndpointNameQuery + | EndpointNetworkQuery + | UserInputQuery + | MultiEndpointQuery + | GlobalMetadataQuery + ) diff --git a/python/mesc/validation.py b/python/mesc/validation.py index 9ed0f16..f929db5 100644 --- a/python/mesc/validation.py +++ b/python/mesc/validation.py @@ -1,12 +1,15 @@ from __future__ import annotations -from typing_extensions import Any -from typing import Sequence +import typing from .exceptions import InvalidConfig from .types import rpc_config_types, endpoint_types, profile_types from . import network_utils +if typing.TYPE_CHECKING: + from typing import Sequence + from typing_extensions import Any + def is_valid(config: Any) -> bool: try: diff --git a/tests/generate.py b/tests/generate.py index 99c0c73..8bffbda 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -235,7 +235,7 @@ def generate_tests() -> list[Test]: new_test = copy.deepcopy(test) new_test[3]["fields"]["profile"] = "not_using_mesc" # type: ignore if query["query_type"] == "global_metadata": - expected: dict | None = {} + expected: dict[str, Any] | None = {} else: expected = None new_test = new_test[0:4] + (expected,) + new_test[5:] From fa0f4b82108ee67dd81aaa366193ac1008cdb182 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 30 Jan 2024 01:37:31 -0800 Subject: [PATCH 65/85] fix python casting annotation issue --- python/mesc/load.py | 12 ++++-------- tests/adapters/python | 17 ++++++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/python/mesc/load.py b/python/mesc/load.py index baa4af3..ffdc67a 100644 --- a/python/mesc/load.py +++ b/python/mesc/load.py @@ -9,7 +9,7 @@ from . import overrides from . import validation if typing.TYPE_CHECKING: - from typing_extensions import cast, Literal, Any + from typing_extensions import Literal, Any from .types import RpcConfig @@ -41,7 +41,7 @@ def read_config_data() -> RpcConfig: # validate validation.validate(config) - return cast(RpcConfig, config) + return config # type: ignore @typing.overload @@ -72,9 +72,7 @@ def read_env_config(*, validate: bool = True) -> RpcConfig | Any: # validate config if validate: validation.validate(config) - return cast(RpcConfig, config) - else: - return config + return config @typing.overload @@ -124,6 +122,4 @@ def read_file_config( # validate config if validate: validation.validate(config) - return cast(RpcConfig, config) - else: - return config + return config diff --git a/tests/adapters/python b/tests/adapters/python index 3635a59..61c82ed 100755 --- a/tests/adapters/python +++ b/tests/adapters/python @@ -4,27 +4,30 @@ from __future__ import annotations import argparse import json -from typing import Sequence, cast, Union +import typing -from mesc.types import Endpoint, EndpointQuery import mesc +if typing.TYPE_CHECKING: + from typing import Sequence, Union + from mesc.types import Endpoint, EndpointQuery + def run_query(query: EndpointQuery) -> Union[Endpoint, Sequence[Endpoint], None]: if query["query_type"] == "default_endpoint": - default_fields = cast(mesc.types.DefaultEndpointQuery, query["fields"]) + default_fields: mesc.types.DefaultEndpointQuery = query["fields"] return mesc.get_default_endpoint(**default_fields) elif query["query_type"] == "endpoint_by_name": - name_fields = cast(mesc.types.EndpointNameQuery, query["fields"]) + name_fields: mesc.types.EndpointNameQuery = query["fields"] return mesc.get_endpoint_by_name(**name_fields) elif query["query_type"] == "endpoint_by_network": - network_fields = cast(mesc.types.EndpointNetworkQuery, query["fields"]) + network_fields: mesc.types.EndpointNetworkQuery = query["fields"] return mesc.get_endpoint_by_network(**network_fields) elif query["query_type"] == "user_input": - user_input_fields = cast(mesc.types.UserInputQuery, query["fields"]) + user_input_fields: mesc.types.UserInputQuery = query["fields"] return mesc.get_endpoint_by_query(**user_input_fields) elif query["query_type"] == "multi_endpoint": - multi_endpoint_fields = cast(mesc.types.MultiEndpointQuery, query["fields"]) + multi_endpoint_fields: mesc.types.MultiEndpointQuery = query["fields"] return mesc.find_endpoints(**multi_endpoint_fields) elif query["query_type"] == "global_metadata": return mesc.get_global_metadata(**query["fields"]) From 21ab52af0b3983bc098b6b09f70d20195634510e Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 30 Jan 2024 01:50:34 -0800 Subject: [PATCH 66/85] add zshrc config to setup if it exists (#20) --- .../mesc_cli/src/cli/subcommands/setup/command.rs | 7 +++++-- .../mesc_cli/src/cli/subcommands/setup/shell_config.rs | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs index d6a890f..a299c6d 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -1,7 +1,7 @@ use crate::{MescCliError, SetupArgs}; use mesc::{MescError, RpcConfig}; -use toolstr::Colorize; use std::path::PathBuf; +use toolstr::Colorize; use super::{config_modification::*, inquire_utils::*, selectors::*, shell_config::*, writing::*}; @@ -25,7 +25,10 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> { let result = modify_existing_config(config, Some(mode)).await; if shell_config_modified { println!(); - println!("{}", "Shell config files were modified. Restart shell to load these files.".magenta()) + println!( + "{}", + "Shell config files were modified. Restart shell to load these files.".magenta() + ) } result } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs index 1704455..c3de2f5 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs @@ -19,7 +19,15 @@ pub(crate) fn get_shell_config_paths() -> Result, MescCliError> { let home_dir = std::env::var("HOME").map_err(|_| MescCliError::Error("home dir not found".to_string()))?; let home_path = PathBuf::from(home_dir); - let candidates = vec![home_path.join(".bashrc"), home_path.join(".profile")]; + let mut candidates = vec![home_path.join(".bashrc"), home_path.join(".profile")]; + + // paths added only if they exist + for path in [home_path.join(".zshrc")] { + if path.exists() { + candidates.push(path) + } + } + Ok(candidates) } From 70125fbdc528a5ac3c8b671c3113cf7e16cd6070 Mon Sep 17 00:00:00 2001 From: kongtaoxing <69096526+kongtaoxing@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:54:12 +0800 Subject: [PATCH 67/85] fix: errors in rust doc (#21) --- rust/README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rust/README.md b/rust/README.md index bc38369..96c961d 100644 --- a/rust/README.md +++ b/rust/README.md @@ -16,7 +16,7 @@ The `crates/mesc_cli` crate is a tool for reading, writing, and validating MESC Inside a cargo project: `cargo add mesc` -Inside a `Cargo.toml`: `mesc = "1.0"` +Inside a `Cargo.toml`: `mesc = "0.2.0"` ## Example Usage @@ -56,12 +56,12 @@ pub struct ChainId(String); Basic read functions ```rust -use mesc; -use mesc::MescError; +use mesc::{MescError, Endpoint}; +use std::collections::HashMap; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; -type MetadataResult = Result, MescError> +type MetadataResult = Result, MescError>; // check whether mesc is enabled let enabled: bool = mesc::is_mesc_enabled(); @@ -70,23 +70,24 @@ let enabled: bool = mesc::is_mesc_enabled(); let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5 as u8, None); // get the default network for a particular tool let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, Some("xyz_tool")); +let endpoint: OptionalResult = mesc::get_endpoint_by_network(5 as u8, Some("xyz_tool")); // get an endpoint by name let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) +let user_str = "local_goerli"; let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria -let query = mesc::MultiEndpointQuery::new().chain_id(5); +let query = mesc::MultiEndpointQuery::new().chain_id(5 as u8).unwrap(); let endpoints: MultiResult = mesc::find_endpoints(query); // get non-endpoint metadata From 52205f77923b4148465fadf8f4c5bca98c0d5b5b Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 30 Jan 2024 02:02:48 -0800 Subject: [PATCH 68/85] fix rust doc examples --- README.md | 19 ++++++++++++------- rust/README.md | 6 +++--- .../mesc_cli/src/cli/subcommands/help.rs | 16 ++++++++++------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ac26bba..5e85ada 100644 --- a/README.md +++ b/README.md @@ -105,33 +105,38 @@ endpoints: list[Endpoint] = mesc.find_endpoints(chain_id=5) ###### rust ```rust -use mesc; -use mesc::MescError; +use mesc::{MescError, Endpoint}; +use std::collections::HashMap; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; +type MetadataResult = Result, MescError>; + +// check whether mesc is enabled +let enabled: bool = mesc::is_mesc_enabled(); // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", None); // get the default network for a particular tool -let chain_id: OptionalResult = mesc::get_default_endpoint("xyz_tool"); +let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, "xyz_tool"); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", Some("xyz_tool")); // get an endpoint by name let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) -let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, "xyz_tool"); +let user_str = "local_goerli"; +let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria -let query = mesc::MultiEndpointQuery::new().chain_id(5); +let query = mesc::MultiEndpointQuery::new().chain_id("5").unwrap(); let endpoints: MultiResult = mesc::find_endpoints(query); ``` diff --git a/rust/README.md b/rust/README.md index 96c961d..aac84bc 100644 --- a/rust/README.md +++ b/rust/README.md @@ -70,13 +70,13 @@ let enabled: bool = mesc::is_mesc_enabled(); let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5 as u8, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", None); // get the default network for a particular tool let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5 as u8, Some("xyz_tool")); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", Some("xyz_tool")); // get an endpoint by name let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); @@ -87,7 +87,7 @@ let user_str = "local_goerli"; let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria -let query = mesc::MultiEndpointQuery::new().chain_id(5 as u8).unwrap(); +let query = mesc::MultiEndpointQuery::new().chain_id("5").unwrap(); let endpoints: MultiResult = mesc::find_endpoints(query); // get non-endpoint metadata diff --git a/rust/crates/mesc_cli/src/cli/subcommands/help.rs b/rust/crates/mesc_cli/src/cli/subcommands/help.rs index f768f1e..37f1a92 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/help.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/help.rs @@ -176,34 +176,38 @@ metadata: Mapping[str, Any] = mesc.get_global_metadata(profile='xyz_tool')"#; } fn print_rust_interface() { - let interface = r#"use mesc; -use mesc::MescError; + let interface = r#"use mesc::{MescError, Endpoint}; +use std::collections::HashMap; type OptionalResult = Result, MescError>; type MultiResult = Result, MescError>; -type MetadataResult = Result, MescError> +type MetadataResult = Result, MescError>; + +// check whether mesc is enabled +let enabled: bool = mesc::is_mesc_enabled(); // get the default endpoint let endpoint: OptionalResult = mesc::get_default_endpoint(None); // get the default endpoint of a network -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, None); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", None); // get the default network for a particular tool let chain_id: OptionalResult = mesc::get_default_endpoint(Some("xyz_tool")); // get the default endpoint of a network for a particular tool -let endpoint: OptionalResult = mesc::get_endpoint_by_network(5, Some("xyz_tool")); +let endpoint: OptionalResult = mesc::get_endpoint_by_network("5", Some("xyz_tool")); // get an endpoint by name let endpoint: OptionalResult = mesc::get_endpoint_by_name("local_goerli"); // parse a user-provided string into a matching endpoint // (first try 1. endpoint name, then 2. chain id, then 3. network name) +let user_str = "local_goerli"; let endpoint: OptionalResult = mesc::get_endpoint_by_query(user_str, Some("xyz_tool")); // find all endpoints matching given criteria -let query = mesc::MultiEndpointQuery::new().chain_id(5); +let query = mesc::MultiEndpointQuery::new().chain_id("5").unwrap(); let endpoints: MultiResult = mesc::find_endpoints(query); // get non-endpoint metadata From 1f6f1fa802583c52a1a502f5aeca2d9f0ef18827 Mon Sep 17 00:00:00 2001 From: Zane Peycke Date: Sat, 3 Feb 2024 16:53:12 -0500 Subject: [PATCH 69/85] Grammar on disabled env vars message (#23) Switch tense on message to set MESC env vars --- rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs index a299c6d..20352c8 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs @@ -125,7 +125,7 @@ fn get_write_mode() -> Result<(ConfigWriteMode, bool), MescCliError> { } (Err(_), Err(_), Err(_), false) => { println!(" MESC is disabled because no MESC env vars are set"); - println!(" To enabled MESC, set one of the MESC env vars"); + println!(" To enable MESC, set one of the MESC env vars"); let mode = select_config_mode()?; let modified_files = setup_mesc_env_vars(&mode)?; Ok((mode, !modified_files.is_empty())) From eef2fa9b35c4548614a4220570395719fab16b2a Mon Sep 17 00:00:00 2001 From: Joshua Hyde Date: Sat, 3 Feb 2024 23:36:27 -0600 Subject: [PATCH 70/85] Add resolution of RPC configuration with override capability (#22) * Initial reading from env * Add default endpoint, network default overrides * Add network names override * Add endpoint overrides * Add profile overrides * Add global metadata override * Add endpoint metadata override support * Ensure overrides overlay, not overwrite * Add synthesization of endpoints for default endpoint --- go/pkg/mesc/endpoint/io/serialization/json.go | 15 + go/pkg/mesc/env.go | 348 ++++++++++++++++++ go/pkg/mesc/env_test.go | 292 +++++++++++++++ go/pkg/mesc/mesc_suite_test.go | 13 + 4 files changed, 668 insertions(+) create mode 100644 go/pkg/mesc/env.go create mode 100644 go/pkg/mesc/env_test.go create mode 100644 go/pkg/mesc/mesc_suite_test.go diff --git a/go/pkg/mesc/endpoint/io/serialization/json.go b/go/pkg/mesc/endpoint/io/serialization/json.go index c0062de..9e1f0fb 100644 --- a/go/pkg/mesc/endpoint/io/serialization/json.go +++ b/go/pkg/mesc/endpoint/io/serialization/json.go @@ -19,6 +19,21 @@ func DeserializeJSON(reader io.Reader) (*model.RPCConfig, error) { return jsonConfig.toModel(), nil } +// DeserializeEndpointMetadataJSON deserializes the given representation of endpoint metadata mapped by endpoint name. +func DeserializeEndpointMetadataJSON(reader io.Reader) (map[string]model.EndpointMetadata, error) { + var endpointJSONMetadata map[string]*jsonEndpoint + if decodeErr := json.NewDecoder(reader).Decode(&endpointJSONMetadata); decodeErr != nil { + return nil, fmt.Errorf("failed to decode endpoint metadata JSON: %w", decodeErr) + } + + endpoints := make(map[string]model.EndpointMetadata, len(endpointJSONMetadata)) + for endpointName, endpointJSON := range endpointJSONMetadata { + endpoints[endpointName] = endpointJSON.toModel() + } + + return endpoints, nil +} + func toOptionalChainID(v *string) *model.ChainID { if v == nil { return nil diff --git a/go/pkg/mesc/env.go b/go/pkg/mesc/env.go new file mode 100644 index 0000000..07a8938 --- /dev/null +++ b/go/pkg/mesc/env.go @@ -0,0 +1,348 @@ +package mesc + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/url" + "os" + "strconv" + "strings" + + "github.com/paradigmxyz/mesc/go/pkg/mesc/endpoint/io/serialization" + model "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +// ResolveRPCConfig resolves an RPC configuration per the MESC specification rules. +func ResolveRPCConfig(ctx context.Context) (*model.RPCConfig, error) { + byMode, hasByMode, err := resolveFromMode() + if err != nil { + return nil, fmt.Errorf("failed to resolve RPC configuration by mode: %w", err) + } else if hasByMode { + return applyOverrides(byMode) + } + + byPath, hasByPath, err := readRPCConfigFile() + if err != nil { + return nil, fmt.Errorf("failed to read RPC configuration from file: %w", err) + } else if hasByPath { + return applyOverrides(byPath) + } + + byEnv, hasByEnv, err := readRPCConfigEnv() + if err != nil { + return nil, fmt.Errorf("failed to read RPC configuration from env: %w", err) + } else if hasByEnv { + return applyOverrides(byEnv) + } + + return nil, fmt.Errorf("unable to resolve MESC configuration") +} + +func applyEndpointMetadataOverrides(rpcConfig *model.RPCConfig) error { + endpointMetadataOverrideJSON := os.Getenv("MESC_ENDPOINT_METADATA") + if endpointMetadataOverrideJSON == "" { + return nil + } + + endpointMetadataOverrides, err := serialization.DeserializeEndpointMetadataJSON(bytes.NewBufferString(endpointMetadataOverrideJSON)) + if err != nil { + return fmt.Errorf("failed to deserialize endpoint metadata overrides: %w", err) + } + + if rpcConfig.Endpoints == nil { + rpcConfig.Endpoints = make(map[string]model.EndpointMetadata) + } + + for endpointName, endpointMetadata := range endpointMetadataOverrides { + rpcConfig.Endpoints[endpointName] = endpointMetadata + } + + return nil +} + +func applyEndpointOverrides(rpcConfig *model.RPCConfig) error { + endpointOverrides := os.Getenv("MESC_ENDPOINTS") + if endpointOverrides == "" { + return nil + } + + endpoints := make(map[string]model.EndpointMetadata) + for _, endpoint := range strings.Split(endpointOverrides, " ") { + splitEndpoint := strings.Split(endpoint, "=") + if len(splitEndpoint) != 2 { + return fmt.Errorf("invalid endpoint override: '%s'", endpoint) + } + + endpoint := model.EndpointMetadata{} + endpointKey := splitEndpoint[0] + if strings.Contains(endpointKey, ":") { + splitKey := strings.Split(endpointKey, ":") + endpoint.Name = splitKey[0] + endpointKey = splitKey[0] + chainID := model.ChainID(splitKey[1]) + endpoint.ChainID = &chainID + } else { + endpoint.Name = splitEndpoint[0] + } + + endpoint.URL = splitEndpoint[1] + + endpoints[endpointKey] = endpoint + } + rpcConfig.Endpoints = endpoints + + return nil +} + +func applyGlobalMetadataOverride(rpcConfig *model.RPCConfig) error { + globalMetadataOverride := os.Getenv("MESC_GLOBAL_METADATA") + if globalMetadataOverride == "" { + return nil + } + + var globalMetadataOverrides map[string]any + if unmarshalErr := json.Unmarshal([]byte(globalMetadataOverride), &globalMetadataOverrides); unmarshalErr != nil { + return fmt.Errorf("failed to unmarshal global metadata override: %w", unmarshalErr) + } + + if rpcConfig.GlobalMetadata == nil { + rpcConfig.GlobalMetadata = make(map[string]any) + } + + for overrideName, overrideValue := range globalMetadataOverrides { + rpcConfig.GlobalMetadata[overrideName] = overrideValue + } + + return nil +} + +func applyNetworkDefaultsOverride(rpcConfig *model.RPCConfig) error { + networkDefaultsOverride := os.Getenv("MESC_NETWORK_DEFAULTS") + if networkDefaultsOverride == "" { + return nil + } + + networkDefaults := make(map[model.ChainID]string) + for _, networkDefault := range strings.Split(networkDefaultsOverride, " ") { + splitNetworkDefault := strings.Split(networkDefault, "=") + if len(splitNetworkDefault) != 2 { + return fmt.Errorf("invalid network default override: '%s'", networkDefault) + } + + networkDefaults[model.ChainID(splitNetworkDefault[0])] = splitNetworkDefault[1] + } + rpcConfig.NetworkDefaults = networkDefaults + + return nil +} + +func applyNetworkNamesOverride(rpcConfig *model.RPCConfig) error { + networkNameOverride := os.Getenv("MESC_NETWORK_NAMES") + if networkNameOverride == "" { + return nil + } + + networkNames := make(map[string]model.ChainID) + for _, networkName := range strings.Split(networkNameOverride, " ") { + splitNetworkName := strings.Split(networkName, "=") + if len(splitNetworkName) != 2 { + return fmt.Errorf("invalid network name overide: '%s'", networkName) + } + + networkNames[splitNetworkName[0]] = model.ChainID(splitNetworkName[1]) + } + rpcConfig.NetworkNames = networkNames + + return nil +} + +func applyOverrides(rpcConfig *model.RPCConfig) (*model.RPCConfig, error) { + if err := applyNetworkDefaultsOverride(rpcConfig); err != nil { + return nil, fmt.Errorf("failed to apply network defaults overrides: %w", err) + } + + if err := applyNetworkNamesOverride(rpcConfig); err != nil { + return nil, fmt.Errorf("failed to apply network names overrides: %w", err) + } + + if err := applyEndpointOverrides(rpcConfig); err != nil { + return nil, fmt.Errorf("failed apply endpoint overrides: %w", err) + } + + if err := applyProfileOverrides(rpcConfig); err != nil { + return nil, fmt.Errorf("failed to apply profile overrides: %w", err) + } + + if err := applyGlobalMetadataOverride(rpcConfig); err != nil { + return nil, fmt.Errorf("failed to apply global metadata overrides: %w", err) + } + + if err := applyEndpointMetadataOverrides(rpcConfig); err != nil { + return nil, fmt.Errorf("failed to apply endpoint metadata overrides: %w", err) + } + + if defaultEndpointOverride := os.Getenv("MESC_DEFAULT_ENDPOINT"); defaultEndpointOverride != "" { + rpcConfig.DefaultEndpoint = &defaultEndpointOverride + synthesizeEndpoint(rpcConfig, defaultEndpointOverride) + } + + return rpcConfig, nil +} + +func applyProfileOverrides(rpcConfig *model.RPCConfig) error { + profileOverrides := os.Getenv("MESC_PROFILES") + if profileOverrides == "" { + return nil + } + + profiles := make(map[string]*model.Profile) + for _, profileOverride := range strings.Split(profileOverrides, " ") { + keyValue := strings.Split(profileOverride, "=") + if len(keyValue) != 2 { + return fmt.Errorf("invalid profile override: '%s'", profileOverride) + } + + keyParts := strings.Split(keyValue[0], ".") + if len(keyParts) < 2 { + return fmt.Errorf("invalid key in profile override key/value pair: '%s'", profileOverride) + } + + profile, hasProfile := profiles[keyParts[0]] + if !hasProfile { + profile = &model.Profile{ + Name: keyParts[0], + } + profiles[keyParts[0]] = profile + } + + switch keyParts[1] { + case "default_endpoint": + profile.DefaultEndpoint = &keyValue[1] + case "network_defaults": + if len(keyParts) < 3 { + return fmt.Errorf("invalid network default setting in profile override: '%s'", profileOverride) + } + + networkDefaults := profile.NetworkDefaults + if networkDefaults == nil { + networkDefaults = make(map[model.ChainID]string) + profile.NetworkDefaults = networkDefaults + } + networkDefaults[model.ChainID(keyParts[2])] = keyValue[1] + case "profile_metadata": + if len(keyParts) < 3 { + return fmt.Errorf("invalid profile metadata setting in profile override: '%s'", profileOverride) + } + + profileMetadata := profile.ProfileMetadata + if profileMetadata == nil { + profileMetadata = make(map[string]any) + profile.ProfileMetadata = profileMetadata + } + profileMetadata[keyParts[2]] = keyValue[1] + case "use_mesc": + parsedBool, parseErr := strconv.ParseBool(keyValue[1]) + if parseErr != nil { + return fmt.Errorf("invalid use_mesc setting in profile override: '%s'", profileOverride) + } + + profile.UseMESC = parsedBool + default: + return fmt.Errorf("unrecognized profile override setting: '%s'", profileOverride) + } + } + + dereffedProfiles := make(map[string]model.Profile, len(profiles)) + for profileName, profile := range profiles { + dereffedProfiles[profileName] = *profile + } + rpcConfig.Profiles = dereffedProfiles + + return nil +} + +func readRPCConfigBytes(jsonBytes []byte) (*model.RPCConfig, error) { + rpcConfig, serializationErr := serialization.DeserializeJSON(bytes.NewBuffer(jsonBytes)) + if serializationErr != nil { + return nil, fmt.Errorf("failed to deserialize JSON: %w", serializationErr) + } + + return rpcConfig, nil +} + +func readRPCConfigEnv() (*model.RPCConfig, bool, error) { + mescJSON := os.Getenv("MESC_ENV") + if mescJSON == "" { + return nil, false, nil + } + + rpcConfig, err := readRPCConfigBytes([]byte(mescJSON)) + if err != nil { + return nil, false, fmt.Errorf("failed to unmarshal RPC config JSON from env var: %w", err) + } + + return rpcConfig, true, nil +} + +func readRPCConfigFile() (*model.RPCConfig, bool, error) { + filePath := os.Getenv("MESC_PATH") + if filePath == "" { + return nil, false, nil + } + + jsonBytes, err := os.ReadFile(filePath) + if err != nil { + return nil, false, fmt.Errorf("failed to read RPC configuration from file '%s': %w", filePath, err) + } + + rpcConfig, err := readRPCConfigBytes(jsonBytes) + if err != nil { + return nil, false, fmt.Errorf("failed to unmarshal RPC config JSON from file '%s': %w", filePath, err) + } + + return rpcConfig, true, nil +} + +func resolveFromMode() (*model.RPCConfig, bool, error) { + mescMode := os.Getenv("MESC_MODE") + switch strings.TrimSpace(mescMode) { + case "PATH": + return readRPCConfigFile() + case "ENV": + return readRPCConfigEnv() + default: + if mescMode != "" { + return nil, false, fmt.Errorf("invalid MESC_MODE value: '%s'", mescMode) + } + } + + return nil, false, nil +} + +func synthesizeEndpoint(rpcConfig *model.RPCConfig, endpointName string) { + endpoints := rpcConfig.Endpoints + if endpoints == nil { + endpoints = make(map[string]model.EndpointMetadata) + rpcConfig.Endpoints = endpoints + } + + syntheticEndpointName := endpointName + if url, parseErr := url.Parse(endpointName); parseErr == nil { + if host := url.Host; host != "" { + syntheticEndpointName = host + } else if scheme := url.Scheme; scheme != "" { + syntheticEndpointName = scheme + } + } + + if _, hasEndpoint := endpoints[syntheticEndpointName]; hasEndpoint { + return + } + + endpoints[syntheticEndpointName] = model.EndpointMetadata{ + Name: syntheticEndpointName, + URL: endpointName, + } +} diff --git a/go/pkg/mesc/env_test.go b/go/pkg/mesc/env_test.go new file mode 100644 index 0000000..56a8a0f --- /dev/null +++ b/go/pkg/mesc/env_test.go @@ -0,0 +1,292 @@ +package mesc_test + +import ( + "context" + "os" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/paradigmxyz/mesc/go/pkg/mesc" + "github.com/paradigmxyz/mesc/go/pkg/mesc/model" +) + +var _ = Describe("Env", func() { + var ctx context.Context + + BeforeEach(func() { + ctx = context.Background() + }) + + Context("reading from environmental variables", func() { + When("the mode is set to ENV", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_MODE", "ENV")).To(Succeed(), "setting the mode should succeed") + }) + + It("reads the configuration from the environment", func() { + Expect(setAndResetEnv("MESC_ENV", `{ "mesc_version": "MESC 1.0", "default_endpoint": "ethereum_env" }`)) + + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configuration should not fail") + Expect(rpcConfig).ToNot(BeNil(), "the resolved RPC configuration should not be nil") + Expect(rpcConfig.DefaultEndpoint).ToNot(BeNil(), "the RPC configuration should have a default endpoint set") + Expect(*rpcConfig.DefaultEndpoint).To(Equal("ethereum_env"), "the RPC config should be read from the environmental variable") + }) + }) + + When("there is no mode set", func() { + When("there is JSON in MESC_ENV", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_ENV", `{ "mesc_version": "MESC 1.0", "default_endpoint": "ethereum_env_nomode" }`)) + }) + + It("resolves the JSON from the environmental variable", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configuration should not fail") + Expect(rpcConfig).ToNot(BeNil(), "the resolved RPC configuration should not be nil") + Expect(rpcConfig.DefaultEndpoint).ToNot(BeNil(), "the RPC configuration should have a default endpoint set") + Expect(*rpcConfig.DefaultEndpoint).To(Equal("ethereum_env_nomode"), "the RPC config should be read from the environmental variable") + }) + }) + }) + }) + + Context("applying overrides", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_MODE", "ENV")).To(Succeed(), "setting the mode should not fail") + Expect(setAndResetEnv("MESC_ENV", `{ "mesc_version": "MESC 1.0" }`)).To(Succeed(), "setting the JSON env should not fail") + }) + + When("there is a default endpoint override", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_DEFAULT_ENDPOINT", "localhost.default:9999")).To(Succeed(), "setting the default endpoint override should succeed") + }) + + It("overrides the default endpoint", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configuration should not fail") + Expect(rpcConfig.DefaultEndpoint).ToNot(BeNil(), "the default endpoint should be set") + Expect(*rpcConfig.DefaultEndpoint).To(Equal("localhost.default:9999"), "the default endpoint override should be applied") + + // A synthesized endpoint should also be created + Expect(rpcConfig.Endpoints).To(And( + HaveLen(1), + HaveKey("localhost.default"), + ), "a synthesized endpoint with the host name should be created") + + endpoint := rpcConfig.Endpoints["localhost.default"] + Expect(endpoint.Name).To(Equal("localhost.default"), "the endpoint name should match its key") + Expect(endpoint.URL).To(Equal("localhost.default:9999"), "the endpoint should inherit the specified URL") + Expect(endpoint.ChainID).To(BeNil(), "no chain ID should be inferred") + }) + + When("the override is a URL with a scheme", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_DEFAULT_ENDPOINT", "http://localhost.schemed:9999")).To(Succeed(), "setting the default endpoint override should succeed") + }) + + It("extracts the host out as the endpoint name", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configuration should not fail") + + Expect(rpcConfig.Endpoints).To(And( + HaveLen(1), + HaveKey("localhost.schemed:9999"), + ), "a synthesized endpoint with the host name should be created") + }) + }) + + When("there is another endpoint configured with the name of the override", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_DEFAULT_ENDPOINT", "localhost.default")).To(Succeed(), "setting the default endpoint override should succeed") + Expect(setAndResetEnv("MESC_ENDPOINTS", "localhost.default=https://alchemy.com/default")).To(Succeed(), "setting the endpoint overrides should succeed") + }) + + It("does not synthesize a new endpoint", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configuration should not fail") + + Expect(rpcConfig.DefaultEndpoint).ToNot(BeNil(), "the default endpoint should be present") + Expect(*rpcConfig.DefaultEndpoint).To(Equal("localhost.default"), "the default endpoint should be correct") + + Expect(rpcConfig.Endpoints).To(And( + HaveLen(1), + HaveKey("localhost.default"), + ), "the existing endpoint should be re-used") + + endpoint := rpcConfig.Endpoints["localhost.default"] + Expect(endpoint.URL).To(Equal("https://alchemy.com/default"), "the URL of the endpoint should be correct") + }) + }) + }) + + When("there are network defaults set", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_NETWORK_DEFAULTS", "5=alchemy_optimism 1=local_mainnet")).To(Succeed(), "setting the network defaults override should succeed") + }) + + It("applies the network default overrides", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.NetworkDefaults).To(And( + HaveLen(2), + HaveKeyWithValue(model.ChainID("1"), "local_mainnet"), + HaveKeyWithValue(model.ChainID("5"), "alchemy_optimism"), + ), "the network default override should have been applied") + }) + }) + + When("there are network names set", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_NETWORK_NAMES", "zora=7777777 scroll=534352")).To(Succeed(), "setting the network names override should work") + }) + + It("applies the network names override", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.NetworkNames).To(And( + HaveLen(2), + HaveKeyWithValue("zora", model.ChainID("7777777")), + HaveKeyWithValue("scroll", model.ChainID("534352")), + ), "the network names override should be applied") + }) + }) + + When("there are endpoint overrides set", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_ENDPOINTS", "alchemy_optimism=https://alchemy.com/fjsj local_goerli:5=localhost:8545")).To(Succeed(), "setting the endpoint overrides should succeed") + }) + + It("applies the endpoint overrides", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.Endpoints).To(And( + HaveLen(2), + HaveKey("alchemy_optimism"), + HaveKey("local_goerli"), + ), "the endpoints should be loaded into the RPC configuration") + + optimismEndpoint := rpcConfig.Endpoints["alchemy_optimism"] + Expect(optimismEndpoint.Name).To(Equal("alchemy_optimism"), "the Optimism endpoint should inherit its key as its name") + Expect(optimismEndpoint.URL).To(Equal("https://alchemy.com/fjsj"), "the Optimism URL should be set") + Expect(optimismEndpoint.ChainID).To(BeNil(), "no chain ID should be set for the Optimism endpoint") + + goerliEndpoint := rpcConfig.Endpoints["local_goerli"] + Expect(goerliEndpoint.Name).To(Equal("local_goerli"), "the Goerli endpoint should inherit its key as its name") + Expect(goerliEndpoint.URL).To(Equal("localhost:8545"), "the Goerli endpoint should have the right URL") + Expect(goerliEndpoint.ChainID).ToNot(BeNil(), "the Goerli endpoint should have a chain ID set") + Expect(*goerliEndpoint.ChainID).To(Equal(model.ChainID("5")), "the Goerli endpoint should have the correct chain ID") + }) + }) + + When("there are profile overrides set", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_PROFILES", "foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism foundry.profile_metadata.metadatum_key=metadatum_value foundry.use_mesc=true")).To(Succeed(), "setting the profiles override should not fail") + }) + + It("applies the profile overrides", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.Profiles).To(And( + HaveLen(1), + HaveKey("foundry"), + ), "the profile should be loaded") + + profile := rpcConfig.Profiles["foundry"] + Expect(profile.Name).To(Equal("foundry"), "the profile should inherit the key as the name") + Expect(profile.DefaultEndpoint).ToNot(BeNil(), "the profile should have a default endpoint") + Expect(*profile.DefaultEndpoint).To(Equal("local_goerli"), "the profile should have the correct default endpoint") + Expect(profile.NetworkDefaults).To(And( + HaveLen(1), + HaveKeyWithValue(model.ChainID("5"), "alchemy_optimism"), + ), "the profile should have the correct network defaults loaded") + Expect(profile.ProfileMetadata).To(And( + HaveLen(1), + HaveKeyWithValue("metadatum_key", "metadatum_value"), + ), "the profile should have the correct metadata") + Expect(profile.UseMESC).To(BeTrue(), "the profile should have MESC enabled") + }) + }) + + When("there is a global metadata override", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_GLOBAL_METADATA", `{ "bool_field": true, "string_field": "str_value" }`)) + }) + + It("assigns the configured metadata as global metadata", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.GlobalMetadata).To(And( + HaveLen(2), + HaveKeyWithValue("bool_field", true), + HaveKeyWithValue("string_field", "str_value"), + ), "the global metadata should be overridden") + }) + + When("the configuration already has global metadata set", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_ENV", `{ "mesc_version": "MESC 1.0", "global_metadata": { "keep_val": "do not lose" } }`)).To(Succeed(), "setting the JSON env should not fail") + }) + + It("overlays the override on top of the data", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.GlobalMetadata).To(And( + HaveLen(3), + HaveKeyWithValue("bool_field", true), + HaveKeyWithValue("string_field", "str_value"), + HaveKeyWithValue("keep_val", "do not lose"), + ), "the global metadata should be overlayed by what's set as an override") + }) + }) + }) + + When("there is an endpoint metadata override", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_ENDPOINT_METADATA", `{ "local_ethereum": { "url": "http://localhost:8545" } }`)) + }) + + It("overrides it with the set JSON", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.Endpoints).To(And( + HaveLen(1), + HaveKey("local_ethereum"), + ), "the RPC configuration should have the endpoint metadata loaded") + Expect(rpcConfig.Endpoints["local_ethereum"].URL).To(Equal("http://localhost:8545"), "the data for the endpoint should have been deserialized") + }) + + When("the RPC configuration already has endpoint metadata", func() { + BeforeEach(func() { + Expect(setAndResetEnv("MESC_ENV", `{ "mesc_version": "MESC 1.0", "endpoints": { "base_mainnet": { "url": "https://base.coinbase.com/rpc" }} }`)).To(Succeed(), "setting the JSON env should not fail") + }) + + It("overlays the existing configuration with the configured override", func() { + rpcConfig, err := mesc.ResolveRPCConfig(ctx) + Expect(err).ToNot(HaveOccurred(), "resolving the RPC configurations should not fail") + Expect(rpcConfig.Endpoints).To(And( + HaveLen(2), + HaveKey("base_mainnet"), + HaveKey("local_ethereum"), + ), "the RPC configuration should have the override endpoint metadata overlayed onto the pre-existing data") + }) + }) + }) + }) + + When("there is no resolvable RPC configuration", func() { + It("fails to resolve an RPC configuration", func() { + _, err := mesc.ResolveRPCConfig(ctx) + Expect(err).To(HaveOccurred(), "resolving the RPC configuration should fail") + Expect(err.Error()).To(Equal("unable to resolve MESC configuration"), "it should fail for the correct reason") + }) + }) +}) + +func setAndResetEnv(name string, value string) error { + originalValue := os.Getenv(name) + DeferCleanup(func() { + _ = os.Setenv(name, originalValue) + }) + return os.Setenv(name, value) +} diff --git a/go/pkg/mesc/mesc_suite_test.go b/go/pkg/mesc/mesc_suite_test.go new file mode 100644 index 0000000..5f0f30f --- /dev/null +++ b/go/pkg/mesc/mesc_suite_test.go @@ -0,0 +1,13 @@ +package mesc_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestMesc(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Mesc Suite") +} From 7c6385f2ad96803dc756ab892321865132b53152 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 12 Feb 2024 19:11:44 -0800 Subject: [PATCH 71/85] feat: typescript implementation (#1) * feat: typescript implementation * parse env variables (wip) * public interface * completed config and override parsing * uniform filenaming convention * safe parse & make default_endpoint nullable * describe all method signatures * parse MESC_PROFILES * chore: update dependencies * update dependencies * add js/ts linter & formatter * add test setup --- .gitignore | 2 + typescript/.env.example | 11 ++ typescript/.gitignore | 175 ++++++++++++++++++++++++++ typescript/.npmrc | 4 + typescript/biome.json | 64 ++++++++++ typescript/bun.lockb | Bin 0 -> 86535 bytes typescript/environment.d.ts | 17 +++ typescript/package.json | 48 +++++++ typescript/reset.d.ts | 2 + typescript/scripts/.gitkeep | 0 typescript/src/errors.ts | 17 +++ typescript/src/index.ts | 42 +++++++ typescript/src/networks.ts | 30 +++++ typescript/src/parsers.ts | 110 ++++++++++++++++ typescript/src/schemas/mesc-config.ts | 23 ++++ typescript/src/schemas/rpc-config.ts | 34 +++++ typescript/src/transform.ts | 97 ++++++++++++++ typescript/src/types.ts | 46 +++++++ typescript/src/utilities.ts | 11 ++ typescript/test/index.test.ts | 6 + typescript/tsconfig.json | 37 ++++++ typescript/tsup.config.ts | 13 ++ typescript/vitest.config.ts | 5 + 23 files changed, 794 insertions(+) create mode 100644 typescript/.env.example create mode 100644 typescript/.gitignore create mode 100644 typescript/.npmrc create mode 100644 typescript/biome.json create mode 100755 typescript/bun.lockb create mode 100644 typescript/environment.d.ts create mode 100644 typescript/package.json create mode 100644 typescript/reset.d.ts create mode 100644 typescript/scripts/.gitkeep create mode 100644 typescript/src/errors.ts create mode 100644 typescript/src/index.ts create mode 100644 typescript/src/networks.ts create mode 100644 typescript/src/parsers.ts create mode 100644 typescript/src/schemas/mesc-config.ts create mode 100644 typescript/src/schemas/rpc-config.ts create mode 100644 typescript/src/transform.ts create mode 100644 typescript/src/types.ts create mode 100644 typescript/src/utilities.ts create mode 100644 typescript/test/index.test.ts create mode 100644 typescript/tsconfig.json create mode 100644 typescript/tsup.config.ts create mode 100644 typescript/vitest.config.ts diff --git a/.gitignore b/.gitignore index 45cae29..5c90b16 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,9 @@ TODO.md INTEGRATION.md PITCH.md *.json +!biome.json __pycache__ python/dist docs/book *.gif +_ diff --git a/typescript/.env.example b/typescript/.env.example new file mode 100644 index 0000000..e9350b1 --- /dev/null +++ b/typescript/.env.example @@ -0,0 +1,11 @@ +NODE_ENV="development" +MESC_MODE="" +MESC_PATH="" +MESC_ENV="" +MESC_NETWORK_DEFAULTS="" +MESC_NETWORK_NAMES="" +MESC_ENDPOINTS="" +MESC_PROFILES="" +MESC_GLOBAL_METADATA="" +MESC_ENDPOINT_METADATA="" +MESC_DEFAULT_ENDPOINT="" diff --git a/typescript/.gitignore b/typescript/.gitignore new file mode 100644 index 0000000..468f82a --- /dev/null +++ b/typescript/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/typescript/.npmrc b/typescript/.npmrc new file mode 100644 index 0000000..62ddad7 --- /dev/null +++ b/typescript/.npmrc @@ -0,0 +1,4 @@ +engine-strict=true +auto-install-peers=true +enable-pre-post-scripts=true +strict-peer-dependencies=false diff --git a/typescript/biome.json b/typescript/biome.json new file mode 100644 index 0000000..904ac51 --- /dev/null +++ b/typescript/biome.json @@ -0,0 +1,64 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "organizeImports": { + "enabled": true + }, + "files": { + "ignore": ["dist", "_"] + }, + "linter": { + "enabled": true, + "rules": { + "all": true, + "style": { + "noNamespace": "off" + }, + "complexity": { + "useLiteralKeys": "off" + }, + "correctness": { + "noUnusedVariables": "off" + }, + "nursery": { + "noNodejsModules": "off" + }, + "performance": { + "noAccumulatingSpread": "off" + } + } + }, + "formatter": { + "enabled": true, + "lineWidth": 100, + "indentWidth": 2, + "indentStyle": "space", + "formatWithErrors": true + }, + "javascript": { + "globals": [ + "NodeJS", + "MESC_MODE", + "MESC_PATH", + "MESC_ENV", + "MESC_ENDPOINTS", + "MESC_DEFAULT_ENDPOINT", + "MESC_PROFILES", + "MESC_NETWORK_NAMES", + "MESC_NETWORK_DEFAULTS", + "MESC_GLOBAL_METADATA", + "MESC_ENDPOINT_METADATA" + ], + "formatter": { + "enabled": true, + "lineWidth": 100, + "indentWidth": 2, + "indentStyle": "space", + "quoteStyle": "single", + "trailingComma": "none", + "semicolons": "asNeeded", + "jsxQuoteStyle": "single", + "quoteProperties": "asNeeded", + "arrowParentheses": "asNeeded" + } + } +} diff --git a/typescript/bun.lockb b/typescript/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..658729a2308673a713a67e49394772cc1f72e6df GIT binary patch literal 86535 zcmeFa2{=|=-#%=(GL<1yA@h)#LZ-|jk||@R%=0`%8Ov0nWQwE+DMOjdJY|T;SW!fV z2qg`q_}1du&%58}|Gf9D+jo55@g3j$JMP_it+m&A{(fs-d+(kec2*%@Z!aM$M>io` zH$N6DUpEqP3AnghJKH(B*b3OWd%0Tr2>1z;;Njrln5sLEx*8~E(d`}ZHo>jBmQ195 zxSeV#ukVSM8W+>#{SaxjWk6;MjUw`8vAT;0)}>!J!2CjR2_t76POOcoUl+g-!cl?^|K>HL>{;0BJ#a z4s4nf;69N40i417Nq|uI1wg1<2N3#ufK4X?gyq5j!g4MEX#g5w?<->O3u4m;07AZp zrH=z_U>jR2UweSA-rx^l)|S?rs0sQ3);j`-LiDn=wDu8j^qv4|5Mt;cHa`;twHKsa z+1=0)_@iqcZ&dF{Fc`4UT)yGw~vhgm>@Vk*!v1#kic@TE-nEe z3&$5|Knn-?Fm79aTWd>@E&_uR`nwAd#_#TC>*MHZi{lDvZ7pEumICr&c^J2Vvu!{O zHhlpg)b|Al<8THDx-9ezK&W%p!O_|Q=sS7?PY_wQ>UWfNt30Cj6x@S66)gIA!`Xv_ zGYuvK)c5wa_OkT0#d*!XHLg4yy)3~D#Bn_bOX1)==D@bQgRPsRT>#D z5XMi-i$#!z?R5{N;rvJk2-^c0kJtFN_+tPe@9%UF{yu@Ncn}>e5EmSW^`L$*{yc!t zU#sBO`XVT_l`aNpIM3dI_JscS3vZz_KsdjAyhM+{cJc6a3$S*#u{8(zuzoF|Jgi4C zKsY`EEL~k-Io!ir{+!%FaWL>;yIO$}=IvtX4g1^G*2~@&lyS6obN2!r{{dV6v&fd; zBcfY;D=$lH(2Y2SAPwVM1_;~xnAq0+DNr7^o1?eDX4m}!`LNs|$cOc|v-I}y1pd5i zeZ677hk;s9fqX^rt+?X=!uj+RTi(XeYg6d7#FqYB5Es<{(|PbejeBbccV|Z%OE0kg z*Z^N1$E3IFBaTI?qg&(9(k%e&SJn=9LA%2G&VhW`-e6OM&5JW4v$ejr1BCS{1_=8# z5g;SLP=H`53v~bpmW)s!zgZ7f`K@|`;knsPcR?DCiy15;<$zBdu(X5%*z|v0aZC3s zKn9R+0TAk{0fg(dFhICp(E)^U;9~E8RM@(IzB{vO@3rm+Z-42uI6Bh}$n=Uv9Xdwo z)a3uJx>Mt~FE_@KLY4TZ|Kn>H_C+j4k7~P&94F6Fh>!NVdGKwt8Y%fi?;-wQoxd2* zY2i)<4u;AR>ezWjci4y@ER;CB_CjS^fs^Q)l5$JT)!*rr?0e@VKA+bjqloG)<;0i? ze~6$W@aeO0>0ZXuNn2c$ztg*3zA^uWg#H<4H8m}z+11nwrk35$<~4}I_y+HK^*WcB zdS5!eUY5fVXraZ-!PYbsL%}Yibe3?r@`y%PMdtOgb3}V(`5xmYcC~*GWe&{NPiUNq z&!gI>`XfPlp4}-nEjk)g;9#*=%6}%==S!yC_i8KJU&Q3h)ZbmsWNi$^KT+VNdL<0JHWX2UOS<7ipmGqrqR** zTlt4;B?T{5a~QL|+ZT5cM|7P2S!;G#%V7D-tH&2>2-bb)$Yte;viJ&DWVI+VA`+g3 z^^snsF|&M9mBy|q)RaZ{teN_j|9Ly3pg>LLTX^q8Da&T|`p@0n*G$WyUh-Oc*Vl@) zrV!0>_pxeoS#!LaflowZ12W$V592MrttfaU5gy3W^36>9%5U#yyh8V68>SNd}FVS_f$-OJ~5%mqwi=D644@K zFfD(4zU;2)+&%gC#u_X~n~%}A|45nV5H2ehayqUb7ELyUZ$Y;_KwcnofQ$ZNkh9ol z0@+Kp*LQJ~hZxJ@KTr95Z9mS~my1@;5-YK^{?r|3rHh)gM(@ha7rp**)u!ssYC5GhBQ^~eY`p@nv7xtWhB^Z$&AxPuH_&quR9l>Rmlv?^E^>!KA>+aI zkF+#>5&He}9Ov9Aj2YR+*&B%2o}9)_A5r;n+vB$j?jsL2<>3PNLuD?D)*16Qr}f_+ zZBRzWqm?IzjQnnLiC&`zFVw!?p87i-gm2t>M0ZYobso{7qoj1vV<#UNB9nBZq&cB> zlcsWxKBC4sV5$7oh+IwZ88z$OY?t(h$Jd`1af_1Pn4GVoZ(#Y|yO-{1%KjG;L)pBe zF}`X%>QZ*&uTsmym3U;WE{T)vGV6ZGCY`ER+&I5t_11!lNK|XJxx5Brl_vUgPpx56 zvAO>N#~0(#=3ka~`-QVmuU?OPbtZ(-ZDU~J7BMxCZEW|~T*`F3>vq@XbXz-K+2%SO zlFQ}{yttSCqif4eqZyq}{WJ3$Kd)JSZ=ilfP}MxcEVJBD{ER}(0b_Jn?>WJPr@TVP zf328Mf60ifR?7QLmU}kbZdy>wSB&J=_;5Jkdy#tno5Rxj`_=s>)cb`sW6j7pj_JuI z@tZ#1b8_Hx`6r$zLY|D1cT4U`GaolUcU}ENj7?&3&2Yz^E557Y`X8^CGrqiNa$~GLT5uPBnqDp~S3}t7{pX|71M3wdkA}(?pS0P>-JkhJ zBSKnn>bNUEAJM&au1P|=LDk(RUB21wDrwA<5lPQyS&ZX_PRDYU%SaNtA8nn}NvnQF zz*BodIPB~BdHd(llpopdcHRiM?bPRplw*rN8?&^xAulW4CC{^&t4RN<{DmU*3HGWq z+x@DEPR()x_lcZ_nLbUeia1ZQ=2fFo8Y4FL&{YEqSOxfYk&`q zmZ7_VHy8uFwquBYaqt5i-9lj+AA9`?KNt{U{V{+9&P9LhUjz_O?|>f*_(nV6PwmjZ z9B6pm9r%w2{4+b?F9E*k4)`Ytz&n5)@QVT8dg;@7SULgG4(Ue<6Tx zu!Hs+1bn!D0l)!683#PBZp)DQPX{KgBH$zI29p1GB1kzCzz2_7|Kk5054n%{sUfrok39q_#XUu_5cYQWz~{O}=p zC;rs{e<$_72KYOPe{hHKGl2*9lRIdCXTaY{`;`H{)(-sRgO@QoiC-J=chY|;fWMRa zzXSZ8^gkzfX|)soZh*g&_NxZ`owOewc!_#q2mOB%@OM)GWWe7^{on7RmqLBQt+{$cu`_{RmCmJr~BV-yY{xZr!l z?HJ-;81Q%U{BRxcm4JWn4s_H1c6`G!i2nt^mjry!4FAg8jt0W#0xw-<0e{y&A;{ zNVyQeKLY%3H*Q21;Wq$29Dm697rFm;i160|UmnYcc}V_t`Lf{UKQjKn_v$|$KWTt} z3hN)PU0^%imLYL206uI#WbH!o|4sxc#|}PfKt4>vYrE};@Qnd~C;guU`0)J)tUJ8^ z)c+jd!~Ta{Xz)2|JBGy14L;%^?FW7Tseg08m%#dm+&`Va$$*a@zkkXf0DKkT|4(9v z?Ss^x9(?rD1bmoAE_na%4B>kMKHR^M@<=|C{+|#jmk;>J`1_yA{-=C|KMwe?{b3o{ z_eefW|CJ%-=)k4{I_0zRC7+if=_E+l?(u<0P{-*$aN4TOIZ@ZtFRld+HH zUj%$){X=5g4kG@m0bd^YhkcLa{Rw|Qc!8N~l5z&{H3|8)HEv22YWWbN2)JrMub0UtR(!`P5~`1`L6Dc8dC-}!&VLEl68 z-vJ-)e@Gf#=C6Ju<<(fX+JC$CMl=zA4B*4@5BYHZZFdeL{AR#M`VVR#`G}wY36XNU z*|zv_{y_eA>w)mS0Uxfv$oN6>|0lmlK2nZ?eQW%~dc!;R??!Wc;5k8K#jm*v=6|B$_7yXzpr_W^w5{Q)wEw&DI??bHnTvLJpK`*wXp zeZ)U0=YQ@0_#hwZY{wA365u2LA%DAu@WTLK5yTJM5BmO7|IL7}j;%k`MEc?H;z0Z} za&4_2@Vfzw|4+XkBm=%2)<5L_Y5bo6AI^WI@BcLZg9o>s-~YrnY#XHhR)7!pA7YpZ zY`cAk@bdv*1@MvdpVof^@RhOc2mK>D@b_OCQcj6`D}I=Uu@n3i33U(Qrvbhq@DFdn z^YeBM;lIK9|EKHU9iFZD3AgJQTMqF*4ES*UN9z5j?a#vdU+X`V{!_jw;L8L5aNNR} z{&f7*0lop?ZmP{=B>&Qo za-0HN{SVhKn1|&5B^g!D8t|2Ye^`FITy)ucSpTs8kiXqFM0`yF{&Cz=={#OBC1@Mu&Bf5VV z1X6Ag@RhLfqt_5CTOUh7aImetHup4`2ebO`dI+Bll-bGr2?Bf#;2)Xyi0;4p`}Z_b zt^@GFf1CA(W&U*htO7DTe?UE?5B}ZPe@Y|%4;}ii^V^^7VF=$F@a2JjIRF2|5Pm7( z!}lNmwEalH!zXM%s0Zth==@zQh<_=--^ug458#Ue|47^aY5(N`z8K)|1_5uE3+sl& zzXbT;zfJ#tS7-EngwGCMKEn8+Z)6QZm;0Z7BYZQmz&7;rmCV|F%1Z5IzAQ!}fz| z=>JdauL$_a^B>ee?;+cXKN0Z35DbNWDgKJ^Z}*V++W;T@x5no57%#G{%ltR;gd@K*Y`Ulw(TIo zHvxPYKhkg8T?Y_;D&WKMi^PxQ|6L47xgNlW{Rh+Atvl34_=KSIG(U!DSwK%q$6(L9iGY7<2mBep2U9qd8uS@_2H3lezJo=O{u7Yj`uj(4+`zv7)A8d5 z_}~ckulD~_egWWvDf}<~pN_xJfDg~l@Z1G`lYnbGhSZ-!Ve9WNBJGFF!@tu&_-25Q zygz~dk#V?P{v*Ig>JRyUx_&%V#KAGfw%WsGJpO_{67F6 zng9QUe;h2nCwCBk65#Ko{*!?JPwEfH7kuXlFK7@Mz{LSB*bY44g6jd88=D4^3|wHi zY})@5hz~p+!}|MAxDVVj#oqt_GQv3z_K;0OBL?JHf(y2T&F0)7wGlHyO)I z!SWzNog3KnUm+zZ^8i~8B5c26Y#NQwPZ_wNZaEe!07CmuxC`W0gA2A#Ex4ee5$e=| z3t~OEph1M?8({(%M0oyg0~hrF3|z2$C%B+Ng!$bt0St|>To1S)z5o|Ah_HM=xM2PO zxS&CV`7dDt*ndJ8*Xzx@TL{a)0T;|4#pa_C>W_g7mYcxdhY0iEW7Gc$;rN-s-v3Vs z+hYNH|34vY_b=draec*>g9!b8!{T=={s0IKBD}wX#Z`dNAVQrraKZb(zy%E=%wGo= z%-;YPG&I8e&71#*a2^nE-u&+fvq-S{5aG|=*z|uwcs8QKmZQd&g9v}pVABv`obcb* zf=GwWhX~t|8JqqSgcKGm47u1E&xzkR^tqX9R(`Y^ zt=4+%Z%}`{Yj2k8M)--gx#!Aszdx8>9Jy;7!7VlXgXf;B(OECu-r6zN<`|NFX^ZSu zU*K66(S>UOVwkfDMRiZ6OFb`sQ;y~fzRb{^I#n#htwy9_Vo$$*?tsDdq!IzHX}(2< z?}BQ-`$Ix&DOl9`t(=@hbPT(Xsb*gVLWnNhgAl_E=1UZazSFnT91U_~vfclnXy%a- zkr=t#Pa9M78>13UdTA>UMDyO*FbxFJIwy8_#YS}T-b}uiMsWQ|grNU$6A(gl;T%K^ z)7asNML}zjAgwVD01A<~_Rw>x7C(=y_YBe*8;~PJ``#|#W{Cv`CO;|&vRE+U? zmtMI@vd2N$Z_|p-UWU&cP#0>#vnyhl8G8JnklR9)!?=>e7i_QQ6uUMt_kJqR6@K>M zfKAn;z^59<{Y;N{tuPv;-dcHYqH#6#=jh2JFKwUSNf$}pH>L!Hka*!)4>3$Ge)m_g zQo)G&nrK_~(8hNDH#s4GE}7hgkM})En`=2xc;4$+f{U(+m9jtKVSyf<>R~63euI_i zwTuyt;qVO$AOxou1wi<$gcznWoKp2M>B=}Azw4f8Zt}dRsSLy!ObmP85i^C}B8d@9 zNWblF-=@rt`+1;}j+eIW=@Ic^`k(;qE53{y?9BwKKnT%=a~Cnp^?E*vuTmL3ooV&s zG35Mvjea{8N?%|MDaZA*j{hji5-!UUM(?3lIig?n>+98wwDf7ZJnAvAL+X-j1_kH6Vx{OtD^c$0h8z;-zpp>X%7ws-`>Z*rmW{9&vh- z$9mgmR85{Nzmw7+neR+D|1=p9b>KU}Q>q7p&-KN9s1c`% zF&HN_y)E4O`#w{Dkln@DoXk2`@kOWL`keTdjpKHwnXTWNMEZ(_s2otETc$amwWYiH z-FP=zSI~|~y2!!S@M-19Ij>|67eU5p-6(;WRl?BgjP&+6!)5wO6sGogGM>vWoJ~F9 z+P9hB*BRgrgeQrz%4NB%dT;6y;e-O*gVt@=G#!?)RkMzomI_ua;)N}F5YImq-b5Mf(^2m z+z=ls-c*nM!%d8z8i#Lt=1H*bO3cBHm5b2Ky8doZ@qHrOwVvNmT$yr@-&ecXN@f)~ zykiKQsbz`p#p=RFhVQr#!^|x+?n*1nH`G@OP4?UC5uSVEgXZqR!E>?47YWwr>z38j z)4XHuo!C{Kv=$QGp{(pAXH5H*DcFZ=q;o}rbLuh>!Ud;PIDW|yQGl3UpBv&o$BelR zehNK^y~PvJ{m{Ogmi_6FxGZMfqAH-*b;ZMi45yX{twD65He#4+-$`4OC9hR^DLvx1C-8@g-36SA-l=ZT6Z`j`p&^-L2?;MxPiTuu zJar*=S2p{@$5!W=(<2#k-&1GO?booG0zyzX6yRP&6d-27OTvcb&7 z_yhjiw*N8=*RTw&*(;^~m}23fvSO|BtUbqTvm0C@GqrP%3K6va%KavsdNVxh{0vRN z6D{eY8+NUPpW79ODUAn-&3vIe?iCO66t++^1Y1e{>QqA*Dtz$zR;DPnkrWNWcX5rN5iJ>);>gy z)~!xDdjGNlNrLYi1~v*tJXc25NG1YrjZWH`TLoU~hdNb>JO~QfR9<}5_?5}mh4+J4 zvp%2$Q(^g>F!0>@v!XR9T^h8m>akCHw+*VAChiM|N1w@MVY!lPhNulgua zF?*VdY~!#BaT!e;lUJv}-S@1;xA1>~fAX}WhN^+xq*QN8|CGw8%G1i!={s&*^-=8= z9I+_feQ4bP4#!+^a@KqumWJ|EIR`^G_R)0xI$G1`Z)hVWFo}o^Tf*fYM(OTH>z*(;vVdE--Z3e5x!0?UMfr4UY!ZA@PxTn5Dg`yS4t(p>><+V;Hj2 zKglzksvV<=S+qV9{;pXAb4h3LYI~t-oayNyW(wuFBd;Av+fBnMm+{Q-r88c+?6=|W zE+QEiiXgnRsk^nFp}#L-D8`fc3muFa48zu3Is4m4C9-P6?^@(Fi`}8}?@uEdSJrRq ziW^#5u+?t(8a_C|Ome%)k=5@OZ*!%%1pCWhCpUGs<{NysfEZ?#>v5*=NcO(gT(h>@ zz7sl&%u8ZNILwDF+Q@=4jfC4@-n*anp--v%bpZ9D8mgl{Qb!3cD-t$;2%U-Cy{BJ4 z1PH{`(Z)8W_RrBv6> zed{ro43$Zk2-BPKT5{rV3w~low2M_F4`@JL7J!W4LJT9fkEKprH|`brVfGgV&u1IC zA}18?hi}{z;9B?Mc9TMAMPwVqv`9uQ7YGrZ~uRgkwoqu}jXOo@z$pJsD(M!LneK?)<#N5h>j4Fr1^qBMhqU}@@l?io#?&f~MiiiTl^lr@GBP9={qQeXq@+=+`5>}#*rR2H(@UXcS zV>sW~OqO~Z^TE*+O0}l*6AqFEC9bx+6e@`|pUAw=tGqgL!)8-AbW@iNty_WFSp0M? z!u-zpu3aKWvJSo1t$Q$5{ITv9SZoUn{a=@Z|tF} z_8h(Cl0sPTjiI&0{-1Ov%`1hZ?Td$EN58y7>2jcTlVjVzYvsBq=CuwJxja9-dzo%X z;E{+bk^juyBtzpja#H++yG-@W&Q04zz18OWMrCr#M54&x)q$D)eVp%SFFI`M5^c5v zCt7!6`kVExB`b;FQTjx7&oeEb^xH6)r~i@^`_`m_%RyJm@L|I5Lh7Cxsd&;0_$s1i z#s}*)_NOMluC(?!di<^DkxkvLeVz-gt3;dk*f({}Dw$ID&HmJf8exMtmE+ki4sWfd zlcG9SUq}XCJC}Hf=;9pHhSmn{d=k@SWlDWWGmEFoxvxidd%_rT!CMPB&JLn=ujWyk zB!@bz;J-JIO6XN>4XTz3s$q^wVju1pFIc<7nn2@rbfuC-RQTlD%U=b#-t!9FO;?Y8 zWq;N&eX);UhIdmJhX|g1xzV}|N#wH6oZHWrYn@M7a){fjQk8!v+jb42WoGK6sl_8qEgBAAe8zg|oTd^+&Jiu;i1+c$>PI&F5hrw60I5%}YXQ8rEM# zJecJSf_CRv?t_n#nX4nF$=BOBv&XB5X9T)W`rjWUvc8tjePj}UIsN&$TH}wr>8n29 z9ajA|b+^vHFm}W+PKK@Ja?uo_m&4zr%O=Jm_@LLUXe&9ny0b(pUbV^;i@9nworB$`R_A_0e zUugdtY2avulVrAUXW`XBmQKo@o8rIjSSsSBC` zOb&juuJmg6I(hy4YpZe%WzAzkzhWBp#O@^s z&Qq(5k{^>Z`?RSWy7}Hs2(7C$oBbo}(u%>^K4yzYslgvh*hNz-+w44_O_O0Tlzxtk2=JXocc?oSSc#`WJC^HS3-PGMWpTV|94AVsU)~I#&>!U>d z?e@#xop7rL&pDUz55iD%*@@KRo@u7%D-%SD9Zs z)js^O`MpR0BP&@>sh^Lt@J88{-ug6O<(ArNv7;(cBPd-Fw61#= zXH`%7Tl%+TT9?905^)KayYX7&1Rr^xyS}iobY2IexrQ&78K>;lNBh2Dwh4dg60a9c zy?~#IMe>_3vadZ+x}s=Zqbw?n*E}Y`G0x+K6aBhrQ9M;C8(upfoBG#m2kjr++%5YC z{9QS<-K+#n=i;ocCo=r_DXUEXY=TfCc(>2oca*LeT36<^$NI%3@#z#lYZ=v(#Ck#o zdZ+OO4qvJfJ8{7(IFE1))8%5=ZTqXb`q3Nz=lng-E_^>X!Sz^!FnsDQCH^s6lrCJ0 z5yL#SyvXWS{KM6=Qe-lcb9conHKq&hyNb`|yWQ?SO-@wETJp|cFE19bHZE$0W#3>|B(77OGY*nJ?w-yui-|_*N}zSq;;g4a?y{y{ zQv4CdGgBgrnFVrfsJrA(wAJ@KV*fzdnzc^xvE<}tmc9M} zNkO3E(ln>xCnN5M2L3-o6YHkbPxCQ+JF<_|qmQ~VHMc&lOkAh5tqi3rjn@70t-Eeq z?BkrF{XD*L;Mn5cU6!*THCi<_T{hTgNY8WVp)r9ZtNM1n@*jV#@zc&kl$(H zY%ghAj-layiqbub)?J_>3G$~D?hvWWbu)KL%l??pZ`~72^fP57-u{UW{U!GVjf!Vc z2ga_y^`^Wq`IXKu=;GnLJY3S)OnW|!`?+%{T^Y3Qy2{>`Go2=fx(Tc5ng$XTb)3uF z^gN$gbWW{*XUEOg?e`^P+!F43!8!dGzIa73@Y^~v&ScTL zl;T(UO!&yXzkZ3mJN_Hf8klpRL6UGpE%sSZr7<6~Q+!Or1;1A2#!qTtY>Nfj22DkR zQbzZmuSy1byEo|OFQIhh(7K$RDhmYu0xT~dUMo077!meNxvuh%q?tM0Q0dJsX7@DFS8GUTY~9NQE}B43ytT z=_;Ugzdh;mUTQIMj_)k`>^=GG6hV>T`woMkn%MftvShJ2?#m{8(`OP5^<}A@oN*{@ zm}R5SJal@jS;((Y#`#oyVhE+Hh}KoNyfM)l-fVHR;iPL+cD-ln)i${o?~)2qN2+!|B z6!pftAdbgC2+>tWL;+&_&GK6~+!7U27)7nf9(|de>#}r;ZNAXsOHM6M##%LhTJfp5 z@{;ZF#iMr)6$=}w>DXC(ZQ~K_JN-!bwfkpB_;+*=-D7Cogx+)~2L9%@^A_iH1q(;t zdJ1kRu6?oPAdz^ed*@n!m)*Ax3p3{avpu15Q;GwNx4FOI3p6%s5Qj-z)UR5vTSV!q zpmlj7Z_S!M(GyF0XZa&o%EiA$&g^7ZcqI9P>Dw2@k0-JXZhjYdeI`!x;4Z(_J9qPF zogQ!>!bxkCJ}#g~Ty?!@9;FN4*&>D+l`{4Dj6YvPsB=7FIQi67+oP{y6TFCyWS;uO zx8Hv5O#7?ZpXF;k3K9+MaTT9!2}skLZbsTWzq-ccX1aG?bL*VCb$)5Yzi}<3`vwzf*N>Wm6tqbuOWE+-t%cwE~6*qfF|hFNCv4 zI;Ghz_*CO9#!Wx_{_w=bOsmLPb?rN^dQ{FQJeJ)0yB}Nes-tzuGD_(mobpkAt6Dg9 zj?zeGg6zSKSj>p&JiWp3s_xju0f!jORIbc$eM6NG&SLex+K*?GOU`on8IBB+Yvg=^ zXLKaq6KGxIOaYuZ9sE-iy>qPhZ_MtO6Y+^9tLvyqv$S*&3H1B?x`&tgP%Hkeb)z}H zYDTf8kS3)Qu5-pk^gk&tkh5RyLFvN112If=CO2theCk`fmL4Bx>+m24>k^UKGi%p= zp4wk>Md77eU1i(nPaNUWR}bEhkR+OX-*Q-L=KB#zCv%DbahsVM_;-$wc;UMf#4vHY z>BUA$f1Y(`V09gxEIOV4WkUNN%Z2C!~)l<_A z>dcmqs{>!5YjPKfYCJ!#r~D7`-^k(TU3Xx)-dvae365lLd} ztpUnXg^HWTwRWF7luEk#R)0v`>2Yepe|s&u_H&Kr$ z!4EK8*2R%u?!8e=%27B~Kiq%gLB$Pb0c%QwcX^*kIflQvQ;IvYMMd6E{~QpMoWh+a z8ulg}rF#mkEBk?@>*HbbYkUbB$*CH=k}2uO7YLYDdNMmtc->WE?(>;QG8i?SI&)I+ zikbqQq{F!%hxR3K2jZvB3);S}eJu6fQ3Si2q2&nONwN9pRLbveGjB~spf z)l`z6$1&RD&}f!B?OCUeM_!Le=d@>+Zxcq16Fj#(LHm2UMoBb3gHh;6Td8oDr0Y|M zEDKJN=>#n(az>Ii96DPKZ=VzFECK!r~Ke5c*HZ3HSWE~_#H~u2(2sn zO}mCbthH7<6HKJ8nhq7bdA$SDOc`|+y|FSLLhj|4-(QZvqcG|{96V@VULN{=4R^6P zBjS6o`p?zCgcDSqr7c0`yj$NPxAqHDL=+&#XPolE5xyUJ$<{n7k~MF~dIiOfJkd+{ zs@2Baylx*=5_z{y|GnqrP?VOUl2V7aoeop>Ph2)q{h2Gwga^;^ZGDg3(uLn%5W~11 zO&$Dnw7I`Ly3d5yJEu1MqtWN7_jk)(T=Cy}9jyQ4dhO>@!5F)a@&v8+XdoPcBShieaUaf_OM~j%XPad(&4*FL>I=67^W`oLO=L2LOtLc zzkcje;G@%>{i6@@<1`blQ%dJ!em(mZOWVpET9C27CM1x=z{MC|L{PwJRug=Z!#-WWLshWL} zHQEZ9lu4S&(zgpn-}U`Y5&Rf-mhj2Xl&$x2TkUI!){V$kewJ3s8=YK&Ym^_1?jwE3g)a%JgZpLk2|(AKa8UkdSyNcSP5d+_wyXC-Iq z`-~q;nRBmpW_@qhZCw~c=~|<81%398R|K)(G#}#;%DqcaH?}~Ll%68Vc?9$5{nG#n zf>3|)b9v6smp)V_r1@0*(p5G8W?)&uG&zAYvxHmq>l#Ye2Ca*Gmd-tYxw}|iTeF0$O-JC2y0$Fl3J6vm+D5n%hnt| zvmxyO-x(l=(a#|+xn>a@(kaZQf2Xq#_jQ3s`t`y5yHhuFGJ^FoqxR1P>7BOsh@i># zu)0U5b@pa_pXtU4Ip+eYntXx*?gk))=-MHo05O*+dN^{(^^}wrdV8dwO}fnX+++C? z*6_64VK%^8@uCo|oYPBhn$9I@j$@OYALbfgxvgub4PSWf^fKPfx4ZQtO4lB(izyM; zG&^PD{VAoEbBwprx`=JHfT!_X!G2oW>*`l3{9axt#b4uIE21g8K91jZ__U?x-MwxO zVGqd1oNDXH97m--qWE6<{IVOt}H@sd1Tf3Z-Mjp@PO zk3m9W3br4Js9K&fcYJg@OnL9VAvvuh;q?be6;%u|vW#}$rZUOi=dFwF)0eag{!t+5 z6!H!TA?@pmhyujq_@);YX!Om?pZIw41#UgYEaBPxDCv{__L^UHn}V}VUOl0H@Hz7r zneF{s<)eM^Ny8+w}Jme^cA9B`-i;MRNPt#!u@tt)o*Q2DO6%#W3{2|PRrjeeU> zHNW~0v77$>`b1;KodJ==L<5SM&jNZx{dL@yR0rb|og{q9^qGcx9coua3{T%j#S71@ zh+%}3@^giF=@V5pmd#c|d}_3VM_Ff{EO@K2=8C?*5Tz4yuxfzEl;+j>iMSgo3Id5~ zG<4@NwFbMF&P1JgIMa&mHxEP&pH1g1$}G=}_LXK#`?d*3;~Got_u6;iCJ22GYLp9VlWL>+kusPu7cS zesHkmd==!-d)XhvQ?YKzGpScPd4ldZzKRTwc2VN-$!>CPi(D>G$zhSWA4)Sa2gP-3 zM^5e$4Fy7ot`{N-5L28r&s?5id2xc=?F89G@3E^BYnj6`mwz&xN=$tFJL}D)+EMk4 z>E3VDOD95}CEVg4BE6)E>tT%Z;#sQV%-1Nm)*!mxXx*OYDx!-sw=QBLi!;AgmZXJA ztX}?lI#|QQi%z)6GzceW<;BbXPCUC^2Y#$yVe+qKb&e2pHGbpMWWG@PZTZ}5l&%k2 zSNV-L^UvtzwX+p89pr@kAg<5I?m2^ zdioO=)C%+T9V)eAl5U`M;WGhZm}3UItmelV%m@?C-pd*uua}|vHe2P*+9;^7afZN+ z_g-KG9ZAH&ru|XmuX6UkP+Ge6ra_c0HraGYjv#yWu{nHpMcTm+5e0}@I5Ew0-$3Q9 z$A!b+REmo;*$g(6>8PXb(a^1ivdn?R*t6kR1-&Tk2( zJ+_P{uTZ*Y(YggUs1yUJ(}P_0kssE|(LEK|Jo+@ZI-f2)hROP=;fjshoAro!lRAzU zAIw%cDGfR~dEUIyr(iUE?5Sya^_?kv214TXN9%s#@k;tgr?fmc@@kwy@~qCvhuNgH zP~J-q6lX;4LawK<{$m^fcAZOk+vP#mCB__^m#o1ts7J% z^>gGK-bw1Cg{P#2X6;H2yY#!h^LV(xvfO-dLNZmzrkEkF)rNy=VUMp%#Ep@F25uai z3nNPG{DBW1#;HfrgCHXnE0>>2&Cq0_JGPKl_gM0bsl zk-j{imS=U@CN;S}=^T#8R7O(wnBhfdSE`Md1bct%1wu$WoJT|fVqz~d^LHybx%+(@ zejD#H$8=@j?vc(|RrIGyi*T)4P7Z$c>Wr^Rnujx<^a3-`T>w2hj~e>ni)FdB1+>ctEtxW4{Vc(*VD`Tyek0 z@JEV+p-Yj(0gkhG7p_enyinfx$kKx-C(q?xd%}# zIg`jN-fYh9wgN##ewvcN`IwhyO%4pcIc=bEM(nG3#gGQ0Tf+hBoOe75uTOW?rN(6m znGkBxgj4euqW8@ZwC-qlhV}y0A@l0+xALjw^L$s*?rSc@u}-;DE7{DczR0OvIhZnD zChr)8bDP1ZlJQDWqN53hUJj3wm6bRmLQ)PDZzx(?rLnKcM>zf~BQx29F7z&#CV-!Qc9 zn!Zi!i?8yOJ(<1voT?9;iht?h3CX`}cP9!mPgp&{T@X^it+<<*d-+(_gBV4VI(_m5 zeLmJhOgVR!4=!oll11rWK0}tk@Zv@PyS-+13MW^4#;xV^rL#DSrc&Z? zZtlHY|HV%vyyxovS7VZm#A}VFri)&#u8nUZI*OerP`VetFd~MQf6EP?{*118+#h_=o|X{ z0N-&ShOrKzkzsxFK*5)yLIL@5|Zt3A35`56_9y^~fg~RB`MZIR5UQ z``$yEvWc@1^ZM!mS#)7&)J$x$&xJ$ID#a>nPnQv~CYi?##!!M|_kfEWh)HGGfh|X;&0^I@JC6UpXWR9v~N2emt`1 zQ$&B(jL7q0ADt{uT%$0ti}A!`oexrb%~Rkv0Hht@w>ZQwhqzxoe;O-6%G7{6+oNm?Ug0|_;M+-@$w@IX=MCo2e>mJ*SC)>Vu`O}hn8i{4+E=FEQ>eusE*Zm~* zdU@(Z^e3kW|t~O>M_&0`&~R)%Cp~^f#b_8W38&hnVdW*-59j4&wSmR-N|nY zABk0{vc0Fv5ofvL9CKArGC$07VMs;_ zLtu`>FOSl_g4Qh&d|?zJ>8>}+;|%XUda?E-F-kWUt$VpBLtj^F!iVA{E$^#*<%{-yPc%Cz zjZPihO*np~o$)4Xs}WsV&u7+dnmeLYiSF&Sx_p?-vJbqkGj8$LKemBqJ*3~_(7Lx1 zj?Sb!bGIo7Y+|E6O;doQ${|Ei7D&@J8)fwSg@<|=V{}G_tQjLWyE}touO*#XjDKUp z&+alzqR2Sy^clGKAi7u4x=dc(#EhR}TaUWVkqW+Kx4%8p8k81njhQoYCab)erGCZf zc8cp%&Fz7g*`K@b_gHD#b$|BIN1SSk_M|+NE__x-3?pQL?{IUUn%a@I*!%Sz zF{L*;v>cph6_h7r${S|yxT+V}JDm7r?V_XkYnoigoJ71-W{C1|zk^##zZCiLndE$Avg6lE0=5YJZrP?l^kW$>%<) z-|1z+LG2Br8{+$&XG-#;=oi`Mj8MAQ(Yh|9zrWyGD1&HCiaaZ^owdQV~mVUn? z=AqKT!-mpLMC*!9OX`JZn%XwcyuGUYRO%J0ziX4?Na2n&^$`UhS6XV)(g!bnT zQnSoTRXcK-z07&Yt|_ycEcjDLSQsZdsPenqc~7Dh{r#l;`{Zx~%a($p)f-<*ez0 zx?c7Mb@0dC*Ya2Mu=96!Etk$&z0~`zw3r&DdjqZ88o+<gPXq zNPo0DXgea1J(uHR=#4yGus#QppiY`iL?rt?+&cZ1yzgXSsIydHxW^Q7)$c7n+yqIqlsoo zl`El?N=By{j6EHYh>!uGU-@mzf?(mp}My0 zx;jcX9j)st<;SaAqA@xJP`V;;mp@~Ej zWxcb6YkO{a@}8t}#R+1+^<@1@{NB^yb;qpBzh!F9@E9B`|5-ze(#=5Y9uP}mXfHT? zUcO^*KyAhn@3@c@^$H%HPUY`6&qeRn*dB@v4b!LI|Ng1fp1|AIa{6qcHYVX+boi(5 zG3UIc5r)sMNc-MK>)wx+;r{*DN7gC+q1yXOA4lWEFUD?;e;ruvd;Xne<_eRC(+RfS zSDkAbd}Pas<(;T*1pAn-Jdpa#PWnCTii;6^7l-KHLF>A5TDHf>^lR)fxH!+w$?WAsvDtB>FBDNu6F&r@quXD_-a@>)As$?#U1AW`rm@|^owQ~GBPp>*M# zMhvrbN2pPsk}0L-zNkd=mn%uX+dTKV&L~Jq9H!tnAQnWXBNTkdv1X}U&HJRUllSFG zyXKL)@@J<#aEW9mjd}7sfDjUI79t7|!)GgDVrenWHMl7I#iwe$>k$VVncBfiTDNr< zibsOArMD9EI(1YchS0IS8#vFb(vHw zU&*%C&K`cBb;Q0h>7$KJ_esPz{+?*XUkWc8p^agL1!Jvh(y9bP^+-O?AB@0`rd!v2P* z!+PRA9cR;%cjVs3%chUH>*Z?=jp>e};>|(pUK|jMxOcNNI8Kev!~N0%k!7SqKD|Eo zi;r!Mt>Fi%UIzpTxIc*vWDcaP^ncoJ;+(*Ix#yTKL%009u23HlHuU?FT(s_&qCrZ0 zVv`Gj~P zh$ukJp02vR`!FU>HTKpYR;>-IN#9IGCLT9xkd80ly4R9Y&R*9iNPV};uH>Odj9KRx zV}tGyag#G+BFBAluW3!kqUZ4gv@Yk#1%IFCah6B)SR=ZpkM0d@A~nV2F{Ul85!Dl1 zFY}i-if7V)>oAD(>jkIOYKpR%PmC*{pb(z*H5P;W)YN*Yc=OS^?wz?SwK`qThe-K9 zMY`Q#m+=ZZ(pZ^GmDEUrx5kynWxS6}s;96j$>{f0({LHrAI$OViPStc&EFC_g2Dgx z>;+1<0Ii!hC$n!xL-$ODK@i!5a0`Q3_ZH;&oj2ceFJIzNzr#LC*J#z9F-D0;cBQT|QIQTHbZieUS+y&}~DftQ?y`ABVGLa504c>cc z78gHz`Z%rpLPn9AD&4~r|9SNJtOOASh`Dnn_!Qk4<93Scd$>Q_V;Bf?GY`4G(Ixwq zJM2Q2_J6ha9Z*edQM&;_u{Xqi!Hy+#6$^^JUOOr_3?V=uB$y&#uUEZx?Dg8aTzl_b z?7bK41$*~e-nY-pWF`oS`qul`zuqFQkC{39?C8sy*w2BTn`yA+>kCly}t2W$M0Jk`9Lj*9!HU@@c#G{&kzn-miVj zectsgZQGaLcKwU8tbvm*C$GQr`Ag z4!=3Hx&Nt~6H1w;wLV|Bo%_1VBgdCbd7e+#y?wS&$8PLH`6=tq@ z@BdN4yH(2DrTN9BXC~fWe9JxD*MIAzEvnE9jfM}*S^dSyNRff-dti1Ml{-TvvVuy}8v&1)>!A-)uP0BmSXV$AFEpy-gzH!Q`x8HWHtl!@^ zd&z05T6Q{ccee7wvMJ5ZExF;7y?EAk=Ufzcwc%_>v7g`3Bl9zz4>||Ve$9MUk}80 zN!qYx_v6!}N{p@NP}gB|kuFD$NqBcid0*dKu9{iGZgM@@YX`Tp%In(#TuUw36x{8^ ziR}gc=o~uou2=gCZ%Q4{b!c*lKSwS9yy0Hmms^iJ-JUqPNx5eiKa@(A@a~lIX5FUi zciQ2`CC`;xRksRhXZa_Oom^wXSWW)=IsP@dC!Q$Wu1AgLHx5o&8MOT2*Ckv1$L4!8 zTst*9?`Cc5xMM3?&>D$Q-*!oP_r<;sYrXhWnSI}$6gd0tX2G-X{%h$Gnf&*ZFJEN` z-EZyF9N929xKy{2CEF%>Y?4o_diC|wi&;O6>v3nVQ_p=9iWimelCOoI!^CY}nw1*$ zXGEYfaeUC-JQa;A>sw zOsi&xza_8g^0Cd$k6!K_+Me&D+;O^jg8>gU(~BIB`b!TE!4G?-ye-DNoS3rx#f}ue zzaKu&)oSvvvG&V$hIu{@3_fGpJn|10g;So%D`wg>FMI!K!o$xk^mR~0;I@>dJDiECZ1 z$Lczd*x&V}W^O~b=$yu99!Kvxo|`l;tZK-HBiUxGI@xB?o|2(mN)#KV{HI0suVG~i zOL%F{CHx#Vot!%Q*}|KCWmb5+-9MpR^*smYHe8eQZlziIeT{)Rvqeo)4UY?X|1Nv= z+qKt@@;f}JYvI=YTRYYYUUmI~Yh>*BP!I|JJt&ak=#Xb;YQIITpA5S`_Uot_&4!oz zFvaKHUehD*Y)z*$m^SN5cjK0J9h@9?_?MVrYU2~M+q>KK55@e?4XGO@k1pD3eob0? z5qJ+td57KG@aAfTSB169FQ)9w6MSopUw-%0m33CkDeO96zw@o}2`=|;EU&oh*_LM4 z&g$Hr+U2TOA!qJ+VZ%B_pp@r@dM4h?bW-SUa-cr{GI%-_MRnIG;ch5 zP*972Ls83yJx+bDYh}8OC2x~gn?Hs;8ZxVX<7#z!f1h5*C3NJzCfU5INO+G(dBgVR zS3Iq`sP>%Xlm)#HZ?C!c)y8$Tf;&wvFy?lXkF{3c@NQRedbO@s8n#Zpe57crs_R~8 zoA!U)BB7Im@687@&o>T{@E(=&j;SuM@VZdFO_3EUy2tlU=`m@sU$MWc9xq&WLFCY} z!|uhNYVT06+2wsDFV7zrkY#Foj|Q9W$JCiq;=w|ISbD-F?yeT5~(Z{;_0mmXg<(Trc=|YU|1uI<5JB@^C}Vl?#uT z7H#)5Y^1U9&YJI$SECDF?zpFHgMFV;<{j8S_w@7vt-4m~ z-^a6I*1Rn~-)c0<>tmPWS-jPy!v`eIX__;1+2<}>K8Kgw@p7K>F0IAc;l1X3IG&X9 zo^QJU$<4toEh-jUbY}VBDa~@#h#w`-b7=X}Y=8aNZT{CB;lo1`zP(JYH1trnD(*+` zEh{_ns82{xWR6ZRyS&>q<2<+i%kk3KNBB7uSexyITUh7O#*2$u`Bu*LcygsvhnFj# z4c+LtVfDx4n1v5s&KhQ#qL0sGm^Z(`jc227t?i&}^}+k%%Q){E?(g3B0ujBpNcPfP zL-;u;N^M(|(sFU1q@rK%+8XKY>j0wVGQjeE`rq&PaPJJ_uJ$<_Anf-A+Yy}xl!_c=A@ zl)qI)AHS^bC6}Pix@T9nzNi{n=uQ2psWo>uXkPsNxvP7Z-u(2q(unnEXSgQKj*;-5 zmGVwhZfoW2;G@kG@OkmD;Et>OLfyJ{X&3T6ra;I7<%oiV0v#8Ajk%m{Os!&vZd7a= z`FGvRUqcNCdz|z7(0Ou9wS8R}FZcb2b5h>a&dw15!xkNJG}aGTlV^vvS4vW!{aJgi z>6Kb>R??R9`VEJ}n$~Jt!X@OtB8&c76VPnN`jBF)I=AnUXn1nly=y0X#>?%8IWOg{ zADJ&qm2_cDK+D>L>RvP~YS%ouckcM7FTG~WJRl1hbb?x@U!R_z8-1KMtjD44=S%dP*Ce(6<*WJ%9t9G!t0Mh& zz4Zo>zv{oQ|F}cIb!OH5z{HyGqt&|E&$~ z#{%15a!grUd-dC+lM|QNm2X(#anTx6VwxTr!g#s%;kuMJ_vkUBs}^bF;@YBqwqjmS z{lB&?Rw*j@P1XW$8dezC@5Hrmrv;bPEzbQNx$N*X-QnTy9`tN}@5GWfPA=`TjKAnK znOlG0+Or!{-nRAb*e5htv2*&DZMt>&8Vzrpt4p)qUuJyM%FjRXNs9VfDR|S~immq^ ziO+xcZoNZ^gF^?c?ph>b#>x=aj*n}Pp24l#bN132o$zzeKdD#$YZbrltt!n6IlMMY z=L4%MJ48D+4jJ2fP3zG$hb`_S+qQjaL*FjlqQC8Vpjnu+#)8wEb59uZ;=j~e(X$?Y zZ44rzUB4xe;^?5ran^o=r~aE`=+RmYZgk!~I%)gFe#2&uYt+f}R;@BlYZr|f`RYm$ zWzTKxJ$HU+diKBF{SQrl9IR|Iyh*V8tz+8ujF)S7ZcBMft7^?G*Ybf zZ~xO*ReB^g)+&zG8Co%U@`YV3?N6`Y?lqxdsKeH*Z_gVmw~6~6J>_KA%L^T!&J5Zy zg7I?gZ;F(6M}@%VODasAxqH1`W!JS0p7c3*s)?`5*)5Ykjvf+F_fznUj{ZyI+u!c< zX4a=lUv~${C)NAMlx5qQ4a>{y@@>CAATQ(PzB6)1%IoT~y61ow13wjh-)H~l375Ba z|EtWIDKG0qK0cg0aamx(f#+fCU;SI^)dhuX`OE72cQplDZ+KVs(1Zm!##K6X_Tkkq z-rhkt-j(w9J9e%4=o$GOCO;2v@~U+9rdb-ynzUk_Kh_$$wp$gOaC30o?MWq_SKYcf zXr)u{PhDJIeJQwP?mEqI_nc>G8knt@?Q=a_kVG8MaJWK z@u1~6=H|mF9+A96SWbk|dD2(^7DOM)a;R3!Jlr~Q0^{;t=e5zGwb!rrtX~-1J zn+8#s$`EQ&Yr4E>BJwWY-1KRI`XhW15wMUfUf97r}U4>Go z*Wx&(IM=uQ&!n803i&?XjqBTo;D~weAO!tC|2gm}2uHf4a{;`Vec$FmX|7BNWs>4J z@o|NC|J#q`=Ln51lB7sGkm1 z>tbjzV`;trKgXgN;%ELcJ&@^vOb=vwAkzbx9?0}SrUx=Tkm-R;4`g~E(*v0v$n-#_ z2Qod7>48iSWO^Xe1DPJk^gyNuGCh##flLo%dLYvSnI6dWK&A&WJ&@^vOb=vwAkzbx z9?0}SrUx=Tkm&&{9w>5$6E@^u=FU;upjUdRwFaX?qw&z_l+od8jmo2gUZtwz=HumN zQ1?;k!mGIXxhXX22(2z0FJIH|+js6q=ky&B+RK}bF7OksX%92r%VskACJ4#10Hyhj zzx4eEI;FkeV*!fKedkRkbHq7)n}WjVy9pF8DK)eqDibwZF@32$+M*xN4 zooCrmfWjUF6c$Uw_!S{V{BqPb`TEp>J2P-B>5#pYF8PK0K=)1dQ2ON%p*&Cla0e;^ zm4M1X6~GN}1&RX2fZ{+2pd|1IK;L4X0n7wu0kZ-6&M$q(@gHCwFdtX|ECdz-ivjW< z-51>>eQSWeOOqcc0N_1M8GWy(5a0sPx2=i*MS)@fUZs?k07?Rs_l1F+KrSFRkO#;M zcwoB+x)%3I3IC%{u66`(AovQZVN22=<9ff_(fpcYUY2mtB; zb%8*j9zfr|SOKgARspMlB;a3Q4M4BD;xh*_6VMxo1LA=MU?4CE&;kR1NQh+PKHDD948Q21B1-1ce zfpx%oU<5E2s1Gy*6hJ7T1fqa&;2kgxm%eYc53m#14r~CzfcL;x;6Gq5 zupc-G>;k?4=Yb2rao`+q5;z6q21WsY1EYblz&Kz$FaaoICzB=OI1#uE>;nz}hk#?i z2_P9b4IBoJ07n4|BRL(LKExmVzC7iQw(2zb@hWf;AiF6I%EK7I9)L+Q4d4qe0=};O1FYy!soPn%>Bk+Tg zB!J`vfdW8&ARmwy$OGgCasfGk96)x!3CIQ%2IxKt0iJ*dAP1@dm4Qk?MZg`X0F(#H z0cC+QKxv>9;0Cw?e*h(c5 zPNyJjGLQho0|r13^a6SVaexsp@z;}Z90c?S`T~7`e*F0W90vkJfWg3c;4fe-Fbo(2 z367j_U?MPqzb4<2kER0+fvLbW{(L5mbAj2wEMN|> z0GJO5_r4wHTY+W3QeX+N7}x@=1O5dlY&ozJSOKg8Rs%`E8elE35m*mw07!Qeuo>6} zkc|g`{lGqe@^>$=8`uTx1oi-wx5)sdL+Ks?i2pEf2yg@_{i6Vd(fM(p2yhNK3!DK? z1E+wKzy;tEa2~h}TmdNTE^r4(0d51gfSbS#;5y)yia+@6%VEckIcj(Hsn*@(k3nHI z^Vr2Z&7cr5^Pos9n5|jXYk&D9Cp&MCsvf>vDAmqErANk%ewBaEGAFwpUJ!Y6bv*|p z$yqDzY~eNdEhOF^ka4vuCnOU+yNoTrF`$N%oe!9@BP7(MWj5^@d~^AUo3+mKIzH88 zMgx7*2R&VK^53hnm;VTfKiHty7@?HTKjj8hsXSa23JFXj9a)SvIj`pxtt zZyiXgc~tlC_LC_i6>1WN3>A%3tzD?)-Mc421`8fP_5i#pQA?NTzOTvCygdfe%dLOD>I7 z7$a5C^BB6lY;ft@g(30wz&~y@L*6lrYWi)%;)G;989^PleB-q&4qPSlbDV#>HNpr_HnFByz|kxT9Ei~xouQy6Jm8bO%d6x*F!_2 z{UP!4@F%|s-)(YtQ0Hrs{c}7dxEo>==|o8&&$emRW&dIQ+zyD6R*=x0 z20AUMy!vCE)}loC0@c3w+uM(|{Av;t_3^H{_@C~s|)bKR7fa)vbH$<&#J30`ihcykWe}3na{)2_E^ocVmeWV zFkKANS~>XPrim9Ls)~|~%V@?W@psBj#(64y6)InufCh2d-fU*&z`F*jW30|#R2mGj zZiWBTTF%{{ug|huYJ%c$qWikr`^N)f9IbV z887M>j0qYO`0CD8_~xlIe2+w8icsjGw)KSa{BFl1NutE4(i>EIjJ$_*`M$J_T|J~z z6?dBP{h-9JgKfoO+jeJ{0^P^Y7~){(=TUpb~JoDn5q zkd%hb=<#1?Z!VMni75GtPv=3sa!&6WG&~?m7D3_$o$3`<`}_QNy0IuZ07+3u>Sk*j zt{-_cOqAS!q$DII`?R*Z-|xa8QSuoQ@Og=CO{$ez zCTi@=k)mW4&$jpe#AO8wH~An+R`WVX-Vbu^wH(3-+rXKKoz`NBx_HS;WB>L3wsD^el z9ug{}`v$g3(cRkKgOzJ98t-UyrdS#UtDCR8Qp@q}rkRuuRM5a};w5!@*zY+1 z!s!;VapQwnxkeqMHpL15D8QJ{%uoWWGq%8>j!_BbL`lR*L?)|;&WG5-oLA-C)Ux3> zCSi4M7$j77HndAjdZg21q>5gKMU)eY{)>zs%<8ChJN<<@4OG* z+?TVO&1HI`o27ElW`JhL^|k9)!D=)Hl-tpepfMlh{_5rnL*bV+exs_5oHIc}HF)vV zxv7qBJ?lZj*Tx}`kasS&YP|I6_!K|p1C|S;AtCP^b9!99d8_2(kns64jhFQ9nNRSt_&HQ-)XP=58lyL-_lNi&QHk;p^iu<322G{kkzPf#1{y%=I8yR;AO`_643?5_M{q z;yjw;ai@}X=Z*Oc32*g647aHDFL`Nb*Xg&8jD!T^N3tNJ5xx)F5M8u7Orek1^LO{+ zbv?H+HZ~K_VC)auG8(P>q&Gk1bDO>~7m9i^?sCt8CAHsa?(7ZcpzuWL5|lcvO!g*c z?_qAvpAz}|K{{)3Ka@YMKkeVR!y%Mff4Uz?4nRUBB=uwHjgW#)RCa`3hX0PQ#jJo; z;p@<$GI}p{Td_TEU(eXvo#t5#CZ%3sP{}qOjLkXg&q8`;fe+axeBrOs%%lm6`e^z> z!cQq*K$lAI@NP$X4sMy_3C#+SUHE;31kKf;%o;4r40+Q+;z9@`8%w-^$*tB|C8EzyrtI*~r#fI;Qh6ON;T9@6Bu=0}$K-(MBhqL}{yYs_ebv8AC#0TpXC_Axg zy#n7_mJNLVG@*8Lmw)(laJN^$Mq{xjZIyl7jCLOY33A7y238o$a&>O;`}nZ-c@ELY zfifFxD?kF!&2dflXb$Ej8^_x|Xmxb&dYj0;) zj?4dy(`j9vo7WdDP(ah6OkOH)d~FPYg#5OrSh=j*LweqZgvL8qVT$A>uJ(6&w0-_O z7LpoVd5ckN)v=iE8M033ubf^Js}a2rmsYSw<4CQ`@O<4gnqhXcnbq*Nx9kDW_VPgg z*x8qkpR>2SfDrP2#%!}Ia4kjf?&prPZ$5Kpwy_fb3KFW@o!XxNv-|6#DJ&i4(f;n7 zN9V3ceCkr@>~KipXd}yklDsOx)c(+<5fEE4Vvf5 zxsdQJYzFCoZ9--4enNYd4G7GcmsYZau`|dpazj_5ikJH17419fA(c_!C}jynLNhHy4H*iYxhFp z$F+P$y&qaeJktqJxjbXzFlrNdtD~V)06L2*-5hOdR z9J@n8lQYD(gIB38#FtQ?P8r$bH6(ngN>IdTC>_7gxpsD%vbG1)@ud=ycJ+(;1*+UN zu(B=JA{p7R&eg*6AGz6sB-B`W$!;JWDpe=%?Tnp1?j6mHcniYRdO7tCh64w$9h>qZ zlD7c4@QAm~yY8ZL{f6c*#w0%EYue+X$3WysyF*7WtCmDTQk5U6s`L>m=)GN1V77f? zIE|}l+zU2?Mq!{)&9gb#ohz!wp5)Vk4-R6im=Cs%4x7Ao$JL{pZOm^Mc**W6v#!<( zDncHmo))3^0lJ^Le{FBD>}#GS%mUU{#iVBee2TCALx*zvY0QCHogcP61|4cc;L%XM zLW#~yw#WH$)@}PAy7IQ+KB_^=+Nz$Z-#<@KyoZGP1>DbSNQf=q&7QT%`KprN_&WCn z5^DJzI{S1uk#)sENcei%2>l7MRq|~59sSPX>WO2j7A9%DjRfU8f)qH^t zrITY$%GF`n?)pMPIR^^{qZ}55V=`%oq3`Fr8M6>M5*FXTHE&kj{L8w>q8q0$=MD+JqQ|Q5pHs^l4bo(?raj2T&`9 zlK5j8g@o0TAM3&Z-sg#i#qlEB&`_TfS zO-#2ovKssZY}8(RIA)pIVTnt5uu*S@{7E}6$%i%(oeWBDWB@lNcfB`!%8AEr!47yb z1SQm}L6A7(khAM?(;{8tnWAJeB$yx$TKcX0y=+A?oI8R##E{7Bub7z zLiO};#JJ@T-xcx|CD$Oqq<_%2P1n|3-0*y>C@B@l)w%4t+J~OBow*&pMhjaFjnzU( zsAly|jW{u~z|+$7G>Nks8OPd0;aMo(U3Jx^>fZOQu(~fi!L_T;dGt)R_4Rk3eBDEo6orJmllRTEsjhWS z%@ZYFkWi1lb5+y2B|7>4BTAY<;sVM2PrlLj%4ESRwUAB-pH5x*a;K=Pf4mSSagfl8 z*|wRgB26Yo?H479kWkJAjSn1>)cj5vQIe0gncb7Af0C3|f%8t^~|jNQ+< z4Q?0S;^X&HTuu-3uX@}rKF_zbPp6xd=1NcUn`r?9_9ndOf@{kE57j3usko%5uM*eP zdmf50R`2aO^lI99Yje!UsHeOZ)OS&*m2O3Ya80x1!G(kJe0TP{slYYqAFL75zHaZD zm(o5rC;KVv$)nXB8g2F4jq`ZA!Bs^`3I!Opc0!1v?L8L?7+}zXzgPBVhl(5b3iMISod9NSiIT z$>S87Xl#y!{jt#zF^UMR7Qq4(msqt@r_^b5c*cioT8lP3sx=0pV5EVnum}|~(`uM! z?-+iK-K}3gw>kmvCjJSEp?X~$3aD^tQb#IcV-w_fN^EBP2`8~sc|UQtWp)*n7ox&{ z*kQxdfQetdqs5wQ_|%rkYD2~h?`nR;kw%;MNc<1};Ajz^ zF)ImwWaKPninv=VnU=;9OFc0!EyKmE{T*gln;tQOe}~u7MIy0f`0p@_xgxTPVZX!3 zc~MdhMB*Przr&xV6pHL=1i!=08Hh?N)&Y?}9pUe!k+vF&38a<$4!hY%s!pgCB70iN z|1EnuC7iW(JKL5}Nve&Pr=0j!4K5^YDb}dXX-5k=(Wy52aOG zxJY2(PULK3jKIK8zN{F+$ACV6hA|o23_}!wf>fc7m&e8`(V>__#I7~HuykTlcO+;_ zb1iM4G+sE~a0)dD9k`$^gi2$Y>ztX+93n}V3!{EDO*D;8r;Yd_VvIW0P|Z)JNfX)9 z6C5Ys3a5!_@U7t$pC(LdHJ*>s?MZ`lu_|raFoQ{}Gg!ouR8%v)*ea(90=<$Xw2uodQ*}-0gdG9SBb>@29J30 zt2A7ZL+*gZeExeRtc03r*wyb5@fE;KB@9b`F~7LmVKvN5#jbwODxn6OxrBhtVq~q#||At#$P%2dWa2b^P&wc{y>o}0*Q-M zVe0U3xk1&-ge51es9`BerDAJVDt)Y8Wi%$p!*zN*eX!C$TEs&N7T0p@Dy7F+G;oUo zy{ADLsftk;6k3BC3tc!-*a-?&;Z%;Tp!7_@dKO6Np)0wPvuBbvv@I-!K5sMK z3wFq|doifBN{vFT_oPL}P+h#0n+QxB7mU0XiXiP?wP6n12MHy1WUE%yNh3mKl!u$N zO1V}Mqq35|MLf`0T!YT`#K59hfWhJ#gL~RCL>bJj#&S|C23f=t>1c{l)rKo9iz{?3 z10*?QEq#6&m0KMJ33nn^3M;z&o?$5QXDCp#R*KtC&?${NIck#0T5d>Ufkbj8PP42e zFVtoOzt9T`;q<4>mo7jrI&JfFZKzO~yBW6`aMS4e{1eY1W$)Lr4( z1~mCI+z7v9ZY51&n>N&hQ>2Ecg*H-?+#K_R`BsrC-#S=HHI1jhkS2uLZmZ2t=Ya{B z(g|h7fpy~ec8M}N6tH5PIS$Co=cp{Un@xWAIO%cw$XR1+>o%y&(wmM@6HbvDb$Zq_ zoFcOaN4z3CM~bvv!n&r#^CxzflIKxyJvH!Ppw%DtOv{S1m>d+`voAbGvt4xf_e5E` z?2S=$DEx@QNk#Zq(Roz))mIEGlB+ODQV#I)g!Oh*iXC zX*58iK1EEVDMq1{qp0GEwgFEbxlp!sia*CwQ+i+srx+u-cyd*|+Q^lka5ePgT2&n8 zeAYU^bYjE6bVAv{!j^+1W)KTAo*BiOEnC|B-X3W3XBboSy}6Yv6!!2yO*myuvaQsl z?t`xM@~4KSHHp^d=UCI*E+jCKvk*{c>F?0K+wZ6z5N9|^D{ zbEvJRn!U0C4R-vgEJ$M~bkl^0EP?=g9aPq)B^L1{giP+1XM2z#Zj6AY zc!4~nCXMfDge@^v9M7g3+=dWte8lYzLAjDX*H>!P7;A+qOd2D$7tl@`w)ucP^CubQ zvGsiiqytNtD%&v6Y&2=ZG}u3Zsk2(I5+2)Vbc!$(CT+Mn0vl9xn%*jTxLy}S{kNAq zRAp3nc!|$t*jzhWtT)&MXVa_m=T*$jXG=nkC}ulq{%xG zqHp0hp-`vI@BZNr?1m-5?AnT#c{R`r1n@53&q*f=5h^V`q>81j7+h^q>8UF)$WgK2 z6OAbb--{3|Np;LlhCTFpi;9McC1 zF?~?S_<;#_WXfZauc*Mf&?pS!iVaRy-<+MK{B}vqCz^Hh#2LC%}zu zRClZGX6-QvuPb4pl5cCKBe5Quk}IUokM*orZ*jxWx434#uC4TcC>3D&A&eDawr<91 zs>%>UEwYVmMzm)gWOR`8FEUZqVhKwXq1U0tqRgo^VNn?I8)8+8XnMbfZLMXSvAt;T z6MGrZhn-Pod$E?ypfu_A309mUiG}nfSGWy&$A_%ID?+$n%m~6ijou{3I$or;(UR~6 z5Lks%)_d7nQ8aUtZ-sQoCo~^}F;?!y>=Zst<{&w}GQesV+jESjDVA2%bXqG!X<~vd zO$h6>m~TQA8U+?0!_b0Yqq8+mi-<&N5de4Fo|l=kAL{0F*g_kZ;hI3TL7`9@JkdFr z)Pa~8U>_oz2H@RCYm1d>qk`S6My-==&s(Gnb!Gt@>hQBw+BYbVQ->KNF?g&=V`kwx z5L@Z7lqU_6;~70Stfrh26k^dF8`OcUn0t$2iX5lMDvuD?d=bdKj$po~m{u~#91r%J z&smYRRqjM%pekOlAvr4~WEwhL>%$r`5?I6wHrTY)Fj1m{LwOs7OEhd$Ku|nXF}f(; z3=D?DO&Sf$5VkxfkJX`jv*Mi$G>}*ZlAjugNlXHhrShf};nTbe)8dOZ2tv6xjf(KReIh`TWUUA-bf z8b||qwuy_z$5wowp$<~E;9zNEn>KY=l7)9+)?w1Ce=-$`2GWpR{gj8LX`62xJmzy& zUu{i@#W@kFiW}af^Cr5}xJZRDE<$e7TN_@Bkw7M1h*eml3&U%N9tNG>7@82L3RQ<` z__mD(G*&yeA0kr{KLnzL*&c<^JEPF10~@v2suRNdqRSsWqH*CdYIWI`+Lbxn#;L`c0$OaI9L&~3&3q0E`Bj`iT3Nw&F!92L2l_3e^qSs^VY4)h zknsUNw(MbR=r2a1Tcd>%Ze~K2jXg-DEvvRj%yGbBKL4qD#Jy_?HSUDv1Z&su*?Wy# zk5xo#^EfdQIm@iU2F9!grgmo_pvsPTqkvIxo0~txx%=+LkZ8-!3N+^{`)D$1? z!KyTlL5T${wY4=k_G&fJpgQ-W4$t;8H~yV#DDh{k53tpQrDGOnJ#Qnse^wW`$254K zOrx^aS4yLiE$rbAr^TGXngF(?LC$I%hM(4+m8OXa#xx;})Yc-M#a*J|;BOIUxWAv- zBf@>W0BXW_3|M7l<$^8E(895m!ex#F2J<=Vn{2g+lBONHk}H-mwzMrD)|uaMvtlVX zL9ux9hIG>jWsb9zzU1i{u}Ge!(KL|l46$O%kI&M6rXdg>pdmrw^rw6!eRu|4=_Si4 zTa5r(8Mp~gJ)vwqXI`?UY4HpT+7{P8WxMzo3+m#yFlj=|98;?+;<1{+Vek_vr-?2w!2qZQ0(`fH#sQPlqUZivY<$mmV15RdDvm z$VwiuQL+#Zd=}SiMs8~_6)fQFU_A{!8$dHh9X@|dw#kLf!wT$E!Ye0f!?73 z!+zB=$tH2Z?}hxql&I1$8?6)wa~xio#h2s`&mL#3Ei=afN1Op`nCMk) zHLASMkIu6>zRd7T3rJn~=mJ_B>e-PCXj9Ry>a6ZQw)~U>If4}61isHQ%jsFX`3cJay*AfdDo#>ojBc?Wyf9Y4G z6#{>klsP6HL(LiZ%Qjk&k$JyNCA2d1bp@VH8uZ(QFvgPZx2%)A2FbHYLVn#gbDgjt Ov#^YPTjqb^pZ^08ayWMY literal 0 HcmV?d00001 diff --git a/typescript/environment.d.ts b/typescript/environment.d.ts new file mode 100644 index 0000000..b34b4ae --- /dev/null +++ b/typescript/environment.d.ts @@ -0,0 +1,17 @@ +interface EnvironmentVariables { + readonly NODE_ENV: 'development' | 'production' | 'test' + readonly MESC_MODE: string + readonly MESC_PATH: string + readonly MESC_ENV: string + readonly MESC_ENDPOINT_METADATA: string + readonly MESC_GLOBAL_METADATA: string + readonly MESC_ENDPOINTS: string + readonly MESC_NETWORK_NAMES: string + readonly MESC_DEFAULT_ENDPOINT: string + readonly MESC_NETWORK_DEFAULTS: string + readonly MESC_PROFILES: string +} + +declare namespace NodeJS { + interface ProcessEnv extends EnvironmentVariables {} +} diff --git a/typescript/package.json b/typescript/package.json new file mode 100644 index 0000000..8607825 --- /dev/null +++ b/typescript/package.json @@ -0,0 +1,48 @@ +{ + "name": "@mesc/core", + "version": "0.0.0", + "description": "MESC is a specification for how crypto tools configure their RPC endpoints.", + "readme": "github:paradigmxyz/mesc#readme", + "type": "module", + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist", + "package.json" + ], + "scripts": { + "build": "tsup --config=tsup.config.ts", + "lint": "bunx @biomejs/biome lint . --apply", + "format": "bunx @biomejs/biome format . --write", + "typecheck": "tsc --project tsconfig.json --noEmit", + "test": "vitest --run" + }, + "dependencies": { + "valibot": "^0.28.1" + }, + "devDependencies": { + "@biomejs/biome": "1.5.3", + "@total-typescript/ts-reset": "^0.5.1", + "@types/bun": "^1.0.5", + "@types/node": "^20.11.17", + "bun": "^1.0.26", + "tsup": "^8.0.2", + "typescript": "^5.3.3", + "vitest": "^1.2.2" + }, + "repository": { + "type": "git", + "url": "https://github.com/paradigmxyz/mesc", + "directory": "typescript" + }, + "license": "MIT", + "sideEffects": false +} diff --git a/typescript/reset.d.ts b/typescript/reset.d.ts new file mode 100644 index 0000000..cede83f --- /dev/null +++ b/typescript/reset.d.ts @@ -0,0 +1,2 @@ +/* https://github.com/total-typescript/ts-reset */ +import '@total-typescript/ts-reset' diff --git a/typescript/scripts/.gitkeep b/typescript/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/typescript/src/errors.ts b/typescript/src/errors.ts new file mode 100644 index 0000000..a0cfa62 --- /dev/null +++ b/typescript/src/errors.ts @@ -0,0 +1,17 @@ +export class MescDisabledError extends Error { + constructor(public message = 'MESCs are disabled') { + super(message) + } +} + +export class MissingEndpointError extends Error { + constructor(public message = 'Missing endpoint') { + super(message) + } +} + +export class InvalidOverrideError extends Error { + constructor(public message = 'Invalid override') { + super(message) + } +} diff --git a/typescript/src/index.ts b/typescript/src/index.ts new file mode 100644 index 0000000..c59eeae --- /dev/null +++ b/typescript/src/index.ts @@ -0,0 +1,42 @@ +export * from '#/types.ts' +import { getRpcConfig } from '#/transform.ts' +import type { Endpoint, Maybe } from '#/types.ts' +import type { ChainId } from '#/schemas/rpc-config.ts' + +/** + * @see https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#reference-implementation + */ + +interface MESC { + getDefaultEndpoint(args?: { profile: string }): Maybe + getEndpointByName({ name }: { name: string }): Endpoint + getEndpointByQuery({ query, profile }: { query: string; profile?: string }): Maybe + getEndpointByNetwork({ + chainId, + profile + }: { chainId: ChainId; profile?: string }): Maybe + findEndpoins(): Endpoint[] +} + +export const mescConfiguration = getRpcConfig(process.env) + +export const mesc = { + getDefaultEndpoint: args => { + throw new Error('Method not implemented.') + }, + + getEndpointByName: args => { + throw new Error('Method not implemented.') + }, + + getEndpointByQuery: args => { + throw new Error('Method not implemented.') + }, + + getEndpointByNetwork: args => { + throw new Error('Method not implemented.') + }, + findEndpoins: () => { + throw new Error('Method not implemented.') + } +} satisfies MESC diff --git a/typescript/src/networks.ts b/typescript/src/networks.ts new file mode 100644 index 0000000..6d4f164 --- /dev/null +++ b/typescript/src/networks.ts @@ -0,0 +1,30 @@ +import type { ChainId } from '#/schemas/rpc-config.ts' +import type { NetworkName, RpcConfig } from '#/types.ts' + +export const knownNetworks = { + ethereum: '1', + goerli: '5', + optimism: '10', + polygon: '137', + holesky: '17000', + arbitrum: '42161' +} satisfies Record + +export function networkNameToChainId({ + networkName, + config +}: { + networkName: string + config?: RpcConfig +}) { + networkName = networkName.toLowerCase() + if (!stringIsNetworkName(networkName)) { + throw new Error(`Unknown network name: ${networkName}`) + } + if (!config) return knownNetworks[networkName] + return config['network_names'][networkName] +} + +function stringIsNetworkName(input: string): input is NetworkName { + return input in knownNetworks +} diff --git a/typescript/src/parsers.ts b/typescript/src/parsers.ts new file mode 100644 index 0000000..2190b3c --- /dev/null +++ b/typescript/src/parsers.ts @@ -0,0 +1,110 @@ +import fs from 'node:fs' +import * as v from 'valibot' +import { raise, removeUndefined } from '#/utilities.ts' +import { rpcConfigSchema } from '#/schemas/rpc-config.ts' +import type { RawMESCConfig } from '#/schemas/mesc-config' + +/** @see https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md#environment-setup */ +export function parseMescVariables({ + MESC_MODE, + MESC_PATH, + MESC_ENV +}: Pick) { + if (MESC_MODE.length > 0 && !['PATH', 'ENV'].includes(MESC_MODE)) { + raise('MESC_MODE must be set to PATH or ENV') + } + + if (MESC_MODE === 'PATH') { + const mescFileExists = fs.existsSync(MESC_PATH) + if (!mescFileExists) raise('MESC_MODE is set to PATH but file set in MESC_PATH does not exist') + const rawRpcConfig = fs.readFileSync(MESC_PATH, { encoding: 'utf-8' }) + return v.safeParse(rpcConfigSchema, JSON.parse(rawRpcConfig), { + abortEarly: false, + abortPipeEarly: false + }) + } + if (MESC_MODE === 'ENV') { + const rawRpcConfig = MESC_ENV?.length + ? MESC_ENV + : raise('MESC_MODE is set to ENV but MESC_ENV is not set or empty') + return v.safeParse(rpcConfigSchema, JSON.parse(rawRpcConfig), { + abortEarly: false, + abortPipeEarly: false + }) + } + raise('MESC_MODE is not enabled') +} + +/** + * parse space-separated items of .[.into a mapping + * Example: "foundry.default_endpoint=local_goerli foundry.network_defaults.5=alchemy_optimism" + * returns { + * foundry: { + * default_endpoint: "local_goerli", + * network_defaults: { + * 5: "alchemy_optimism" + * } + * } + * } + */ +export function parseSpaceSeparatedProfiles(input?: string) { + if (!input) return false + const parts = input.split(' ') + const groups = {} as { + [profile: string]: { + default_endpoint?: string + network_defaults?: Record + } + } + for (const part of parts) { + if (part.includes('default_endpoint')) { + const [profile, key] = part.split('.') + if (!profile || !key) raise(`Failed to parse MESC_PROFILES profile: ${part}`) + const [key_, value] = key.split('=') + if (!key_ || !value) raise(`Failed to parse MESC_PROFILES: ${part}`) + groups[profile] = { default_endpoint: value, ...groups[profile] } + } + if (part.includes('network_defaults')) { + const [profile, key, chainIdNetworkName] = part.split('.') + if (!profile || !key || !chainIdNetworkName) raise(`Failed to parse MESC_PROFILES: ${part}`) + const [chainId, networkName] = chainIdNetworkName.split('=') + if (!chainId || !networkName) raise(`Failed to parse MESC_PROFILES: ${part}`) + groups[profile] = { ...groups[profile], network_defaults: { [chainId]: networkName } } + } + } + return groups +} + +/** + * parse space-separated items of [[:]=] into a mapping + * returns {Record} + */ +export function parseSpaceSeparatedEndpoints(input?: string) { + if (!input) return false + return removeUndefined( + input.split(' ').reduce((accumulator, item) => { + const [name, url] = item.split('=') as [string, string] + const [name_, chain_id] = name.split(':') as [string, string | undefined] + return { ...accumulator, [name_]: { url, chain_id } } + }, {}) + ) as Record +} + +/** + * parse space-separated pairs of = into a mapping + */ +export function parseSpaceSeparatedPairs(input?: string) { + if (!input) return false + return input.split(' ').reduce((accumulator, pair) => { + const [key, value] = pair.split('=') as [string, string] + return { ...accumulator, [key]: value } + }, {}) +} + +/** + * parse JSON string into a JSON object + */ +export function parseStringJSON(input?: string) { + if (!input) return false + return JSON.parse(input) as Record +} diff --git a/typescript/src/schemas/mesc-config.ts b/typescript/src/schemas/mesc-config.ts new file mode 100644 index 0000000..13f5d9f --- /dev/null +++ b/typescript/src/schemas/mesc-config.ts @@ -0,0 +1,23 @@ +import * as v from 'valibot' + +export const mescConfigSchema = v.object({ + MESC_MODE: v.union([v.literal('PATH'), v.literal('ENV'), v.literal('DISABLED')]), + MESC_PATH: v.string(), + MESC_ENV: v.optional(v.string()), + /** JSON mapping of {"endpoint_name": {}} */ + MESC_ENDPOINT_METADATA: v.optional(v.string()), + /** JSON formatted global metadata */ + MESC_GLOBAL_METADATA: v.optional(v.string()), + /** space-separated items of [[:]=] */ + MESC_ENDPOINTS: v.optional(v.string([v.regex(/(\w+(\.\w+)?(:\d+)?=[\w\d]+)+/)])), + /** space-separated pairs of = */ + MESC_NETWORK_NAMES: v.optional(v.string([v.regex(/(\w+=[\w\d]+)+/)])), + /** url, endpoint name, or network name */ + MESC_DEFAULT_ENDPOINT: v.optional(v.string()), + /** space-separated pairs of .[. */ + MESC_PROFILES: v.optional(v.string([v.regex(/(\w+\.\w+(\.\d+)?)=[\w\d]+/)])), + /** space-separated pairs of = */ + MESC_NETWORK_DEFAULTS: v.optional(v.string([v.regex(/(\d+=[\w\d]+)+/)])) +}) + +export type RawMESCConfig = v.Input diff --git a/typescript/src/schemas/rpc-config.ts b/typescript/src/schemas/rpc-config.ts new file mode 100644 index 0000000..41a5288 --- /dev/null +++ b/typescript/src/schemas/rpc-config.ts @@ -0,0 +1,34 @@ +import * as v from 'valibot' + +/** + * chain_id should be represented using either a decimal string or a hex string. + * Strings are used because chain id's can be 256 bits and most languages do not have native 256 bit integer types. + * For readability, decimal should be used for small chain id values and hex should be used for values that use the entire 256 bits. + */ +export const chainIdSchema = v.union([v.string(), v.number()]) + +export type ChainId = v.Output + +export const rpcConfigSchema = v.object({ + mesc_version: v.literal('MESC 1.0'), + default_endpoint: v.optional(v.string()), + network_defaults: v.record(v.string()), + network_names: v.record(v.string()), + endpoints: v.record( + v.object({ + name: v.string(), + url: v.string(), + chain_id: v.optional(v.string()), + endpoint_metadata: v.any() + }) + ), + profiles: v.record( + v.object({ + default_endpoint: v.optional(v.nullable(v.string())), + network_defaults: v.record(v.string()) + }) + ), + global_metadata: v.any() +}) + +export type RpcConfig = v.Output diff --git a/typescript/src/transform.ts b/typescript/src/transform.ts new file mode 100644 index 0000000..6abd062 --- /dev/null +++ b/typescript/src/transform.ts @@ -0,0 +1,97 @@ +import * as v from 'valibot' +import { + parseStringJSON, + parseMescVariables, + parseSpaceSeparatedPairs, + parseSpaceSeparatedProfiles, + parseSpaceSeparatedEndpoints +} from '#/parsers.ts' +import { raise } from '#/utilities.ts' +import { mescConfigSchema } from '#/schemas/mesc-config.ts' + +/** + * TODO: check if MESC_NETWORK_DEFAULTS is supposed to be merged with existing network_defaults or override it + * if the latter, then: + * 'Object.assign(rpcConfig.network_defaults, rpcConfig.network_defaults, mescNetworkDefaults)' + */ + +/** @see https://github.com/paradigmxyz/mesc/blob/main/SPECIFICATION.md */ +export const mescConfigurationTransform = v.transform( + mescConfigSchema, + ({ + MESC_MODE, + MESC_PATH, + MESC_ENV, + MESC_ENDPOINTS, + MESC_DEFAULT_ENDPOINT, + MESC_PROFILES, + MESC_NETWORK_NAMES, + MESC_NETWORK_DEFAULTS, + MESC_GLOBAL_METADATA, + MESC_ENDPOINT_METADATA + }) => { + // MESC is not enabled + if (MESC_MODE === 'DISABLED' || [MESC_MODE, MESC_ENV, MESC_PATH].filter(Boolean).length === 0) + return null + const { + success, + output: rpcConfig, + issues + } = parseMescVariables({ MESC_MODE, MESC_PATH, MESC_ENV }) + if (!success) + raise(`Failed to parse MESC variables: ${JSON.stringify(v.flatten(issues), undefined, 2)}`) + + if (MESC_DEFAULT_ENDPOINT?.length) { + Object.assign(rpcConfig, { default_endpoint: MESC_DEFAULT_ENDPOINT }) + } + + const mescNetworkDefaults = parseSpaceSeparatedPairs(MESC_NETWORK_DEFAULTS) + if (mescNetworkDefaults) { + Object.assign(rpcConfig, { network_defaults: mescNetworkDefaults }) + } + + const mescNetworkNames = parseSpaceSeparatedPairs(MESC_NETWORK_NAMES) + if (mescNetworkNames) { + Object.assign(rpcConfig, { network_names: mescNetworkNames }) + } + + const mescEndpoints = parseSpaceSeparatedEndpoints(MESC_ENDPOINTS) + if (mescEndpoints) { + Object.assign(rpcConfig, { endpoints: mescEndpoints }) + } + + const mescProfiles = parseSpaceSeparatedProfiles(MESC_PROFILES) + if (mescProfiles) { + Object.assign(rpcConfig, { profiles: mescProfiles }) + } + + const mescGlobalMetadata = parseStringJSON(MESC_GLOBAL_METADATA) + if (mescGlobalMetadata) { + Object.assign(rpcConfig.global_metadata, rpcConfig.global_metadata, mescGlobalMetadata) + } + + const mescEndpointMetadata = parseStringJSON(MESC_ENDPOINT_METADATA) + if (mescEndpointMetadata) { + for (const endpoint in mescEndpointMetadata) { + const metadata = mescEndpointMetadata[endpoint] + if (!rpcConfig.endpoints[endpoint]) continue + Object.assign(rpcConfig.endpoints[endpoint]?.endpoint_metadata, metadata) + } + } + + return rpcConfig + } +) + +export type MESCConfiguration = v.Output + +export function getRpcConfig(env: Record = process.env): MESCConfiguration { + const { output, success, issues } = v.safeParse(mescConfigurationTransform, env, { + abortEarly: false, + abortPipeEarly: false + }) + + if (!success) raise(`Failed to parse MESC configuration: ${JSON.stringify(issues, undefined, 2)}`) + + return output +} diff --git a/typescript/src/types.ts b/typescript/src/types.ts new file mode 100644 index 0000000..edbcb69 --- /dev/null +++ b/typescript/src/types.ts @@ -0,0 +1,46 @@ +import type { ChainId } from '#/schemas/rpc-config.ts' + +export type NetworkName = 'ethereum' | 'goerli' | 'optimism' | 'polygon' | 'holesky' | 'arbitrum' + +export interface RpcConfig { + mesc_version: string + default_endpoint?: string + endpoints: Record + network_defaults: Record + network_names: Record + profiles: Record + global_metadata: Record +} + +export interface Endpoint { + name: string + url: string + chain_id?: ChainId + endpoint_metadata: Record +} + +export interface Profile { + name: string + default_endpoint?: string + network_defaults: Record +} + +export interface Query { + default_endpoint?: string + endpoint_by_name?: string + endpoint_by_network?: string + user_input?: string + multi_endpoint?: string + global_metadata?: string +} + +export type Maybe = T | undefined + +type Json = string | number | boolean | null | Json[] | { [key: string]: Json } + +/** + * This type utility is used to unwrap complex types so you can hover over them in your editor + */ +export type Pretty = { + [K in keyof T]: T[K] +} & {} diff --git a/typescript/src/utilities.ts b/typescript/src/utilities.ts new file mode 100644 index 0000000..53e3b5c --- /dev/null +++ b/typescript/src/utilities.ts @@ -0,0 +1,11 @@ +export function raise(error: unknown): never { + throw typeof error === 'string' ? new Error(error) : error +} + +export const unixTimestamp = () => `${Math.floor(Date.now() / 1_000)}` + +// removed properties with undefined values from object +export function removeUndefined(object?: T): T { + if (!object) return {} as T + return (typeof object === 'string' ? JSON.parse(object) : JSON.parse(JSON.stringify(object))) as T +} diff --git a/typescript/test/index.test.ts b/typescript/test/index.test.ts new file mode 100644 index 0000000..afc291f --- /dev/null +++ b/typescript/test/index.test.ts @@ -0,0 +1,6 @@ +import { expect, test } from 'vitest' + +// placeholder test +test(() => { + expect(1).toBe(1) +}) diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json new file mode 100644 index 0000000..0d876f2 --- /dev/null +++ b/typescript/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "noEmit": true, + "paths": { + "#/*": ["./src/*"], + "~test-json": ["../tests/generated/tests.json"] + }, + "types": ["node", "bun"], + "lib": ["ESNext"], + "module": "ESNext", + "target": "ESNext", + "moduleResolution": "Bundler", + "useDefineForClassFields": true, + "resolveJsonModule": true, + "resolvePackageJsonExports": true, + "resolvePackageJsonImports": true, + "allowImportingTsExtensions": true, + "noUncheckedIndexedAccess": true, + "noFallthroughCasesInSwitch": true, + "sourceMap": false, + "declarationMap": false, + "noPropertyAccessFromIndexSignature": true, + "alwaysStrict": true, + "strictNullChecks": true, + "verbatimModuleSyntax": true, + "strict": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "allowJs": true, + "checkJs": true + }, + "include": ["src", "test", "scripts"], + "files": ["environment.d.ts", "reset.d.ts"], + "exclude": ["_"] +} diff --git a/typescript/tsup.config.ts b/typescript/tsup.config.ts new file mode 100644 index 0000000..73bd18e --- /dev/null +++ b/typescript/tsup.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + dts: true, + shims: true, + clean: true, + bundle: true, + outDir: 'dist', + format: ['esm'], + target: ['node20'], + treeshake: 'recommended', + entry: ['./src/index.ts'] +}) diff --git a/typescript/vitest.config.ts b/typescript/vitest.config.ts new file mode 100644 index 0000000..29aebba --- /dev/null +++ b/typescript/vitest.config.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: {} +}) From 5baaf3d3848adf2126b7abd66cb5bf0b6e258cec Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 12 Feb 2024 19:27:21 -0800 Subject: [PATCH 72/85] feat: typescript ci (#25) * feat: typescript ci * remove path-based trigger condition * add typecheck step * pass working directory to biome * use local biome --- .github/workflows/typescript.yml | 51 ++++++++++++++++++++++++++++++++ .gitignore | 6 +++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/typescript.yml diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml new file mode 100644 index 0000000..c8e0f2a --- /dev/null +++ b/.github/workflows/typescript.yml @@ -0,0 +1,51 @@ +name: TypeScript + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +defaults: + run: + working-directory: typescript + +env: + # enable debug logging + ACTIONS_RUNNER_DEBUG: true + +jobs: + build-lint-test: + runs-on: ubuntu-latest + defaults: + run: + working-directory: typescript + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Biome + uses: biomejs/setup-biome@v2 + with: + version: latest + + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Lint, Format, & Typecheck + working-directory: typescript + run: | + bun run lint + bun run format + bun run typecheck + + - name: Build + run: bun run build + + - name: Test + run: bun run test diff --git a/.gitignore b/.gitignore index 5c90b16..9b55d9e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,8 @@ __pycache__ python/dist docs/book *.gif -_ +node_modules +dist +.env +!.env.example +_ \ No newline at end of file From 5d8b4f77dd34087bc400c40213843d5ebd9cf6ce Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 12 Feb 2024 19:51:12 -0800 Subject: [PATCH 73/85] Update typescript action (#26) --- .github/workflows/typescript.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index c8e0f2a..7630e50 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -24,11 +24,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup Biome - uses: biomejs/setup-biome@v2 - with: - version: latest - - name: Set up Bun uses: oven-sh/setup-bun@v1 with: From 4899c3c632592d48018eb5d52e2b53924dcfe384 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 12:57:53 -0700 Subject: [PATCH 74/85] run latest rust formatter --- rust/Cargo.lock | 16 ++++++++++++---- rust/crates/mesc/src/metadata.rs | 4 ++-- rust/crates/mesc/src/types/chain_ids.rs | 12 ++++++------ rust/crates/mesc_cli/src/cli/subcommands/set.rs | 12 +++++++++--- .../src/cli/subcommands/setup/endpoints.rs | 2 +- .../src/cli/subcommands/setup/metadata.rs | 4 ++-- .../src/cli/subcommands/setup/selectors.rs | 6 +++--- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 80168c7..e69a8ea 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1519,6 +1519,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.17" @@ -2767,12 +2773,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -2787,10 +2794,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/rust/crates/mesc/src/metadata.rs b/rust/crates/mesc/src/metadata.rs index f58c86c..e4edbca 100644 --- a/rust/crates/mesc/src/metadata.rs +++ b/rust/crates/mesc/src/metadata.rs @@ -15,7 +15,7 @@ pub fn get_api_key>( if let Some(api_keys) = profile.profile_metadata.get("api_keys") { let api_keys: HashMap = get_value_at(api_keys, &[])?; if let Some(key) = api_keys.get(key_name) { - return Ok(Some(key.clone())) + return Ok(Some(key.clone())); } } } @@ -24,7 +24,7 @@ pub fn get_api_key>( if let Some(api_keys) = config.global_metadata.get("api_keys") { let api_keys: HashMap = get_value_at(api_keys, &[])?; if let Some(key) = api_keys.get(key_name) { - return Ok(Some(key.clone())) + return Ok(Some(key.clone())); } } diff --git a/rust/crates/mesc/src/types/chain_ids.rs b/rust/crates/mesc/src/types/chain_ids.rs index 09bd4a5..4c3b7fa 100644 --- a/rust/crates/mesc/src/types/chain_ids.rs +++ b/rust/crates/mesc/src/types/chain_ids.rs @@ -128,9 +128,9 @@ impl TryIntoChainId for ChainId { impl TryIntoChainId for String { fn try_into_chain_id(self) -> Result { - if !self.is_empty() && - (self.chars().all(|c| c.is_ascii_digit()) || - (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) + if !self.is_empty() + && (self.chars().all(|c| c.is_ascii_digit()) + || (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) { Ok(ChainId(self)) } else { @@ -141,9 +141,9 @@ impl TryIntoChainId for String { impl TryIntoChainId for &str { fn try_into_chain_id(self) -> Result { - if !self.is_empty() && - (self.chars().all(|c| c.is_ascii_digit()) || - (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) + if !self.is_empty() + && (self.chars().all(|c| c.is_ascii_digit()) + || (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) { Ok(ChainId(self.to_string())) } else { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/set.rs b/rust/crates/mesc_cli/src/cli/subcommands/set.rs index b7b73ec..6c48326 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/set.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/set.rs @@ -69,7 +69,9 @@ fn determine_kv_pairs(args: &SetArgs) -> Result)>, M return Err(MescCliError::InvalidInput("specify one of key or --keys".to_string())) } (Some(_), _, Some(_), _, _) => { - return Err(MescCliError::InvalidInput("cannot specify both key and --keys".to_string())) + return Err(MescCliError::InvalidInput( + "cannot specify both key and --keys".to_string(), + )) } (_, None, _, None, false) => { return Err(MescCliError::InvalidInput("specify value or --values".to_string())) @@ -129,7 +131,9 @@ fn set_config_value( ["endpoint_metadata", location @ ..] => { set_metadata_entry(&mut endpoint.endpoint_metadata, location, value)?; } - _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), + _ => { + return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))) + } } }; } @@ -162,7 +166,9 @@ fn set_config_value( )) } }, - _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), + _ => { + return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))) + } } } } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs index 30958fe..66c4013 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs @@ -73,7 +73,7 @@ pub(crate) async fn modify_endpoint(config: &mut RpcConfig) -> Result<(), MescCl let mut options: Vec = config.endpoints.clone().into_keys().collect(); if options.is_empty() { println!(" No endpoints to modify"); - return Ok(()) + return Ok(()); } options.sort(); let endpoint_name = match inquire::Select::new("Which endpoint to modify?", options).prompt() { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs index bd2e4f4..1c4988b 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/metadata.rs @@ -170,7 +170,7 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), } } } else { - return Ok(()) + return Ok(()); } } Ok("Modify endpoint metadata") => { @@ -179,7 +179,7 @@ pub(crate) async fn modify_global_metadata(config: &mut RpcConfig) -> Result<(), } else if let Some(endpoint) = select_endpoint(config, "Which endpoint?")? { modify_endpoint_metadata(endpoint.as_str(), config)?; } else { - return Ok(()) + return Ok(()); } } Ok("Print global metadata") => { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs index 4cf1dfe..358f57d 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs @@ -100,7 +100,7 @@ pub(crate) fn select_endpoint( ) -> Result, MescCliError> { let mut options: Vec = config.endpoints.clone().into_keys().collect(); if options.is_empty() { - return Ok(None) + return Ok(None); } options.sort(); match inquire::Select::new(prompt, options).prompt() { @@ -123,7 +123,7 @@ pub(crate) fn select_endpoint_of_network( .map(|endpoint| endpoint.name.clone()) .collect(); if options.is_empty() { - return Ok(None) + return Ok(None); } options.sort(); match inquire::Select::new(prompt, options).prompt() { @@ -139,7 +139,7 @@ pub(crate) fn select_profile( ) -> Result, MescCliError> { let mut options: Vec<_> = config.profiles.keys().collect(); if options.is_empty() { - return Ok(None) + return Ok(None); } options.sort(); match inquire::Select::new(prompt, options).prompt() { From c64c47f4c2c9d2b7354b9983ef7db20097510706 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 12:58:48 -0700 Subject: [PATCH 75/85] use full list of network names in network query --- rust/crates/mesc/src/directory.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rust/crates/mesc/src/directory.rs b/rust/crates/mesc/src/directory.rs index 383e055..de80908 100644 --- a/rust/crates/mesc/src/directory.rs +++ b/rust/crates/mesc/src/directory.rs @@ -15,15 +15,21 @@ fn known_networks() -> HashMap<&'static str, ChainId> { } /// get chain id of given network name -pub(crate) fn get_network_chain_id(network: &str) -> Option { - known_networks().remove(network) +pub(crate) fn get_network_chain_id(network_name: &str) -> Option { + let network_names = crate::network_names::get_network_names(); + for (chain_id, network) in network_names.into_iter() { + if network == network_name { + return Some(chain_id); + } + } + None } /// get network name of given chain id pub fn get_network_name(chain_id: &ChainId) -> Option { for (name, other_chain_id) in known_networks().iter() { if chain_id == other_chain_id { - return Some(name.to_string()) + return Some(name.to_string()); } } None From 5ca919ea293396ba3a4f4c8ceb5faee8b19436d4 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 12:59:05 -0700 Subject: [PATCH 76/85] display name instead of chain_id in default endpoint summary --- rust/crates/mesc_cli/src/printing.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rust/crates/mesc_cli/src/printing.rs b/rust/crates/mesc_cli/src/printing.rs index de35c33..76a62ee 100644 --- a/rust/crates/mesc_cli/src/printing.rs +++ b/rust/crates/mesc_cli/src/printing.rs @@ -49,10 +49,20 @@ pub(crate) fn print_endpoints( let mut names = Vec::new(); let mut networks = Vec::new(); let mut urls = Vec::new(); + let mut network_names = Vec::new(); let sorted_endpoints = sort_endpoints(endpoints); + + let all_network_names = mesc::network_names::get_network_names(); for endpoint in sorted_endpoints.into_iter() { names.push(endpoint.name.clone()); networks.push(endpoint.chain_id_string()); + + let network_name = match endpoint.chain_id { + Some(ref chain_id) => all_network_names.get(&chain_id).map(String::clone), + None => None, + }; + let network_name = network_name.unwrap_or(endpoint.chain_id_string().clone()); + network_names.push(network_name); if reveal { urls.push(endpoint.url.clone()); } else { @@ -71,9 +81,14 @@ pub(crate) fn print_endpoints( let mut table = toolstr::Table::default(); table.add_column("endpoint", names)?; format.add_column(ColumnFormatShorthand::new().name("endpoint").font_style(metavar_style)); - table.add_column("network", networks)?; - format - .add_column(ColumnFormatShorthand::new().name("network").font_style(description_style)); + table.add_column("network", network_names)?; + format.add_column( + ColumnFormatShorthand::new().name("network").font_style(description_style.clone()), + ); + // table.add_column("chain id", networks)?; + // format.add_column( + // ColumnFormatShorthand::new().name("chain id").font_style(description_style), + // ); table.add_column("url", urls)?; format.add_column(ColumnFormatShorthand::new().name("url").font_style(option_style)); format.print(table)?; From 2aa90305660010f350e8ec41f5e54cf1b2346c2f Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 12:59:38 -0700 Subject: [PATCH 77/85] move python typing-extensions from deps to test-deps --- python/pyproject.toml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 872b7ea..94f0de8 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -28,14 +28,17 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Typing :: Typed", ] -dependencies = [ - "typing-extensions >=4.9.0", -] +dependencies = [] [project.urls] Documentation = "https://github.com/paradigmxyz/mesc" Source = "https://github.com/paradigmxyz/mesc" +[project.optional-dependencies] +test = [ + "typing-extensions >=4.9.0", +] + [tool.mypy] python_version = "3.9" strict = true From 64e4dda0ef08d992805d57c650b3d2dd83c3bd84 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 12:59:46 -0700 Subject: [PATCH 78/85] update README.md --- docs/src/setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/setup.md b/docs/src/setup.md index c86b195..eabb06b 100644 --- a/docs/src/setup.md +++ b/docs/src/setup.md @@ -11,7 +11,7 @@ As described in the [quickstart](./quickstart.md), the `mesc.json` file is usual ## Alternative setup without a `mesc.json` -Sometimes it is convenient to configure a system without editing any files (e.g. inside a container, or on a network drive, or in a low-privilege environment). +Sometimes it is convenient to configure a system without editing any files (e.g. inside a container, or when creating lots of unit tests, or in a low-privilege environment). This can be accomplished with MESC by setting the `MESC_ENV` variable instead of the `MESC_PATH` variable. `MESC_ENV` should simply contain the JSON content of a MESC configuration. From 98a756a1a151357f1f214b591ead5a63f42c2bd4 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 13 Aug 2024 13:01:24 -0700 Subject: [PATCH 79/85] update list of known networks --- python/mesc/network_names.py | 620 ++++++++++++++++++++++++-- rust/crates/mesc/src/network_names.rs | 620 ++++++++++++++++++++++++-- 2 files changed, 1168 insertions(+), 72 deletions(-) diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index e074245..1eb41b6 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -22,7 +22,7 @@ network_names = { '13': 'diode_testnet_staging', '14': 'flare', '15': 'diode_prenet', - '16': 'flare_testnet_coston', + '16': 'songbird_testnet_coston', '17': 'thaifi', '18': 'thundercore_testnet', '19': 'songbird_canary', @@ -94,8 +94,8 @@ network_names = { '85': 'gate_testnet', '86': 'gate', '87': 'nova', - '88': 'tomo', - '89': 'tomo_testnet', + '88': 'viction', + '89': 'viction_testnet', '90': 'garizon_stage0', '91': 'garizon_stage1', '92': 'garizon_stage2', @@ -136,15 +136,20 @@ network_names = { '128': 'huobi_eco', '129': 'innovator', '131': 'engram_testnet', + '132': 'namefi', + '133': 'hashkey_testnet', '134': 'iexec', '135': 'alyx_testnet', '136': 'deam', '137': 'polygon', '138': 'defi_oracle_meta', '139': 'woop', + '140': 'eternal', '141': 'openpiece_testnet', '142': 'dax', '144': 'phi_v2', + '145': 'soraai_testnet', + '147': 'flag', '148': 'shimmerevm', '150': 'six_protocol_testnet', '151': 'redbelly', @@ -153,43 +158,63 @@ network_names = { '154': 'redbelly_tge', '155': 'tenet_testnet', '156': 'oeblock_testnet', + '157': 'puppynet_shibarium', + '158': 'roburna', + '159': 'roburna_testnet', '160': 'armonia_eva', '161': 'armonia_eva_testnet', '162': 'lightstreams_testnet', '163': 'lightstreams', - '165': 'omni_testnet', + '164': 'omni_omega', + '166': 'omni', '167': 'atoshi_testnet', '168': 'aioz', '169': 'manta_pacific', '170': 'hoo_testnet', '172': 'latam_block_resil_testnet', + '176': 'dc', + '178': 'abey_testnet', + '179': 'abey', '180': 'ame', + '181': 'waterfall', + '184': 'dojima_testnet', + '185': 'mint', '186': 'seele', + '187': 'dojima', '188': 'bmc', '189': 'bmc_testnet', + '190': 'cmdao_bbq', + '191': 'filefilego', '193': 'crypto_emergency', - '195': 'x1_testnet', - '196': 'x1', + '195': 'x_layer_testnet', + '196': 'x_layer', '197': 'neutrinos_testnet', '198': 'bit', '199': 'bittorrent', '200': 'arbitrum_on_xdai', '201': 'moac_testnet', + '202': 'edgeless_testnet', '204': 'opbnb', '206': 'vinu_testnet', '207': 'vinu', '208': 'structx', '210': 'bitnet', '211': 'freight_trust', - '212': 'map_makalu', + '212': 'mapo_makalu', + '213': 'b2_hub', '214': 'shinarium', '217': 'siriusnet_v2', '218': 'soterone_old', '220': 'scalind_testnet', + '221': 'blockex', '222': 'permission', + '223': 'b2', + '224': 'viridis_testnet', '225': 'la', '226': 'la_testnet', + '228': 'mind', '230': 'swapdex', + '234': 'protojumbo_testnet', '236': 'deam_testnet', '238': 'blast', '242': 'plinga', @@ -197,13 +222,21 @@ network_names = { '248': 'oasys', '250': 'fantom_opera', '252': 'fraxtal', + '254': 'swan', '255': 'kroma', '256': 'huobi_eco_testnet', '258': 'setheum', '259': 'neonlink', + '261': 'guru_testnet', '262': 'sur_block', + '266': 'neura', + '267': 'neura_testnet', + '268': 'neura_devnet', '269': 'high_performance_block', '271': 'egoncoin', + '278': 'xfair.ai', + '279': 'bpx_block', + '282': 'cronos_zkevm_testnet', '288': 'boba', '291': 'orderly', '295': 'hedera', @@ -212,7 +245,11 @@ network_names = { '298': 'hedera_localnet', '300': 'zksync_sepolia_testnet', '301': 'bobaopera', + '302': 'zkcandy_sepolia_testnet', '303': 'neuro_testnet', + '305': 'zksats', + '307': 'lovely_testnet', + '308': 'furtheon', '309': 'wyzth_testnet', '311': 'omax', '313': 'neuro', @@ -221,10 +258,14 @@ network_names = { '322': 'kcc_testnet', '323': 'cosvm', '324': 'zksync', + '325': 'grvt', + '326': 'grvt_sepolia_testnet', '333': 'web3q', '335': 'dfk_test', '336': 'shiden', '338': 'cronos_testnet', + '345': 'tsc', + '360': 'shape', '361': 'theta', '363': 'theta_sapphire_testnet', '364': 'theta_amber_testnet', @@ -234,24 +275,33 @@ network_names = { '380': 'zkamoeba_testnet', '381': 'zkamoeba', '385': 'lisinski', + '388': 'cronos_zkevm', + '395': 'camdl_testnet', + '397': 'near', + '398': 'near_testnet', '399': 'nativ3', '400': 'hyperon_testnet', '401': 'ozone_testnet', + '404': 'syndr_l3', '411': 'pepe', '416': 'sx', '418': 'latestnet', '420': 'optimism_goerli_testnet', + '422': 'viridis', '424': 'pgn_public_goods', '427': 'zeeth', '428': 'geso_verse', + '434': 'boyaa', '443': 'ten_testnet', '444': 'synapse_testnet', '456': 'arzio', '462': 'areon_testnet', '463': 'areon', + '480': 'world', '499': 'rupaya', '500': 'camino_c', '501': 'columbus_test', + '510': 'syndicate', '512': 'double_a', '513': 'double_a_testnet', '516': 'gear_zero', @@ -259,12 +309,15 @@ network_names = { '529': 'fire', '530': 'fxcore', '534': 'candle', + '537': 'optrust', '542': 'paw_testnet', + '545': 'testnet', '555': 'vela1', '558': 'tao', '568': 'doge_testnet', '570': 'rollux', '571': 'meta', + '579': 'filenova', '588': 'metis_stardust_testnet', '592': 'astar', '595': 'acala_mandala_testnet_tc9', @@ -273,28 +326,38 @@ network_names = { '599': 'metis_goerli_testnet', '600': 'meshnyan_testnet', '601': 'vine_testnet', + '610': 'darwin_devnet', '612': 'eiob', '614': 'graphlinq_block', + '624': 'binary', + '625': 'binary_sepolia', '634': 'avocado', + '646': 'previewnet', '647': 'sx_testnet', '648': 'endurance', '653': 'kali_testnet', '654': 'kali', + '662': 'ultronsmart', '666': 'pixie_testnet', '667': 'laos_arrakis', '668': 'junca', '669': 'junca_testnet', '686': 'karura', + '690': 'redstone', '700': 'star_social_testnet', + '701': 'darwinia_koi_testnet', '707': 'block_station', '708': 'block_station_testnet', '710': 'highbury', + '713': 'vrcscan', '719': 'shibarium_beta', '721': 'lycan', '727': 'blucrates', + '730': 'lovely', '740': 'canto_testnet', '741': 'vention_testnet', '742': 'script_testnet', + '747': 'mainnet', '766': 'ql1', '776': 'open_testnet', '777': 'cheapeth', @@ -302,6 +365,7 @@ network_names = { '787': 'acala', '788': 'aero_testnet', '789': 'patex', + '799': 'rupaya_testnet', '800': 'lucid_block', '803': 'haic', '808': 'portal_fantasy_test', @@ -310,20 +374,26 @@ network_names = { '814': 'fire_zkevm', '818': 'beone', '820': 'callisto', + '822': 'runic_testnet', + '831': 'checkdot_block_devnet', '841': 'taraxa', '842': 'taraxa_testnet', + '852': 'hongkong', '859': 'zeeth_dev', '868': 'fantasia', '876': 'bandai_namco_research_verse', '877': 'dexit', '880': 'ambros', '888': 'wan', + '898': 'maxi_testnet', + '899': 'maxi', '900': 'garizon_testnet_stage0', '901': 'garizon_testnet_stage1', '902': 'garizon_testnet_stage2', '903': 'garizon_testnet_stage3', '909': 'portal_fantasy', '910': 'decentrabone_layer1_testnet', + '911': 'taproot', '917': 'rinia_testnet', '919': 'mode_testnet', '927': 'yidark', @@ -334,24 +404,29 @@ network_names = { '956': 'munode_testnet', '957': 'lyra', '963': 'btc20', + '969': 'ethxy', '970': 'oort', '971': 'oort_huygens', '972': 'oort_ascraeus', '977': 'nepal_block', + '979': 'ethxy_testnet', '980': 'top_evm', '985': 'memo', '989': 'top', '990': 'eliberty', + '995': '5ire', '997': '5ire_thunder', '998': 'lucky', '999': 'wan_testnet', '1000': 'gton', - '1001': 'klaytn_testnet_baobab', + '1001': 'kaia_testnet_kairos', '1003': 'tectum_emission_token', '1004': 't_ekta', '1007': 'newton_testnet', '1008': 'eurus', + '1009': 'jumbo', '1010': 'evrice', + '1011': 'rebus', '1012': 'newton', '1022': 'sakura', '1023': 'clover_testnet', @@ -362,37 +437,52 @@ network_names = { '1038': 'bronos_testnet', '1039': 'bronos', '1073': 'shimmerevm_testnet', + '1075': 'iota_evm_testnet', '1079': 'mintara_testnet', '1080': 'mintara', '1088': 'metis_andromeda', '1089': 'humans.ai', '1099': 'moac', + '1100': 'dymension', '1101': 'polygon_zkevm', '1107': 'blxq_testnet', '1108': 'blxq', '1111': 'wemix', '1112': 'wemix_testnet', + '1113': 'b2_hub_testnet', '1115': 'core_block_testnet', '1116': 'core_block', '1117': 'dogcoin', + '1123': 'b2_testnet', '1130': 'defi_evm', '1131': 'defi_evm_testnet', '1133': 'defimeta_changi_testnet', + '1135': 'lisk', '1138': 'amstar_testnet', '1139': 'math', '1140': 'math_testnet', + '1147': 'flag_testnet', '1149': 'symplexia', '1170': 'origin_testnet', '1177': 'smart_host_teknoloji_testnet', + '1188': 'clubmos', '1197': 'iora', + '1200': 'cuckoo', '1201': 'evanesco_testnet', '1202': 'world_trade_technical', + '1209': 'saitablocksbc', + '1210': 'cuckoo_sepolia', '1213': 'popcateum', '1214': 'enter', + '1221': 'cycle_testnet', + '1223': 'cycle_testnet_jellyfish', + '1225': 'hybrid_testnet', + '1227': 'bitcoin_protocol_testnet', '1229': 'exzo', '1230': 'ultron_testnet', '1231': 'ultron', '1234': 'step', + '1235': 'itx', '1243': 'arc', '1244': 'arc_testnet', '1246': 'om_platform', @@ -408,62 +498,90 @@ network_names = { '1294': 'bobabeam', '1297': 'bobabase_testnet', '1311': 'dos_fuji_subnet', + '1313': 'jaiho', '1314': 'alyx', '1319': 'aia', '1320': 'aia_testnet', + '1328': 'sei_testnet', + '1329': 'sei', '1337': 'geth_testnet', '1338': 'elysium_testnet', '1339': 'elysium', '1343': 'blitz_subnet', '1353': 'cic', '1369': 'zafirium', + '1370': 'ramestta', + '1377': 'pingaksha_testnet', '1379': 'kalar', '1388': 'amstar', '1392': 'joseon', '1402': 'polygon_zkevm_testnet_old', + '1414': 'silicon_zkevm_sepolia_testnet', '1422': 'polygon_zkevm_testnet_pre_audit_upgraded', '1433': 'rikeza', '1440': 'living_assets', '1442': 'polygon_zkevm_testnet', '1452': 'gil_testnet', + '1453': 'meta_istanbul', '1455': 'ctex_scan_block', + '1456': 'zkbase', + '1490': 'vitruveo', + '1499': 'idos_games_testnet', '1501': 'bevm_canary', '1506': 'sherpax', '1507': 'sherpax_testnet', '1515': 'beagle_messaging', '1559': 'tenet', + '1570': 'star_testnet', + '1578': 'star', + '1617': 'ethereum_inscription', '1618': 'catecoin', '1620': 'atheios', + '1625': 'gravity_alpha', + '1648': 'pivotal', '1657': 'bta', '1662': 'liqui', '1663': 'horizen_gobi_testnet', + '1686': 'mint_testnet', + '1687': 'mint_sepolia_testnet', '1688': 'ludan', '1701': 'anytype_evm', '1707': 'tbsi', '1708': 'tbsi_testnet', + '1717': 'doric', '1718': 'palette', + '1729': 'reya', + '1740': 'metal_l2_testnet', + '1750': 'metal_l2', '1773': 'party', '1777': 'gauss', + '1789': 'zkbase_sepolia_testnet', '1804': 'kerleano', '1807': 'rabbit_analog_testnet', + '1811': 'lif3_testnet', '1818': 'cube', '1819': 'cube_testnet', '1821': 'ruby', '1856': 'teslafunds', - '1875': 'whitebit', + '1875': 'white', '1881': 'gitshock_cartenz_testnet', '1890': 'lightlink_phoenix', '1891': 'lightlink_pegasus_testnet', '1898': 'bon', + '1899': 'redefi_layer_2', '1904': 'sports', '1907': 'bitci', '1908': 'bitci_testnet', '1909': 'merkle_scan', '1911': 'scalind', '1912': 'ruby_testnet', + '1918': 'upb_crescdi_testnet', '1945': 'onus_testnet', '1951': 'd', + '1953': 'selendra_testnet', '1954': 'dexilla_testnet', + '1956': 'aiw3_testnet', + '1961': 'selendra', '1967': 'eleanor', '1969': 'super_testnet', '1970': 'super', @@ -474,29 +592,42 @@ network_names = { '1985': 'satoshie', '1986': 'satoshie_testnet', '1987': 'ethergem', + '1992': 'hubble_exchange', + '1993': 'b3_sepolia_testnet', '1994': 'ekta', '1995': 'edexa_testnet', + '1996': 'sanko', + '1997': 'kyoto', '1998': 'kyoto_testnet', '2000': 'doge', '2001': 'milkomeda_c1', '2002': 'milkomeda_a1', + '2004': 'metalink', '2008': 'cloudwalk_testnet', '2009': 'cloudwalk', + '2013': 'panarchy', + '2014': 'now_testnet', '2016': 'mainnetz', + '2017': 'adiri', '2018': 'publicmint_devnet', '2019': 'publicmint_testnet', '2020': 'publicmint', '2021': 'edgeware_edgeevm', '2022': 'beresheet_bereevm_testnet', '2023': 'taycan_testnet', + '2024': 'swan_saturn_testnet', '2025': 'rangers_protocol', + '2026': 'edgeless', '2031': 'centrifuge', '2032': 'catalyst', '2035': 'phala', '2037': 'kiwi_subnet', '2038': 'shrapnel_testnet', - '2043': 'origintrail_para', + '2039': 'aleph_zero_testnet', + '2040': 'vanar', + '2043': 'neuroweb', '2044': 'shrapnel_subnet', + '2045': 'aiw3', '2047': 'stratos_testnet', '2048': 'stratos', '2049': 'movo', @@ -506,14 +637,20 @@ network_names = { '2100': 'ecoball', '2101': 'ecoball_testnet_espuma', '2109': 'exosama', + '2112': 'u', + '2121': 'catena', '2122': 'metaplayerone', '2124': 'metaplayerone_dubai_testnet', + '2136': 'bigshortbets_testnet', '2137': 'bigshortbets', '2138': 'defi_oracle_meta_testnet', + '2140': 'oneness', + '2141': 'oneness_testnet', '2151': 'bosagora', '2152': 'findora', '2153': 'findora_testnet', '2154': 'findora_forge', + '2162': 'anime_testnet', '2199': 'moonsama', '2202': 'antofy', '2203': 'bitcoin_evm', @@ -525,52 +662,86 @@ network_names = { '2300': 'bomb', '2306': 'ebro', '2309': 'arevia', + '2311': 'chronicle_vesuvius___lit_protocol_testnet', '2323': 'soma_testnet', '2330': 'altcoin', + '2331': 'rss3_vsl_sepolia_testnet', '2332': 'soma', + '2340': 'atleta_olympia', + '2342': 'omnia', + '2355': 'silicon_zkevm', '2358': 'kroma_sepolia', + '2370': 'nexis_testnet', '2399': 'bomb_testnet', '2400': 'tcg_verse', + '2410': 'karak', '2415': 'xodex', - '2458': 'hybrid_testnet', + '2425': 'king_of_legends', + '2442': 'polygon_zkevm_cardona_testnet', '2468': 'hybrid', '2484': 'unicorn_ultra_nebulas_testnet', + '2511': 'karak_goerli', '2522': 'fraxtal_testnet', + '2525': 'inevm', '2559': 'kortho', '2569': 'techpay', '2606': 'pocrnet', '2611': 'redlight', '2612': 'ez_c', '2613': 'ez_c_testnet', - '2625': 'whitebit_testnet', + '2625': 'white_testnet', + '2648': 'ailayer_testnet', + '2649': 'ailayer', + '2662': 'apex', '2710': 'morph_testnet', '2718': 'k_laos', + '2730': 'xr_sepolia', + '2731': 'elizabeth_testnet', + '2748': 'nanon', + '2777': 'gm', + '2810': 'morph_holesky', + '2882': 'chips', '2888': 'boba_goerli_testnet', + '2907': 'elux', + '2911': 'hy', + '2941': 'xenon_testnet', '2999': 'bityuan', '3000': 'cennznet_rata', '3001': 'cennznet_nikau', '3003': 'canxium', '3011': 'playa3ull_games', '3031': 'orlando', + '3033': 'rebus_testnet', '3068': 'bifrost', + '3073': 'movement_evm', + '3084': 'xl_testnet', '3100': 'immu3_evm', '3102': 'vulture_evm_beta', + '3109': 'satoshivm_alpha', + '3110': 'satoshivm_testnet', '3141': 'filecoin___hyperspace_testnet', '3269': 'dubxcoin', '3270': 'dubxcoin_testnet', '3306': 'debounce_subnet_testnet', '3331': 'zcore_testnet', - '3333': 'web3q_testnet', + '3333': 'ethstorage_testnet', '3334': 'web3q_galileo', + '3335': 'ethstorage', + '3338': 'peaq', '3400': 'paribu_net', + '3424': 'evolve', '3434': 'secure_testnet', + '3456': 'layeredge_testnet', + '3490': 'gtcscan', '3500': 'paribu_net_testnet', '3501': 'jfin', '3601': 'pandoproject', '3602': 'pandoproject_testnet', + '3630': 'tycooncoin', '3636': 'botanix_testnet', '3637': 'botanix', '3639': 'i', + '3645': 'i_testnet', '3666': 'jouleverse', '3690': 'bittex', '3693': 'empire', @@ -578,6 +749,7 @@ network_names = { '3699': 'senjepowers', '3701': 'xpla_testnet', '3737': 'crossbell', + '3776': 'astar_zkevm', '3797': 'alvey', '3799': 'tangle_testnet', '3885': 'fire_zkevm_ghostrider', @@ -587,23 +759,32 @@ network_names = { '3939': 'dos_tesnet', '3966': 'dyno', '3967': 'dyno_testnet', + '3993': 'apex_testnet', '3999': 'yuan', '4000': 'ozone', '4001': 'peperium_testnet', '4002': 'fantom_testnet', '4003': 'x1_fastnet', + '4040': 'carbonium_testnet', + '4048': 'gan_testnet', '4051': 'bobaopera_testnet', + '4058': 'bahamut_ocean', '4061': 'nahmii_3', '4062': 'nahmii_3_testnet', '4078': 'muster', + '4080': 'tobe', '4090': 'fastex_bahamut_oasis_testnet', '4096': 'bitindi_testnet', '4099': 'bitindi', '4102': 'aioz_testnet', '4139': 'humans.ai_testnet', '4141': 'tipboxcoin_testnet', + '4157': 'crossfi_testnet', + '4162': 'sx_rollup', '4181': 'phi_v1', + '4200': 'merlin', '4201': 'lukso_testnet', + '4202': 'lisk_sepolia_testnet', '4242': 'nexi', '4243': 'nexi_v2', '4328': 'bobafuji_testnet', @@ -611,10 +792,15 @@ network_names = { '4400': 'credit', '4444': 'htmlcoin', '4460': 'orderly_sepolia_testnet', + '4488': 'hydra', + '4544': 'emoney_testnet', + '4613': 'very', + '4653': 'gold', '4689': 'iotex', '4690': 'iotex_testnet', '4759': 'meverse_testnet', '4777': 'blackfort_exchange_testnet', + '4801': 'world_sepolia_testnet', '4893': 'globel', '4918': 'venidium_testnet', '4919': 'venidium', @@ -624,6 +810,17 @@ network_names = { '5002': 'treasurenet_alpha', '5003': 'mantle_sepolia_testnet', '5005': 'treasurenet_testnet', + '5039': 'onigiri_test_subnet', + '5040': 'onigiri_subnet', + '5051': 'nollie_skate_testnet', + '5100': 'syndicate_testnet', + '5101': 'syndicate_frame', + '5102': 'sic_testnet', + '5103': 'coordinape_testnet', + '5104': 'charmverse_testnet', + '5105': 'superloyalty_testnet', + '5106': 'azra_testnet', + '5112': 'ham', '5165': 'bahamut', '5169': 'smart_layer', '5177': 'tl', @@ -631,52 +828,78 @@ network_names = { '5234': 'humanode', '5290': 'fire_old', '5315': 'uzmi', + '5317': 'optrust_testnet', + '5321': 'itx_testnet', + '5333': 'netsbo', '5353': 'tritanium_testnet', + '5372': 'settlus_testnet', + '5424': 'edexa', + '5439': 'ego', '5522': 'vex_evm_testnet', - '5551': 'nahmii', - '5553': 'nahmii_testnet', + '5551': 'nahmii_2', + '5553': 'nahmii_2_testnet', '5555': 'verse', '5611': 'opbnb_testnet', + '5615': 'arcturus_testneet', '5616': 'arcturus_testnet', - '5678': 'tanssi_evm_container', + '5656': 'qie_block', + '5675': 'filenova_testnet', + '5678': 'tanssi_demo', '5700': 'syscoin_tanenbaum_testnet', '5729': 'hika_testnet', '5758': 'satoshi_testnet', '5777': 'ganache', + '5845': 'tangle', '5851': 'ontology_testnet', '5869': 'wego_rubidium', + '6000': 'bouncebit_testnet', + '6001': 'bouncebit', '6065': 'tres_testnet', '6066': 'tres', '6102': 'cascadia_testnet', '6118': 'uptn_testnet', '6119': 'uptn', + '6283': 'laos', + '6321': 'aura_euphoria_testnet', + '6322': 'aura', '6363': 'digit_soul', + '6398': 'connext_sepolia', '6502': 'peerpay', + '6550': 'flamma_testnet', '6552': 'scolcoin_wei_testnet', '6565': 'fox_testnet', '6626': 'pixie', '6660': 'latest_testnet', '6661': 'cybria', '6666': 'cybria_testnet', + '6678': 'edgamatrix', '6688': 'irishub', + '6699': 'ox', '6701': 'paxb', '6779': 'compverse', - '6789': 'gold', + '6805': 'race', + '6806': 'race_testnet', + '6868': 'pools', '6969': 'tomb', '6999': 'polysmart', '7000': 'zeta', - '7001': 'zeta_athens_3_testnet', + '7001': 'zeta_testnet', '7007': 'bst', '7027': 'ella_the_heart', '7070': 'planq', + '7077': 'planq_atlas_testnet', '7100': 'nume', '7118': 'help_the_homeless', '7171': 'bitrock', + '7222': 'nibiru_devnet_3', + '7244': 'zeus_testnet', + '7300': 'xpla_verse', '7331': 'klyntar', '7332': 'horizen_eon', '7341': 'shyft', '7484': 'raba', '7518': 'meverse', + '7560': 'cyber', '7575': 'adil_testnet', '7576': 'adil_v2', '7668': 'the_root', @@ -684,15 +907,27 @@ network_names = { '7700': 'canto', '7701': 'canto_tesnet', '7771': 'bitrock_testnet', + '7774': 'gdcc', + '7775': 'gdcc_testnet', + '7776': 'pandasea', '7777': 'rise_of_the_warbots_testnet', + '7778': 'orenium_protocol', + '7798': 'openex_long_testnet', '7860': 'maal_testnet', + '7862': 'maal_v2', + '7863': 'maal_testnet_v2', '7878': 'hazlor_testnet', '7887': 'kinto', '7895': 'ardenium_athena', + '7923': 'dot_blox', + '7924': 'mo', '7979': 'dos', '8000': 'teleport', '8001': 'teleport_testnet', + '8008': 'polynomial', '8029': 'mdgl_testnet', + '8047': 'boat', + '8054': 'karak_sepolia', '8080': 'shardeum_liberty_1.x', '8081': 'shardeum_liberty_2.x', '8082': 'shardeum_sphinx_1.x', @@ -708,11 +943,15 @@ network_names = { '8181': 'testnet_beone', '8192': 'torus', '8194': 'torus_testnet', - '8217': 'klaytn_cypress', + '8217': 'kaia', + '8227': 'space_subnet', '8272': 'blockton_block', '8285': 'korthotest', + '8329': 'lorenzo', + '8333': 'b3', '8387': 'dracones_financial_services', '8453': 'base', + '8545': 'chakra_testnet', '8654': 'toki', '8655': 'toki_testnet', '8668': 'hela_official_runtime', @@ -720,28 +959,45 @@ network_names = { '8724': 'tool_global_testnet', '8726': 'storage', '8727': 'storage_testnet', + '8732': 'bullions', '8738': 'alph', '8768': 'tmy', + '8822': 'iota_evm', + '8844': 'hydra_testnet', '8848': 'maro_block', + '8866': 'superlumio', + '8869': 'lif3', '8880': 'unique', '8881': 'quartz_by_unique', '8882': 'opal_testnet_by_unique', '8883': 'sapphire_by_unique', + '8886': 'avenium_testnet', '8888': 'xana', '8889': 'vyvo', + '8890': 'orenium_testnet_protocol', '8898': 'mammoth', '8899': 'jib', + '8911': 'algen', + '8912': 'algen_testnet', + '8921': 'algen_layer2', + '8922': 'algen_layer2_testnet', '8989': 'giant_mammoth', '8995': 'bloxberg', '9000': 'evmos_testnet', '9001': 'evmos', + '9007': 'shido_testnet_block', + '9008': 'shido_block', '9012': 'berylbit', - '9024': 'nexa_block', + '9024': 'nexa_testnet_block', + '9025': 'nexa_block', '9100': 'genesis_coin', '9170': 'rinia_testnet_old', '9223': 'codefin', '9339': 'dogcoin_testnet', + '9372': 'oasys_testnet', + '9393': 'dela_sepolia_testnet', '9395': 'evoke', + '9496': 'weavevm_testnet', '9527': 'rangers_protocol_testnet_robin', '9528': 'qeasyweb3_testnet', '9559': 'neonlink_testnet', @@ -749,90 +1005,146 @@ network_names = { '9728': 'boba_bnb_testnet', '9768': 'mainnetz_testnet', '9779': 'pepenetwork', + '9789': 'tabi_testnet', '9790': 'carbon_evm', '9792': 'carbon_evm_testnet', + '9797': 'optimusz7', '9818': 'imperium_testnet', '9819': 'imperium', + '9876': 'binary_testnet', '9888': 'dogelayer', + '9898': 'larissa', + '9911': 'espento', '9977': 'mind_testnet', '9980': 'combo', + '9981': 'volley', '9990': 'agung', - '9996': 'mind', '9997': 'altlayer_testnet', + '9998': 'ztc', '9999': 'myown_testnet', '10000': 'smart_bitcoin_cash', '10001': 'smart_bitcoin_cash_testnet', '10024': 'gon', '10081': 'japan_open_testnet', '10086': 'sjatsh', + '10096': 'metanova_verse', '10101': 'block_genesis', '10200': 'gnosis_chiado_testnet', '10201': 'maxx', + '10222': 'glscan', '10242': 'arthera', '10243': 'arthera_testnet', '10248': '0xtade', + '10321': 'tao_evm', + '10324': 'tao_evm_testnet', '10395': 'worldland_testnet', '10507': 'numbers', '10508': 'numbers_testnet', '10823': 'cryptocoinpay', + '10849': 'lamina1', + '10850': 'lamina1_identity', '10946': 'quadrans_block', '10947': 'quadrans_block_testnet', + '11011': 'shape_sepolia_testnet', '11110': 'astra', '11111': 'wagmi', '11115': 'astra_testnet', '11119': 'hashbit', + '11124': 'abstract_testnet', + '11221': 'shine', + '11227': 'jiritsu_testnet_subnet', '11235': 'haqq', '11437': 'shyft_testnet', + '11501': 'bevm', + '11503': 'bevm_testnet', + '11521': 'sats', '11612': 'sardis_testnet', - '11888': 'sanr', + '11822': 'artela_testnet', '11891': 'polygon_supernet_arianee', + '12001': 'fuse_testnet', '12009': 'satoshi', + '12020': 'aternos', '12051': 'singularity_zero_testnet', '12052': 'singularity_zero', '12123': 'brc', '12306': 'fibonacci', '12321': 'blg_testnet', + '12324': 'l3x_protocol', + '12325': 'l3x_protocol_testnet', '12345': 'step_testnet', - '12611': 'astar_zkevm', + '12553': 'rss3_vsl', '12715': 'rikeza_testnet', + '12781': 'playdapp_testnet', '12890': 'quantum_testnet', + '12898': 'playfair_testnet_subnet', '13000': 'sps', '13337': 'beam_testnet', '13371': 'immutable_zkevm', '13381': 'phoenix', + '13396': 'masa', '13473': 'immutable_zkevm_testnet', + '13505': 'gravity_alpha_testnet_sepolia', + '13600': 'kronobit', '13812': 'susono', '14000': 'sps_testnet', + '14324': 'evolve_testnet', + '14333': 'vitruveo_testnet', + '14801': 'vana_satori_testnet', '14853': 'humanode_testnet_5_israfel', '15003': 'immutable_zkevm_devnet', + '15257': 'poodl_testnet', + '15259': 'poodl', + '15430': 'kymtc', '15551': 'loopnetwork', '15555': 'trust_evm_testnet', '15557': 'eos_evm_testnet', '16000': 'metadot', '16001': 'metadot_testnet', + '16116': 'defiverse', + '16180': 'plyr_phi', + '16350': 'incentiv_devnet', + '16481': 'pivotal_sepolia', '16507': 'genesys', + '16600': '0g_newton_testnet', '16688': 'irishub_testnet', '16718': 'airdao', '16888': 'ivar_testnet', '17000': 'holesky', '17001': 'redstone_holesky_testnet', + '17069': 'garnet_holesky', + '17071': 'on_points', + '17117': 'defiverse_testnet', '17171': 'g8', '17172': 'eclipse_subnet', '17180': 'palette_testnet', + '17217': 'konet', '17777': 'eos_evm', '18000': 'frontier_of_dreams_testnet', '18122': 'smart_trades', '18159': 'proof_of_memes', '18181': 'g8_testnet', - '18686': 'mxc_zkevm', + '18231': 'unreal_old', + '18233': 'unreal', + '18686': 'mxc_zkevm_moon', + '18888': 'titan_tkx', + '18889': 'titan_tkx_testnet', '19011': 'home_verse', + '19077': 'blockx_atlantis_testnet', + '19191': 'blockx', + '19224': 'decentraconnect_social', '19527': 'magnet', + '19600': 'lbry', '19845': 'btcix', '20001': 'camelark', + '20041': 'niza', + '20073': 'niza_testnet', '20729': 'callisto_testnet', '20736': 'p12', '20765': 'jono11_subnet', + '21004': 'c4ei', '21133': 'all_about_healthy', + '21223': 'dcpay', + '21224': 'dcpay_testnet', '21337': 'cennznet_azalea', '21816': 'om', '21912': 'bsl', @@ -840,72 +1152,114 @@ network_names = { '22040': 'airdao_testnet', '22222': 'nautilus', '22324': 'goldx_testnet', - '22776': 'map', + '22776': 'map_protocol', '23006': 'antofy_testnet', '23118': 'opside_testnet', '23294': 'oasis_sapphire', '23295': 'oasis_sapphire_testnet', + '23451': 'dreyerx', + '23452': 'dreyerx_testnet', '23888': 'blast_testnet', + '24076': 'kymtc_testnet', '24484': 'web', '24734': 'mintme.com', '25186': 'liquidlayer', + '25839': 'alvey_testnet', '25888': 'hammer', '25925': 'bitkub_testnet', '26026': 'ferrum_testnet', '26600': 'hertz', '26863': 'oasis', + '27181': 'klaos_nova', + '27483': 'nanon_sepolia', + '27827': 'zeroone_subnet', + '28516': 'vizing_testnet', + '28518': 'vizing', '28528': 'optimism_bedrock_goerli_alpha_testnet', + '28882': 'boba_sepolia', + '29112': 'hy_testnet', + '29223': 'nexa_metanet', + '29536': 'kai_testnet', '29548': 'mch_verse', '30067': 'piece_testnet', + '30088': 'miyou', '30103': 'cerium_testnet', + '30730': 'movement_evm_legacy', + '30731': 'movement_evm_devnet', + '30732': 'movement_evm_testnet', '31102': 'ethersocial', '31223': 'cloudtx', '31224': 'cloudtx_testnet', '31337': 'go_testnet', '31414': 'evoke_testnet', '31415': 'filecoin___wallaby_testnet', + '31753': 'x', + '31754': 'x_testnet', '32001': 'w3gamez_holesky_testnet', + '32382': 'santiment_intelligence', '32520': 'bitgert', '32659': 'fusion', '32769': 'zilliqa_evm', '32990': 'zilliqa_evm_isolated_server', + '33033': 'entangle', '33101': 'zilliqa_evm_testnet', + '33103': 'zilliqa_2_evm_proto_testnet', + '33111': 'curtis', + '33133': 'entangle_testnet', '33210': 'cloudverse_subnet', '33333': 'aves', '33385': 'zilliqa_evm_devnet', + '33401': 'slingshot', '33469': 'zilliqa_2_evm_devnet', + '33979': 'funki', '34443': 'mode', + '34504': 'zeus', '35011': 'j2o_taro', '35441': 'q', '35443': 'q_testnet', '38400': 'connectormanager', '38401': 'connectormanager_robin', + '39656': 'prm', '39797': 'energi', '39815': 'oho', + '41455': 'aleph_zero_evm', '41500': 'opulent_x_beta', '42069': 'pegglecoin', + '42072': 'agentlayer_testnet', '42161': 'arbitrum_one', '42170': 'arbitrum_nova', '42220': 'celo', '42261': 'oasis_emerald_testnet', '42262': 'oasis_emerald', '42355': 'goldx', + '42421': 'asset_testnet', '42766': 'zkfair', + '42793': 'etherlink', '42801': 'gesoten_verse_testnet', '42888': 'kinto_testnet', '43110': 'athereum', + '43111': 'hemi', '43113': 'avalanche_fuji_testnet', '43114': 'avalanche_c', '43288': 'boba_avax', '43851': 'zkfair_testnet', '44444': 'fren', + '44445': 'quantum', '44787': 'celo_alfajores_testnet', '45000': 'autobahn', + '45454': 'swamps_l2', '45510': 'deelance', + '45513': 'blessnet', '46688': 'fusion_testnet', + '47763': 'neo_x', + '47803': 'redefi_layer_1', '47805': 'rei', + '48795': 'space_subnet_testnet', + '48899': 'zircuit_testnet', + '48900': 'zircuit', '49049': 'wireshape_floripa_testnet', '49088': 'bifrost_testnet', + '49321': 'gunz_testnet', '49797': 'energi_testnet', '50001': 'liveplex_oracleevm', '50005': 'yooldo_verse', @@ -914,30 +1268,52 @@ network_names = { '51178': 'lumoz_testnet_alpha', '51712': 'sardis', '52014': 'electroneum', + '53277': 'doid', + '53302': 'superseed_sepolia_testnet', + '53457': 'dodo_testnet', '53935': 'dfk', '54211': 'haqq_testnet', '54321': 'toronet_testnet', '55004': 'titan', + '55551': 'photon_aurora_testnet', '55556': 'rei_testnet', + '55614': 'flamma', + '56026': 'lambda', '56288': 'boba_bnb', + '56400': 'testnet_zeroone_subnet', '56789': 'velo_labs', + '56797': 'doid_testnet', '57000': 'rollux_testnet', + '57451': 'coinsec', '58008': 'sepolia_pgn_public_goods', - '59140': 'linea_testnet', + '59140': 'linea_goerli', + '59141': 'linea_sepolia', '59144': 'linea', + '59902': 'metis_sepolia_testnet', '59971': 'genesys_code', '60000': 'thinkium_testnet_0', '60001': 'thinkium_testnet_1', '60002': 'thinkium_testnet_2', '60103': 'thinkium_testnet_103', + '60808': 'bob', + '61022': 'orange', + '61406': 'kai', '61800': 'axel_dev_net', '61803': 'etica', '61916': 'doken_super', + '62049': 'optopia_testnet', + '62050': 'optopia', + '62298': 'citrea_devnet', '62320': 'celo_baklava_testnet', '62621': 'multivac', + '62831': 'plyr_tau_testnet', + '62850': 'laos_sigma_testnet', '63000': 'ecredits', '63001': 'ecredits_testnet', + '65349': 'cratd2c_testnet', + '65357': 'vecno', '65450': 'scolcoin', + '65536': 'automata', '66988': 'janus_testnet', '67390': 'siriusnet', '67588': 'cosmic', @@ -947,25 +1323,38 @@ network_names = { '70001': 'thinkium_1', '70002': 'thinkium_2', '70103': 'thinkium_103', + '70700': 'proof_of_play___apex', '71111': 'guapcoinx', '71393': 'polyjuice_testnet', '71401': 'godwoken_testnet_v1', '71402': 'godwoken', + '72778': 'caga_crypto_ankara_testnet', '72992': 'grok', + '73114': 'icb_testnet', + '73115': 'icb', '73799': 'energy_web_volta_testnet', '73927': 'mixin_virtual_machine', '75000': 'resincoin', + '75512': 'geek_verse', + '75513': 'geek_verse_testnet', + '77001': 'bora', '77238': 'foundry_testnet', '77612': 'vention', + '77677': 'cycle_sailboat', '77777': 'toronet', '78110': 'firenze_test', '78281': 'dragonfly_hexapod', '78430': 'amplify_subnet', '78431': 'bulletin_subnet', '78432': 'conduit_subnet', + '78600': 'vanguard', '79879': 'gold_testnet', '80001': 'mumbai', + '80002': 'amoy', + '80008': 'polynomia_sepolia', + '80084': 'bera_bartio', '80085': 'bera_artio', + '80096': 'hizoco', '81041': 'nordek', '81341': 'amana_testnet', '81342': 'amana_mixnet', @@ -976,23 +1365,38 @@ network_names = { '81361': 'mizana_testnet', '81362': 'mizana_mixnet', '81363': 'mizana_privnet', - '81720': 'quantum', '82459': 'smart_layer_testnet', + '83144': 'xprotocol_testnet', + '83872': 'zedxion', '84531': 'base_goerli_testnet', '84532': 'base_sepolia_testnet', '84886': 'aerie', '85449': 'cybertrust', '88002': 'nautilus_proteus_testnet', + '88559': 'inoai', + '88800': 'zkasino', + '88817': 'unit_zero_testnet', + '88819': 'unit_zero_stagenet', '88880': 'chiliz_scoville_testnet', - '88888': 'ivar', + '88882': 'chiliz_spicy_testnet', + '88888': 'chiliz', + '90001': 'fxcore_testnet', '90210': 'beverly_hills', + '90354': 'camp_testnet', '91002': 'nautilus_trition', + '91120': 'metadap_enterprise', '91715': 'combo_testnet', '92001': 'lambda_testnet', '93572': 'liquidlayer_testnet', + '93747': 'stratovm_testnet', '96970': 'mantis_testnet_hexapod', '97288': 'boba_bnb_old', + '97435': 'slingshot_testnet', + '97531': 'green_testnet', + '97970': 'optimusz7_testnet', + '98881': 'ebi', '99099': 'eliberty_testnet', + '99876': 'edgamatrix_testnet', '99998': 'ubtestnet', '99999': 'ub', '100000': 'quark_root', @@ -1006,8 +1410,13 @@ network_names = { '100008': 'quark_shard_7', '100009': 've', '100010': 've_testnet', - '101010': 'soverun_testnet', + '100011': 'quark_l2', + '101010': 'global_trust', + '102031': 'creditcoin_testnet', '103090': 'crystaleum', + '103454': 'masa_testnet', + '104566': 'kaspaclassic', + '105105': 'stratis', '108801': 'bro', '110000': 'quark_devnet_root', '110001': 'quark_devnet_shard_0', @@ -1018,60 +1427,101 @@ network_names = { '110006': 'quark_devnet_shard_5', '110007': 'quark_devnet_shard_6', '110008': 'quark_devnet_shard_7', + '110011': 'quark_l2_testnet', + '110110': 'mars_credit', '111000': 'siberium_test', '111111': 'siberium', + '111188': 're.al', '112358': 'meta_one', + '119139': 'metadap_enterprise_testnet', + '123321': 'gem', '123456': 'adil_devnet', '128123': 'etherlink_testnet', + '131313': 'odyssey_testnet', '131419': 'etnds', + '132902': 'form_testnet', + '141319': 'magape_testnet', '142857': 'icplaza', + '161212': 'playfi', + '165279': 'eclat', + '167000': 'taiko', '167004': 'taiko_alpha_2_testnet', '167005': 'taiko_grimsvotn_l2', '167006': 'taiko_eldfell_l3', '167007': 'taiko_jolnir_l2', '167008': 'taiko_katla_l2', + '167009': 'taiko_hekla_l2', + '175177': 'chronicle___lit_protocol_testnet', + '175188': 'chronicle_yellowstone___lit_protocol_testnet', '188710': 'bitica', '188881': 'condor_test', + '199991': 'mazze_testnet', + '200000': 'xfair.ai_testnet', '200101': 'milkomeda_c1_testnet', '200202': 'milkomeda_a1_testnet', '200625': 'akroma', + '200810': 'bitlayer_testnet', + '200901': 'bitlayer', '201018': 'alaya', '201030': 'alaya_dev_testnet', '201804': 'mythical', '202020': 'decimal_testnet', '202212': 'x1_devnet', + '202401': 'ymtech_besu_testnet', '202624': 'jellie', '204005': 'x1_network', + '205205': 'auroria_testnet', + '210049': 'gitagi_atlas_testnet', '210425': 'platon', '220315': 'mas', '221230': 'reap', '221231': 'reap_testnet', + '222222': 'hydradx', + '222555': 'deepl', + '222666': 'deepl_testnet', '224168': 'taf_eco', '224422': 'conet_sebolia_testnet', '224433': 'conet_holesky', - '230315': 'hashkey_testnet', + '229772': 'abyss_protocol', + '230315': 'hashkey_testnetdiscard', '234666': 'haymo_testnet', + '240515': 'orange_testnet', '246529': 'artis_sigma1', '246785': 'artis_testnet_tau1', '247253': 'saakuru_testnet', '256256': 'cmp', + '262371': 'eclat_testnet', '266256': 'gear_zero_testnet', '271271': 'egoncoin_testnet', '281121': 'social', + '282828': 'zillion_sepolia_testnet', + '292003': 'cipherem_testnet', + '309075': 'one_world', + '313313': 'saharaai_testnet', '314159': 'filecoin___calibration_testnet', + '322202': 'parex', + '323213': 'bloom_genesis_testnet', + '327126': 'waba_testnet', + '328527': 'nal', '330844': 'ttcoin', + '333313': 'bloom_genesis', '333331': 'aves_testnet', '333333': 'nativ3_testnet', '333666': 'oone_testnet', '333777': 'oone_devnet', '333888': 'polis_testnet', '333999': 'polis', + '336655': 'up_testnet', + '336666': 'up', + '355110': 'bitfinity', '355113': 'bitfinity_testnet', + '360890': 'lavita', '363636': 'digit_soul_2', '373737': 'hap_testnet', '381931': 'metal_c', '381932': 'metal_tahoe_c', '404040': 'tipboxcoin', + '413413': 'aie_testnet', '420420': 'kek', '420666': 'kek_kektest', '420692': 'alterium_l2_testnet', @@ -1082,31 +1532,60 @@ network_names = { '431140': 'markr_go', '432201': 'dexalot_subnet_testnet', '432204': 'dexalot_subnet', + '444444': 'syndr_l3_sepolia', '444900': 'weelink_testnet', '471100': 'patex_sepolia_testnet', '473861': 'ultra_pro', '474142': 'open', + '486487': 'gobbl_testnet', + '490000': 'autonomys_testnet_nova_domain', + '504441': 'playdapp', '512512': 'cmp_testnet', - '513100': 'ethereum_fair', + '513100': 'dis', + '526916': 'docoin_community', '534351': 'scroll_sepolia_testnet', '534352': 'scroll', '534353': 'scroll_alpha_testnet', '534354': 'scroll_pre_alpha_testnet', '534849': 'shinarium_beta', '535037': 'beaneco_smart', + '552981': 'one_world_testnet', + '555555': 'pentagon_testnet', + '555666': 'eclipse_testnet', '622277': 'hypra', + '622463': 'atlas', '641230': 'bear', '651940': 'all', + '656476': 'open_campus_codex', + '660279': 'xai', '666666': 'vision___vpioneer_test', '666888': 'hela_official_runtime_testnet', + '686868': 'won', + '696969': 'galadriel_devnet', + '710420': 'tiltyard_subnet', + '713715': 'sei_devnet', + '721529': 'eram', + '743111': 'hemi_sepolia', '751230': 'bear_testnet', + '752024': 'ternoa_testnet', '761412': 'miexs_smart', + '764984': 'lamina1_testnet', + '767368': 'lamina1_identity_testnet', '776877': 'modularium', '800001': 'octaspace', + '808080': 'biz_testnet', + '808813': 'bob_sepolia', + '810180': 'zklink_nova', + '810181': 'zklink_nova_sepolia_testnet', + '810182': 'zklink_nova_goerli_testnet', + '820522': 'tsc_testnet', '827431': 'curve', + '839320': 'prm_testnet', + '840000': 'runevm_testnet', '846000': '4goodnetwork', '855456': 'dodao', '879151': 'blocx', + '888882': 'rexx', '888888': 'vision', '900000': 'posi_shard_0', '910000': 'posi_testnet_shard_0', @@ -1116,34 +1595,57 @@ network_names = { '923018': 'fncy_testnet', '955081': 'jono12_subnet', '955305': 'eluvio_content_fabric', + '978657': 'treasure_ruby', + '984122': 'forma', + '984123': 'forma_sketchpad', '988207': 'ecrox', - '1127469': 'tiltyard_subnet', + '998899': 'supernet_testnet', + '999999': 'am', + '1100789': 'netmind_testnet', + '1234567': 'sharecle', '1261120': 'zkatana', '1313114': 'etho_protocol', '1313500': 'xerom', '1337702': 'kintsugi', '1337802': 'kiln', '1337803': 'zhejiang', + '1398243': 'automata_testnet', + '1612127': 'playfi_albireo_testnet', + '1637450': 'xterio_testnet', '1731313': 'turkey_demo_dev', '2021398': 'debank_testnet', '2099156': 'plian_main', '2206132': 'platon_dev_testnet2', '2611555': 'dpu', + '2702128': 'xterio', + '3132023': 'saharaai', '3141592': 'filecoin___butterfly_testnet', + '3397901': 'funki_sepolia_sandbox', '3441005': 'manta_pacific_testnet', + '3441006': 'manta_pacific_sepolia_testnet', '4000003': 'altlayer_zero_gas', '4281033': 'worlds_caldera', + '4444444': 'altar_testnet', + '4457845': 'zero_testnet_sepolia', + '5112023': 'numblock', '5167003': 'mxc_wannsee_zkevm_testnet', + '5167004': 'moon_geneva_testnet', '5201420': 'electroneum_testnet', + '5318008': 'reactive_kopli', '5555555': 'imversed', '5555558': 'imversed_testnet', + '6038361': 'astar_zkyoto', + '6666665': 'safeanwang', + '6666666': 'safeanwang_testnet', '7225878': 'saakuru', '7355310': 'openvessel', '7668378': 'ql1_testnet', '7762959': 'musicoin', '7777777': 'zora', '8007736': 'plian_sub_1', + '8008135': 'fhenix_helium', '8080808': 'hokum', + '8601152': 'waterfall_8_test', '8794598': 'hap', '8888881': 'quarix_testnet', '8888888': 'quarix', @@ -1151,15 +1653,30 @@ network_names = { '9322253': 'milvine', '10067275': 'plian_testnet_sub_1', '10101010': 'soverun', + '10241024': 'alienx', + '10241025': 'alienx_hal_testnet', + '11145513': 'blessnet_sepolia', '11155111': 'sepolia', '11155420': 'op_sepolia_testnet', + '12052024': 'memento_testnet', + '12227331': 'neox_testnet_t3', + '12227332': 'neox_testnet_t4', + '13068200': 'coti_devnet', '13371337': 'pep_churchill', '14288640': 'andus', '16658437': 'plian_testnet_main', + '18071918': 'mande', '18289463': 'iolite', + '19850818': 'deepbrain_testnet', + '19880818': 'deepbrain', + '20180427': 'stability_testnet', '20180430': 'smartmesh', '20181205': 'quarkblock', '20201022': 'pego', + '20230825': 'vcity_testnet', + '20240324': 'debank_sepolia_testnet', + '20240603': 'dbk', + '20241133': 'swan_proxima_testnet', '20482050': 'hokum_testnet', '22052002': 'excelon', '27082017': 'excoincial_volta_testnet', @@ -1169,42 +1686,64 @@ network_names = { '29032022': 'fla', '31415926': 'filecoin___local_testnet', '35855456': 'joys_digital', + '37084624': 'skale_nebula_hub_testnet', + '39916801': 'kingdom', '43214913': 'maistestsubnet', '61717561': 'aqua', '65010000': 'autonity_bakerloo_thames_testnet', '65010001': 'autonity_bakerloo_barada_testnet', + '65010002': 'autonity_bakerloo_sumida_testnet', + '65010003': 'autonity_bakerloo_yamuna_testnet', '65100000': 'autonity_piccadilly_thames_testnet', '65100001': 'autonity_piccadilly_barada_testnet', + '65100002': 'autonity_piccadilly_sumida_testnet', + '65100003': 'autonity_piccadilly_yamuna_testnet', '68840142': 'frame_testnet', + '77787778': '0xhash_testnet', + '79479957': 'sx_toronto_rollup', + '88558801': 'backstop_testnet', '88888888': 't.e.a.m_block', + '94204209': 'polygon_blackberry', '99415706': 'joys_digital_testnet', + '108160679': 'orai', + '111557560': 'cyber_testnet', + '123420111': 'op_celestia_raspberry', + '161221135': 'plume_testnet', '168587773': 'blast_sepolia_testnet', '192837465': 'gather', '222000222': 'kanazawa', '245022926': 'neon_evm_devnet', + '245022929': 'neon_evm_devnet_rollup', '245022934': 'neon_evm', '245022940': 'neon_evm_testnet', '278611351': 'razor_skale', '311752642': 'oneledger', + '328527624': 'nal_sepolia_testnet', '333000333': 'meld', - '344106930': 'skale_calypso_hub_testnet', '356256156': 'gather_testnet', - '476158412': 'skale_europa_hub_testnet', + '476462898': 'skopje_testnet', '486217935': 'gather_devnet', - '503129905': 'skale_nebula_hub_testnet', + '666666666': 'degen', '888888888': 'ancient8', + '889910245': 'ptcescan_testnet', + '889910246': 'ptcescan', + '974399131': 'skale_calypso_hub_testnet', '999999999': 'zora_sepolia_testnet', + '1020352220': 'skale_titan_hub_testnet', '1122334455': 'ipos', '1146703430': 'cyberdecknet', '1273227453': 'human_protocol', '1313161554': 'aurora', '1313161555': 'aurora_testnet', '1313161556': 'aurora_betanet', + '1313161560': 'powergold', '1350216234': 'skale_titan_hub', '1351057110': 'chaos_skale_testnet', + '1380012617': 'rari', '1380996178': 'raptor', + '1444673419': 'skale_europa_hub_testnet', '1482601649': 'skale_nebula_hub', - '1517929550': 'skale_titan_hub_testnet', + '1511670449': 'gpt', '1564830818': 'skale_calypso_hub', '1666600000': 'harmony_shard_0', '1666600001': 'harmony_shard_1', @@ -1214,16 +1753,25 @@ network_names = { '1666700001': 'harmony_testnet_shard_1', '1666900000': 'harmony_devnet_shard_0', '1666900001': 'harmony_devnet_shard_1', + '1802203764': 'kakarot_sepolia', + '1903648807': 'gemu_testnet', + '1918988905': 'rari_testnet', '2021121117': 'datahopper', '2046399126': 'skale_europa_hub', '3125659152': 'pirl', '4216137055': 'oneledger_testnet_frankenstein', '11297108099': 'palm_testnet', '11297108109': 'palm', + '28872323069': 'gitswarm_test', + '37714555429': 'xai_testnet_v2', + '88153591557': 'arbitrum_blueberry', '111222333444': 'alphabet', + '123420000220': 'fluence_stage', '197710212030': 'ntity', '197710212031': 'haradev_testnet', + '202402181627': 'gm_testnet', '383414847825': 'zeniq', '666301171999': 'pdc', '6022140761023': 'molereum', + '2713017997578000': 'd_testnet', } diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index ae3c7c5..82f6e46 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -27,7 +27,7 @@ pub fn get_network_names() -> HashMap { ("13", "diode_testnet_staging"), ("14", "flare"), ("15", "diode_prenet"), - ("16", "flare_testnet_coston"), + ("16", "songbird_testnet_coston"), ("17", "thaifi"), ("18", "thundercore_testnet"), ("19", "songbird_canary"), @@ -99,8 +99,8 @@ pub fn get_network_names() -> HashMap { ("85", "gate_testnet"), ("86", "gate"), ("87", "nova"), - ("88", "tomo"), - ("89", "tomo_testnet"), + ("88", "viction"), + ("89", "viction_testnet"), ("90", "garizon_stage0"), ("91", "garizon_stage1"), ("92", "garizon_stage2"), @@ -141,15 +141,20 @@ pub fn get_network_names() -> HashMap { ("128", "huobi_eco"), ("129", "innovator"), ("131", "engram_testnet"), + ("132", "namefi"), + ("133", "hashkey_testnet"), ("134", "iexec"), ("135", "alyx_testnet"), ("136", "deam"), ("137", "polygon"), ("138", "defi_oracle_meta"), ("139", "woop"), + ("140", "eternal"), ("141", "openpiece_testnet"), ("142", "dax"), ("144", "phi_v2"), + ("145", "soraai_testnet"), + ("147", "flag"), ("148", "shimmerevm"), ("150", "six_protocol_testnet"), ("151", "redbelly"), @@ -158,43 +163,63 @@ pub fn get_network_names() -> HashMap { ("154", "redbelly_tge"), ("155", "tenet_testnet"), ("156", "oeblock_testnet"), + ("157", "puppynet_shibarium"), + ("158", "roburna"), + ("159", "roburna_testnet"), ("160", "armonia_eva"), ("161", "armonia_eva_testnet"), ("162", "lightstreams_testnet"), ("163", "lightstreams"), - ("165", "omni_testnet"), + ("164", "omni_omega"), + ("166", "omni"), ("167", "atoshi_testnet"), ("168", "aioz"), ("169", "manta_pacific"), ("170", "hoo_testnet"), ("172", "latam_block_resil_testnet"), + ("176", "dc"), + ("178", "abey_testnet"), + ("179", "abey"), ("180", "ame"), + ("181", "waterfall"), + ("184", "dojima_testnet"), + ("185", "mint"), ("186", "seele"), + ("187", "dojima"), ("188", "bmc"), ("189", "bmc_testnet"), + ("190", "cmdao_bbq"), + ("191", "filefilego"), ("193", "crypto_emergency"), - ("195", "x1_testnet"), - ("196", "x1"), + ("195", "x_layer_testnet"), + ("196", "x_layer"), ("197", "neutrinos_testnet"), ("198", "bit"), ("199", "bittorrent"), ("200", "arbitrum_on_xdai"), ("201", "moac_testnet"), + ("202", "edgeless_testnet"), ("204", "opbnb"), ("206", "vinu_testnet"), ("207", "vinu"), ("208", "structx"), ("210", "bitnet"), ("211", "freight_trust"), - ("212", "map_makalu"), + ("212", "mapo_makalu"), + ("213", "b2_hub"), ("214", "shinarium"), ("217", "siriusnet_v2"), ("218", "soterone_old"), ("220", "scalind_testnet"), + ("221", "blockex"), ("222", "permission"), + ("223", "b2"), + ("224", "viridis_testnet"), ("225", "la"), ("226", "la_testnet"), + ("228", "mind"), ("230", "swapdex"), + ("234", "protojumbo_testnet"), ("236", "deam_testnet"), ("238", "blast"), ("242", "plinga"), @@ -202,13 +227,21 @@ pub fn get_network_names() -> HashMap { ("248", "oasys"), ("250", "fantom_opera"), ("252", "fraxtal"), + ("254", "swan"), ("255", "kroma"), ("256", "huobi_eco_testnet"), ("258", "setheum"), ("259", "neonlink"), + ("261", "guru_testnet"), ("262", "sur_block"), + ("266", "neura"), + ("267", "neura_testnet"), + ("268", "neura_devnet"), ("269", "high_performance_block"), ("271", "egoncoin"), + ("278", "xfair.ai"), + ("279", "bpx_block"), + ("282", "cronos_zkevm_testnet"), ("288", "boba"), ("291", "orderly"), ("295", "hedera"), @@ -217,7 +250,11 @@ pub fn get_network_names() -> HashMap { ("298", "hedera_localnet"), ("300", "zksync_sepolia_testnet"), ("301", "bobaopera"), + ("302", "zkcandy_sepolia_testnet"), ("303", "neuro_testnet"), + ("305", "zksats"), + ("307", "lovely_testnet"), + ("308", "furtheon"), ("309", "wyzth_testnet"), ("311", "omax"), ("313", "neuro"), @@ -226,10 +263,14 @@ pub fn get_network_names() -> HashMap { ("322", "kcc_testnet"), ("323", "cosvm"), ("324", "zksync"), + ("325", "grvt"), + ("326", "grvt_sepolia_testnet"), ("333", "web3q"), ("335", "dfk_test"), ("336", "shiden"), ("338", "cronos_testnet"), + ("345", "tsc"), + ("360", "shape"), ("361", "theta"), ("363", "theta_sapphire_testnet"), ("364", "theta_amber_testnet"), @@ -239,24 +280,33 @@ pub fn get_network_names() -> HashMap { ("380", "zkamoeba_testnet"), ("381", "zkamoeba"), ("385", "lisinski"), + ("388", "cronos_zkevm"), + ("395", "camdl_testnet"), + ("397", "near"), + ("398", "near_testnet"), ("399", "nativ3"), ("400", "hyperon_testnet"), ("401", "ozone_testnet"), + ("404", "syndr_l3"), ("411", "pepe"), ("416", "sx"), ("418", "latestnet"), ("420", "optimism_goerli_testnet"), + ("422", "viridis"), ("424", "pgn_public_goods"), ("427", "zeeth"), ("428", "geso_verse"), + ("434", "boyaa"), ("443", "ten_testnet"), ("444", "synapse_testnet"), ("456", "arzio"), ("462", "areon_testnet"), ("463", "areon"), + ("480", "world"), ("499", "rupaya"), ("500", "camino_c"), ("501", "columbus_test"), + ("510", "syndicate"), ("512", "double_a"), ("513", "double_a_testnet"), ("516", "gear_zero"), @@ -264,12 +314,15 @@ pub fn get_network_names() -> HashMap { ("529", "fire"), ("530", "fxcore"), ("534", "candle"), + ("537", "optrust"), ("542", "paw_testnet"), + ("545", "testnet"), ("555", "vela1"), ("558", "tao"), ("568", "doge_testnet"), ("570", "rollux"), ("571", "meta"), + ("579", "filenova"), ("588", "metis_stardust_testnet"), ("592", "astar"), ("595", "acala_mandala_testnet_tc9"), @@ -278,28 +331,38 @@ pub fn get_network_names() -> HashMap { ("599", "metis_goerli_testnet"), ("600", "meshnyan_testnet"), ("601", "vine_testnet"), + ("610", "darwin_devnet"), ("612", "eiob"), ("614", "graphlinq_block"), + ("624", "binary"), + ("625", "binary_sepolia"), ("634", "avocado"), + ("646", "previewnet"), ("647", "sx_testnet"), ("648", "endurance"), ("653", "kali_testnet"), ("654", "kali"), + ("662", "ultronsmart"), ("666", "pixie_testnet"), ("667", "laos_arrakis"), ("668", "junca"), ("669", "junca_testnet"), ("686", "karura"), + ("690", "redstone"), ("700", "star_social_testnet"), + ("701", "darwinia_koi_testnet"), ("707", "block_station"), ("708", "block_station_testnet"), ("710", "highbury"), + ("713", "vrcscan"), ("719", "shibarium_beta"), ("721", "lycan"), ("727", "blucrates"), + ("730", "lovely"), ("740", "canto_testnet"), ("741", "vention_testnet"), ("742", "script_testnet"), + ("747", "mainnet"), ("766", "ql1"), ("776", "open_testnet"), ("777", "cheapeth"), @@ -307,6 +370,7 @@ pub fn get_network_names() -> HashMap { ("787", "acala"), ("788", "aero_testnet"), ("789", "patex"), + ("799", "rupaya_testnet"), ("800", "lucid_block"), ("803", "haic"), ("808", "portal_fantasy_test"), @@ -315,20 +379,26 @@ pub fn get_network_names() -> HashMap { ("814", "fire_zkevm"), ("818", "beone"), ("820", "callisto"), + ("822", "runic_testnet"), + ("831", "checkdot_block_devnet"), ("841", "taraxa"), ("842", "taraxa_testnet"), + ("852", "hongkong"), ("859", "zeeth_dev"), ("868", "fantasia"), ("876", "bandai_namco_research_verse"), ("877", "dexit"), ("880", "ambros"), ("888", "wan"), + ("898", "maxi_testnet"), + ("899", "maxi"), ("900", "garizon_testnet_stage0"), ("901", "garizon_testnet_stage1"), ("902", "garizon_testnet_stage2"), ("903", "garizon_testnet_stage3"), ("909", "portal_fantasy"), ("910", "decentrabone_layer1_testnet"), + ("911", "taproot"), ("917", "rinia_testnet"), ("919", "mode_testnet"), ("927", "yidark"), @@ -339,24 +409,29 @@ pub fn get_network_names() -> HashMap { ("956", "munode_testnet"), ("957", "lyra"), ("963", "btc20"), + ("969", "ethxy"), ("970", "oort"), ("971", "oort_huygens"), ("972", "oort_ascraeus"), ("977", "nepal_block"), + ("979", "ethxy_testnet"), ("980", "top_evm"), ("985", "memo"), ("989", "top"), ("990", "eliberty"), + ("995", "5ire"), ("997", "5ire_thunder"), ("998", "lucky"), ("999", "wan_testnet"), ("1000", "gton"), - ("1001", "klaytn_testnet_baobab"), + ("1001", "kaia_testnet_kairos"), ("1003", "tectum_emission_token"), ("1004", "t_ekta"), ("1007", "newton_testnet"), ("1008", "eurus"), + ("1009", "jumbo"), ("1010", "evrice"), + ("1011", "rebus"), ("1012", "newton"), ("1022", "sakura"), ("1023", "clover_testnet"), @@ -367,37 +442,52 @@ pub fn get_network_names() -> HashMap { ("1038", "bronos_testnet"), ("1039", "bronos"), ("1073", "shimmerevm_testnet"), + ("1075", "iota_evm_testnet"), ("1079", "mintara_testnet"), ("1080", "mintara"), ("1088", "metis_andromeda"), ("1089", "humans.ai"), ("1099", "moac"), + ("1100", "dymension"), ("1101", "polygon_zkevm"), ("1107", "blxq_testnet"), ("1108", "blxq"), ("1111", "wemix"), ("1112", "wemix_testnet"), + ("1113", "b2_hub_testnet"), ("1115", "core_block_testnet"), ("1116", "core_block"), ("1117", "dogcoin"), + ("1123", "b2_testnet"), ("1130", "defi_evm"), ("1131", "defi_evm_testnet"), ("1133", "defimeta_changi_testnet"), + ("1135", "lisk"), ("1138", "amstar_testnet"), ("1139", "math"), ("1140", "math_testnet"), + ("1147", "flag_testnet"), ("1149", "symplexia"), ("1170", "origin_testnet"), ("1177", "smart_host_teknoloji_testnet"), + ("1188", "clubmos"), ("1197", "iora"), + ("1200", "cuckoo"), ("1201", "evanesco_testnet"), ("1202", "world_trade_technical"), + ("1209", "saitablocksbc"), + ("1210", "cuckoo_sepolia"), ("1213", "popcateum"), ("1214", "enter"), + ("1221", "cycle_testnet"), + ("1223", "cycle_testnet_jellyfish"), + ("1225", "hybrid_testnet"), + ("1227", "bitcoin_protocol_testnet"), ("1229", "exzo"), ("1230", "ultron_testnet"), ("1231", "ultron"), ("1234", "step"), + ("1235", "itx"), ("1243", "arc"), ("1244", "arc_testnet"), ("1246", "om_platform"), @@ -413,62 +503,90 @@ pub fn get_network_names() -> HashMap { ("1294", "bobabeam"), ("1297", "bobabase_testnet"), ("1311", "dos_fuji_subnet"), + ("1313", "jaiho"), ("1314", "alyx"), ("1319", "aia"), ("1320", "aia_testnet"), + ("1328", "sei_testnet"), + ("1329", "sei"), ("1337", "geth_testnet"), ("1338", "elysium_testnet"), ("1339", "elysium"), ("1343", "blitz_subnet"), ("1353", "cic"), ("1369", "zafirium"), + ("1370", "ramestta"), + ("1377", "pingaksha_testnet"), ("1379", "kalar"), ("1388", "amstar"), ("1392", "joseon"), ("1402", "polygon_zkevm_testnet_old"), + ("1414", "silicon_zkevm_sepolia_testnet"), ("1422", "polygon_zkevm_testnet_pre_audit_upgraded"), ("1433", "rikeza"), ("1440", "living_assets"), ("1442", "polygon_zkevm_testnet"), ("1452", "gil_testnet"), + ("1453", "meta_istanbul"), ("1455", "ctex_scan_block"), + ("1456", "zkbase"), + ("1490", "vitruveo"), + ("1499", "idos_games_testnet"), ("1501", "bevm_canary"), ("1506", "sherpax"), ("1507", "sherpax_testnet"), ("1515", "beagle_messaging"), ("1559", "tenet"), + ("1570", "star_testnet"), + ("1578", "star"), + ("1617", "ethereum_inscription"), ("1618", "catecoin"), ("1620", "atheios"), + ("1625", "gravity_alpha"), + ("1648", "pivotal"), ("1657", "bta"), ("1662", "liqui"), ("1663", "horizen_gobi_testnet"), + ("1686", "mint_testnet"), + ("1687", "mint_sepolia_testnet"), ("1688", "ludan"), ("1701", "anytype_evm"), ("1707", "tbsi"), ("1708", "tbsi_testnet"), + ("1717", "doric"), ("1718", "palette"), + ("1729", "reya"), + ("1740", "metal_l2_testnet"), + ("1750", "metal_l2"), ("1773", "party"), ("1777", "gauss"), + ("1789", "zkbase_sepolia_testnet"), ("1804", "kerleano"), ("1807", "rabbit_analog_testnet"), + ("1811", "lif3_testnet"), ("1818", "cube"), ("1819", "cube_testnet"), ("1821", "ruby"), ("1856", "teslafunds"), - ("1875", "whitebit"), + ("1875", "white"), ("1881", "gitshock_cartenz_testnet"), ("1890", "lightlink_phoenix"), ("1891", "lightlink_pegasus_testnet"), ("1898", "bon"), + ("1899", "redefi_layer_2"), ("1904", "sports"), ("1907", "bitci"), ("1908", "bitci_testnet"), ("1909", "merkle_scan"), ("1911", "scalind"), ("1912", "ruby_testnet"), + ("1918", "upb_crescdi_testnet"), ("1945", "onus_testnet"), ("1951", "d"), + ("1953", "selendra_testnet"), ("1954", "dexilla_testnet"), + ("1956", "aiw3_testnet"), + ("1961", "selendra"), ("1967", "eleanor"), ("1969", "super_testnet"), ("1970", "super"), @@ -479,29 +597,42 @@ pub fn get_network_names() -> HashMap { ("1985", "satoshie"), ("1986", "satoshie_testnet"), ("1987", "ethergem"), + ("1992", "hubble_exchange"), + ("1993", "b3_sepolia_testnet"), ("1994", "ekta"), ("1995", "edexa_testnet"), + ("1996", "sanko"), + ("1997", "kyoto"), ("1998", "kyoto_testnet"), ("2000", "doge"), ("2001", "milkomeda_c1"), ("2002", "milkomeda_a1"), + ("2004", "metalink"), ("2008", "cloudwalk_testnet"), ("2009", "cloudwalk"), + ("2013", "panarchy"), + ("2014", "now_testnet"), ("2016", "mainnetz"), + ("2017", "adiri"), ("2018", "publicmint_devnet"), ("2019", "publicmint_testnet"), ("2020", "publicmint"), ("2021", "edgeware_edgeevm"), ("2022", "beresheet_bereevm_testnet"), ("2023", "taycan_testnet"), + ("2024", "swan_saturn_testnet"), ("2025", "rangers_protocol"), + ("2026", "edgeless"), ("2031", "centrifuge"), ("2032", "catalyst"), ("2035", "phala"), ("2037", "kiwi_subnet"), ("2038", "shrapnel_testnet"), - ("2043", "origintrail_para"), + ("2039", "aleph_zero_testnet"), + ("2040", "vanar"), + ("2043", "neuroweb"), ("2044", "shrapnel_subnet"), + ("2045", "aiw3"), ("2047", "stratos_testnet"), ("2048", "stratos"), ("2049", "movo"), @@ -511,14 +642,20 @@ pub fn get_network_names() -> HashMap { ("2100", "ecoball"), ("2101", "ecoball_testnet_espuma"), ("2109", "exosama"), + ("2112", "u"), + ("2121", "catena"), ("2122", "metaplayerone"), ("2124", "metaplayerone_dubai_testnet"), + ("2136", "bigshortbets_testnet"), ("2137", "bigshortbets"), ("2138", "defi_oracle_meta_testnet"), + ("2140", "oneness"), + ("2141", "oneness_testnet"), ("2151", "bosagora"), ("2152", "findora"), ("2153", "findora_testnet"), ("2154", "findora_forge"), + ("2162", "anime_testnet"), ("2199", "moonsama"), ("2202", "antofy"), ("2203", "bitcoin_evm"), @@ -530,52 +667,86 @@ pub fn get_network_names() -> HashMap { ("2300", "bomb"), ("2306", "ebro"), ("2309", "arevia"), + ("2311", "chronicle_vesuvius___lit_protocol_testnet"), ("2323", "soma_testnet"), ("2330", "altcoin"), + ("2331", "rss3_vsl_sepolia_testnet"), ("2332", "soma"), + ("2340", "atleta_olympia"), + ("2342", "omnia"), + ("2355", "silicon_zkevm"), ("2358", "kroma_sepolia"), + ("2370", "nexis_testnet"), ("2399", "bomb_testnet"), ("2400", "tcg_verse"), + ("2410", "karak"), ("2415", "xodex"), - ("2458", "hybrid_testnet"), + ("2425", "king_of_legends"), + ("2442", "polygon_zkevm_cardona_testnet"), ("2468", "hybrid"), ("2484", "unicorn_ultra_nebulas_testnet"), + ("2511", "karak_goerli"), ("2522", "fraxtal_testnet"), + ("2525", "inevm"), ("2559", "kortho"), ("2569", "techpay"), ("2606", "pocrnet"), ("2611", "redlight"), ("2612", "ez_c"), ("2613", "ez_c_testnet"), - ("2625", "whitebit_testnet"), + ("2625", "white_testnet"), + ("2648", "ailayer_testnet"), + ("2649", "ailayer"), + ("2662", "apex"), ("2710", "morph_testnet"), ("2718", "k_laos"), + ("2730", "xr_sepolia"), + ("2731", "elizabeth_testnet"), + ("2748", "nanon"), + ("2777", "gm"), + ("2810", "morph_holesky"), + ("2882", "chips"), ("2888", "boba_goerli_testnet"), + ("2907", "elux"), + ("2911", "hy"), + ("2941", "xenon_testnet"), ("2999", "bityuan"), ("3000", "cennznet_rata"), ("3001", "cennznet_nikau"), ("3003", "canxium"), ("3011", "playa3ull_games"), ("3031", "orlando"), + ("3033", "rebus_testnet"), ("3068", "bifrost"), + ("3073", "movement_evm"), + ("3084", "xl_testnet"), ("3100", "immu3_evm"), ("3102", "vulture_evm_beta"), + ("3109", "satoshivm_alpha"), + ("3110", "satoshivm_testnet"), ("3141", "filecoin___hyperspace_testnet"), ("3269", "dubxcoin"), ("3270", "dubxcoin_testnet"), ("3306", "debounce_subnet_testnet"), ("3331", "zcore_testnet"), - ("3333", "web3q_testnet"), + ("3333", "ethstorage_testnet"), ("3334", "web3q_galileo"), + ("3335", "ethstorage"), + ("3338", "peaq"), ("3400", "paribu_net"), + ("3424", "evolve"), ("3434", "secure_testnet"), + ("3456", "layeredge_testnet"), + ("3490", "gtcscan"), ("3500", "paribu_net_testnet"), ("3501", "jfin"), ("3601", "pandoproject"), ("3602", "pandoproject_testnet"), + ("3630", "tycooncoin"), ("3636", "botanix_testnet"), ("3637", "botanix"), ("3639", "i"), + ("3645", "i_testnet"), ("3666", "jouleverse"), ("3690", "bittex"), ("3693", "empire"), @@ -583,6 +754,7 @@ pub fn get_network_names() -> HashMap { ("3699", "senjepowers"), ("3701", "xpla_testnet"), ("3737", "crossbell"), + ("3776", "astar_zkevm"), ("3797", "alvey"), ("3799", "tangle_testnet"), ("3885", "fire_zkevm_ghostrider"), @@ -592,23 +764,32 @@ pub fn get_network_names() -> HashMap { ("3939", "dos_tesnet"), ("3966", "dyno"), ("3967", "dyno_testnet"), + ("3993", "apex_testnet"), ("3999", "yuan"), ("4000", "ozone"), ("4001", "peperium_testnet"), ("4002", "fantom_testnet"), ("4003", "x1_fastnet"), + ("4040", "carbonium_testnet"), + ("4048", "gan_testnet"), ("4051", "bobaopera_testnet"), + ("4058", "bahamut_ocean"), ("4061", "nahmii_3"), ("4062", "nahmii_3_testnet"), ("4078", "muster"), + ("4080", "tobe"), ("4090", "fastex_bahamut_oasis_testnet"), ("4096", "bitindi_testnet"), ("4099", "bitindi"), ("4102", "aioz_testnet"), ("4139", "humans.ai_testnet"), ("4141", "tipboxcoin_testnet"), + ("4157", "crossfi_testnet"), + ("4162", "sx_rollup"), ("4181", "phi_v1"), + ("4200", "merlin"), ("4201", "lukso_testnet"), + ("4202", "lisk_sepolia_testnet"), ("4242", "nexi"), ("4243", "nexi_v2"), ("4328", "bobafuji_testnet"), @@ -616,10 +797,15 @@ pub fn get_network_names() -> HashMap { ("4400", "credit"), ("4444", "htmlcoin"), ("4460", "orderly_sepolia_testnet"), + ("4488", "hydra"), + ("4544", "emoney_testnet"), + ("4613", "very"), + ("4653", "gold"), ("4689", "iotex"), ("4690", "iotex_testnet"), ("4759", "meverse_testnet"), ("4777", "blackfort_exchange_testnet"), + ("4801", "world_sepolia_testnet"), ("4893", "globel"), ("4918", "venidium_testnet"), ("4919", "venidium"), @@ -629,6 +815,17 @@ pub fn get_network_names() -> HashMap { ("5002", "treasurenet_alpha"), ("5003", "mantle_sepolia_testnet"), ("5005", "treasurenet_testnet"), + ("5039", "onigiri_test_subnet"), + ("5040", "onigiri_subnet"), + ("5051", "nollie_skate_testnet"), + ("5100", "syndicate_testnet"), + ("5101", "syndicate_frame"), + ("5102", "sic_testnet"), + ("5103", "coordinape_testnet"), + ("5104", "charmverse_testnet"), + ("5105", "superloyalty_testnet"), + ("5106", "azra_testnet"), + ("5112", "ham"), ("5165", "bahamut"), ("5169", "smart_layer"), ("5177", "tl"), @@ -636,52 +833,78 @@ pub fn get_network_names() -> HashMap { ("5234", "humanode"), ("5290", "fire_old"), ("5315", "uzmi"), + ("5317", "optrust_testnet"), + ("5321", "itx_testnet"), + ("5333", "netsbo"), ("5353", "tritanium_testnet"), + ("5372", "settlus_testnet"), + ("5424", "edexa"), + ("5439", "ego"), ("5522", "vex_evm_testnet"), - ("5551", "nahmii"), - ("5553", "nahmii_testnet"), + ("5551", "nahmii_2"), + ("5553", "nahmii_2_testnet"), ("5555", "verse"), ("5611", "opbnb_testnet"), + ("5615", "arcturus_testneet"), ("5616", "arcturus_testnet"), - ("5678", "tanssi_evm_container"), + ("5656", "qie_block"), + ("5675", "filenova_testnet"), + ("5678", "tanssi_demo"), ("5700", "syscoin_tanenbaum_testnet"), ("5729", "hika_testnet"), ("5758", "satoshi_testnet"), ("5777", "ganache"), + ("5845", "tangle"), ("5851", "ontology_testnet"), ("5869", "wego_rubidium"), + ("6000", "bouncebit_testnet"), + ("6001", "bouncebit"), ("6065", "tres_testnet"), ("6066", "tres"), ("6102", "cascadia_testnet"), ("6118", "uptn_testnet"), ("6119", "uptn"), + ("6283", "laos"), + ("6321", "aura_euphoria_testnet"), + ("6322", "aura"), ("6363", "digit_soul"), + ("6398", "connext_sepolia"), ("6502", "peerpay"), + ("6550", "flamma_testnet"), ("6552", "scolcoin_wei_testnet"), ("6565", "fox_testnet"), ("6626", "pixie"), ("6660", "latest_testnet"), ("6661", "cybria"), ("6666", "cybria_testnet"), + ("6678", "edgamatrix"), ("6688", "irishub"), + ("6699", "ox"), ("6701", "paxb"), ("6779", "compverse"), - ("6789", "gold"), + ("6805", "race"), + ("6806", "race_testnet"), + ("6868", "pools"), ("6969", "tomb"), ("6999", "polysmart"), ("7000", "zeta"), - ("7001", "zeta_athens_3_testnet"), + ("7001", "zeta_testnet"), ("7007", "bst"), ("7027", "ella_the_heart"), ("7070", "planq"), + ("7077", "planq_atlas_testnet"), ("7100", "nume"), ("7118", "help_the_homeless"), ("7171", "bitrock"), + ("7222", "nibiru_devnet_3"), + ("7244", "zeus_testnet"), + ("7300", "xpla_verse"), ("7331", "klyntar"), ("7332", "horizen_eon"), ("7341", "shyft"), ("7484", "raba"), ("7518", "meverse"), + ("7560", "cyber"), ("7575", "adil_testnet"), ("7576", "adil_v2"), ("7668", "the_root"), @@ -689,15 +912,27 @@ pub fn get_network_names() -> HashMap { ("7700", "canto"), ("7701", "canto_tesnet"), ("7771", "bitrock_testnet"), + ("7774", "gdcc"), + ("7775", "gdcc_testnet"), + ("7776", "pandasea"), ("7777", "rise_of_the_warbots_testnet"), + ("7778", "orenium_protocol"), + ("7798", "openex_long_testnet"), ("7860", "maal_testnet"), + ("7862", "maal_v2"), + ("7863", "maal_testnet_v2"), ("7878", "hazlor_testnet"), ("7887", "kinto"), ("7895", "ardenium_athena"), + ("7923", "dot_blox"), + ("7924", "mo"), ("7979", "dos"), ("8000", "teleport"), ("8001", "teleport_testnet"), + ("8008", "polynomial"), ("8029", "mdgl_testnet"), + ("8047", "boat"), + ("8054", "karak_sepolia"), ("8080", "shardeum_liberty_1.x"), ("8081", "shardeum_liberty_2.x"), ("8082", "shardeum_sphinx_1.x"), @@ -713,11 +948,15 @@ pub fn get_network_names() -> HashMap { ("8181", "testnet_beone"), ("8192", "torus"), ("8194", "torus_testnet"), - ("8217", "klaytn_cypress"), + ("8217", "kaia"), + ("8227", "space_subnet"), ("8272", "blockton_block"), ("8285", "korthotest"), + ("8329", "lorenzo"), + ("8333", "b3"), ("8387", "dracones_financial_services"), ("8453", "base"), + ("8545", "chakra_testnet"), ("8654", "toki"), ("8655", "toki_testnet"), ("8668", "hela_official_runtime"), @@ -725,28 +964,45 @@ pub fn get_network_names() -> HashMap { ("8724", "tool_global_testnet"), ("8726", "storage"), ("8727", "storage_testnet"), + ("8732", "bullions"), ("8738", "alph"), ("8768", "tmy"), + ("8822", "iota_evm"), + ("8844", "hydra_testnet"), ("8848", "maro_block"), + ("8866", "superlumio"), + ("8869", "lif3"), ("8880", "unique"), ("8881", "quartz_by_unique"), ("8882", "opal_testnet_by_unique"), ("8883", "sapphire_by_unique"), + ("8886", "avenium_testnet"), ("8888", "xana"), ("8889", "vyvo"), + ("8890", "orenium_testnet_protocol"), ("8898", "mammoth"), ("8899", "jib"), + ("8911", "algen"), + ("8912", "algen_testnet"), + ("8921", "algen_layer2"), + ("8922", "algen_layer2_testnet"), ("8989", "giant_mammoth"), ("8995", "bloxberg"), ("9000", "evmos_testnet"), ("9001", "evmos"), + ("9007", "shido_testnet_block"), + ("9008", "shido_block"), ("9012", "berylbit"), - ("9024", "nexa_block"), + ("9024", "nexa_testnet_block"), + ("9025", "nexa_block"), ("9100", "genesis_coin"), ("9170", "rinia_testnet_old"), ("9223", "codefin"), ("9339", "dogcoin_testnet"), + ("9372", "oasys_testnet"), + ("9393", "dela_sepolia_testnet"), ("9395", "evoke"), + ("9496", "weavevm_testnet"), ("9527", "rangers_protocol_testnet_robin"), ("9528", "qeasyweb3_testnet"), ("9559", "neonlink_testnet"), @@ -754,90 +1010,146 @@ pub fn get_network_names() -> HashMap { ("9728", "boba_bnb_testnet"), ("9768", "mainnetz_testnet"), ("9779", "pepenetwork"), + ("9789", "tabi_testnet"), ("9790", "carbon_evm"), ("9792", "carbon_evm_testnet"), + ("9797", "optimusz7"), ("9818", "imperium_testnet"), ("9819", "imperium"), + ("9876", "binary_testnet"), ("9888", "dogelayer"), + ("9898", "larissa"), + ("9911", "espento"), ("9977", "mind_testnet"), ("9980", "combo"), + ("9981", "volley"), ("9990", "agung"), - ("9996", "mind"), ("9997", "altlayer_testnet"), + ("9998", "ztc"), ("9999", "myown_testnet"), ("10000", "smart_bitcoin_cash"), ("10001", "smart_bitcoin_cash_testnet"), ("10024", "gon"), ("10081", "japan_open_testnet"), ("10086", "sjatsh"), + ("10096", "metanova_verse"), ("10101", "block_genesis"), ("10200", "gnosis_chiado_testnet"), ("10201", "maxx"), + ("10222", "glscan"), ("10242", "arthera"), ("10243", "arthera_testnet"), ("10248", "0xtade"), + ("10321", "tao_evm"), + ("10324", "tao_evm_testnet"), ("10395", "worldland_testnet"), ("10507", "numbers"), ("10508", "numbers_testnet"), ("10823", "cryptocoinpay"), + ("10849", "lamina1"), + ("10850", "lamina1_identity"), ("10946", "quadrans_block"), ("10947", "quadrans_block_testnet"), + ("11011", "shape_sepolia_testnet"), ("11110", "astra"), ("11111", "wagmi"), ("11115", "astra_testnet"), ("11119", "hashbit"), + ("11124", "abstract_testnet"), + ("11221", "shine"), + ("11227", "jiritsu_testnet_subnet"), ("11235", "haqq"), ("11437", "shyft_testnet"), + ("11501", "bevm"), + ("11503", "bevm_testnet"), + ("11521", "sats"), ("11612", "sardis_testnet"), - ("11888", "sanr"), + ("11822", "artela_testnet"), ("11891", "polygon_supernet_arianee"), + ("12001", "fuse_testnet"), ("12009", "satoshi"), + ("12020", "aternos"), ("12051", "singularity_zero_testnet"), ("12052", "singularity_zero"), ("12123", "brc"), ("12306", "fibonacci"), ("12321", "blg_testnet"), + ("12324", "l3x_protocol"), + ("12325", "l3x_protocol_testnet"), ("12345", "step_testnet"), - ("12611", "astar_zkevm"), + ("12553", "rss3_vsl"), ("12715", "rikeza_testnet"), + ("12781", "playdapp_testnet"), ("12890", "quantum_testnet"), + ("12898", "playfair_testnet_subnet"), ("13000", "sps"), ("13337", "beam_testnet"), ("13371", "immutable_zkevm"), ("13381", "phoenix"), + ("13396", "masa"), ("13473", "immutable_zkevm_testnet"), + ("13505", "gravity_alpha_testnet_sepolia"), + ("13600", "kronobit"), ("13812", "susono"), ("14000", "sps_testnet"), + ("14324", "evolve_testnet"), + ("14333", "vitruveo_testnet"), + ("14801", "vana_satori_testnet"), ("14853", "humanode_testnet_5_israfel"), ("15003", "immutable_zkevm_devnet"), + ("15257", "poodl_testnet"), + ("15259", "poodl"), + ("15430", "kymtc"), ("15551", "loopnetwork"), ("15555", "trust_evm_testnet"), ("15557", "eos_evm_testnet"), ("16000", "metadot"), ("16001", "metadot_testnet"), + ("16116", "defiverse"), + ("16180", "plyr_phi"), + ("16350", "incentiv_devnet"), + ("16481", "pivotal_sepolia"), ("16507", "genesys"), + ("16600", "0g_newton_testnet"), ("16688", "irishub_testnet"), ("16718", "airdao"), ("16888", "ivar_testnet"), ("17000", "holesky"), ("17001", "redstone_holesky_testnet"), + ("17069", "garnet_holesky"), + ("17071", "on_points"), + ("17117", "defiverse_testnet"), ("17171", "g8"), ("17172", "eclipse_subnet"), ("17180", "palette_testnet"), + ("17217", "konet"), ("17777", "eos_evm"), ("18000", "frontier_of_dreams_testnet"), ("18122", "smart_trades"), ("18159", "proof_of_memes"), ("18181", "g8_testnet"), - ("18686", "mxc_zkevm"), + ("18231", "unreal_old"), + ("18233", "unreal"), + ("18686", "mxc_zkevm_moon"), + ("18888", "titan_tkx"), + ("18889", "titan_tkx_testnet"), ("19011", "home_verse"), + ("19077", "blockx_atlantis_testnet"), + ("19191", "blockx"), + ("19224", "decentraconnect_social"), ("19527", "magnet"), + ("19600", "lbry"), ("19845", "btcix"), ("20001", "camelark"), + ("20041", "niza"), + ("20073", "niza_testnet"), ("20729", "callisto_testnet"), ("20736", "p12"), ("20765", "jono11_subnet"), + ("21004", "c4ei"), ("21133", "all_about_healthy"), + ("21223", "dcpay"), + ("21224", "dcpay_testnet"), ("21337", "cennznet_azalea"), ("21816", "om"), ("21912", "bsl"), @@ -845,72 +1157,114 @@ pub fn get_network_names() -> HashMap { ("22040", "airdao_testnet"), ("22222", "nautilus"), ("22324", "goldx_testnet"), - ("22776", "map"), + ("22776", "map_protocol"), ("23006", "antofy_testnet"), ("23118", "opside_testnet"), ("23294", "oasis_sapphire"), ("23295", "oasis_sapphire_testnet"), + ("23451", "dreyerx"), + ("23452", "dreyerx_testnet"), ("23888", "blast_testnet"), + ("24076", "kymtc_testnet"), ("24484", "web"), ("24734", "mintme.com"), ("25186", "liquidlayer"), + ("25839", "alvey_testnet"), ("25888", "hammer"), ("25925", "bitkub_testnet"), ("26026", "ferrum_testnet"), ("26600", "hertz"), ("26863", "oasis"), + ("27181", "klaos_nova"), + ("27483", "nanon_sepolia"), + ("27827", "zeroone_subnet"), + ("28516", "vizing_testnet"), + ("28518", "vizing"), ("28528", "optimism_bedrock_goerli_alpha_testnet"), + ("28882", "boba_sepolia"), + ("29112", "hy_testnet"), + ("29223", "nexa_metanet"), + ("29536", "kai_testnet"), ("29548", "mch_verse"), ("30067", "piece_testnet"), + ("30088", "miyou"), ("30103", "cerium_testnet"), + ("30730", "movement_evm_legacy"), + ("30731", "movement_evm_devnet"), + ("30732", "movement_evm_testnet"), ("31102", "ethersocial"), ("31223", "cloudtx"), ("31224", "cloudtx_testnet"), ("31337", "go_testnet"), ("31414", "evoke_testnet"), ("31415", "filecoin___wallaby_testnet"), + ("31753", "x"), + ("31754", "x_testnet"), ("32001", "w3gamez_holesky_testnet"), + ("32382", "santiment_intelligence"), ("32520", "bitgert"), ("32659", "fusion"), ("32769", "zilliqa_evm"), ("32990", "zilliqa_evm_isolated_server"), + ("33033", "entangle"), ("33101", "zilliqa_evm_testnet"), + ("33103", "zilliqa_2_evm_proto_testnet"), + ("33111", "curtis"), + ("33133", "entangle_testnet"), ("33210", "cloudverse_subnet"), ("33333", "aves"), ("33385", "zilliqa_evm_devnet"), + ("33401", "slingshot"), ("33469", "zilliqa_2_evm_devnet"), + ("33979", "funki"), ("34443", "mode"), + ("34504", "zeus"), ("35011", "j2o_taro"), ("35441", "q"), ("35443", "q_testnet"), ("38400", "connectormanager"), ("38401", "connectormanager_robin"), + ("39656", "prm"), ("39797", "energi"), ("39815", "oho"), + ("41455", "aleph_zero_evm"), ("41500", "opulent_x_beta"), ("42069", "pegglecoin"), + ("42072", "agentlayer_testnet"), ("42161", "arbitrum_one"), ("42170", "arbitrum_nova"), ("42220", "celo"), ("42261", "oasis_emerald_testnet"), ("42262", "oasis_emerald"), ("42355", "goldx"), + ("42421", "asset_testnet"), ("42766", "zkfair"), + ("42793", "etherlink"), ("42801", "gesoten_verse_testnet"), ("42888", "kinto_testnet"), ("43110", "athereum"), + ("43111", "hemi"), ("43113", "avalanche_fuji_testnet"), ("43114", "avalanche_c"), ("43288", "boba_avax"), ("43851", "zkfair_testnet"), ("44444", "fren"), + ("44445", "quantum"), ("44787", "celo_alfajores_testnet"), ("45000", "autobahn"), + ("45454", "swamps_l2"), ("45510", "deelance"), + ("45513", "blessnet"), ("46688", "fusion_testnet"), + ("47763", "neo_x"), + ("47803", "redefi_layer_1"), ("47805", "rei"), + ("48795", "space_subnet_testnet"), + ("48899", "zircuit_testnet"), + ("48900", "zircuit"), ("49049", "wireshape_floripa_testnet"), ("49088", "bifrost_testnet"), + ("49321", "gunz_testnet"), ("49797", "energi_testnet"), ("50001", "liveplex_oracleevm"), ("50005", "yooldo_verse"), @@ -919,30 +1273,52 @@ pub fn get_network_names() -> HashMap { ("51178", "lumoz_testnet_alpha"), ("51712", "sardis"), ("52014", "electroneum"), + ("53277", "doid"), + ("53302", "superseed_sepolia_testnet"), + ("53457", "dodo_testnet"), ("53935", "dfk"), ("54211", "haqq_testnet"), ("54321", "toronet_testnet"), ("55004", "titan"), + ("55551", "photon_aurora_testnet"), ("55556", "rei_testnet"), + ("55614", "flamma"), + ("56026", "lambda"), ("56288", "boba_bnb"), + ("56400", "testnet_zeroone_subnet"), ("56789", "velo_labs"), + ("56797", "doid_testnet"), ("57000", "rollux_testnet"), + ("57451", "coinsec"), ("58008", "sepolia_pgn_public_goods"), - ("59140", "linea_testnet"), + ("59140", "linea_goerli"), + ("59141", "linea_sepolia"), ("59144", "linea"), + ("59902", "metis_sepolia_testnet"), ("59971", "genesys_code"), ("60000", "thinkium_testnet_0"), ("60001", "thinkium_testnet_1"), ("60002", "thinkium_testnet_2"), ("60103", "thinkium_testnet_103"), + ("60808", "bob"), + ("61022", "orange"), + ("61406", "kai"), ("61800", "axel_dev_net"), ("61803", "etica"), ("61916", "doken_super"), + ("62049", "optopia_testnet"), + ("62050", "optopia"), + ("62298", "citrea_devnet"), ("62320", "celo_baklava_testnet"), ("62621", "multivac"), + ("62831", "plyr_tau_testnet"), + ("62850", "laos_sigma_testnet"), ("63000", "ecredits"), ("63001", "ecredits_testnet"), + ("65349", "cratd2c_testnet"), + ("65357", "vecno"), ("65450", "scolcoin"), + ("65536", "automata"), ("66988", "janus_testnet"), ("67390", "siriusnet"), ("67588", "cosmic"), @@ -952,25 +1328,38 @@ pub fn get_network_names() -> HashMap { ("70001", "thinkium_1"), ("70002", "thinkium_2"), ("70103", "thinkium_103"), + ("70700", "proof_of_play___apex"), ("71111", "guapcoinx"), ("71393", "polyjuice_testnet"), ("71401", "godwoken_testnet_v1"), ("71402", "godwoken"), + ("72778", "caga_crypto_ankara_testnet"), ("72992", "grok"), + ("73114", "icb_testnet"), + ("73115", "icb"), ("73799", "energy_web_volta_testnet"), ("73927", "mixin_virtual_machine"), ("75000", "resincoin"), + ("75512", "geek_verse"), + ("75513", "geek_verse_testnet"), + ("77001", "bora"), ("77238", "foundry_testnet"), ("77612", "vention"), + ("77677", "cycle_sailboat"), ("77777", "toronet"), ("78110", "firenze_test"), ("78281", "dragonfly_hexapod"), ("78430", "amplify_subnet"), ("78431", "bulletin_subnet"), ("78432", "conduit_subnet"), + ("78600", "vanguard"), ("79879", "gold_testnet"), ("80001", "mumbai"), + ("80002", "amoy"), + ("80008", "polynomia_sepolia"), + ("80084", "bera_bartio"), ("80085", "bera_artio"), + ("80096", "hizoco"), ("81041", "nordek"), ("81341", "amana_testnet"), ("81342", "amana_mixnet"), @@ -981,23 +1370,38 @@ pub fn get_network_names() -> HashMap { ("81361", "mizana_testnet"), ("81362", "mizana_mixnet"), ("81363", "mizana_privnet"), - ("81720", "quantum"), ("82459", "smart_layer_testnet"), + ("83144", "xprotocol_testnet"), + ("83872", "zedxion"), ("84531", "base_goerli_testnet"), ("84532", "base_sepolia_testnet"), ("84886", "aerie"), ("85449", "cybertrust"), ("88002", "nautilus_proteus_testnet"), + ("88559", "inoai"), + ("88800", "zkasino"), + ("88817", "unit_zero_testnet"), + ("88819", "unit_zero_stagenet"), ("88880", "chiliz_scoville_testnet"), - ("88888", "ivar"), + ("88882", "chiliz_spicy_testnet"), + ("88888", "chiliz"), + ("90001", "fxcore_testnet"), ("90210", "beverly_hills"), + ("90354", "camp_testnet"), ("91002", "nautilus_trition"), + ("91120", "metadap_enterprise"), ("91715", "combo_testnet"), ("92001", "lambda_testnet"), ("93572", "liquidlayer_testnet"), + ("93747", "stratovm_testnet"), ("96970", "mantis_testnet_hexapod"), ("97288", "boba_bnb_old"), + ("97435", "slingshot_testnet"), + ("97531", "green_testnet"), + ("97970", "optimusz7_testnet"), + ("98881", "ebi"), ("99099", "eliberty_testnet"), + ("99876", "edgamatrix_testnet"), ("99998", "ubtestnet"), ("99999", "ub"), ("100000", "quark_root"), @@ -1011,8 +1415,13 @@ pub fn get_network_names() -> HashMap { ("100008", "quark_shard_7"), ("100009", "ve"), ("100010", "ve_testnet"), - ("101010", "soverun_testnet"), + ("100011", "quark_l2"), + ("101010", "global_trust"), + ("102031", "creditcoin_testnet"), ("103090", "crystaleum"), + ("103454", "masa_testnet"), + ("104566", "kaspaclassic"), + ("105105", "stratis"), ("108801", "bro"), ("110000", "quark_devnet_root"), ("110001", "quark_devnet_shard_0"), @@ -1023,60 +1432,101 @@ pub fn get_network_names() -> HashMap { ("110006", "quark_devnet_shard_5"), ("110007", "quark_devnet_shard_6"), ("110008", "quark_devnet_shard_7"), + ("110011", "quark_l2_testnet"), + ("110110", "mars_credit"), ("111000", "siberium_test"), ("111111", "siberium"), + ("111188", "re.al"), ("112358", "meta_one"), + ("119139", "metadap_enterprise_testnet"), + ("123321", "gem"), ("123456", "adil_devnet"), ("128123", "etherlink_testnet"), + ("131313", "odyssey_testnet"), ("131419", "etnds"), + ("132902", "form_testnet"), + ("141319", "magape_testnet"), ("142857", "icplaza"), + ("161212", "playfi"), + ("165279", "eclat"), + ("167000", "taiko"), ("167004", "taiko_alpha_2_testnet"), ("167005", "taiko_grimsvotn_l2"), ("167006", "taiko_eldfell_l3"), ("167007", "taiko_jolnir_l2"), ("167008", "taiko_katla_l2"), + ("167009", "taiko_hekla_l2"), + ("175177", "chronicle___lit_protocol_testnet"), + ("175188", "chronicle_yellowstone___lit_protocol_testnet"), ("188710", "bitica"), ("188881", "condor_test"), + ("199991", "mazze_testnet"), + ("200000", "xfair.ai_testnet"), ("200101", "milkomeda_c1_testnet"), ("200202", "milkomeda_a1_testnet"), ("200625", "akroma"), + ("200810", "bitlayer_testnet"), + ("200901", "bitlayer"), ("201018", "alaya"), ("201030", "alaya_dev_testnet"), ("201804", "mythical"), ("202020", "decimal_testnet"), ("202212", "x1_devnet"), + ("202401", "ymtech_besu_testnet"), ("202624", "jellie"), ("204005", "x1_network"), + ("205205", "auroria_testnet"), + ("210049", "gitagi_atlas_testnet"), ("210425", "platon"), ("220315", "mas"), ("221230", "reap"), ("221231", "reap_testnet"), + ("222222", "hydradx"), + ("222555", "deepl"), + ("222666", "deepl_testnet"), ("224168", "taf_eco"), ("224422", "conet_sebolia_testnet"), ("224433", "conet_holesky"), - ("230315", "hashkey_testnet"), + ("229772", "abyss_protocol"), + ("230315", "hashkey_testnetdiscard"), ("234666", "haymo_testnet"), + ("240515", "orange_testnet"), ("246529", "artis_sigma1"), ("246785", "artis_testnet_tau1"), ("247253", "saakuru_testnet"), ("256256", "cmp"), + ("262371", "eclat_testnet"), ("266256", "gear_zero_testnet"), ("271271", "egoncoin_testnet"), ("281121", "social"), + ("282828", "zillion_sepolia_testnet"), + ("292003", "cipherem_testnet"), + ("309075", "one_world"), + ("313313", "saharaai_testnet"), ("314159", "filecoin___calibration_testnet"), + ("322202", "parex"), + ("323213", "bloom_genesis_testnet"), + ("327126", "waba_testnet"), + ("328527", "nal"), ("330844", "ttcoin"), + ("333313", "bloom_genesis"), ("333331", "aves_testnet"), ("333333", "nativ3_testnet"), ("333666", "oone_testnet"), ("333777", "oone_devnet"), ("333888", "polis_testnet"), ("333999", "polis"), + ("336655", "up_testnet"), + ("336666", "up"), + ("355110", "bitfinity"), ("355113", "bitfinity_testnet"), + ("360890", "lavita"), ("363636", "digit_soul_2"), ("373737", "hap_testnet"), ("381931", "metal_c"), ("381932", "metal_tahoe_c"), ("404040", "tipboxcoin"), + ("413413", "aie_testnet"), ("420420", "kek"), ("420666", "kek_kektest"), ("420692", "alterium_l2_testnet"), @@ -1087,31 +1537,60 @@ pub fn get_network_names() -> HashMap { ("431140", "markr_go"), ("432201", "dexalot_subnet_testnet"), ("432204", "dexalot_subnet"), + ("444444", "syndr_l3_sepolia"), ("444900", "weelink_testnet"), ("471100", "patex_sepolia_testnet"), ("473861", "ultra_pro"), ("474142", "open"), + ("486487", "gobbl_testnet"), + ("490000", "autonomys_testnet_nova_domain"), + ("504441", "playdapp"), ("512512", "cmp_testnet"), - ("513100", "ethereum_fair"), + ("513100", "dis"), + ("526916", "docoin_community"), ("534351", "scroll_sepolia_testnet"), ("534352", "scroll"), ("534353", "scroll_alpha_testnet"), ("534354", "scroll_pre_alpha_testnet"), ("534849", "shinarium_beta"), ("535037", "beaneco_smart"), + ("552981", "one_world_testnet"), + ("555555", "pentagon_testnet"), + ("555666", "eclipse_testnet"), ("622277", "hypra"), + ("622463", "atlas"), ("641230", "bear"), ("651940", "all"), + ("656476", "open_campus_codex"), + ("660279", "xai"), ("666666", "vision___vpioneer_test"), ("666888", "hela_official_runtime_testnet"), + ("686868", "won"), + ("696969", "galadriel_devnet"), + ("710420", "tiltyard_subnet"), + ("713715", "sei_devnet"), + ("721529", "eram"), + ("743111", "hemi_sepolia"), ("751230", "bear_testnet"), + ("752024", "ternoa_testnet"), ("761412", "miexs_smart"), + ("764984", "lamina1_testnet"), + ("767368", "lamina1_identity_testnet"), ("776877", "modularium"), ("800001", "octaspace"), + ("808080", "biz_testnet"), + ("808813", "bob_sepolia"), + ("810180", "zklink_nova"), + ("810181", "zklink_nova_sepolia_testnet"), + ("810182", "zklink_nova_goerli_testnet"), + ("820522", "tsc_testnet"), ("827431", "curve"), + ("839320", "prm_testnet"), + ("840000", "runevm_testnet"), ("846000", "4goodnetwork"), ("855456", "dodao"), ("879151", "blocx"), + ("888882", "rexx"), ("888888", "vision"), ("900000", "posi_shard_0"), ("910000", "posi_testnet_shard_0"), @@ -1121,34 +1600,57 @@ pub fn get_network_names() -> HashMap { ("923018", "fncy_testnet"), ("955081", "jono12_subnet"), ("955305", "eluvio_content_fabric"), + ("978657", "treasure_ruby"), + ("984122", "forma"), + ("984123", "forma_sketchpad"), ("988207", "ecrox"), - ("1127469", "tiltyard_subnet"), + ("998899", "supernet_testnet"), + ("999999", "am"), + ("1100789", "netmind_testnet"), + ("1234567", "sharecle"), ("1261120", "zkatana"), ("1313114", "etho_protocol"), ("1313500", "xerom"), ("1337702", "kintsugi"), ("1337802", "kiln"), ("1337803", "zhejiang"), + ("1398243", "automata_testnet"), + ("1612127", "playfi_albireo_testnet"), + ("1637450", "xterio_testnet"), ("1731313", "turkey_demo_dev"), ("2021398", "debank_testnet"), ("2099156", "plian_main"), ("2206132", "platon_dev_testnet2"), ("2611555", "dpu"), + ("2702128", "xterio"), + ("3132023", "saharaai"), ("3141592", "filecoin___butterfly_testnet"), + ("3397901", "funki_sepolia_sandbox"), ("3441005", "manta_pacific_testnet"), + ("3441006", "manta_pacific_sepolia_testnet"), ("4000003", "altlayer_zero_gas"), ("4281033", "worlds_caldera"), + ("4444444", "altar_testnet"), + ("4457845", "zero_testnet_sepolia"), + ("5112023", "numblock"), ("5167003", "mxc_wannsee_zkevm_testnet"), + ("5167004", "moon_geneva_testnet"), ("5201420", "electroneum_testnet"), + ("5318008", "reactive_kopli"), ("5555555", "imversed"), ("5555558", "imversed_testnet"), + ("6038361", "astar_zkyoto"), + ("6666665", "safeanwang"), + ("6666666", "safeanwang_testnet"), ("7225878", "saakuru"), ("7355310", "openvessel"), ("7668378", "ql1_testnet"), ("7762959", "musicoin"), ("7777777", "zora"), ("8007736", "plian_sub_1"), + ("8008135", "fhenix_helium"), ("8080808", "hokum"), + ("8601152", "waterfall_8_test"), ("8794598", "hap"), ("8888881", "quarix_testnet"), ("8888888", "quarix"), @@ -1156,15 +1658,30 @@ pub fn get_network_names() -> HashMap { ("9322253", "milvine"), ("10067275", "plian_testnet_sub_1"), ("10101010", "soverun"), + ("10241024", "alienx"), + ("10241025", "alienx_hal_testnet"), + ("11145513", "blessnet_sepolia"), ("11155111", "sepolia"), ("11155420", "op_sepolia_testnet"), + ("12052024", "memento_testnet"), + ("12227331", "neox_testnet_t3"), + ("12227332", "neox_testnet_t4"), + ("13068200", "coti_devnet"), ("13371337", "pep_churchill"), ("14288640", "andus"), ("16658437", "plian_testnet_main"), + ("18071918", "mande"), ("18289463", "iolite"), + ("19850818", "deepbrain_testnet"), + ("19880818", "deepbrain"), + ("20180427", "stability_testnet"), ("20180430", "smartmesh"), ("20181205", "quarkblock"), ("20201022", "pego"), + ("20230825", "vcity_testnet"), + ("20240324", "debank_sepolia_testnet"), + ("20240603", "dbk"), + ("20241133", "swan_proxima_testnet"), ("20482050", "hokum_testnet"), ("22052002", "excelon"), ("27082017", "excoincial_volta_testnet"), @@ -1174,42 +1691,64 @@ pub fn get_network_names() -> HashMap { ("29032022", "fla"), ("31415926", "filecoin___local_testnet"), ("35855456", "joys_digital"), + ("37084624", "skale_nebula_hub_testnet"), + ("39916801", "kingdom"), ("43214913", "maistestsubnet"), ("61717561", "aqua"), ("65010000", "autonity_bakerloo_thames_testnet"), ("65010001", "autonity_bakerloo_barada_testnet"), + ("65010002", "autonity_bakerloo_sumida_testnet"), + ("65010003", "autonity_bakerloo_yamuna_testnet"), ("65100000", "autonity_piccadilly_thames_testnet"), ("65100001", "autonity_piccadilly_barada_testnet"), + ("65100002", "autonity_piccadilly_sumida_testnet"), + ("65100003", "autonity_piccadilly_yamuna_testnet"), ("68840142", "frame_testnet"), + ("77787778", "0xhash_testnet"), + ("79479957", "sx_toronto_rollup"), + ("88558801", "backstop_testnet"), ("88888888", "t.e.a.m_block"), + ("94204209", "polygon_blackberry"), ("99415706", "joys_digital_testnet"), + ("108160679", "orai"), + ("111557560", "cyber_testnet"), + ("123420111", "op_celestia_raspberry"), + ("161221135", "plume_testnet"), ("168587773", "blast_sepolia_testnet"), ("192837465", "gather"), ("222000222", "kanazawa"), ("245022926", "neon_evm_devnet"), + ("245022929", "neon_evm_devnet_rollup"), ("245022934", "neon_evm"), ("245022940", "neon_evm_testnet"), ("278611351", "razor_skale"), ("311752642", "oneledger"), + ("328527624", "nal_sepolia_testnet"), ("333000333", "meld"), - ("344106930", "skale_calypso_hub_testnet"), ("356256156", "gather_testnet"), - ("476158412", "skale_europa_hub_testnet"), + ("476462898", "skopje_testnet"), ("486217935", "gather_devnet"), - ("503129905", "skale_nebula_hub_testnet"), + ("666666666", "degen"), ("888888888", "ancient8"), + ("889910245", "ptcescan_testnet"), + ("889910246", "ptcescan"), + ("974399131", "skale_calypso_hub_testnet"), ("999999999", "zora_sepolia_testnet"), + ("1020352220", "skale_titan_hub_testnet"), ("1122334455", "ipos"), ("1146703430", "cyberdecknet"), ("1273227453", "human_protocol"), ("1313161554", "aurora"), ("1313161555", "aurora_testnet"), ("1313161556", "aurora_betanet"), + ("1313161560", "powergold"), ("1350216234", "skale_titan_hub"), ("1351057110", "chaos_skale_testnet"), + ("1380012617", "rari"), ("1380996178", "raptor"), + ("1444673419", "skale_europa_hub_testnet"), ("1482601649", "skale_nebula_hub"), - ("1517929550", "skale_titan_hub_testnet"), + ("1511670449", "gpt"), ("1564830818", "skale_calypso_hub"), ("1666600000", "harmony_shard_0"), ("1666600001", "harmony_shard_1"), @@ -1219,18 +1758,27 @@ pub fn get_network_names() -> HashMap { ("1666700001", "harmony_testnet_shard_1"), ("1666900000", "harmony_devnet_shard_0"), ("1666900001", "harmony_devnet_shard_1"), + ("1802203764", "kakarot_sepolia"), + ("1903648807", "gemu_testnet"), + ("1918988905", "rari_testnet"), ("2021121117", "datahopper"), ("2046399126", "skale_europa_hub"), ("3125659152", "pirl"), ("4216137055", "oneledger_testnet_frankenstein"), ("11297108099", "palm_testnet"), ("11297108109", "palm"), + ("28872323069", "gitswarm_test"), + ("37714555429", "xai_testnet_v2"), + ("88153591557", "arbitrum_blueberry"), ("111222333444", "alphabet"), + ("123420000220", "fluence_stage"), ("197710212030", "ntity"), ("197710212031", "haradev_testnet"), + ("202402181627", "gm_testnet"), ("383414847825", "zeniq"), ("666301171999", "pdc"), ("6022140761023", "molereum"), + ("2713017997578000", "d_testnet"), ] .into_iter() .filter_map(|(chain_id, name)| match chain_id.try_into_chain_id() { From e4318f96b5094b3fcfcfdcd603f380886e6e3624 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 27 Aug 2024 11:06:38 -0700 Subject: [PATCH 80/85] bump to 0.2.1 --- python/mesc/__init__.py | 2 +- rust/Cargo.toml | 2 +- rust/README.md | 2 +- rust/crates/mesc_cli/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/mesc/__init__.py b/python/mesc/__init__.py index 5d6e603..8b0e8f0 100644 --- a/python/mesc/__init__.py +++ b/python/mesc/__init__.py @@ -39,4 +39,4 @@ else: 'get_global_metadata', ) -__version__ = '0.2.0' +__version__ = '0.2.1' diff --git a/rust/Cargo.toml b/rust/Cargo.toml index f5e759d..8210660 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" diff --git a/rust/README.md b/rust/README.md index aac84bc..75bb36d 100644 --- a/rust/README.md +++ b/rust/README.md @@ -16,7 +16,7 @@ The `crates/mesc_cli` crate is a tool for reading, writing, and validating MESC Inside a cargo project: `cargo add mesc` -Inside a `Cargo.toml`: `mesc = "0.2.0"` +Inside a `Cargo.toml`: `mesc = "0.2.1"` ## Example Usage diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 3c25d1c..40d34b3 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -19,7 +19,7 @@ edit = "0.1.4" futures = "0.3.29" inquire = "0.6.2" ipgeolocate = "0.3.6" -mesc = { version = "0.2.0", path = "../mesc" } +mesc = { version = "0.2.1", path = "../mesc" } reqwest = { version = "0.11.22", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } From 1ee7e21eeab7ac4b8f349cb25b39820b20c23f9a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:26:00 +0200 Subject: [PATCH 81/85] Update all Rust dependencies (#34) --- rust/Cargo.lock | 972 ++++++++++-------- rust/crates/mesc_cli/Cargo.toml | 6 +- .../cli/subcommands/setup/inquire_utils.rs | 2 +- rust/crates/mesc_cli/src/network.rs | 2 +- rust/crates/mesc_cli/src/printing.rs | 2 +- 5 files changed, 528 insertions(+), 456 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e69a8ea..0ba95c3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -4,24 +4,24 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -32,9 +32,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -56,9 +56,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -77,56 +77,57 @@ dependencies = [ [[package]] name = "ansi_colours" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1558bd2075d341b9ca698ec8eb6fcc55a746b1fc4255585aad5b141d918a80" +checksum = "14eec43e0298190790f41679fe69ef7a829d2a2ddd78c8c00339e84710e435fe" dependencies = [ "rgb", ] [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -134,9 +135,9 @@ dependencies = [ [[package]] name = "argminmax" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202108b46429b765ef483f8a24d5c46f48c14acfdacc086dd4ab6dddf6bcdbd2" +checksum = "52424b59d69d69d5056d508b260553afd91c57e21849579cd1f50ee8b8b88eaa" dependencies = [ "num-traits", ] @@ -176,18 +177,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -207,23 +208,23 @@ checksum = "9ae037714f313c1353189ead58ef9eec30a8e8dc101b2622d461418fd59e28a9" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -232,6 +233,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bat" version = "0.24.0" @@ -286,15 +293,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "brotli" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -313,9 +320,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", "regex-automata", @@ -335,35 +342,41 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.5.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] -name = "bytes" +name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "bytesize" @@ -373,12 +386,13 @@ checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -389,23 +403,23 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] name = "clap" -version = "4.4.18" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -413,9 +427,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -426,21 +440,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clircle" @@ -456,15 +470,15 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "colored_json" -version = "4.1.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79cff32df5cfea75e6484eeff0b4e48ad3977fb6582676a7862b3590dddc7a87" +checksum = "e35980a1b846f8e3e359fd18099172a0857140ba9230affc4f71348081e039b6" dependencies = [ "serde", "serde_json", @@ -473,13 +487,13 @@ dependencies = [ [[package]] name = "comfy-table" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" +checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm 0.27.0", "strum", - "strum_macros", + "strum_macros 0.26.4", "unicode-width", ] @@ -517,24 +531,24 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -569,9 +583,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -582,7 +596,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot", "signal-hook", "signal-hook-mio", @@ -595,7 +609,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "crossterm_winapi", "libc", "parking_lot", @@ -622,9 +636,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "edit" @@ -638,9 +652,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "encode_unicode" @@ -650,23 +664,23 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] [[package]] name = "enum_dispatch" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f33313078bb8d4d05a2733a94ac4c2d8a0df9a2b84424ebf4f33bfc224a890e" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -677,9 +691,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -716,15 +730,15 @@ checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "miniz_oxide", @@ -831,7 +845,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -865,10 +879,28 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.2.12" +name = "fuzzy-matcher" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -879,9 +911,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "git-version" @@ -900,16 +932,16 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "git2" -version = "0.18.1" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", "libgit2-sys", "log", @@ -924,22 +956,22 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", "log", "regex-automata", - "regex-syntax 0.8.2", + "regex-syntax", ] [[package]] name = "grep-cli" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea40788c059ab8b622c4d074732750bfb3bd2912e2dd58eabc11798a4d5ad725" +checksum = "47f1288f0e06f279f84926fa4c17e3fcd2a22b357927a82f2777f7be26e4cec0" dependencies = [ "bstr", "globset", @@ -951,9 +983,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -970,28 +1002,19 @@ dependencies = [ [[package]] name = "halfbrown" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5681137554ddff44396e5f149892c769d45301dd9aa19c51602a89ee214cb0ec" +checksum = "8588661a8607108a5ca69cab034063441a0413a0b041c13618a7dd348021ef6f" dependencies = [ - "hashbrown 0.13.2", + "hashbrown", "serde", ] [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -1005,10 +1028,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "hermit-abi" -version = "0.3.4" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1027,9 +1056,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1049,9 +1078,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -1061,9 +1090,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -1098,9 +1127,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1131,26 +1160,27 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown", ] [[package]] name = "inquire" -version = "0.6.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33e7c1ddeb15c9abcbfef6029d8e29f69b52b6d6c891031b88ed91b5065803b" +checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "crossterm 0.25.0", "dyn-clone", - "lazy_static", + "fuzzy-matcher", + "fxhash", "newline-converter", - "thiserror", + "once_cell", "unicode-segmentation", "unicode-width", ] @@ -1170,39 +1200,45 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lexical-core" @@ -1270,15 +1306,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libgit2-sys" -version = "0.16.1+1.7.1" +version = "0.16.2+1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" dependencies = [ "cc", "libc", @@ -1294,9 +1330,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libz-sys" -version = "1.1.15" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "libc", @@ -1304,15 +1340,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "line-wrap" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -dependencies = [ - "safemem", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1321,15 +1348,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1337,15 +1364,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lz4" -version = "1.24.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" dependencies = [ "libc", "lz4-sys", @@ -1353,9 +1380,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" dependencies = [ "cc", "libc", @@ -1363,9 +1390,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -1378,7 +1405,7 @@ dependencies = [ [[package]] name = "mesc" -version = "0.2.0" +version = "0.2.1" dependencies = [ "serde", "serde_json", @@ -1387,7 +1414,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.2.0" +version = "0.2.1" dependencies = [ "bat", "clap", @@ -1414,18 +1441,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -1434,10 +1461,22 @@ dependencies = [ ] [[package]] -name = "multiversion" -version = "0.7.3" +name = "mio" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2c7b9d7fe61760ce5ea19532ead98541f6b4c495d87247aff9826445cf6872a" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "multiversion" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4851161a11d3ad0bf9402d90ffc3967bf231768bfd7aeb61755ad06dbf1a142" dependencies = [ "multiversion-macros", "target-features", @@ -1445,9 +1484,9 @@ dependencies = [ [[package]] name = "multiversion-macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a83d8500ed06d68877e9de1dde76c1dbb83885dcdbda4ef44ccbc3fbda2ac8" +checksum = "79a74ddee9e0c27d2578323c13905793e91622148f138ba29738f9dddb835e90" dependencies = [ "proc-macro2", "quote", @@ -1457,11 +1496,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -1475,9 +1513,9 @@ dependencies = [ [[package]] name = "newline-converter" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f71d09d5c87634207f894c6b31b6a2b2c64ea3bdcf71bd5599fdbbe1600c00f" +checksum = "47b6b097ecb1cbfed438542d16e84fd7ad9b0c76c8a65b7f9039212a3d14dc7f" dependencies = [ "unicode-segmentation", ] @@ -1527,29 +1565,19 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.32.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -1584,11 +1612,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -1605,7 +1633,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -1616,9 +1644,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -1634,9 +1662,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -1644,15 +1672,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -1682,9 +1710,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1694,9 +1722,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "planus" @@ -1709,13 +1737,12 @@ dependencies = [ [[package]] name = "plist" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ - "base64", + "base64 0.22.1", "indexmap", - "line-wrap", "quick-xml", "serde", "time", @@ -1755,7 +1782,7 @@ dependencies = [ "foreign_vec", "futures", "getrandom", - "hashbrown 0.14.3", + "hashbrown", "itoa", "lz4", "multiversion", @@ -1777,12 +1804,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae73d5b8e55decde670caba1cc82b61f14bfb9a72503198f0997d657a98dcfd6" dependencies = [ "ahash", - "bitflags 2.4.2", + "bitflags 2.6.0", "bytemuck", "chrono", "comfy-table", "either", - "hashbrown 0.14.3", + "hashbrown", "indexmap", "num-traits", "once_cell", @@ -1859,7 +1886,7 @@ dependencies = [ "ahash", "chrono", "fallible-streaming-iterator", - "hashbrown 0.14.3", + "hashbrown", "indexmap", "itoa", "num-traits", @@ -1878,7 +1905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3555f759705be6dd0d3762d16a0b8787b2dc4da73b57465f3b2bf1a070ba8f20" dependencies = [ "ahash", - "bitflags 2.4.2", + "bitflags 2.6.0", "glob", "once_cell", "polars-arrow", @@ -1903,10 +1930,10 @@ checksum = "1a7eb218296aaa7f79945f08288ca32ca3cf25fa505649eeee689ec21eebf636" dependencies = [ "ahash", "argminmax", - "base64", + "base64 0.21.7", "bytemuck", "either", - "hashbrown 0.14.3", + "hashbrown", "hex", "indexmap", "memchr", @@ -1929,7 +1956,7 @@ checksum = "146010e4b7dd4d2d0e58ddc762f6361f77d7a0385c54471199370c17164f67dd" dependencies = [ "ahash", "async-stream", - "base64", + "base64 0.21.7", "brotli", "ethnum", "flate2", @@ -1956,7 +1983,7 @@ dependencies = [ "crossbeam-channel", "crossbeam-queue", "enum_dispatch", - "hashbrown 0.14.3", + "hashbrown", "num-traits", "polars-arrow", "polars-core", @@ -1990,7 +2017,7 @@ dependencies = [ "rayon", "regex", "smartstring", - "strum_macros", + "strum_macros 0.25.3", "version_check", ] @@ -2049,7 +2076,7 @@ checksum = "da6ce68169fe61d46958c8eab7447360f30f2f23f6e24a0ce703a14b0a3cfbfc" dependencies = [ "ahash", "bytemuck", - "hashbrown 0.14.3", + "hashbrown", "indexmap", "num-traits", "once_cell", @@ -2068,33 +2095,36 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -2141,9 +2171,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2161,75 +2191,69 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] name = "ref-cast" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4846d4c50d1721b1a3bef8af76924eef20d5e723647333798c1b519b3a9473f" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.2", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2247,9 +2271,11 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -2263,35 +2289,35 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" dependencies = [ "bytemuck", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -2299,22 +2325,25 @@ dependencies = [ ] [[package]] -name = "rustversion" -version = "1.0.14" +name = "rustls-pemfile" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -2327,11 +2356,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2342,11 +2371,11 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -2355,9 +2384,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -2365,9 +2394,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "seq-macro" @@ -2377,31 +2406,32 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -2420,9 +2450,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.31" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ "indexmap", "itoa", @@ -2452,6 +2482,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -2464,29 +2500,29 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio", + "mio 0.8.11", "signal-hook", ] [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "simd-json" -version = "0.13.8" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faf8f101b9bc484337a6a6b0409cf76c139f2fb70a9e3aee6b6774be7bfbf76" +checksum = "570c430b3d902ea083097e853263ae782dfe40857d93db019a12356c8e8143fa" dependencies = [ "ahash", "getrandom", @@ -2517,9 +2553,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smartstring" @@ -2540,12 +2576,12 @@ checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2592,15 +2628,15 @@ checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.25.0" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "strum_macros" @@ -2608,11 +2644,24 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.77", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.77", ] [[package]] @@ -2628,9 +2677,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -2638,10 +2687,16 @@ dependencies = [ ] [[package]] -name = "syntect" -version = "5.1.0" +name = "sync_wrapper" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" dependencies = [ "bincode", "bitflags 1.3.2", @@ -2650,8 +2705,9 @@ dependencies = [ "once_cell", "onig", "plist", - "regex-syntax 0.7.5", + "regex-syntax", "serde", + "serde_derive", "serde_json", "thiserror", "walkdir", @@ -2705,21 +2761,21 @@ dependencies = [ [[package]] name = "target-features" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb5fa503293557c5158bd215fdc225695e567a77e453f5d4452a50a193969bd" +checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2743,29 +2799,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -2804,9 +2860,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2819,32 +2875,31 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.2", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -2859,23 +2914,22 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toolstr" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af0deafe22b11f8422063fc8bf7aeeaeaf291fc644fc2926917774e9c5eea394" +checksum = "eea5389dd1f24e3b2b025cd6f4efe63729a57b1c930e7208daec0905b8318388" dependencies = [ "chrono", "polars", @@ -2897,9 +2951,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -2920,7 +2974,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] @@ -2972,24 +3026,24 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-truncate" @@ -3002,21 +3056,21 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -3025,9 +3079,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" @@ -3055,15 +3109,15 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -3086,34 +3140,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -3123,9 +3178,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3133,28 +3188,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -3199,11 +3254,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -3218,7 +3273,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -3236,7 +3291,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -3256,17 +3320,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -3277,9 +3342,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -3289,9 +3354,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -3301,9 +3366,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -3313,9 +3384,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -3325,9 +3396,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -3337,9 +3408,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -3349,9 +3420,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winreg" @@ -3365,9 +3436,9 @@ dependencies = [ [[package]] name = "xxhash-rust" -version = "0.8.8" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53be06678ed9e83edb1745eb72efc0bbcd7b5c3c35711a860906aed827a13d61" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" [[package]] name = "yaml-rust" @@ -3380,53 +3451,54 @@ dependencies = [ [[package]] name = "yansi" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.77", ] [[package]] name = "zstd" -version = "0.13.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.0.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 40d34b3..3952d7e 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -14,13 +14,13 @@ path = "src/main.rs" [dependencies] bat = "0.24.0" clap = { version = "4.4.8", features = ["derive"] } -colored_json = "4.1.0" +colored_json = "5" edit = "0.1.4" futures = "0.3.29" -inquire = "0.6.2" +inquire = "0.7" ipgeolocate = "0.3.6" mesc = { version = "0.2.1", path = "../mesc" } -reqwest = { version = "0.11.22", features = ["json"] } +reqwest = { version = "0.11", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs index 789dfed..9064f12 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/inquire_utils.rs @@ -1,6 +1,6 @@ use inquire::ui::{Attributes, Color, IndexPrefix, RenderConfig, StyleSheet, Styled}; -pub(crate) fn get_render_config() -> RenderConfig { +pub(crate) fn get_render_config() -> RenderConfig<'static> { let highlight_color = Color::DarkGreen; let mut render_config = RenderConfig::default(); diff --git a/rust/crates/mesc_cli/src/network.rs b/rust/crates/mesc_cli/src/network.rs index 2118e67..9c7edc0 100644 --- a/rust/crates/mesc_cli/src/network.rs +++ b/rust/crates/mesc_cli/src/network.rs @@ -43,7 +43,7 @@ pub(crate) async fn get_node_network_info( // ip address and location let (ip_address, location) = - if fields.contains(&"ip".to_string()) | fields.contains(&"location".to_string()) { + if fields.contains(&"ip".to_string()) || fields.contains(&"location".to_string()) { match get_ip_address(url.as_str()) { Ok(ip) => { let service = ipgeolocate::Service::IpApi; diff --git a/rust/crates/mesc_cli/src/printing.rs b/rust/crates/mesc_cli/src/printing.rs index 76a62ee..fe4d242 100644 --- a/rust/crates/mesc_cli/src/printing.rs +++ b/rust/crates/mesc_cli/src/printing.rs @@ -14,7 +14,7 @@ pub(crate) fn print_endpoint_pretty(endpoint: Endpoint) { println!("- url: {}", endpoint.url); println!( "- chain_id: {}", - endpoint.chain_id.map_or("-".to_string(), |chain_id| chain_id.to_string()) + endpoint.chain_id.map_or_else(|| "-".to_string(), |chain_id| chain_id.to_string()) ); println!("- metadata: {:?}", endpoint.endpoint_metadata); } From 0b3150b194556fbd96304ef263d4b9acff636cee Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:33:04 +0200 Subject: [PATCH 82/85] Reduce size of Rust library (#33) * Reduce size of Rust library * simpler * fix tests * ci: cache Rust * ci: cache rust/ dir --- .github/workflows/rust-tests.yml | 14 +- python/generate_network_names.py | 24 +- python/mesc/network_names.py | 70 +- rust/crates/mesc/src/directory.rs | 34 +- rust/crates/mesc/src/network_names.rs | 3603 +++++++++-------- rust/crates/mesc/src/overrides.rs | 8 +- rust/crates/mesc/src/query.rs | 23 +- rust/crates/mesc/src/types/chain_ids.rs | 154 +- rust/crates/mesc/src/validate.rs | 25 - .../mesc_cli/src/cli/subcommands/set.rs | 12 +- .../src/cli/subcommands/setup/endpoints.rs | 2 +- .../cli/subcommands/setup/network_names.rs | 2 +- .../src/cli/subcommands/setup/selectors.rs | 26 +- rust/crates/mesc_cli/src/printing.rs | 10 +- tests/generate.py | 14 +- 15 files changed, 1997 insertions(+), 2024 deletions(-) diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index 688dc9c..d058692 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -10,16 +10,16 @@ jobs: - uses: actions/checkout@v2 - name: Install Rust - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust artifacts + uses: Swatinem/rust-cache@v2 with: - profile: minimal - toolchain: stable - override: true + cache-on-failure: true + workspaces: rust - name: Build and Install Rust Project - run: | - cd rust - cargo install --path crates/mesc_cli + run: cargo install --path rust/crates/mesc_cli --profile dev - name: Set up Python uses: actions/setup-python@v2 diff --git a/python/generate_network_names.py b/python/generate_network_names.py index 7dc3419..6a7390e 100755 --- a/python/generate_network_names.py +++ b/python/generate_network_names.py @@ -8,12 +8,13 @@ This script creates the following files in the MESC repository: - ./python/mesc/network_names.py - ./rust/crates/mesc/src/network_names.rs """ + from __future__ import annotations import os -import requests from typing import Mapping, MutableMapping +import requests # specialcase the standard name for certain chains special_cases: Mapping[str, str] = { @@ -119,13 +120,16 @@ def generate_python_content(network_names: Mapping[str, str]) -> str: rust_path = '../rust/crates/mesc/src/network_names.rs' rust_template = """{preamble} -use crate::{{ChainId, TryIntoChainId}}; -use std::collections::HashMap; +use crate::ChainId; +use std::{{collections::HashMap, sync::OnceLock}}; /// get default mapping between chain_id's and network names -pub fn get_network_names() -> HashMap {{ - {name_data} +pub fn get_network_names() -> &'static HashMap {{ + static CACHE: OnceLock> = OnceLock::new(); + CACHE.get_or_init(|| NETWORKS.iter().map(|&(chain_id, name)| (chain_id.into(), name)).collect()) }} + +pub(crate) const NETWORKS: &[(u64, &str)] = &{name_data}; """ @@ -133,14 +137,8 @@ def generate_rust_content(network_names: Mapping[str, str]) -> str: rust_preamble = '\n'.join(('//! ' + line).strip() for line in preamble.split('\n')) name_data = '[' for chain_id, network_name in network_names.items(): - name_data += '\n ("' + chain_id + '", "' + network_name + '"),' - name_data += """\n ] - .into_iter() - .filter_map(|(chain_id, name)| match chain_id.try_into_chain_id() { - Ok(chain_id) => Some((chain_id, name.to_string())), - Err(_) => None, - }) - .collect()""" + name_data += '\n (' + chain_id + ', "' + network_name + '"),' + name_data += '\n]' return rust_template.format(preamble=rust_preamble, name_data=name_data) diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index 1eb41b6..426d867 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -171,6 +171,7 @@ network_names = { '168': 'aioz', '169': 'manta_pacific', '170': 'hoo_testnet', + '171': 'co2e_ledger', '172': 'latam_block_resil_testnet', '176': 'dc', '178': 'abey_testnet', @@ -195,6 +196,7 @@ network_names = { '201': 'moac_testnet', '202': 'edgeless_testnet', '204': 'opbnb', + '205': 'ekaash', '206': 'vinu_testnet', '207': 'vinu', '208': 'structx', @@ -214,6 +216,7 @@ network_names = { '226': 'la_testnet', '228': 'mind', '230': 'swapdex', + '233': 'ethernity_testnet', '234': 'protojumbo_testnet', '236': 'deam_testnet', '238': 'blast', @@ -311,7 +314,7 @@ network_names = { '534': 'candle', '537': 'optrust', '542': 'paw_testnet', - '545': 'testnet', + '545': 'evm_on_flow_testnet', '555': 'vela1', '558': 'tao', '568': 'doge_testnet', @@ -349,6 +352,8 @@ network_names = { '707': 'block_station', '708': 'block_station_testnet', '710': 'highbury', + '711': 'tucana', + '712': 'birdee_2', '713': 'vrcscan', '719': 'shibarium_beta', '721': 'lycan', @@ -357,7 +362,7 @@ network_names = { '740': 'canto_testnet', '741': 'vention_testnet', '742': 'script_testnet', - '747': 'mainnet', + '747': 'evm_on_flow', '766': 'ql1', '776': 'open_testnet', '777': 'cheapeth', @@ -401,6 +406,7 @@ network_names = { '941': 'pulse_testnet_v2b', '942': 'pulse_testnet_v3', '943': 'pulse_testnet_v4', + '945': 'subtensor_evm_testnet', '956': 'munode_testnet', '957': 'lyra', '963': 'btc20', @@ -408,6 +414,7 @@ network_names = { '970': 'oort', '971': 'oort_huygens', '972': 'oort_ascraeus', + '973': 'palm', '977': 'nepal_block', '979': 'ethxy_testnet', '980': 'top_evm', @@ -415,7 +422,8 @@ network_names = { '989': 'top', '990': 'eliberty', '995': '5ire', - '997': '5ire_thunder', + '996': 'bifrost_polkadot', + '997': '5ire_thunder_testnet', '998': 'lucky', '999': 'wan_testnet', '1000': 'gton', @@ -478,6 +486,7 @@ network_names = { '1223': 'cycle_testnet_jellyfish', '1225': 'hybrid_testnet', '1227': 'bitcoin_protocol_testnet', + '1228': 'cycle_testnet_cuttlefish', '1229': 'exzo', '1230': 'ultron_testnet', '1231': 'ultron', @@ -530,6 +539,7 @@ network_names = { '1501': 'bevm_canary', '1506': 'sherpax', '1507': 'sherpax_testnet', + '1513': 'story_testnet', '1515': 'beagle_messaging', '1559': 'tenet', '1570': 'star_testnet', @@ -562,6 +572,7 @@ network_names = { '1818': 'cube', '1819': 'cube_testnet', '1821': 'ruby', + '1853': 'highoctane_subnet', '1856': 'teslafunds', '1875': 'white', '1881': 'gitshock_cartenz_testnet', @@ -577,6 +588,7 @@ network_names = { '1912': 'ruby_testnet', '1918': 'upb_crescdi_testnet', '1945': 'onus_testnet', + '1946': 'minato', '1951': 'd', '1953': 'selendra_testnet', '1954': 'dexilla_testnet', @@ -623,7 +635,7 @@ network_names = { '2035': 'phala', '2037': 'kiwi_subnet', '2038': 'shrapnel_testnet', - '2039': 'aleph_zero_testnet', + '2039': 'aleph_zero', '2040': 'vanar', '2043': 'neuroweb', '2044': 'shrapnel_subnet', @@ -651,6 +663,7 @@ network_names = { '2153': 'findora_testnet', '2154': 'findora_forge', '2162': 'anime_testnet', + '2192': 'snax', '2199': 'moonsama', '2202': 'antofy', '2203': 'bitcoin_evm', @@ -679,6 +692,7 @@ network_names = { '2425': 'king_of_legends', '2442': 'polygon_zkevm_cardona_testnet', '2468': 'hybrid', + '2477': '6degree_of_outreach', '2484': 'unicorn_ultra_nebulas_testnet', '2511': 'karak_goerli', '2522': 'fraxtal_testnet', @@ -772,7 +786,8 @@ network_names = { '4061': 'nahmii_3', '4062': 'nahmii_3_testnet', '4078': 'muster', - '4080': 'tobe', + '4080': 'tobe_testnet', + '4088': 'zeroth', '4090': 'fastex_bahamut_oasis_testnet', '4096': 'bitindi_testnet', '4099': 'bitindi', @@ -787,6 +802,7 @@ network_names = { '4202': 'lisk_sepolia_testnet', '4242': 'nexi', '4243': 'nexi_v2', + '4269': 'laika_testnet', '4328': 'bobafuji_testnet', '4337': 'beam', '4400': 'credit', @@ -821,6 +837,7 @@ network_names = { '5105': 'superloyalty_testnet', '5106': 'azra_testnet', '5112': 'ham', + '5151': 'me_testnet', '5165': 'bahamut', '5169': 'smart_layer', '5177': 'tl', @@ -851,6 +868,7 @@ network_names = { '5777': 'ganache', '5845': 'tangle', '5851': 'ontology_testnet', + '5858': 'chang_foundation', '5869': 'wego_rubidium', '6000': 'bouncebit_testnet', '6001': 'bouncebit', @@ -872,7 +890,8 @@ network_names = { '6660': 'latest_testnet', '6661': 'cybria', '6666': 'cybria_testnet', - '6678': 'edgamatrix', + '6667': 'stor', + '6678': 'edge_matrix', '6688': 'irishub', '6699': 'ox', '6701': 'paxb', @@ -880,6 +899,7 @@ network_names = { '6805': 'race', '6806': 'race_testnet', '6868': 'pools', + '6942': 'laika', '6969': 'tomb', '6999': 'polysmart', '7000': 'zeta', @@ -891,6 +911,7 @@ network_names = { '7100': 'nume', '7118': 'help_the_homeless', '7171': 'bitrock', + '7210': 'nibiru_testnet_1', '7222': 'nibiru_devnet_3', '7244': 'zeus_testnet', '7300': 'xpla_verse', @@ -990,6 +1011,8 @@ network_names = { '9012': 'berylbit', '9024': 'nexa_testnet_block', '9025': 'nexa_block', + '9069': 'apex_fusion___nexus', + '9070': 'apex_fusion___nexus_testnet', '9100': 'genesis_coin', '9170': 'rinia_testnet_old', '9223': 'codefin', @@ -1015,6 +1038,7 @@ network_names = { '9888': 'dogelayer', '9898': 'larissa', '9911': 'espento', + '9966': 'uxer_testnet', '9977': 'mind_testnet', '9980': 'combo', '9981': 'volley', @@ -1045,6 +1069,7 @@ network_names = { '10850': 'lamina1_identity', '10946': 'quadrans_block', '10947': 'quadrans_block_testnet', + '11000': 'kb', '11011': 'shape_sepolia_testnet', '11110': 'astra', '11111': 'wagmi', @@ -1087,6 +1112,7 @@ network_names = { '13600': 'kronobit', '13812': 'susono', '14000': 'sps_testnet', + '14088': 'zeroth_testnet', '14324': 'evolve_testnet', '14333': 'vitruveo_testnet', '14801': 'vana_satori_testnet', @@ -1101,6 +1127,7 @@ network_names = { '16000': 'metadot', '16001': 'metadot_testnet', '16116': 'defiverse', + '16166': 'cypherium', '16180': 'plyr_phi', '16350': 'incentiv_devnet', '16481': 'pivotal_sepolia', @@ -1146,6 +1173,7 @@ network_names = { '21223': 'dcpay', '21224': 'dcpay_testnet', '21337': 'cennznet_azalea', + '21363': 'lestnet', '21816': 'om', '21912': 'bsl', '22023': 'taycan', @@ -1168,6 +1196,8 @@ network_names = { '25888': 'hammer', '25925': 'bitkub_testnet', '26026': 'ferrum_testnet', + '26482': 'ducatusx_testnet', + '26483': 'ducatusx', '26600': 'hertz', '26863': 'oasis', '27181': 'klaos_nova', @@ -1181,6 +1211,7 @@ network_names = { '29223': 'nexa_metanet', '29536': 'kai_testnet', '29548': 'mch_verse', + '30000': 'q', '30067': 'piece_testnet', '30088': 'miyou', '30103': 'cerium_testnet', @@ -1215,13 +1246,13 @@ network_names = { '34443': 'mode', '34504': 'zeus', '35011': 'j2o_taro', - '35441': 'q', '35443': 'q_testnet', '38400': 'connectormanager', '38401': 'connectormanager_robin', '39656': 'prm', '39797': 'energi', '39815': 'oho', + '40000': 'div', '41455': 'aleph_zero_evm', '41500': 'opulent_x_beta', '42069': 'pegglecoin', @@ -1265,6 +1296,7 @@ network_names = { '50005': 'yooldo_verse', '50006': 'yooldo_verse_testnet', '50021': 'gton_testnet', + '50888': 'erbie', '51178': 'lumoz_testnet_alpha', '51712': 'sardis', '52014': 'electroneum', @@ -1272,6 +1304,7 @@ network_names = { '53302': 'superseed_sepolia_testnet', '53457': 'dodo_testnet', '53935': 'dfk', + '54176': 'overprotocol', '54211': 'haqq_testnet', '54321': 'toronet_testnet', '55004': 'titan', @@ -1286,6 +1319,7 @@ network_names = { '57000': 'rollux_testnet', '57451': 'coinsec', '58008': 'sepolia_pgn_public_goods', + '58680': 'lumoz_quidditch_testnet', '59140': 'linea_goerli', '59141': 'linea_sepolia', '59144': 'linea', @@ -1310,6 +1344,7 @@ network_names = { '62850': 'laos_sigma_testnet', '63000': 'ecredits', '63001': 'ecredits_testnet', + '63002': 'esync_testnet', '65349': 'cratd2c_testnet', '65357': 'vecno', '65450': 'scolcoin', @@ -1367,6 +1402,7 @@ network_names = { '81363': 'mizana_privnet', '82459': 'smart_layer_testnet', '83144': 'xprotocol_testnet', + '83278': 'esa', '83872': 'zedxion', '84531': 'base_goerli_testnet', '84532': 'base_sepolia_testnet', @@ -1396,7 +1432,7 @@ network_names = { '97970': 'optimusz7_testnet', '98881': 'ebi', '99099': 'eliberty_testnet', - '99876': 'edgamatrix_testnet', + '99876': 'edge_matrix_testnet', '99998': 'ubtestnet', '99999': 'ub', '100000': 'quark_root', @@ -1412,7 +1448,9 @@ network_names = { '100010': 've_testnet', '100011': 'quark_l2', '101010': 'global_trust', + '102030': 'creditcoin', '102031': 'creditcoin_testnet', + '102032': 'creditcoin_devnet', '103090': 'crystaleum', '103454': 'masa_testnet', '104566': 'kaspaclassic', @@ -1451,6 +1489,8 @@ network_names = { '167007': 'taiko_jolnir_l2', '167008': 'taiko_katla_l2', '167009': 'taiko_hekla_l2', + '168168': 'zs', + '171000': 'fair_testnet', '175177': 'chronicle___lit_protocol_testnet', '175188': 'chronicle_yellowstone___lit_protocol_testnet', '188710': 'bitica', @@ -1466,6 +1506,7 @@ network_names = { '201030': 'alaya_dev_testnet', '201804': 'mythical', '202020': 'decimal_testnet', + '202105': 'duck_testnet', '202212': 'x1_devnet', '202401': 'ymtech_besu_testnet', '202624': 'jellie', @@ -1473,6 +1514,7 @@ network_names = { '205205': 'auroria_testnet', '210049': 'gitagi_atlas_testnet', '210425': 'platon', + '212013': 'litentry', '220315': 'mas', '221230': 'reap', '221231': 'reap_testnet', @@ -1549,9 +1591,11 @@ network_names = { '534354': 'scroll_pre_alpha_testnet', '534849': 'shinarium_beta', '535037': 'beaneco_smart', + '541764': 'overprotocol_testnet', '552981': 'one_world_testnet', '555555': 'pentagon_testnet', '555666': 'eclipse_testnet', + '555888': 'dustboy_iot', '622277': 'hypra', '622463': 'atlas', '641230': 'bear', @@ -1651,6 +1695,7 @@ network_names = { '8888888': 'quarix', '9322252': 'xcap', '9322253': 'milvine', + '9999999': 'fluence', '10067275': 'plian_testnet_sub_1', '10101010': 'soverun', '10241024': 'alienx', @@ -1660,7 +1705,7 @@ network_names = { '11155420': 'op_sepolia_testnet', '12052024': 'memento_testnet', '12227331': 'neox_testnet_t3', - '12227332': 'neox_testnet_t4', + '12227332': 'neo_x_testnet_t4', '13068200': 'coti_devnet', '13371337': 'pep_churchill', '14288640': 'andus', @@ -1685,10 +1730,12 @@ network_names = { '28945486': 'auxilium', '29032022': 'fla', '31415926': 'filecoin___local_testnet', + '33626250': 'toliman_suave_testnet', '35855456': 'joys_digital', '37084624': 'skale_nebula_hub_testnet', '39916801': 'kingdom', '43214913': 'maistestsubnet', + '52164803': 'fluence_testnet', '61717561': 'aqua', '65010000': 'autonity_bakerloo_thames_testnet', '65010001': 'autonity_bakerloo_barada_testnet', @@ -1705,6 +1752,7 @@ network_names = { '88888888': 't.e.a.m_block', '94204209': 'polygon_blackberry', '99415706': 'joys_digital_testnet', + '100000000': 'ethos', '108160679': 'orai', '111557560': 'cyber_testnet', '123420111': 'op_celestia_raspberry', @@ -1723,7 +1771,9 @@ network_names = { '356256156': 'gather_testnet', '476462898': 'skopje_testnet', '486217935': 'gather_devnet', + '531050104': 'sophon_testnet', '666666666': 'degen', + '728126428': 'tron', '888888888': 'ancient8', '889910245': 'ptcescan_testnet', '889910246': 'ptcescan', @@ -1761,11 +1811,11 @@ network_names = { '3125659152': 'pirl', '4216137055': 'oneledger_testnet_frankenstein', '11297108099': 'palm_testnet', - '11297108109': 'palm', '28872323069': 'gitswarm_test', '37714555429': 'xai_testnet_v2', '88153591557': 'arbitrum_blueberry', '111222333444': 'alphabet', + '111551119090': 'thanos_sepolia', '123420000220': 'fluence_stage', '197710212030': 'ntity', '197710212031': 'haradev_testnet', diff --git a/rust/crates/mesc/src/directory.rs b/rust/crates/mesc/src/directory.rs index de80908..25069a5 100644 --- a/rust/crates/mesc/src/directory.rs +++ b/rust/crates/mesc/src/directory.rs @@ -1,36 +1,14 @@ use crate::ChainId; -use std::collections::HashMap; - -fn known_networks() -> HashMap<&'static str, ChainId> { - [ - ("ethereum", 1u32.into()), - ("goerli", 5u32.into()), - ("optimism", 10u32.into()), - ("polygon", 137u32.into()), - ("arbitrum", 42161u32.into()), - ] - .iter() - .cloned() - .collect() -} /// get chain id of given network name pub(crate) fn get_network_chain_id(network_name: &str) -> Option { - let network_names = crate::network_names::get_network_names(); - for (chain_id, network) in network_names.into_iter() { - if network == network_name { - return Some(chain_id); - } - } - None + crate::network_names::NETWORKS + .iter() + .find(|(_, name)| *name == network_name) + .map(|(chain_id, _)| (*chain_id).into()) } /// get network name of given chain id -pub fn get_network_name(chain_id: &ChainId) -> Option { - for (name, other_chain_id) in known_networks().iter() { - if chain_id == other_chain_id { - return Some(name.to_string()); - } - } - None +pub fn get_network_name(chain_id: &ChainId) -> Option<&'static str> { + crate::network_names::get_network_names().get(chain_id).copied() } diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index 82f6e46..8975a84 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -6,1784 +6,1831 @@ //! //! Do not edit this file manually. -use crate::{ChainId, TryIntoChainId}; -use std::collections::HashMap; +use crate::ChainId; +use std::{collections::HashMap, sync::OnceLock}; /// get default mapping between chain_id's and network names -pub fn get_network_names() -> HashMap { - [ - ("1", "ethereum"), - ("2", "expanse"), - ("3", "ropsten"), - ("4", "rinkeby"), - ("5", "goerli"), - ("6", "kotti_testnet"), - ("7", "thai"), - ("8", "ubiq"), - ("9", "ubiq_testnet"), - ("10", "optimism"), - ("11", "metadium"), - ("12", "metadium_testnet"), - ("13", "diode_testnet_staging"), - ("14", "flare"), - ("15", "diode_prenet"), - ("16", "songbird_testnet_coston"), - ("17", "thaifi"), - ("18", "thundercore_testnet"), - ("19", "songbird_canary"), - ("20", "elastos"), - ("21", "elastos_testnet"), - ("22", "ela_did"), - ("23", "ela_did_testnet"), - ("24", "kardia"), - ("25", "cronos"), - ("26", "genesis_testnet"), - ("27", "shiba"), - ("28", "boba_rinkeby_testnet"), - ("29", "genesis"), - ("30", "rootstock"), - ("31", "rootstock_testnet"), - ("32", "gooddata_testnet"), - ("33", "gooddata"), - ("34", "secure"), - ("35", "tbwg"), - ("36", "dx"), - ("37", "xpla"), - ("38", "valorbit"), - ("39", "u2u_solaris"), - ("40", "telos_evm"), - ("41", "telos_evm_testnet"), - ("42", "lukso"), - ("43", "darwinia_pangolin_testnet"), - ("44", "crab"), - ("45", "darwinia_pangoro_testnet"), - ("46", "darwinia"), - ("47", "acria_intelli"), - ("48", "ennothem_proterozoic"), - ("49", "ennothem_testnet_pioneer"), - ("50", "xdc"), - ("51", "xdc_apothem"), - ("52", "coinex"), - ("53", "coinex_testnet"), - ("54", "openpiece"), - ("55", "zyx"), - ("56", "bnb"), - ("57", "syscoin"), - ("58", "ontology"), - ("59", "eos_evm_legacy"), - ("60", "go"), - ("61", "ethereum_classic"), - ("62", "morden_testnet"), - ("63", "mordor_testnet"), - ("64", "ellaism"), - ("65", "okex_testnet"), - ("66", "okx"), - ("67", "db_testnet"), - ("68", "soterone"), - ("69", "optimism_kovan"), - ("70", "hoo"), - ("71", "conflux_espace_testnet"), - ("72", "dx_testnet"), - ("73", "fncy"), - ("74", "id"), - ("75", "decimal"), - ("76", "mix"), - ("77", "poa_sokol"), - ("78", "primus"), - ("79", "zenith"), - ("80", "gene"), - ("81", "japan_open"), - ("82", "meter"), - ("83", "meter_testnet"), - ("84", "linqto_devnet"), - ("85", "gate_testnet"), - ("86", "gate"), - ("87", "nova"), - ("88", "viction"), - ("89", "viction_testnet"), - ("90", "garizon_stage0"), - ("91", "garizon_stage1"), - ("92", "garizon_stage2"), - ("93", "garizon_stage3"), - ("94", "swissdlt"), - ("95", "camdl"), - ("96", "bitkub"), - ("97", "bnb_testnet"), - ("98", "six_protocol"), - ("99", "poa_core"), - ("100", "gnosis"), - ("101", "etherinc"), - ("102", "web3games_testnet"), - ("103", "worldland"), - ("104", "kaiba_lightning_testnet"), - ("105", "web3games_devnet"), - ("106", "velas_evm"), - ("107", "nebula_testnet"), - ("108", "thundercore"), - ("109", "shibarium"), - ("110", "proton_testnet"), - ("111", "etherlite"), - ("112", "coinbit"), - ("113", "dehvo"), - ("114", "flare_testnet_coston2"), - ("116", "debank"), - ("117", "uptick"), - ("118", "arcology_testnet"), - ("119", "enuls"), - ("120", "enuls_testnet"), - ("121", "real"), - ("122", "fuse"), - ("123", "fuse_sparknet"), - ("124", "decentralized_web"), - ("125", "oy_testnet"), - ("126", "oy"), - ("127", "factory_127"), - ("128", "huobi_eco"), - ("129", "innovator"), - ("131", "engram_testnet"), - ("132", "namefi"), - ("133", "hashkey_testnet"), - ("134", "iexec"), - ("135", "alyx_testnet"), - ("136", "deam"), - ("137", "polygon"), - ("138", "defi_oracle_meta"), - ("139", "woop"), - ("140", "eternal"), - ("141", "openpiece_testnet"), - ("142", "dax"), - ("144", "phi_v2"), - ("145", "soraai_testnet"), - ("147", "flag"), - ("148", "shimmerevm"), - ("150", "six_protocol_testnet"), - ("151", "redbelly"), - ("152", "redbelly_devnet"), - ("153", "redbelly_testnet"), - ("154", "redbelly_tge"), - ("155", "tenet_testnet"), - ("156", "oeblock_testnet"), - ("157", "puppynet_shibarium"), - ("158", "roburna"), - ("159", "roburna_testnet"), - ("160", "armonia_eva"), - ("161", "armonia_eva_testnet"), - ("162", "lightstreams_testnet"), - ("163", "lightstreams"), - ("164", "omni_omega"), - ("166", "omni"), - ("167", "atoshi_testnet"), - ("168", "aioz"), - ("169", "manta_pacific"), - ("170", "hoo_testnet"), - ("172", "latam_block_resil_testnet"), - ("176", "dc"), - ("178", "abey_testnet"), - ("179", "abey"), - ("180", "ame"), - ("181", "waterfall"), - ("184", "dojima_testnet"), - ("185", "mint"), - ("186", "seele"), - ("187", "dojima"), - ("188", "bmc"), - ("189", "bmc_testnet"), - ("190", "cmdao_bbq"), - ("191", "filefilego"), - ("193", "crypto_emergency"), - ("195", "x_layer_testnet"), - ("196", "x_layer"), - ("197", "neutrinos_testnet"), - ("198", "bit"), - ("199", "bittorrent"), - ("200", "arbitrum_on_xdai"), - ("201", "moac_testnet"), - ("202", "edgeless_testnet"), - ("204", "opbnb"), - ("206", "vinu_testnet"), - ("207", "vinu"), - ("208", "structx"), - ("210", "bitnet"), - ("211", "freight_trust"), - ("212", "mapo_makalu"), - ("213", "b2_hub"), - ("214", "shinarium"), - ("217", "siriusnet_v2"), - ("218", "soterone_old"), - ("220", "scalind_testnet"), - ("221", "blockex"), - ("222", "permission"), - ("223", "b2"), - ("224", "viridis_testnet"), - ("225", "la"), - ("226", "la_testnet"), - ("228", "mind"), - ("230", "swapdex"), - ("234", "protojumbo_testnet"), - ("236", "deam_testnet"), - ("238", "blast"), - ("242", "plinga"), - ("246", "energy_web"), - ("248", "oasys"), - ("250", "fantom_opera"), - ("252", "fraxtal"), - ("254", "swan"), - ("255", "kroma"), - ("256", "huobi_eco_testnet"), - ("258", "setheum"), - ("259", "neonlink"), - ("261", "guru_testnet"), - ("262", "sur_block"), - ("266", "neura"), - ("267", "neura_testnet"), - ("268", "neura_devnet"), - ("269", "high_performance_block"), - ("271", "egoncoin"), - ("278", "xfair.ai"), - ("279", "bpx_block"), - ("282", "cronos_zkevm_testnet"), - ("288", "boba"), - ("291", "orderly"), - ("295", "hedera"), - ("296", "hedera_testnet"), - ("297", "hedera_previewnet"), - ("298", "hedera_localnet"), - ("300", "zksync_sepolia_testnet"), - ("301", "bobaopera"), - ("302", "zkcandy_sepolia_testnet"), - ("303", "neuro_testnet"), - ("305", "zksats"), - ("307", "lovely_testnet"), - ("308", "furtheon"), - ("309", "wyzth_testnet"), - ("311", "omax"), - ("313", "neuro"), - ("314", "filecoin"), - ("321", "kcc"), - ("322", "kcc_testnet"), - ("323", "cosvm"), - ("324", "zksync"), - ("325", "grvt"), - ("326", "grvt_sepolia_testnet"), - ("333", "web3q"), - ("335", "dfk_test"), - ("336", "shiden"), - ("338", "cronos_testnet"), - ("345", "tsc"), - ("360", "shape"), - ("361", "theta"), - ("363", "theta_sapphire_testnet"), - ("364", "theta_amber_testnet"), - ("365", "theta_testnet"), - ("369", "pulse"), - ("371", "consta_testnet"), - ("380", "zkamoeba_testnet"), - ("381", "zkamoeba"), - ("385", "lisinski"), - ("388", "cronos_zkevm"), - ("395", "camdl_testnet"), - ("397", "near"), - ("398", "near_testnet"), - ("399", "nativ3"), - ("400", "hyperon_testnet"), - ("401", "ozone_testnet"), - ("404", "syndr_l3"), - ("411", "pepe"), - ("416", "sx"), - ("418", "latestnet"), - ("420", "optimism_goerli_testnet"), - ("422", "viridis"), - ("424", "pgn_public_goods"), - ("427", "zeeth"), - ("428", "geso_verse"), - ("434", "boyaa"), - ("443", "ten_testnet"), - ("444", "synapse_testnet"), - ("456", "arzio"), - ("462", "areon_testnet"), - ("463", "areon"), - ("480", "world"), - ("499", "rupaya"), - ("500", "camino_c"), - ("501", "columbus_test"), - ("510", "syndicate"), - ("512", "double_a"), - ("513", "double_a_testnet"), - ("516", "gear_zero"), - ("520", "xt"), - ("529", "fire"), - ("530", "fxcore"), - ("534", "candle"), - ("537", "optrust"), - ("542", "paw_testnet"), - ("545", "testnet"), - ("555", "vela1"), - ("558", "tao"), - ("568", "doge_testnet"), - ("570", "rollux"), - ("571", "meta"), - ("579", "filenova"), - ("588", "metis_stardust_testnet"), - ("592", "astar"), - ("595", "acala_mandala_testnet_tc9"), - ("596", "karura_testnet"), - ("597", "acala_testnet"), - ("599", "metis_goerli_testnet"), - ("600", "meshnyan_testnet"), - ("601", "vine_testnet"), - ("610", "darwin_devnet"), - ("612", "eiob"), - ("614", "graphlinq_block"), - ("624", "binary"), - ("625", "binary_sepolia"), - ("634", "avocado"), - ("646", "previewnet"), - ("647", "sx_testnet"), - ("648", "endurance"), - ("653", "kali_testnet"), - ("654", "kali"), - ("662", "ultronsmart"), - ("666", "pixie_testnet"), - ("667", "laos_arrakis"), - ("668", "junca"), - ("669", "junca_testnet"), - ("686", "karura"), - ("690", "redstone"), - ("700", "star_social_testnet"), - ("701", "darwinia_koi_testnet"), - ("707", "block_station"), - ("708", "block_station_testnet"), - ("710", "highbury"), - ("713", "vrcscan"), - ("719", "shibarium_beta"), - ("721", "lycan"), - ("727", "blucrates"), - ("730", "lovely"), - ("740", "canto_testnet"), - ("741", "vention_testnet"), - ("742", "script_testnet"), - ("747", "mainnet"), - ("766", "ql1"), - ("776", "open_testnet"), - ("777", "cheapeth"), - ("786", "maal"), - ("787", "acala"), - ("788", "aero_testnet"), - ("789", "patex"), - ("799", "rupaya_testnet"), - ("800", "lucid_block"), - ("803", "haic"), - ("808", "portal_fantasy_test"), - ("810", "haven1_testnet"), - ("813", "qitmeer"), - ("814", "fire_zkevm"), - ("818", "beone"), - ("820", "callisto"), - ("822", "runic_testnet"), - ("831", "checkdot_block_devnet"), - ("841", "taraxa"), - ("842", "taraxa_testnet"), - ("852", "hongkong"), - ("859", "zeeth_dev"), - ("868", "fantasia"), - ("876", "bandai_namco_research_verse"), - ("877", "dexit"), - ("880", "ambros"), - ("888", "wan"), - ("898", "maxi_testnet"), - ("899", "maxi"), - ("900", "garizon_testnet_stage0"), - ("901", "garizon_testnet_stage1"), - ("902", "garizon_testnet_stage2"), - ("903", "garizon_testnet_stage3"), - ("909", "portal_fantasy"), - ("910", "decentrabone_layer1_testnet"), - ("911", "taproot"), - ("917", "rinia_testnet"), - ("919", "mode_testnet"), - ("927", "yidark"), - ("940", "pulse_testnet"), - ("941", "pulse_testnet_v2b"), - ("942", "pulse_testnet_v3"), - ("943", "pulse_testnet_v4"), - ("956", "munode_testnet"), - ("957", "lyra"), - ("963", "btc20"), - ("969", "ethxy"), - ("970", "oort"), - ("971", "oort_huygens"), - ("972", "oort_ascraeus"), - ("977", "nepal_block"), - ("979", "ethxy_testnet"), - ("980", "top_evm"), - ("985", "memo"), - ("989", "top"), - ("990", "eliberty"), - ("995", "5ire"), - ("997", "5ire_thunder"), - ("998", "lucky"), - ("999", "wan_testnet"), - ("1000", "gton"), - ("1001", "kaia_testnet_kairos"), - ("1003", "tectum_emission_token"), - ("1004", "t_ekta"), - ("1007", "newton_testnet"), - ("1008", "eurus"), - ("1009", "jumbo"), - ("1010", "evrice"), - ("1011", "rebus"), - ("1012", "newton"), - ("1022", "sakura"), - ("1023", "clover_testnet"), - ("1024", "clv_para"), - ("1028", "bittorrent_testnet"), - ("1030", "conflux_espace"), - ("1031", "proxy_testnet"), - ("1038", "bronos_testnet"), - ("1039", "bronos"), - ("1073", "shimmerevm_testnet"), - ("1075", "iota_evm_testnet"), - ("1079", "mintara_testnet"), - ("1080", "mintara"), - ("1088", "metis_andromeda"), - ("1089", "humans.ai"), - ("1099", "moac"), - ("1100", "dymension"), - ("1101", "polygon_zkevm"), - ("1107", "blxq_testnet"), - ("1108", "blxq"), - ("1111", "wemix"), - ("1112", "wemix_testnet"), - ("1113", "b2_hub_testnet"), - ("1115", "core_block_testnet"), - ("1116", "core_block"), - ("1117", "dogcoin"), - ("1123", "b2_testnet"), - ("1130", "defi_evm"), - ("1131", "defi_evm_testnet"), - ("1133", "defimeta_changi_testnet"), - ("1135", "lisk"), - ("1138", "amstar_testnet"), - ("1139", "math"), - ("1140", "math_testnet"), - ("1147", "flag_testnet"), - ("1149", "symplexia"), - ("1170", "origin_testnet"), - ("1177", "smart_host_teknoloji_testnet"), - ("1188", "clubmos"), - ("1197", "iora"), - ("1200", "cuckoo"), - ("1201", "evanesco_testnet"), - ("1202", "world_trade_technical"), - ("1209", "saitablocksbc"), - ("1210", "cuckoo_sepolia"), - ("1213", "popcateum"), - ("1214", "enter"), - ("1221", "cycle_testnet"), - ("1223", "cycle_testnet_jellyfish"), - ("1225", "hybrid_testnet"), - ("1227", "bitcoin_protocol_testnet"), - ("1229", "exzo"), - ("1230", "ultron_testnet"), - ("1231", "ultron"), - ("1234", "step"), - ("1235", "itx"), - ("1243", "arc"), - ("1244", "arc_testnet"), - ("1246", "om_platform"), - ("1248", "dogether"), - ("1252", "cic_testnet"), - ("1280", "halo"), - ("1284", "moonbeam"), - ("1285", "moonriver"), - ("1286", "moonrock_old"), - ("1287", "moonbase_alpha"), - ("1288", "moonrock"), - ("1291", "swisstronik_testnet"), - ("1294", "bobabeam"), - ("1297", "bobabase_testnet"), - ("1311", "dos_fuji_subnet"), - ("1313", "jaiho"), - ("1314", "alyx"), - ("1319", "aia"), - ("1320", "aia_testnet"), - ("1328", "sei_testnet"), - ("1329", "sei"), - ("1337", "geth_testnet"), - ("1338", "elysium_testnet"), - ("1339", "elysium"), - ("1343", "blitz_subnet"), - ("1353", "cic"), - ("1369", "zafirium"), - ("1370", "ramestta"), - ("1377", "pingaksha_testnet"), - ("1379", "kalar"), - ("1388", "amstar"), - ("1392", "joseon"), - ("1402", "polygon_zkevm_testnet_old"), - ("1414", "silicon_zkevm_sepolia_testnet"), - ("1422", "polygon_zkevm_testnet_pre_audit_upgraded"), - ("1433", "rikeza"), - ("1440", "living_assets"), - ("1442", "polygon_zkevm_testnet"), - ("1452", "gil_testnet"), - ("1453", "meta_istanbul"), - ("1455", "ctex_scan_block"), - ("1456", "zkbase"), - ("1490", "vitruveo"), - ("1499", "idos_games_testnet"), - ("1501", "bevm_canary"), - ("1506", "sherpax"), - ("1507", "sherpax_testnet"), - ("1515", "beagle_messaging"), - ("1559", "tenet"), - ("1570", "star_testnet"), - ("1578", "star"), - ("1617", "ethereum_inscription"), - ("1618", "catecoin"), - ("1620", "atheios"), - ("1625", "gravity_alpha"), - ("1648", "pivotal"), - ("1657", "bta"), - ("1662", "liqui"), - ("1663", "horizen_gobi_testnet"), - ("1686", "mint_testnet"), - ("1687", "mint_sepolia_testnet"), - ("1688", "ludan"), - ("1701", "anytype_evm"), - ("1707", "tbsi"), - ("1708", "tbsi_testnet"), - ("1717", "doric"), - ("1718", "palette"), - ("1729", "reya"), - ("1740", "metal_l2_testnet"), - ("1750", "metal_l2"), - ("1773", "party"), - ("1777", "gauss"), - ("1789", "zkbase_sepolia_testnet"), - ("1804", "kerleano"), - ("1807", "rabbit_analog_testnet"), - ("1811", "lif3_testnet"), - ("1818", "cube"), - ("1819", "cube_testnet"), - ("1821", "ruby"), - ("1856", "teslafunds"), - ("1875", "white"), - ("1881", "gitshock_cartenz_testnet"), - ("1890", "lightlink_phoenix"), - ("1891", "lightlink_pegasus_testnet"), - ("1898", "bon"), - ("1899", "redefi_layer_2"), - ("1904", "sports"), - ("1907", "bitci"), - ("1908", "bitci_testnet"), - ("1909", "merkle_scan"), - ("1911", "scalind"), - ("1912", "ruby_testnet"), - ("1918", "upb_crescdi_testnet"), - ("1945", "onus_testnet"), - ("1951", "d"), - ("1953", "selendra_testnet"), - ("1954", "dexilla_testnet"), - ("1956", "aiw3_testnet"), - ("1961", "selendra"), - ("1967", "eleanor"), - ("1969", "super_testnet"), - ("1970", "super"), - ("1971", "atelier"), - ("1972", "redecoin"), - ("1975", "onus"), - ("1984", "eurus_testnet"), - ("1985", "satoshie"), - ("1986", "satoshie_testnet"), - ("1987", "ethergem"), - ("1992", "hubble_exchange"), - ("1993", "b3_sepolia_testnet"), - ("1994", "ekta"), - ("1995", "edexa_testnet"), - ("1996", "sanko"), - ("1997", "kyoto"), - ("1998", "kyoto_testnet"), - ("2000", "doge"), - ("2001", "milkomeda_c1"), - ("2002", "milkomeda_a1"), - ("2004", "metalink"), - ("2008", "cloudwalk_testnet"), - ("2009", "cloudwalk"), - ("2013", "panarchy"), - ("2014", "now_testnet"), - ("2016", "mainnetz"), - ("2017", "adiri"), - ("2018", "publicmint_devnet"), - ("2019", "publicmint_testnet"), - ("2020", "publicmint"), - ("2021", "edgeware_edgeevm"), - ("2022", "beresheet_bereevm_testnet"), - ("2023", "taycan_testnet"), - ("2024", "swan_saturn_testnet"), - ("2025", "rangers_protocol"), - ("2026", "edgeless"), - ("2031", "centrifuge"), - ("2032", "catalyst"), - ("2035", "phala"), - ("2037", "kiwi_subnet"), - ("2038", "shrapnel_testnet"), - ("2039", "aleph_zero_testnet"), - ("2040", "vanar"), - ("2043", "neuroweb"), - ("2044", "shrapnel_subnet"), - ("2045", "aiw3"), - ("2047", "stratos_testnet"), - ("2048", "stratos"), - ("2049", "movo"), - ("2077", "quokkacoin"), - ("2088", "altair"), - ("2089", "algol"), - ("2100", "ecoball"), - ("2101", "ecoball_testnet_espuma"), - ("2109", "exosama"), - ("2112", "u"), - ("2121", "catena"), - ("2122", "metaplayerone"), - ("2124", "metaplayerone_dubai_testnet"), - ("2136", "bigshortbets_testnet"), - ("2137", "bigshortbets"), - ("2138", "defi_oracle_meta_testnet"), - ("2140", "oneness"), - ("2141", "oneness_testnet"), - ("2151", "bosagora"), - ("2152", "findora"), - ("2153", "findora_testnet"), - ("2154", "findora_forge"), - ("2162", "anime_testnet"), - ("2199", "moonsama"), - ("2202", "antofy"), - ("2203", "bitcoin_evm"), - ("2213", "evanesco"), - ("2221", "kava_testnet"), - ("2222", "kava"), - ("2223", "v"), - ("2241", "krest"), - ("2300", "bomb"), - ("2306", "ebro"), - ("2309", "arevia"), - ("2311", "chronicle_vesuvius___lit_protocol_testnet"), - ("2323", "soma_testnet"), - ("2330", "altcoin"), - ("2331", "rss3_vsl_sepolia_testnet"), - ("2332", "soma"), - ("2340", "atleta_olympia"), - ("2342", "omnia"), - ("2355", "silicon_zkevm"), - ("2358", "kroma_sepolia"), - ("2370", "nexis_testnet"), - ("2399", "bomb_testnet"), - ("2400", "tcg_verse"), - ("2410", "karak"), - ("2415", "xodex"), - ("2425", "king_of_legends"), - ("2442", "polygon_zkevm_cardona_testnet"), - ("2468", "hybrid"), - ("2484", "unicorn_ultra_nebulas_testnet"), - ("2511", "karak_goerli"), - ("2522", "fraxtal_testnet"), - ("2525", "inevm"), - ("2559", "kortho"), - ("2569", "techpay"), - ("2606", "pocrnet"), - ("2611", "redlight"), - ("2612", "ez_c"), - ("2613", "ez_c_testnet"), - ("2625", "white_testnet"), - ("2648", "ailayer_testnet"), - ("2649", "ailayer"), - ("2662", "apex"), - ("2710", "morph_testnet"), - ("2718", "k_laos"), - ("2730", "xr_sepolia"), - ("2731", "elizabeth_testnet"), - ("2748", "nanon"), - ("2777", "gm"), - ("2810", "morph_holesky"), - ("2882", "chips"), - ("2888", "boba_goerli_testnet"), - ("2907", "elux"), - ("2911", "hy"), - ("2941", "xenon_testnet"), - ("2999", "bityuan"), - ("3000", "cennznet_rata"), - ("3001", "cennznet_nikau"), - ("3003", "canxium"), - ("3011", "playa3ull_games"), - ("3031", "orlando"), - ("3033", "rebus_testnet"), - ("3068", "bifrost"), - ("3073", "movement_evm"), - ("3084", "xl_testnet"), - ("3100", "immu3_evm"), - ("3102", "vulture_evm_beta"), - ("3109", "satoshivm_alpha"), - ("3110", "satoshivm_testnet"), - ("3141", "filecoin___hyperspace_testnet"), - ("3269", "dubxcoin"), - ("3270", "dubxcoin_testnet"), - ("3306", "debounce_subnet_testnet"), - ("3331", "zcore_testnet"), - ("3333", "ethstorage_testnet"), - ("3334", "web3q_galileo"), - ("3335", "ethstorage"), - ("3338", "peaq"), - ("3400", "paribu_net"), - ("3424", "evolve"), - ("3434", "secure_testnet"), - ("3456", "layeredge_testnet"), - ("3490", "gtcscan"), - ("3500", "paribu_net_testnet"), - ("3501", "jfin"), - ("3601", "pandoproject"), - ("3602", "pandoproject_testnet"), - ("3630", "tycooncoin"), - ("3636", "botanix_testnet"), - ("3637", "botanix"), - ("3639", "i"), - ("3645", "i_testnet"), - ("3666", "jouleverse"), - ("3690", "bittex"), - ("3693", "empire"), - ("3698", "senjepowers_testnet"), - ("3699", "senjepowers"), - ("3701", "xpla_testnet"), - ("3737", "crossbell"), - ("3776", "astar_zkevm"), - ("3797", "alvey"), - ("3799", "tangle_testnet"), - ("3885", "fire_zkevm_ghostrider"), - ("3888", "kaly"), - ("3889", "kaly_testnet"), - ("3912", "drac"), - ("3939", "dos_tesnet"), - ("3966", "dyno"), - ("3967", "dyno_testnet"), - ("3993", "apex_testnet"), - ("3999", "yuan"), - ("4000", "ozone"), - ("4001", "peperium_testnet"), - ("4002", "fantom_testnet"), - ("4003", "x1_fastnet"), - ("4040", "carbonium_testnet"), - ("4048", "gan_testnet"), - ("4051", "bobaopera_testnet"), - ("4058", "bahamut_ocean"), - ("4061", "nahmii_3"), - ("4062", "nahmii_3_testnet"), - ("4078", "muster"), - ("4080", "tobe"), - ("4090", "fastex_bahamut_oasis_testnet"), - ("4096", "bitindi_testnet"), - ("4099", "bitindi"), - ("4102", "aioz_testnet"), - ("4139", "humans.ai_testnet"), - ("4141", "tipboxcoin_testnet"), - ("4157", "crossfi_testnet"), - ("4162", "sx_rollup"), - ("4181", "phi_v1"), - ("4200", "merlin"), - ("4201", "lukso_testnet"), - ("4202", "lisk_sepolia_testnet"), - ("4242", "nexi"), - ("4243", "nexi_v2"), - ("4328", "bobafuji_testnet"), - ("4337", "beam"), - ("4400", "credit"), - ("4444", "htmlcoin"), - ("4460", "orderly_sepolia_testnet"), - ("4488", "hydra"), - ("4544", "emoney_testnet"), - ("4613", "very"), - ("4653", "gold"), - ("4689", "iotex"), - ("4690", "iotex_testnet"), - ("4759", "meverse_testnet"), - ("4777", "blackfort_exchange_testnet"), - ("4801", "world_sepolia_testnet"), - ("4893", "globel"), - ("4918", "venidium_testnet"), - ("4919", "venidium"), - ("4999", "blackfort_exchange"), - ("5000", "mantle"), - ("5001", "mantle_testnet"), - ("5002", "treasurenet_alpha"), - ("5003", "mantle_sepolia_testnet"), - ("5005", "treasurenet_testnet"), - ("5039", "onigiri_test_subnet"), - ("5040", "onigiri_subnet"), - ("5051", "nollie_skate_testnet"), - ("5100", "syndicate_testnet"), - ("5101", "syndicate_frame"), - ("5102", "sic_testnet"), - ("5103", "coordinape_testnet"), - ("5104", "charmverse_testnet"), - ("5105", "superloyalty_testnet"), - ("5106", "azra_testnet"), - ("5112", "ham"), - ("5165", "bahamut"), - ("5169", "smart_layer"), - ("5177", "tl"), - ("5197", "eraswap"), - ("5234", "humanode"), - ("5290", "fire_old"), - ("5315", "uzmi"), - ("5317", "optrust_testnet"), - ("5321", "itx_testnet"), - ("5333", "netsbo"), - ("5353", "tritanium_testnet"), - ("5372", "settlus_testnet"), - ("5424", "edexa"), - ("5439", "ego"), - ("5522", "vex_evm_testnet"), - ("5551", "nahmii_2"), - ("5553", "nahmii_2_testnet"), - ("5555", "verse"), - ("5611", "opbnb_testnet"), - ("5615", "arcturus_testneet"), - ("5616", "arcturus_testnet"), - ("5656", "qie_block"), - ("5675", "filenova_testnet"), - ("5678", "tanssi_demo"), - ("5700", "syscoin_tanenbaum_testnet"), - ("5729", "hika_testnet"), - ("5758", "satoshi_testnet"), - ("5777", "ganache"), - ("5845", "tangle"), - ("5851", "ontology_testnet"), - ("5869", "wego_rubidium"), - ("6000", "bouncebit_testnet"), - ("6001", "bouncebit"), - ("6065", "tres_testnet"), - ("6066", "tres"), - ("6102", "cascadia_testnet"), - ("6118", "uptn_testnet"), - ("6119", "uptn"), - ("6283", "laos"), - ("6321", "aura_euphoria_testnet"), - ("6322", "aura"), - ("6363", "digit_soul"), - ("6398", "connext_sepolia"), - ("6502", "peerpay"), - ("6550", "flamma_testnet"), - ("6552", "scolcoin_wei_testnet"), - ("6565", "fox_testnet"), - ("6626", "pixie"), - ("6660", "latest_testnet"), - ("6661", "cybria"), - ("6666", "cybria_testnet"), - ("6678", "edgamatrix"), - ("6688", "irishub"), - ("6699", "ox"), - ("6701", "paxb"), - ("6779", "compverse"), - ("6805", "race"), - ("6806", "race_testnet"), - ("6868", "pools"), - ("6969", "tomb"), - ("6999", "polysmart"), - ("7000", "zeta"), - ("7001", "zeta_testnet"), - ("7007", "bst"), - ("7027", "ella_the_heart"), - ("7070", "planq"), - ("7077", "planq_atlas_testnet"), - ("7100", "nume"), - ("7118", "help_the_homeless"), - ("7171", "bitrock"), - ("7222", "nibiru_devnet_3"), - ("7244", "zeus_testnet"), - ("7300", "xpla_verse"), - ("7331", "klyntar"), - ("7332", "horizen_eon"), - ("7341", "shyft"), - ("7484", "raba"), - ("7518", "meverse"), - ("7560", "cyber"), - ("7575", "adil_testnet"), - ("7576", "adil_v2"), - ("7668", "the_root"), - ("7672", "the_root___porcini_testnet"), - ("7700", "canto"), - ("7701", "canto_tesnet"), - ("7771", "bitrock_testnet"), - ("7774", "gdcc"), - ("7775", "gdcc_testnet"), - ("7776", "pandasea"), - ("7777", "rise_of_the_warbots_testnet"), - ("7778", "orenium_protocol"), - ("7798", "openex_long_testnet"), - ("7860", "maal_testnet"), - ("7862", "maal_v2"), - ("7863", "maal_testnet_v2"), - ("7878", "hazlor_testnet"), - ("7887", "kinto"), - ("7895", "ardenium_athena"), - ("7923", "dot_blox"), - ("7924", "mo"), - ("7979", "dos"), - ("8000", "teleport"), - ("8001", "teleport_testnet"), - ("8008", "polynomial"), - ("8029", "mdgl_testnet"), - ("8047", "boat"), - ("8054", "karak_sepolia"), - ("8080", "shardeum_liberty_1.x"), - ("8081", "shardeum_liberty_2.x"), - ("8082", "shardeum_sphinx_1.x"), - ("8086", "bitcoin"), - ("8087", "e_dollar"), - ("8098", "streamux_block"), - ("8131", "qitmeer_testnet"), - ("8132", "qitmeer_mixnet"), - ("8133", "qitmeer_privnet"), - ("8134", "amana"), - ("8135", "flana"), - ("8136", "mizana"), - ("8181", "testnet_beone"), - ("8192", "torus"), - ("8194", "torus_testnet"), - ("8217", "kaia"), - ("8227", "space_subnet"), - ("8272", "blockton_block"), - ("8285", "korthotest"), - ("8329", "lorenzo"), - ("8333", "b3"), - ("8387", "dracones_financial_services"), - ("8453", "base"), - ("8545", "chakra_testnet"), - ("8654", "toki"), - ("8655", "toki_testnet"), - ("8668", "hela_official_runtime"), - ("8723", "tool_global"), - ("8724", "tool_global_testnet"), - ("8726", "storage"), - ("8727", "storage_testnet"), - ("8732", "bullions"), - ("8738", "alph"), - ("8768", "tmy"), - ("8822", "iota_evm"), - ("8844", "hydra_testnet"), - ("8848", "maro_block"), - ("8866", "superlumio"), - ("8869", "lif3"), - ("8880", "unique"), - ("8881", "quartz_by_unique"), - ("8882", "opal_testnet_by_unique"), - ("8883", "sapphire_by_unique"), - ("8886", "avenium_testnet"), - ("8888", "xana"), - ("8889", "vyvo"), - ("8890", "orenium_testnet_protocol"), - ("8898", "mammoth"), - ("8899", "jib"), - ("8911", "algen"), - ("8912", "algen_testnet"), - ("8921", "algen_layer2"), - ("8922", "algen_layer2_testnet"), - ("8989", "giant_mammoth"), - ("8995", "bloxberg"), - ("9000", "evmos_testnet"), - ("9001", "evmos"), - ("9007", "shido_testnet_block"), - ("9008", "shido_block"), - ("9012", "berylbit"), - ("9024", "nexa_testnet_block"), - ("9025", "nexa_block"), - ("9100", "genesis_coin"), - ("9170", "rinia_testnet_old"), - ("9223", "codefin"), - ("9339", "dogcoin_testnet"), - ("9372", "oasys_testnet"), - ("9393", "dela_sepolia_testnet"), - ("9395", "evoke"), - ("9496", "weavevm_testnet"), - ("9527", "rangers_protocol_testnet_robin"), - ("9528", "qeasyweb3_testnet"), - ("9559", "neonlink_testnet"), - ("9700", "oortdev"), - ("9728", "boba_bnb_testnet"), - ("9768", "mainnetz_testnet"), - ("9779", "pepenetwork"), - ("9789", "tabi_testnet"), - ("9790", "carbon_evm"), - ("9792", "carbon_evm_testnet"), - ("9797", "optimusz7"), - ("9818", "imperium_testnet"), - ("9819", "imperium"), - ("9876", "binary_testnet"), - ("9888", "dogelayer"), - ("9898", "larissa"), - ("9911", "espento"), - ("9977", "mind_testnet"), - ("9980", "combo"), - ("9981", "volley"), - ("9990", "agung"), - ("9997", "altlayer_testnet"), - ("9998", "ztc"), - ("9999", "myown_testnet"), - ("10000", "smart_bitcoin_cash"), - ("10001", "smart_bitcoin_cash_testnet"), - ("10024", "gon"), - ("10081", "japan_open_testnet"), - ("10086", "sjatsh"), - ("10096", "metanova_verse"), - ("10101", "block_genesis"), - ("10200", "gnosis_chiado_testnet"), - ("10201", "maxx"), - ("10222", "glscan"), - ("10242", "arthera"), - ("10243", "arthera_testnet"), - ("10248", "0xtade"), - ("10321", "tao_evm"), - ("10324", "tao_evm_testnet"), - ("10395", "worldland_testnet"), - ("10507", "numbers"), - ("10508", "numbers_testnet"), - ("10823", "cryptocoinpay"), - ("10849", "lamina1"), - ("10850", "lamina1_identity"), - ("10946", "quadrans_block"), - ("10947", "quadrans_block_testnet"), - ("11011", "shape_sepolia_testnet"), - ("11110", "astra"), - ("11111", "wagmi"), - ("11115", "astra_testnet"), - ("11119", "hashbit"), - ("11124", "abstract_testnet"), - ("11221", "shine"), - ("11227", "jiritsu_testnet_subnet"), - ("11235", "haqq"), - ("11437", "shyft_testnet"), - ("11501", "bevm"), - ("11503", "bevm_testnet"), - ("11521", "sats"), - ("11612", "sardis_testnet"), - ("11822", "artela_testnet"), - ("11891", "polygon_supernet_arianee"), - ("12001", "fuse_testnet"), - ("12009", "satoshi"), - ("12020", "aternos"), - ("12051", "singularity_zero_testnet"), - ("12052", "singularity_zero"), - ("12123", "brc"), - ("12306", "fibonacci"), - ("12321", "blg_testnet"), - ("12324", "l3x_protocol"), - ("12325", "l3x_protocol_testnet"), - ("12345", "step_testnet"), - ("12553", "rss3_vsl"), - ("12715", "rikeza_testnet"), - ("12781", "playdapp_testnet"), - ("12890", "quantum_testnet"), - ("12898", "playfair_testnet_subnet"), - ("13000", "sps"), - ("13337", "beam_testnet"), - ("13371", "immutable_zkevm"), - ("13381", "phoenix"), - ("13396", "masa"), - ("13473", "immutable_zkevm_testnet"), - ("13505", "gravity_alpha_testnet_sepolia"), - ("13600", "kronobit"), - ("13812", "susono"), - ("14000", "sps_testnet"), - ("14324", "evolve_testnet"), - ("14333", "vitruveo_testnet"), - ("14801", "vana_satori_testnet"), - ("14853", "humanode_testnet_5_israfel"), - ("15003", "immutable_zkevm_devnet"), - ("15257", "poodl_testnet"), - ("15259", "poodl"), - ("15430", "kymtc"), - ("15551", "loopnetwork"), - ("15555", "trust_evm_testnet"), - ("15557", "eos_evm_testnet"), - ("16000", "metadot"), - ("16001", "metadot_testnet"), - ("16116", "defiverse"), - ("16180", "plyr_phi"), - ("16350", "incentiv_devnet"), - ("16481", "pivotal_sepolia"), - ("16507", "genesys"), - ("16600", "0g_newton_testnet"), - ("16688", "irishub_testnet"), - ("16718", "airdao"), - ("16888", "ivar_testnet"), - ("17000", "holesky"), - ("17001", "redstone_holesky_testnet"), - ("17069", "garnet_holesky"), - ("17071", "on_points"), - ("17117", "defiverse_testnet"), - ("17171", "g8"), - ("17172", "eclipse_subnet"), - ("17180", "palette_testnet"), - ("17217", "konet"), - ("17777", "eos_evm"), - ("18000", "frontier_of_dreams_testnet"), - ("18122", "smart_trades"), - ("18159", "proof_of_memes"), - ("18181", "g8_testnet"), - ("18231", "unreal_old"), - ("18233", "unreal"), - ("18686", "mxc_zkevm_moon"), - ("18888", "titan_tkx"), - ("18889", "titan_tkx_testnet"), - ("19011", "home_verse"), - ("19077", "blockx_atlantis_testnet"), - ("19191", "blockx"), - ("19224", "decentraconnect_social"), - ("19527", "magnet"), - ("19600", "lbry"), - ("19845", "btcix"), - ("20001", "camelark"), - ("20041", "niza"), - ("20073", "niza_testnet"), - ("20729", "callisto_testnet"), - ("20736", "p12"), - ("20765", "jono11_subnet"), - ("21004", "c4ei"), - ("21133", "all_about_healthy"), - ("21223", "dcpay"), - ("21224", "dcpay_testnet"), - ("21337", "cennznet_azalea"), - ("21816", "om"), - ("21912", "bsl"), - ("22023", "taycan"), - ("22040", "airdao_testnet"), - ("22222", "nautilus"), - ("22324", "goldx_testnet"), - ("22776", "map_protocol"), - ("23006", "antofy_testnet"), - ("23118", "opside_testnet"), - ("23294", "oasis_sapphire"), - ("23295", "oasis_sapphire_testnet"), - ("23451", "dreyerx"), - ("23452", "dreyerx_testnet"), - ("23888", "blast_testnet"), - ("24076", "kymtc_testnet"), - ("24484", "web"), - ("24734", "mintme.com"), - ("25186", "liquidlayer"), - ("25839", "alvey_testnet"), - ("25888", "hammer"), - ("25925", "bitkub_testnet"), - ("26026", "ferrum_testnet"), - ("26600", "hertz"), - ("26863", "oasis"), - ("27181", "klaos_nova"), - ("27483", "nanon_sepolia"), - ("27827", "zeroone_subnet"), - ("28516", "vizing_testnet"), - ("28518", "vizing"), - ("28528", "optimism_bedrock_goerli_alpha_testnet"), - ("28882", "boba_sepolia"), - ("29112", "hy_testnet"), - ("29223", "nexa_metanet"), - ("29536", "kai_testnet"), - ("29548", "mch_verse"), - ("30067", "piece_testnet"), - ("30088", "miyou"), - ("30103", "cerium_testnet"), - ("30730", "movement_evm_legacy"), - ("30731", "movement_evm_devnet"), - ("30732", "movement_evm_testnet"), - ("31102", "ethersocial"), - ("31223", "cloudtx"), - ("31224", "cloudtx_testnet"), - ("31337", "go_testnet"), - ("31414", "evoke_testnet"), - ("31415", "filecoin___wallaby_testnet"), - ("31753", "x"), - ("31754", "x_testnet"), - ("32001", "w3gamez_holesky_testnet"), - ("32382", "santiment_intelligence"), - ("32520", "bitgert"), - ("32659", "fusion"), - ("32769", "zilliqa_evm"), - ("32990", "zilliqa_evm_isolated_server"), - ("33033", "entangle"), - ("33101", "zilliqa_evm_testnet"), - ("33103", "zilliqa_2_evm_proto_testnet"), - ("33111", "curtis"), - ("33133", "entangle_testnet"), - ("33210", "cloudverse_subnet"), - ("33333", "aves"), - ("33385", "zilliqa_evm_devnet"), - ("33401", "slingshot"), - ("33469", "zilliqa_2_evm_devnet"), - ("33979", "funki"), - ("34443", "mode"), - ("34504", "zeus"), - ("35011", "j2o_taro"), - ("35441", "q"), - ("35443", "q_testnet"), - ("38400", "connectormanager"), - ("38401", "connectormanager_robin"), - ("39656", "prm"), - ("39797", "energi"), - ("39815", "oho"), - ("41455", "aleph_zero_evm"), - ("41500", "opulent_x_beta"), - ("42069", "pegglecoin"), - ("42072", "agentlayer_testnet"), - ("42161", "arbitrum_one"), - ("42170", "arbitrum_nova"), - ("42220", "celo"), - ("42261", "oasis_emerald_testnet"), - ("42262", "oasis_emerald"), - ("42355", "goldx"), - ("42421", "asset_testnet"), - ("42766", "zkfair"), - ("42793", "etherlink"), - ("42801", "gesoten_verse_testnet"), - ("42888", "kinto_testnet"), - ("43110", "athereum"), - ("43111", "hemi"), - ("43113", "avalanche_fuji_testnet"), - ("43114", "avalanche_c"), - ("43288", "boba_avax"), - ("43851", "zkfair_testnet"), - ("44444", "fren"), - ("44445", "quantum"), - ("44787", "celo_alfajores_testnet"), - ("45000", "autobahn"), - ("45454", "swamps_l2"), - ("45510", "deelance"), - ("45513", "blessnet"), - ("46688", "fusion_testnet"), - ("47763", "neo_x"), - ("47803", "redefi_layer_1"), - ("47805", "rei"), - ("48795", "space_subnet_testnet"), - ("48899", "zircuit_testnet"), - ("48900", "zircuit"), - ("49049", "wireshape_floripa_testnet"), - ("49088", "bifrost_testnet"), - ("49321", "gunz_testnet"), - ("49797", "energi_testnet"), - ("50001", "liveplex_oracleevm"), - ("50005", "yooldo_verse"), - ("50006", "yooldo_verse_testnet"), - ("50021", "gton_testnet"), - ("51178", "lumoz_testnet_alpha"), - ("51712", "sardis"), - ("52014", "electroneum"), - ("53277", "doid"), - ("53302", "superseed_sepolia_testnet"), - ("53457", "dodo_testnet"), - ("53935", "dfk"), - ("54211", "haqq_testnet"), - ("54321", "toronet_testnet"), - ("55004", "titan"), - ("55551", "photon_aurora_testnet"), - ("55556", "rei_testnet"), - ("55614", "flamma"), - ("56026", "lambda"), - ("56288", "boba_bnb"), - ("56400", "testnet_zeroone_subnet"), - ("56789", "velo_labs"), - ("56797", "doid_testnet"), - ("57000", "rollux_testnet"), - ("57451", "coinsec"), - ("58008", "sepolia_pgn_public_goods"), - ("59140", "linea_goerli"), - ("59141", "linea_sepolia"), - ("59144", "linea"), - ("59902", "metis_sepolia_testnet"), - ("59971", "genesys_code"), - ("60000", "thinkium_testnet_0"), - ("60001", "thinkium_testnet_1"), - ("60002", "thinkium_testnet_2"), - ("60103", "thinkium_testnet_103"), - ("60808", "bob"), - ("61022", "orange"), - ("61406", "kai"), - ("61800", "axel_dev_net"), - ("61803", "etica"), - ("61916", "doken_super"), - ("62049", "optopia_testnet"), - ("62050", "optopia"), - ("62298", "citrea_devnet"), - ("62320", "celo_baklava_testnet"), - ("62621", "multivac"), - ("62831", "plyr_tau_testnet"), - ("62850", "laos_sigma_testnet"), - ("63000", "ecredits"), - ("63001", "ecredits_testnet"), - ("65349", "cratd2c_testnet"), - ("65357", "vecno"), - ("65450", "scolcoin"), - ("65536", "automata"), - ("66988", "janus_testnet"), - ("67390", "siriusnet"), - ("67588", "cosmic"), - ("68770", "dm2_verse"), - ("69420", "condrieu"), - ("70000", "thinkium_0"), - ("70001", "thinkium_1"), - ("70002", "thinkium_2"), - ("70103", "thinkium_103"), - ("70700", "proof_of_play___apex"), - ("71111", "guapcoinx"), - ("71393", "polyjuice_testnet"), - ("71401", "godwoken_testnet_v1"), - ("71402", "godwoken"), - ("72778", "caga_crypto_ankara_testnet"), - ("72992", "grok"), - ("73114", "icb_testnet"), - ("73115", "icb"), - ("73799", "energy_web_volta_testnet"), - ("73927", "mixin_virtual_machine"), - ("75000", "resincoin"), - ("75512", "geek_verse"), - ("75513", "geek_verse_testnet"), - ("77001", "bora"), - ("77238", "foundry_testnet"), - ("77612", "vention"), - ("77677", "cycle_sailboat"), - ("77777", "toronet"), - ("78110", "firenze_test"), - ("78281", "dragonfly_hexapod"), - ("78430", "amplify_subnet"), - ("78431", "bulletin_subnet"), - ("78432", "conduit_subnet"), - ("78600", "vanguard"), - ("79879", "gold_testnet"), - ("80001", "mumbai"), - ("80002", "amoy"), - ("80008", "polynomia_sepolia"), - ("80084", "bera_bartio"), - ("80085", "bera_artio"), - ("80096", "hizoco"), - ("81041", "nordek"), - ("81341", "amana_testnet"), - ("81342", "amana_mixnet"), - ("81343", "amana_privnet"), - ("81351", "flana_testnet"), - ("81352", "flana_mixnet"), - ("81353", "flana_privnet"), - ("81361", "mizana_testnet"), - ("81362", "mizana_mixnet"), - ("81363", "mizana_privnet"), - ("82459", "smart_layer_testnet"), - ("83144", "xprotocol_testnet"), - ("83872", "zedxion"), - ("84531", "base_goerli_testnet"), - ("84532", "base_sepolia_testnet"), - ("84886", "aerie"), - ("85449", "cybertrust"), - ("88002", "nautilus_proteus_testnet"), - ("88559", "inoai"), - ("88800", "zkasino"), - ("88817", "unit_zero_testnet"), - ("88819", "unit_zero_stagenet"), - ("88880", "chiliz_scoville_testnet"), - ("88882", "chiliz_spicy_testnet"), - ("88888", "chiliz"), - ("90001", "fxcore_testnet"), - ("90210", "beverly_hills"), - ("90354", "camp_testnet"), - ("91002", "nautilus_trition"), - ("91120", "metadap_enterprise"), - ("91715", "combo_testnet"), - ("92001", "lambda_testnet"), - ("93572", "liquidlayer_testnet"), - ("93747", "stratovm_testnet"), - ("96970", "mantis_testnet_hexapod"), - ("97288", "boba_bnb_old"), - ("97435", "slingshot_testnet"), - ("97531", "green_testnet"), - ("97970", "optimusz7_testnet"), - ("98881", "ebi"), - ("99099", "eliberty_testnet"), - ("99876", "edgamatrix_testnet"), - ("99998", "ubtestnet"), - ("99999", "ub"), - ("100000", "quark_root"), - ("100001", "quark_shard_0"), - ("100002", "quark_shard_1"), - ("100003", "quark_shard_2"), - ("100004", "quark_shard_3"), - ("100005", "quark_shard_4"), - ("100006", "quark_shard_5"), - ("100007", "quark_shard_6"), - ("100008", "quark_shard_7"), - ("100009", "ve"), - ("100010", "ve_testnet"), - ("100011", "quark_l2"), - ("101010", "global_trust"), - ("102031", "creditcoin_testnet"), - ("103090", "crystaleum"), - ("103454", "masa_testnet"), - ("104566", "kaspaclassic"), - ("105105", "stratis"), - ("108801", "bro"), - ("110000", "quark_devnet_root"), - ("110001", "quark_devnet_shard_0"), - ("110002", "quark_devnet_shard_1"), - ("110003", "quark_devnet_shard_2"), - ("110004", "quark_devnet_shard_3"), - ("110005", "quark_devnet_shard_4"), - ("110006", "quark_devnet_shard_5"), - ("110007", "quark_devnet_shard_6"), - ("110008", "quark_devnet_shard_7"), - ("110011", "quark_l2_testnet"), - ("110110", "mars_credit"), - ("111000", "siberium_test"), - ("111111", "siberium"), - ("111188", "re.al"), - ("112358", "meta_one"), - ("119139", "metadap_enterprise_testnet"), - ("123321", "gem"), - ("123456", "adil_devnet"), - ("128123", "etherlink_testnet"), - ("131313", "odyssey_testnet"), - ("131419", "etnds"), - ("132902", "form_testnet"), - ("141319", "magape_testnet"), - ("142857", "icplaza"), - ("161212", "playfi"), - ("165279", "eclat"), - ("167000", "taiko"), - ("167004", "taiko_alpha_2_testnet"), - ("167005", "taiko_grimsvotn_l2"), - ("167006", "taiko_eldfell_l3"), - ("167007", "taiko_jolnir_l2"), - ("167008", "taiko_katla_l2"), - ("167009", "taiko_hekla_l2"), - ("175177", "chronicle___lit_protocol_testnet"), - ("175188", "chronicle_yellowstone___lit_protocol_testnet"), - ("188710", "bitica"), - ("188881", "condor_test"), - ("199991", "mazze_testnet"), - ("200000", "xfair.ai_testnet"), - ("200101", "milkomeda_c1_testnet"), - ("200202", "milkomeda_a1_testnet"), - ("200625", "akroma"), - ("200810", "bitlayer_testnet"), - ("200901", "bitlayer"), - ("201018", "alaya"), - ("201030", "alaya_dev_testnet"), - ("201804", "mythical"), - ("202020", "decimal_testnet"), - ("202212", "x1_devnet"), - ("202401", "ymtech_besu_testnet"), - ("202624", "jellie"), - ("204005", "x1_network"), - ("205205", "auroria_testnet"), - ("210049", "gitagi_atlas_testnet"), - ("210425", "platon"), - ("220315", "mas"), - ("221230", "reap"), - ("221231", "reap_testnet"), - ("222222", "hydradx"), - ("222555", "deepl"), - ("222666", "deepl_testnet"), - ("224168", "taf_eco"), - ("224422", "conet_sebolia_testnet"), - ("224433", "conet_holesky"), - ("229772", "abyss_protocol"), - ("230315", "hashkey_testnetdiscard"), - ("234666", "haymo_testnet"), - ("240515", "orange_testnet"), - ("246529", "artis_sigma1"), - ("246785", "artis_testnet_tau1"), - ("247253", "saakuru_testnet"), - ("256256", "cmp"), - ("262371", "eclat_testnet"), - ("266256", "gear_zero_testnet"), - ("271271", "egoncoin_testnet"), - ("281121", "social"), - ("282828", "zillion_sepolia_testnet"), - ("292003", "cipherem_testnet"), - ("309075", "one_world"), - ("313313", "saharaai_testnet"), - ("314159", "filecoin___calibration_testnet"), - ("322202", "parex"), - ("323213", "bloom_genesis_testnet"), - ("327126", "waba_testnet"), - ("328527", "nal"), - ("330844", "ttcoin"), - ("333313", "bloom_genesis"), - ("333331", "aves_testnet"), - ("333333", "nativ3_testnet"), - ("333666", "oone_testnet"), - ("333777", "oone_devnet"), - ("333888", "polis_testnet"), - ("333999", "polis"), - ("336655", "up_testnet"), - ("336666", "up"), - ("355110", "bitfinity"), - ("355113", "bitfinity_testnet"), - ("360890", "lavita"), - ("363636", "digit_soul_2"), - ("373737", "hap_testnet"), - ("381931", "metal_c"), - ("381932", "metal_tahoe_c"), - ("404040", "tipboxcoin"), - ("413413", "aie_testnet"), - ("420420", "kek"), - ("420666", "kek_kektest"), - ("420692", "alterium_l2_testnet"), - ("421611", "arbitrum_rinkeby"), - ("421613", "arbitrum_goerli"), - ("421614", "arbitrum_sepolia"), - ("424242", "fastex_testnet"), - ("431140", "markr_go"), - ("432201", "dexalot_subnet_testnet"), - ("432204", "dexalot_subnet"), - ("444444", "syndr_l3_sepolia"), - ("444900", "weelink_testnet"), - ("471100", "patex_sepolia_testnet"), - ("473861", "ultra_pro"), - ("474142", "open"), - ("486487", "gobbl_testnet"), - ("490000", "autonomys_testnet_nova_domain"), - ("504441", "playdapp"), - ("512512", "cmp_testnet"), - ("513100", "dis"), - ("526916", "docoin_community"), - ("534351", "scroll_sepolia_testnet"), - ("534352", "scroll"), - ("534353", "scroll_alpha_testnet"), - ("534354", "scroll_pre_alpha_testnet"), - ("534849", "shinarium_beta"), - ("535037", "beaneco_smart"), - ("552981", "one_world_testnet"), - ("555555", "pentagon_testnet"), - ("555666", "eclipse_testnet"), - ("622277", "hypra"), - ("622463", "atlas"), - ("641230", "bear"), - ("651940", "all"), - ("656476", "open_campus_codex"), - ("660279", "xai"), - ("666666", "vision___vpioneer_test"), - ("666888", "hela_official_runtime_testnet"), - ("686868", "won"), - ("696969", "galadriel_devnet"), - ("710420", "tiltyard_subnet"), - ("713715", "sei_devnet"), - ("721529", "eram"), - ("743111", "hemi_sepolia"), - ("751230", "bear_testnet"), - ("752024", "ternoa_testnet"), - ("761412", "miexs_smart"), - ("764984", "lamina1_testnet"), - ("767368", "lamina1_identity_testnet"), - ("776877", "modularium"), - ("800001", "octaspace"), - ("808080", "biz_testnet"), - ("808813", "bob_sepolia"), - ("810180", "zklink_nova"), - ("810181", "zklink_nova_sepolia_testnet"), - ("810182", "zklink_nova_goerli_testnet"), - ("820522", "tsc_testnet"), - ("827431", "curve"), - ("839320", "prm_testnet"), - ("840000", "runevm_testnet"), - ("846000", "4goodnetwork"), - ("855456", "dodao"), - ("879151", "blocx"), - ("888882", "rexx"), - ("888888", "vision"), - ("900000", "posi_shard_0"), - ("910000", "posi_testnet_shard_0"), - ("912559", "astria_evm_dusknet"), - ("920000", "posi_devnet_shard_0"), - ("920001", "posi_devnet_shard_1"), - ("923018", "fncy_testnet"), - ("955081", "jono12_subnet"), - ("955305", "eluvio_content_fabric"), - ("978657", "treasure_ruby"), - ("984122", "forma"), - ("984123", "forma_sketchpad"), - ("988207", "ecrox"), - ("998899", "supernet_testnet"), - ("999999", "am"), - ("1100789", "netmind_testnet"), - ("1234567", "sharecle"), - ("1261120", "zkatana"), - ("1313114", "etho_protocol"), - ("1313500", "xerom"), - ("1337702", "kintsugi"), - ("1337802", "kiln"), - ("1337803", "zhejiang"), - ("1398243", "automata_testnet"), - ("1612127", "playfi_albireo_testnet"), - ("1637450", "xterio_testnet"), - ("1731313", "turkey_demo_dev"), - ("2021398", "debank_testnet"), - ("2099156", "plian_main"), - ("2206132", "platon_dev_testnet2"), - ("2611555", "dpu"), - ("2702128", "xterio"), - ("3132023", "saharaai"), - ("3141592", "filecoin___butterfly_testnet"), - ("3397901", "funki_sepolia_sandbox"), - ("3441005", "manta_pacific_testnet"), - ("3441006", "manta_pacific_sepolia_testnet"), - ("4000003", "altlayer_zero_gas"), - ("4281033", "worlds_caldera"), - ("4444444", "altar_testnet"), - ("4457845", "zero_testnet_sepolia"), - ("5112023", "numblock"), - ("5167003", "mxc_wannsee_zkevm_testnet"), - ("5167004", "moon_geneva_testnet"), - ("5201420", "electroneum_testnet"), - ("5318008", "reactive_kopli"), - ("5555555", "imversed"), - ("5555558", "imversed_testnet"), - ("6038361", "astar_zkyoto"), - ("6666665", "safeanwang"), - ("6666666", "safeanwang_testnet"), - ("7225878", "saakuru"), - ("7355310", "openvessel"), - ("7668378", "ql1_testnet"), - ("7762959", "musicoin"), - ("7777777", "zora"), - ("8007736", "plian_sub_1"), - ("8008135", "fhenix_helium"), - ("8080808", "hokum"), - ("8601152", "waterfall_8_test"), - ("8794598", "hap"), - ("8888881", "quarix_testnet"), - ("8888888", "quarix"), - ("9322252", "xcap"), - ("9322253", "milvine"), - ("10067275", "plian_testnet_sub_1"), - ("10101010", "soverun"), - ("10241024", "alienx"), - ("10241025", "alienx_hal_testnet"), - ("11145513", "blessnet_sepolia"), - ("11155111", "sepolia"), - ("11155420", "op_sepolia_testnet"), - ("12052024", "memento_testnet"), - ("12227331", "neox_testnet_t3"), - ("12227332", "neox_testnet_t4"), - ("13068200", "coti_devnet"), - ("13371337", "pep_churchill"), - ("14288640", "andus"), - ("16658437", "plian_testnet_main"), - ("18071918", "mande"), - ("18289463", "iolite"), - ("19850818", "deepbrain_testnet"), - ("19880818", "deepbrain"), - ("20180427", "stability_testnet"), - ("20180430", "smartmesh"), - ("20181205", "quarkblock"), - ("20201022", "pego"), - ("20230825", "vcity_testnet"), - ("20240324", "debank_sepolia_testnet"), - ("20240603", "dbk"), - ("20241133", "swan_proxima_testnet"), - ("20482050", "hokum_testnet"), - ("22052002", "excelon"), - ("27082017", "excoincial_volta_testnet"), - ("27082022", "excoincial"), - ("28122024", "ancient8_testnet"), - ("28945486", "auxilium"), - ("29032022", "fla"), - ("31415926", "filecoin___local_testnet"), - ("35855456", "joys_digital"), - ("37084624", "skale_nebula_hub_testnet"), - ("39916801", "kingdom"), - ("43214913", "maistestsubnet"), - ("61717561", "aqua"), - ("65010000", "autonity_bakerloo_thames_testnet"), - ("65010001", "autonity_bakerloo_barada_testnet"), - ("65010002", "autonity_bakerloo_sumida_testnet"), - ("65010003", "autonity_bakerloo_yamuna_testnet"), - ("65100000", "autonity_piccadilly_thames_testnet"), - ("65100001", "autonity_piccadilly_barada_testnet"), - ("65100002", "autonity_piccadilly_sumida_testnet"), - ("65100003", "autonity_piccadilly_yamuna_testnet"), - ("68840142", "frame_testnet"), - ("77787778", "0xhash_testnet"), - ("79479957", "sx_toronto_rollup"), - ("88558801", "backstop_testnet"), - ("88888888", "t.e.a.m_block"), - ("94204209", "polygon_blackberry"), - ("99415706", "joys_digital_testnet"), - ("108160679", "orai"), - ("111557560", "cyber_testnet"), - ("123420111", "op_celestia_raspberry"), - ("161221135", "plume_testnet"), - ("168587773", "blast_sepolia_testnet"), - ("192837465", "gather"), - ("222000222", "kanazawa"), - ("245022926", "neon_evm_devnet"), - ("245022929", "neon_evm_devnet_rollup"), - ("245022934", "neon_evm"), - ("245022940", "neon_evm_testnet"), - ("278611351", "razor_skale"), - ("311752642", "oneledger"), - ("328527624", "nal_sepolia_testnet"), - ("333000333", "meld"), - ("356256156", "gather_testnet"), - ("476462898", "skopje_testnet"), - ("486217935", "gather_devnet"), - ("666666666", "degen"), - ("888888888", "ancient8"), - ("889910245", "ptcescan_testnet"), - ("889910246", "ptcescan"), - ("974399131", "skale_calypso_hub_testnet"), - ("999999999", "zora_sepolia_testnet"), - ("1020352220", "skale_titan_hub_testnet"), - ("1122334455", "ipos"), - ("1146703430", "cyberdecknet"), - ("1273227453", "human_protocol"), - ("1313161554", "aurora"), - ("1313161555", "aurora_testnet"), - ("1313161556", "aurora_betanet"), - ("1313161560", "powergold"), - ("1350216234", "skale_titan_hub"), - ("1351057110", "chaos_skale_testnet"), - ("1380012617", "rari"), - ("1380996178", "raptor"), - ("1444673419", "skale_europa_hub_testnet"), - ("1482601649", "skale_nebula_hub"), - ("1511670449", "gpt"), - ("1564830818", "skale_calypso_hub"), - ("1666600000", "harmony_shard_0"), - ("1666600001", "harmony_shard_1"), - ("1666600002", "harmony_shard_2"), - ("1666600003", "harmony_shard_3"), - ("1666700000", "harmony_testnet_shard_0"), - ("1666700001", "harmony_testnet_shard_1"), - ("1666900000", "harmony_devnet_shard_0"), - ("1666900001", "harmony_devnet_shard_1"), - ("1802203764", "kakarot_sepolia"), - ("1903648807", "gemu_testnet"), - ("1918988905", "rari_testnet"), - ("2021121117", "datahopper"), - ("2046399126", "skale_europa_hub"), - ("3125659152", "pirl"), - ("4216137055", "oneledger_testnet_frankenstein"), - ("11297108099", "palm_testnet"), - ("11297108109", "palm"), - ("28872323069", "gitswarm_test"), - ("37714555429", "xai_testnet_v2"), - ("88153591557", "arbitrum_blueberry"), - ("111222333444", "alphabet"), - ("123420000220", "fluence_stage"), - ("197710212030", "ntity"), - ("197710212031", "haradev_testnet"), - ("202402181627", "gm_testnet"), - ("383414847825", "zeniq"), - ("666301171999", "pdc"), - ("6022140761023", "molereum"), - ("2713017997578000", "d_testnet"), - ] - .into_iter() - .filter_map(|(chain_id, name)| match chain_id.try_into_chain_id() { - Ok(chain_id) => Some((chain_id, name.to_string())), - Err(_) => None, - }) - .collect() +pub fn get_network_names() -> &'static HashMap { + static CACHE: OnceLock> = OnceLock::new(); + CACHE.get_or_init(|| NETWORKS.iter().map(|&(chain_id, name)| (chain_id.into(), name)).collect()) } + +pub(crate) const NETWORKS: &[(u64, &str)] = &[ + (1, "ethereum"), + (2, "expanse"), + (3, "ropsten"), + (4, "rinkeby"), + (5, "goerli"), + (6, "kotti_testnet"), + (7, "thai"), + (8, "ubiq"), + (9, "ubiq_testnet"), + (10, "optimism"), + (11, "metadium"), + (12, "metadium_testnet"), + (13, "diode_testnet_staging"), + (14, "flare"), + (15, "diode_prenet"), + (16, "songbird_testnet_coston"), + (17, "thaifi"), + (18, "thundercore_testnet"), + (19, "songbird_canary"), + (20, "elastos"), + (21, "elastos_testnet"), + (22, "ela_did"), + (23, "ela_did_testnet"), + (24, "kardia"), + (25, "cronos"), + (26, "genesis_testnet"), + (27, "shiba"), + (28, "boba_rinkeby_testnet"), + (29, "genesis"), + (30, "rootstock"), + (31, "rootstock_testnet"), + (32, "gooddata_testnet"), + (33, "gooddata"), + (34, "secure"), + (35, "tbwg"), + (36, "dx"), + (37, "xpla"), + (38, "valorbit"), + (39, "u2u_solaris"), + (40, "telos_evm"), + (41, "telos_evm_testnet"), + (42, "lukso"), + (43, "darwinia_pangolin_testnet"), + (44, "crab"), + (45, "darwinia_pangoro_testnet"), + (46, "darwinia"), + (47, "acria_intelli"), + (48, "ennothem_proterozoic"), + (49, "ennothem_testnet_pioneer"), + (50, "xdc"), + (51, "xdc_apothem"), + (52, "coinex"), + (53, "coinex_testnet"), + (54, "openpiece"), + (55, "zyx"), + (56, "bnb"), + (57, "syscoin"), + (58, "ontology"), + (59, "eos_evm_legacy"), + (60, "go"), + (61, "ethereum_classic"), + (62, "morden_testnet"), + (63, "mordor_testnet"), + (64, "ellaism"), + (65, "okex_testnet"), + (66, "okx"), + (67, "db_testnet"), + (68, "soterone"), + (69, "optimism_kovan"), + (70, "hoo"), + (71, "conflux_espace_testnet"), + (72, "dx_testnet"), + (73, "fncy"), + (74, "id"), + (75, "decimal"), + (76, "mix"), + (77, "poa_sokol"), + (78, "primus"), + (79, "zenith"), + (80, "gene"), + (81, "japan_open"), + (82, "meter"), + (83, "meter_testnet"), + (84, "linqto_devnet"), + (85, "gate_testnet"), + (86, "gate"), + (87, "nova"), + (88, "viction"), + (89, "viction_testnet"), + (90, "garizon_stage0"), + (91, "garizon_stage1"), + (92, "garizon_stage2"), + (93, "garizon_stage3"), + (94, "swissdlt"), + (95, "camdl"), + (96, "bitkub"), + (97, "bnb_testnet"), + (98, "six_protocol"), + (99, "poa_core"), + (100, "gnosis"), + (101, "etherinc"), + (102, "web3games_testnet"), + (103, "worldland"), + (104, "kaiba_lightning_testnet"), + (105, "web3games_devnet"), + (106, "velas_evm"), + (107, "nebula_testnet"), + (108, "thundercore"), + (109, "shibarium"), + (110, "proton_testnet"), + (111, "etherlite"), + (112, "coinbit"), + (113, "dehvo"), + (114, "flare_testnet_coston2"), + (116, "debank"), + (117, "uptick"), + (118, "arcology_testnet"), + (119, "enuls"), + (120, "enuls_testnet"), + (121, "real"), + (122, "fuse"), + (123, "fuse_sparknet"), + (124, "decentralized_web"), + (125, "oy_testnet"), + (126, "oy"), + (127, "factory_127"), + (128, "huobi_eco"), + (129, "innovator"), + (131, "engram_testnet"), + (132, "namefi"), + (133, "hashkey_testnet"), + (134, "iexec"), + (135, "alyx_testnet"), + (136, "deam"), + (137, "polygon"), + (138, "defi_oracle_meta"), + (139, "woop"), + (140, "eternal"), + (141, "openpiece_testnet"), + (142, "dax"), + (144, "phi_v2"), + (145, "soraai_testnet"), + (147, "flag"), + (148, "shimmerevm"), + (150, "six_protocol_testnet"), + (151, "redbelly"), + (152, "redbelly_devnet"), + (153, "redbelly_testnet"), + (154, "redbelly_tge"), + (155, "tenet_testnet"), + (156, "oeblock_testnet"), + (157, "puppynet_shibarium"), + (158, "roburna"), + (159, "roburna_testnet"), + (160, "armonia_eva"), + (161, "armonia_eva_testnet"), + (162, "lightstreams_testnet"), + (163, "lightstreams"), + (164, "omni_omega"), + (166, "omni"), + (167, "atoshi_testnet"), + (168, "aioz"), + (169, "manta_pacific"), + (170, "hoo_testnet"), + (171, "co2e_ledger"), + (172, "latam_block_resil_testnet"), + (176, "dc"), + (178, "abey_testnet"), + (179, "abey"), + (180, "ame"), + (181, "waterfall"), + (184, "dojima_testnet"), + (185, "mint"), + (186, "seele"), + (187, "dojima"), + (188, "bmc"), + (189, "bmc_testnet"), + (190, "cmdao_bbq"), + (191, "filefilego"), + (193, "crypto_emergency"), + (195, "x_layer_testnet"), + (196, "x_layer"), + (197, "neutrinos_testnet"), + (198, "bit"), + (199, "bittorrent"), + (200, "arbitrum_on_xdai"), + (201, "moac_testnet"), + (202, "edgeless_testnet"), + (204, "opbnb"), + (205, "ekaash"), + (206, "vinu_testnet"), + (207, "vinu"), + (208, "structx"), + (210, "bitnet"), + (211, "freight_trust"), + (212, "mapo_makalu"), + (213, "b2_hub"), + (214, "shinarium"), + (217, "siriusnet_v2"), + (218, "soterone_old"), + (220, "scalind_testnet"), + (221, "blockex"), + (222, "permission"), + (223, "b2"), + (224, "viridis_testnet"), + (225, "la"), + (226, "la_testnet"), + (228, "mind"), + (230, "swapdex"), + (233, "ethernity_testnet"), + (234, "protojumbo_testnet"), + (236, "deam_testnet"), + (238, "blast"), + (242, "plinga"), + (246, "energy_web"), + (248, "oasys"), + (250, "fantom_opera"), + (252, "fraxtal"), + (254, "swan"), + (255, "kroma"), + (256, "huobi_eco_testnet"), + (258, "setheum"), + (259, "neonlink"), + (261, "guru_testnet"), + (262, "sur_block"), + (266, "neura"), + (267, "neura_testnet"), + (268, "neura_devnet"), + (269, "high_performance_block"), + (271, "egoncoin"), + (278, "xfair.ai"), + (279, "bpx_block"), + (282, "cronos_zkevm_testnet"), + (288, "boba"), + (291, "orderly"), + (295, "hedera"), + (296, "hedera_testnet"), + (297, "hedera_previewnet"), + (298, "hedera_localnet"), + (300, "zksync_sepolia_testnet"), + (301, "bobaopera"), + (302, "zkcandy_sepolia_testnet"), + (303, "neuro_testnet"), + (305, "zksats"), + (307, "lovely_testnet"), + (308, "furtheon"), + (309, "wyzth_testnet"), + (311, "omax"), + (313, "neuro"), + (314, "filecoin"), + (321, "kcc"), + (322, "kcc_testnet"), + (323, "cosvm"), + (324, "zksync"), + (325, "grvt"), + (326, "grvt_sepolia_testnet"), + (333, "web3q"), + (335, "dfk_test"), + (336, "shiden"), + (338, "cronos_testnet"), + (345, "tsc"), + (360, "shape"), + (361, "theta"), + (363, "theta_sapphire_testnet"), + (364, "theta_amber_testnet"), + (365, "theta_testnet"), + (369, "pulse"), + (371, "consta_testnet"), + (380, "zkamoeba_testnet"), + (381, "zkamoeba"), + (385, "lisinski"), + (388, "cronos_zkevm"), + (395, "camdl_testnet"), + (397, "near"), + (398, "near_testnet"), + (399, "nativ3"), + (400, "hyperon_testnet"), + (401, "ozone_testnet"), + (404, "syndr_l3"), + (411, "pepe"), + (416, "sx"), + (418, "latestnet"), + (420, "optimism_goerli_testnet"), + (422, "viridis"), + (424, "pgn_public_goods"), + (427, "zeeth"), + (428, "geso_verse"), + (434, "boyaa"), + (443, "ten_testnet"), + (444, "synapse_testnet"), + (456, "arzio"), + (462, "areon_testnet"), + (463, "areon"), + (480, "world"), + (499, "rupaya"), + (500, "camino_c"), + (501, "columbus_test"), + (510, "syndicate"), + (512, "double_a"), + (513, "double_a_testnet"), + (516, "gear_zero"), + (520, "xt"), + (529, "fire"), + (530, "fxcore"), + (534, "candle"), + (537, "optrust"), + (542, "paw_testnet"), + (545, "evm_on_flow_testnet"), + (555, "vela1"), + (558, "tao"), + (568, "doge_testnet"), + (570, "rollux"), + (571, "meta"), + (579, "filenova"), + (588, "metis_stardust_testnet"), + (592, "astar"), + (595, "acala_mandala_testnet_tc9"), + (596, "karura_testnet"), + (597, "acala_testnet"), + (599, "metis_goerli_testnet"), + (600, "meshnyan_testnet"), + (601, "vine_testnet"), + (610, "darwin_devnet"), + (612, "eiob"), + (614, "graphlinq_block"), + (624, "binary"), + (625, "binary_sepolia"), + (634, "avocado"), + (646, "previewnet"), + (647, "sx_testnet"), + (648, "endurance"), + (653, "kali_testnet"), + (654, "kali"), + (662, "ultronsmart"), + (666, "pixie_testnet"), + (667, "laos_arrakis"), + (668, "junca"), + (669, "junca_testnet"), + (686, "karura"), + (690, "redstone"), + (700, "star_social_testnet"), + (701, "darwinia_koi_testnet"), + (707, "block_station"), + (708, "block_station_testnet"), + (710, "highbury"), + (711, "tucana"), + (712, "birdee_2"), + (713, "vrcscan"), + (719, "shibarium_beta"), + (721, "lycan"), + (727, "blucrates"), + (730, "lovely"), + (740, "canto_testnet"), + (741, "vention_testnet"), + (742, "script_testnet"), + (747, "evm_on_flow"), + (766, "ql1"), + (776, "open_testnet"), + (777, "cheapeth"), + (786, "maal"), + (787, "acala"), + (788, "aero_testnet"), + (789, "patex"), + (799, "rupaya_testnet"), + (800, "lucid_block"), + (803, "haic"), + (808, "portal_fantasy_test"), + (810, "haven1_testnet"), + (813, "qitmeer"), + (814, "fire_zkevm"), + (818, "beone"), + (820, "callisto"), + (822, "runic_testnet"), + (831, "checkdot_block_devnet"), + (841, "taraxa"), + (842, "taraxa_testnet"), + (852, "hongkong"), + (859, "zeeth_dev"), + (868, "fantasia"), + (876, "bandai_namco_research_verse"), + (877, "dexit"), + (880, "ambros"), + (888, "wan"), + (898, "maxi_testnet"), + (899, "maxi"), + (900, "garizon_testnet_stage0"), + (901, "garizon_testnet_stage1"), + (902, "garizon_testnet_stage2"), + (903, "garizon_testnet_stage3"), + (909, "portal_fantasy"), + (910, "decentrabone_layer1_testnet"), + (911, "taproot"), + (917, "rinia_testnet"), + (919, "mode_testnet"), + (927, "yidark"), + (940, "pulse_testnet"), + (941, "pulse_testnet_v2b"), + (942, "pulse_testnet_v3"), + (943, "pulse_testnet_v4"), + (945, "subtensor_evm_testnet"), + (956, "munode_testnet"), + (957, "lyra"), + (963, "btc20"), + (969, "ethxy"), + (970, "oort"), + (971, "oort_huygens"), + (972, "oort_ascraeus"), + (973, "palm"), + (977, "nepal_block"), + (979, "ethxy_testnet"), + (980, "top_evm"), + (985, "memo"), + (989, "top"), + (990, "eliberty"), + (995, "5ire"), + (996, "bifrost_polkadot"), + (997, "5ire_thunder_testnet"), + (998, "lucky"), + (999, "wan_testnet"), + (1000, "gton"), + (1001, "kaia_testnet_kairos"), + (1003, "tectum_emission_token"), + (1004, "t_ekta"), + (1007, "newton_testnet"), + (1008, "eurus"), + (1009, "jumbo"), + (1010, "evrice"), + (1011, "rebus"), + (1012, "newton"), + (1022, "sakura"), + (1023, "clover_testnet"), + (1024, "clv_para"), + (1028, "bittorrent_testnet"), + (1030, "conflux_espace"), + (1031, "proxy_testnet"), + (1038, "bronos_testnet"), + (1039, "bronos"), + (1073, "shimmerevm_testnet"), + (1075, "iota_evm_testnet"), + (1079, "mintara_testnet"), + (1080, "mintara"), + (1088, "metis_andromeda"), + (1089, "humans.ai"), + (1099, "moac"), + (1100, "dymension"), + (1101, "polygon_zkevm"), + (1107, "blxq_testnet"), + (1108, "blxq"), + (1111, "wemix"), + (1112, "wemix_testnet"), + (1113, "b2_hub_testnet"), + (1115, "core_block_testnet"), + (1116, "core_block"), + (1117, "dogcoin"), + (1123, "b2_testnet"), + (1130, "defi_evm"), + (1131, "defi_evm_testnet"), + (1133, "defimeta_changi_testnet"), + (1135, "lisk"), + (1138, "amstar_testnet"), + (1139, "math"), + (1140, "math_testnet"), + (1147, "flag_testnet"), + (1149, "symplexia"), + (1170, "origin_testnet"), + (1177, "smart_host_teknoloji_testnet"), + (1188, "clubmos"), + (1197, "iora"), + (1200, "cuckoo"), + (1201, "evanesco_testnet"), + (1202, "world_trade_technical"), + (1209, "saitablocksbc"), + (1210, "cuckoo_sepolia"), + (1213, "popcateum"), + (1214, "enter"), + (1221, "cycle_testnet"), + (1223, "cycle_testnet_jellyfish"), + (1225, "hybrid_testnet"), + (1227, "bitcoin_protocol_testnet"), + (1228, "cycle_testnet_cuttlefish"), + (1229, "exzo"), + (1230, "ultron_testnet"), + (1231, "ultron"), + (1234, "step"), + (1235, "itx"), + (1243, "arc"), + (1244, "arc_testnet"), + (1246, "om_platform"), + (1248, "dogether"), + (1252, "cic_testnet"), + (1280, "halo"), + (1284, "moonbeam"), + (1285, "moonriver"), + (1286, "moonrock_old"), + (1287, "moonbase_alpha"), + (1288, "moonrock"), + (1291, "swisstronik_testnet"), + (1294, "bobabeam"), + (1297, "bobabase_testnet"), + (1311, "dos_fuji_subnet"), + (1313, "jaiho"), + (1314, "alyx"), + (1319, "aia"), + (1320, "aia_testnet"), + (1328, "sei_testnet"), + (1329, "sei"), + (1337, "geth_testnet"), + (1338, "elysium_testnet"), + (1339, "elysium"), + (1343, "blitz_subnet"), + (1353, "cic"), + (1369, "zafirium"), + (1370, "ramestta"), + (1377, "pingaksha_testnet"), + (1379, "kalar"), + (1388, "amstar"), + (1392, "joseon"), + (1402, "polygon_zkevm_testnet_old"), + (1414, "silicon_zkevm_sepolia_testnet"), + (1422, "polygon_zkevm_testnet_pre_audit_upgraded"), + (1433, "rikeza"), + (1440, "living_assets"), + (1442, "polygon_zkevm_testnet"), + (1452, "gil_testnet"), + (1453, "meta_istanbul"), + (1455, "ctex_scan_block"), + (1456, "zkbase"), + (1490, "vitruveo"), + (1499, "idos_games_testnet"), + (1501, "bevm_canary"), + (1506, "sherpax"), + (1507, "sherpax_testnet"), + (1513, "story_testnet"), + (1515, "beagle_messaging"), + (1559, "tenet"), + (1570, "star_testnet"), + (1578, "star"), + (1617, "ethereum_inscription"), + (1618, "catecoin"), + (1620, "atheios"), + (1625, "gravity_alpha"), + (1648, "pivotal"), + (1657, "bta"), + (1662, "liqui"), + (1663, "horizen_gobi_testnet"), + (1686, "mint_testnet"), + (1687, "mint_sepolia_testnet"), + (1688, "ludan"), + (1701, "anytype_evm"), + (1707, "tbsi"), + (1708, "tbsi_testnet"), + (1717, "doric"), + (1718, "palette"), + (1729, "reya"), + (1740, "metal_l2_testnet"), + (1750, "metal_l2"), + (1773, "party"), + (1777, "gauss"), + (1789, "zkbase_sepolia_testnet"), + (1804, "kerleano"), + (1807, "rabbit_analog_testnet"), + (1811, "lif3_testnet"), + (1818, "cube"), + (1819, "cube_testnet"), + (1821, "ruby"), + (1853, "highoctane_subnet"), + (1856, "teslafunds"), + (1875, "white"), + (1881, "gitshock_cartenz_testnet"), + (1890, "lightlink_phoenix"), + (1891, "lightlink_pegasus_testnet"), + (1898, "bon"), + (1899, "redefi_layer_2"), + (1904, "sports"), + (1907, "bitci"), + (1908, "bitci_testnet"), + (1909, "merkle_scan"), + (1911, "scalind"), + (1912, "ruby_testnet"), + (1918, "upb_crescdi_testnet"), + (1945, "onus_testnet"), + (1946, "minato"), + (1951, "d"), + (1953, "selendra_testnet"), + (1954, "dexilla_testnet"), + (1956, "aiw3_testnet"), + (1961, "selendra"), + (1967, "eleanor"), + (1969, "super_testnet"), + (1970, "super"), + (1971, "atelier"), + (1972, "redecoin"), + (1975, "onus"), + (1984, "eurus_testnet"), + (1985, "satoshie"), + (1986, "satoshie_testnet"), + (1987, "ethergem"), + (1992, "hubble_exchange"), + (1993, "b3_sepolia_testnet"), + (1994, "ekta"), + (1995, "edexa_testnet"), + (1996, "sanko"), + (1997, "kyoto"), + (1998, "kyoto_testnet"), + (2000, "doge"), + (2001, "milkomeda_c1"), + (2002, "milkomeda_a1"), + (2004, "metalink"), + (2008, "cloudwalk_testnet"), + (2009, "cloudwalk"), + (2013, "panarchy"), + (2014, "now_testnet"), + (2016, "mainnetz"), + (2017, "adiri"), + (2018, "publicmint_devnet"), + (2019, "publicmint_testnet"), + (2020, "publicmint"), + (2021, "edgeware_edgeevm"), + (2022, "beresheet_bereevm_testnet"), + (2023, "taycan_testnet"), + (2024, "swan_saturn_testnet"), + (2025, "rangers_protocol"), + (2026, "edgeless"), + (2031, "centrifuge"), + (2032, "catalyst"), + (2035, "phala"), + (2037, "kiwi_subnet"), + (2038, "shrapnel_testnet"), + (2039, "aleph_zero"), + (2040, "vanar"), + (2043, "neuroweb"), + (2044, "shrapnel_subnet"), + (2045, "aiw3"), + (2047, "stratos_testnet"), + (2048, "stratos"), + (2049, "movo"), + (2077, "quokkacoin"), + (2088, "altair"), + (2089, "algol"), + (2100, "ecoball"), + (2101, "ecoball_testnet_espuma"), + (2109, "exosama"), + (2112, "u"), + (2121, "catena"), + (2122, "metaplayerone"), + (2124, "metaplayerone_dubai_testnet"), + (2136, "bigshortbets_testnet"), + (2137, "bigshortbets"), + (2138, "defi_oracle_meta_testnet"), + (2140, "oneness"), + (2141, "oneness_testnet"), + (2151, "bosagora"), + (2152, "findora"), + (2153, "findora_testnet"), + (2154, "findora_forge"), + (2162, "anime_testnet"), + (2192, "snax"), + (2199, "moonsama"), + (2202, "antofy"), + (2203, "bitcoin_evm"), + (2213, "evanesco"), + (2221, "kava_testnet"), + (2222, "kava"), + (2223, "v"), + (2241, "krest"), + (2300, "bomb"), + (2306, "ebro"), + (2309, "arevia"), + (2311, "chronicle_vesuvius___lit_protocol_testnet"), + (2323, "soma_testnet"), + (2330, "altcoin"), + (2331, "rss3_vsl_sepolia_testnet"), + (2332, "soma"), + (2340, "atleta_olympia"), + (2342, "omnia"), + (2355, "silicon_zkevm"), + (2358, "kroma_sepolia"), + (2370, "nexis_testnet"), + (2399, "bomb_testnet"), + (2400, "tcg_verse"), + (2410, "karak"), + (2415, "xodex"), + (2425, "king_of_legends"), + (2442, "polygon_zkevm_cardona_testnet"), + (2468, "hybrid"), + (2477, "6degree_of_outreach"), + (2484, "unicorn_ultra_nebulas_testnet"), + (2511, "karak_goerli"), + (2522, "fraxtal_testnet"), + (2525, "inevm"), + (2559, "kortho"), + (2569, "techpay"), + (2606, "pocrnet"), + (2611, "redlight"), + (2612, "ez_c"), + (2613, "ez_c_testnet"), + (2625, "white_testnet"), + (2648, "ailayer_testnet"), + (2649, "ailayer"), + (2662, "apex"), + (2710, "morph_testnet"), + (2718, "k_laos"), + (2730, "xr_sepolia"), + (2731, "elizabeth_testnet"), + (2748, "nanon"), + (2777, "gm"), + (2810, "morph_holesky"), + (2882, "chips"), + (2888, "boba_goerli_testnet"), + (2907, "elux"), + (2911, "hy"), + (2941, "xenon_testnet"), + (2999, "bityuan"), + (3000, "cennznet_rata"), + (3001, "cennznet_nikau"), + (3003, "canxium"), + (3011, "playa3ull_games"), + (3031, "orlando"), + (3033, "rebus_testnet"), + (3068, "bifrost"), + (3073, "movement_evm"), + (3084, "xl_testnet"), + (3100, "immu3_evm"), + (3102, "vulture_evm_beta"), + (3109, "satoshivm_alpha"), + (3110, "satoshivm_testnet"), + (3141, "filecoin___hyperspace_testnet"), + (3269, "dubxcoin"), + (3270, "dubxcoin_testnet"), + (3306, "debounce_subnet_testnet"), + (3331, "zcore_testnet"), + (3333, "ethstorage_testnet"), + (3334, "web3q_galileo"), + (3335, "ethstorage"), + (3338, "peaq"), + (3400, "paribu_net"), + (3424, "evolve"), + (3434, "secure_testnet"), + (3456, "layeredge_testnet"), + (3490, "gtcscan"), + (3500, "paribu_net_testnet"), + (3501, "jfin"), + (3601, "pandoproject"), + (3602, "pandoproject_testnet"), + (3630, "tycooncoin"), + (3636, "botanix_testnet"), + (3637, "botanix"), + (3639, "i"), + (3645, "i_testnet"), + (3666, "jouleverse"), + (3690, "bittex"), + (3693, "empire"), + (3698, "senjepowers_testnet"), + (3699, "senjepowers"), + (3701, "xpla_testnet"), + (3737, "crossbell"), + (3776, "astar_zkevm"), + (3797, "alvey"), + (3799, "tangle_testnet"), + (3885, "fire_zkevm_ghostrider"), + (3888, "kaly"), + (3889, "kaly_testnet"), + (3912, "drac"), + (3939, "dos_tesnet"), + (3966, "dyno"), + (3967, "dyno_testnet"), + (3993, "apex_testnet"), + (3999, "yuan"), + (4000, "ozone"), + (4001, "peperium_testnet"), + (4002, "fantom_testnet"), + (4003, "x1_fastnet"), + (4040, "carbonium_testnet"), + (4048, "gan_testnet"), + (4051, "bobaopera_testnet"), + (4058, "bahamut_ocean"), + (4061, "nahmii_3"), + (4062, "nahmii_3_testnet"), + (4078, "muster"), + (4080, "tobe_testnet"), + (4088, "zeroth"), + (4090, "fastex_bahamut_oasis_testnet"), + (4096, "bitindi_testnet"), + (4099, "bitindi"), + (4102, "aioz_testnet"), + (4139, "humans.ai_testnet"), + (4141, "tipboxcoin_testnet"), + (4157, "crossfi_testnet"), + (4162, "sx_rollup"), + (4181, "phi_v1"), + (4200, "merlin"), + (4201, "lukso_testnet"), + (4202, "lisk_sepolia_testnet"), + (4242, "nexi"), + (4243, "nexi_v2"), + (4269, "laika_testnet"), + (4328, "bobafuji_testnet"), + (4337, "beam"), + (4400, "credit"), + (4444, "htmlcoin"), + (4460, "orderly_sepolia_testnet"), + (4488, "hydra"), + (4544, "emoney_testnet"), + (4613, "very"), + (4653, "gold"), + (4689, "iotex"), + (4690, "iotex_testnet"), + (4759, "meverse_testnet"), + (4777, "blackfort_exchange_testnet"), + (4801, "world_sepolia_testnet"), + (4893, "globel"), + (4918, "venidium_testnet"), + (4919, "venidium"), + (4999, "blackfort_exchange"), + (5000, "mantle"), + (5001, "mantle_testnet"), + (5002, "treasurenet_alpha"), + (5003, "mantle_sepolia_testnet"), + (5005, "treasurenet_testnet"), + (5039, "onigiri_test_subnet"), + (5040, "onigiri_subnet"), + (5051, "nollie_skate_testnet"), + (5100, "syndicate_testnet"), + (5101, "syndicate_frame"), + (5102, "sic_testnet"), + (5103, "coordinape_testnet"), + (5104, "charmverse_testnet"), + (5105, "superloyalty_testnet"), + (5106, "azra_testnet"), + (5112, "ham"), + (5151, "me_testnet"), + (5165, "bahamut"), + (5169, "smart_layer"), + (5177, "tl"), + (5197, "eraswap"), + (5234, "humanode"), + (5290, "fire_old"), + (5315, "uzmi"), + (5317, "optrust_testnet"), + (5321, "itx_testnet"), + (5333, "netsbo"), + (5353, "tritanium_testnet"), + (5372, "settlus_testnet"), + (5424, "edexa"), + (5439, "ego"), + (5522, "vex_evm_testnet"), + (5551, "nahmii_2"), + (5553, "nahmii_2_testnet"), + (5555, "verse"), + (5611, "opbnb_testnet"), + (5615, "arcturus_testneet"), + (5616, "arcturus_testnet"), + (5656, "qie_block"), + (5675, "filenova_testnet"), + (5678, "tanssi_demo"), + (5700, "syscoin_tanenbaum_testnet"), + (5729, "hika_testnet"), + (5758, "satoshi_testnet"), + (5777, "ganache"), + (5845, "tangle"), + (5851, "ontology_testnet"), + (5858, "chang_foundation"), + (5869, "wego_rubidium"), + (6000, "bouncebit_testnet"), + (6001, "bouncebit"), + (6065, "tres_testnet"), + (6066, "tres"), + (6102, "cascadia_testnet"), + (6118, "uptn_testnet"), + (6119, "uptn"), + (6283, "laos"), + (6321, "aura_euphoria_testnet"), + (6322, "aura"), + (6363, "digit_soul"), + (6398, "connext_sepolia"), + (6502, "peerpay"), + (6550, "flamma_testnet"), + (6552, "scolcoin_wei_testnet"), + (6565, "fox_testnet"), + (6626, "pixie"), + (6660, "latest_testnet"), + (6661, "cybria"), + (6666, "cybria_testnet"), + (6667, "stor"), + (6678, "edge_matrix"), + (6688, "irishub"), + (6699, "ox"), + (6701, "paxb"), + (6779, "compverse"), + (6805, "race"), + (6806, "race_testnet"), + (6868, "pools"), + (6942, "laika"), + (6969, "tomb"), + (6999, "polysmart"), + (7000, "zeta"), + (7001, "zeta_testnet"), + (7007, "bst"), + (7027, "ella_the_heart"), + (7070, "planq"), + (7077, "planq_atlas_testnet"), + (7100, "nume"), + (7118, "help_the_homeless"), + (7171, "bitrock"), + (7210, "nibiru_testnet_1"), + (7222, "nibiru_devnet_3"), + (7244, "zeus_testnet"), + (7300, "xpla_verse"), + (7331, "klyntar"), + (7332, "horizen_eon"), + (7341, "shyft"), + (7484, "raba"), + (7518, "meverse"), + (7560, "cyber"), + (7575, "adil_testnet"), + (7576, "adil_v2"), + (7668, "the_root"), + (7672, "the_root___porcini_testnet"), + (7700, "canto"), + (7701, "canto_tesnet"), + (7771, "bitrock_testnet"), + (7774, "gdcc"), + (7775, "gdcc_testnet"), + (7776, "pandasea"), + (7777, "rise_of_the_warbots_testnet"), + (7778, "orenium_protocol"), + (7798, "openex_long_testnet"), + (7860, "maal_testnet"), + (7862, "maal_v2"), + (7863, "maal_testnet_v2"), + (7878, "hazlor_testnet"), + (7887, "kinto"), + (7895, "ardenium_athena"), + (7923, "dot_blox"), + (7924, "mo"), + (7979, "dos"), + (8000, "teleport"), + (8001, "teleport_testnet"), + (8008, "polynomial"), + (8029, "mdgl_testnet"), + (8047, "boat"), + (8054, "karak_sepolia"), + (8080, "shardeum_liberty_1.x"), + (8081, "shardeum_liberty_2.x"), + (8082, "shardeum_sphinx_1.x"), + (8086, "bitcoin"), + (8087, "e_dollar"), + (8098, "streamux_block"), + (8131, "qitmeer_testnet"), + (8132, "qitmeer_mixnet"), + (8133, "qitmeer_privnet"), + (8134, "amana"), + (8135, "flana"), + (8136, "mizana"), + (8181, "testnet_beone"), + (8192, "torus"), + (8194, "torus_testnet"), + (8217, "kaia"), + (8227, "space_subnet"), + (8272, "blockton_block"), + (8285, "korthotest"), + (8329, "lorenzo"), + (8333, "b3"), + (8387, "dracones_financial_services"), + (8453, "base"), + (8545, "chakra_testnet"), + (8654, "toki"), + (8655, "toki_testnet"), + (8668, "hela_official_runtime"), + (8723, "tool_global"), + (8724, "tool_global_testnet"), + (8726, "storage"), + (8727, "storage_testnet"), + (8732, "bullions"), + (8738, "alph"), + (8768, "tmy"), + (8822, "iota_evm"), + (8844, "hydra_testnet"), + (8848, "maro_block"), + (8866, "superlumio"), + (8869, "lif3"), + (8880, "unique"), + (8881, "quartz_by_unique"), + (8882, "opal_testnet_by_unique"), + (8883, "sapphire_by_unique"), + (8886, "avenium_testnet"), + (8888, "xana"), + (8889, "vyvo"), + (8890, "orenium_testnet_protocol"), + (8898, "mammoth"), + (8899, "jib"), + (8911, "algen"), + (8912, "algen_testnet"), + (8921, "algen_layer2"), + (8922, "algen_layer2_testnet"), + (8989, "giant_mammoth"), + (8995, "bloxberg"), + (9000, "evmos_testnet"), + (9001, "evmos"), + (9007, "shido_testnet_block"), + (9008, "shido_block"), + (9012, "berylbit"), + (9024, "nexa_testnet_block"), + (9025, "nexa_block"), + (9069, "apex_fusion___nexus"), + (9070, "apex_fusion___nexus_testnet"), + (9100, "genesis_coin"), + (9170, "rinia_testnet_old"), + (9223, "codefin"), + (9339, "dogcoin_testnet"), + (9372, "oasys_testnet"), + (9393, "dela_sepolia_testnet"), + (9395, "evoke"), + (9496, "weavevm_testnet"), + (9527, "rangers_protocol_testnet_robin"), + (9528, "qeasyweb3_testnet"), + (9559, "neonlink_testnet"), + (9700, "oortdev"), + (9728, "boba_bnb_testnet"), + (9768, "mainnetz_testnet"), + (9779, "pepenetwork"), + (9789, "tabi_testnet"), + (9790, "carbon_evm"), + (9792, "carbon_evm_testnet"), + (9797, "optimusz7"), + (9818, "imperium_testnet"), + (9819, "imperium"), + (9876, "binary_testnet"), + (9888, "dogelayer"), + (9898, "larissa"), + (9911, "espento"), + (9966, "uxer_testnet"), + (9977, "mind_testnet"), + (9980, "combo"), + (9981, "volley"), + (9990, "agung"), + (9997, "altlayer_testnet"), + (9998, "ztc"), + (9999, "myown_testnet"), + (10000, "smart_bitcoin_cash"), + (10001, "smart_bitcoin_cash_testnet"), + (10024, "gon"), + (10081, "japan_open_testnet"), + (10086, "sjatsh"), + (10096, "metanova_verse"), + (10101, "block_genesis"), + (10200, "gnosis_chiado_testnet"), + (10201, "maxx"), + (10222, "glscan"), + (10242, "arthera"), + (10243, "arthera_testnet"), + (10248, "0xtade"), + (10321, "tao_evm"), + (10324, "tao_evm_testnet"), + (10395, "worldland_testnet"), + (10507, "numbers"), + (10508, "numbers_testnet"), + (10823, "cryptocoinpay"), + (10849, "lamina1"), + (10850, "lamina1_identity"), + (10946, "quadrans_block"), + (10947, "quadrans_block_testnet"), + (11000, "kb"), + (11011, "shape_sepolia_testnet"), + (11110, "astra"), + (11111, "wagmi"), + (11115, "astra_testnet"), + (11119, "hashbit"), + (11124, "abstract_testnet"), + (11221, "shine"), + (11227, "jiritsu_testnet_subnet"), + (11235, "haqq"), + (11437, "shyft_testnet"), + (11501, "bevm"), + (11503, "bevm_testnet"), + (11521, "sats"), + (11612, "sardis_testnet"), + (11822, "artela_testnet"), + (11891, "polygon_supernet_arianee"), + (12001, "fuse_testnet"), + (12009, "satoshi"), + (12020, "aternos"), + (12051, "singularity_zero_testnet"), + (12052, "singularity_zero"), + (12123, "brc"), + (12306, "fibonacci"), + (12321, "blg_testnet"), + (12324, "l3x_protocol"), + (12325, "l3x_protocol_testnet"), + (12345, "step_testnet"), + (12553, "rss3_vsl"), + (12715, "rikeza_testnet"), + (12781, "playdapp_testnet"), + (12890, "quantum_testnet"), + (12898, "playfair_testnet_subnet"), + (13000, "sps"), + (13337, "beam_testnet"), + (13371, "immutable_zkevm"), + (13381, "phoenix"), + (13396, "masa"), + (13473, "immutable_zkevm_testnet"), + (13505, "gravity_alpha_testnet_sepolia"), + (13600, "kronobit"), + (13812, "susono"), + (14000, "sps_testnet"), + (14088, "zeroth_testnet"), + (14324, "evolve_testnet"), + (14333, "vitruveo_testnet"), + (14801, "vana_satori_testnet"), + (14853, "humanode_testnet_5_israfel"), + (15003, "immutable_zkevm_devnet"), + (15257, "poodl_testnet"), + (15259, "poodl"), + (15430, "kymtc"), + (15551, "loopnetwork"), + (15555, "trust_evm_testnet"), + (15557, "eos_evm_testnet"), + (16000, "metadot"), + (16001, "metadot_testnet"), + (16116, "defiverse"), + (16166, "cypherium"), + (16180, "plyr_phi"), + (16350, "incentiv_devnet"), + (16481, "pivotal_sepolia"), + (16507, "genesys"), + (16600, "0g_newton_testnet"), + (16688, "irishub_testnet"), + (16718, "airdao"), + (16888, "ivar_testnet"), + (17000, "holesky"), + (17001, "redstone_holesky_testnet"), + (17069, "garnet_holesky"), + (17071, "on_points"), + (17117, "defiverse_testnet"), + (17171, "g8"), + (17172, "eclipse_subnet"), + (17180, "palette_testnet"), + (17217, "konet"), + (17777, "eos_evm"), + (18000, "frontier_of_dreams_testnet"), + (18122, "smart_trades"), + (18159, "proof_of_memes"), + (18181, "g8_testnet"), + (18231, "unreal_old"), + (18233, "unreal"), + (18686, "mxc_zkevm_moon"), + (18888, "titan_tkx"), + (18889, "titan_tkx_testnet"), + (19011, "home_verse"), + (19077, "blockx_atlantis_testnet"), + (19191, "blockx"), + (19224, "decentraconnect_social"), + (19527, "magnet"), + (19600, "lbry"), + (19845, "btcix"), + (20001, "camelark"), + (20041, "niza"), + (20073, "niza_testnet"), + (20729, "callisto_testnet"), + (20736, "p12"), + (20765, "jono11_subnet"), + (21004, "c4ei"), + (21133, "all_about_healthy"), + (21223, "dcpay"), + (21224, "dcpay_testnet"), + (21337, "cennznet_azalea"), + (21363, "lestnet"), + (21816, "om"), + (21912, "bsl"), + (22023, "taycan"), + (22040, "airdao_testnet"), + (22222, "nautilus"), + (22324, "goldx_testnet"), + (22776, "map_protocol"), + (23006, "antofy_testnet"), + (23118, "opside_testnet"), + (23294, "oasis_sapphire"), + (23295, "oasis_sapphire_testnet"), + (23451, "dreyerx"), + (23452, "dreyerx_testnet"), + (23888, "blast_testnet"), + (24076, "kymtc_testnet"), + (24484, "web"), + (24734, "mintme.com"), + (25186, "liquidlayer"), + (25839, "alvey_testnet"), + (25888, "hammer"), + (25925, "bitkub_testnet"), + (26026, "ferrum_testnet"), + (26482, "ducatusx_testnet"), + (26483, "ducatusx"), + (26600, "hertz"), + (26863, "oasis"), + (27181, "klaos_nova"), + (27483, "nanon_sepolia"), + (27827, "zeroone_subnet"), + (28516, "vizing_testnet"), + (28518, "vizing"), + (28528, "optimism_bedrock_goerli_alpha_testnet"), + (28882, "boba_sepolia"), + (29112, "hy_testnet"), + (29223, "nexa_metanet"), + (29536, "kai_testnet"), + (29548, "mch_verse"), + (30000, "q"), + (30067, "piece_testnet"), + (30088, "miyou"), + (30103, "cerium_testnet"), + (30730, "movement_evm_legacy"), + (30731, "movement_evm_devnet"), + (30732, "movement_evm_testnet"), + (31102, "ethersocial"), + (31223, "cloudtx"), + (31224, "cloudtx_testnet"), + (31337, "go_testnet"), + (31414, "evoke_testnet"), + (31415, "filecoin___wallaby_testnet"), + (31753, "x"), + (31754, "x_testnet"), + (32001, "w3gamez_holesky_testnet"), + (32382, "santiment_intelligence"), + (32520, "bitgert"), + (32659, "fusion"), + (32769, "zilliqa_evm"), + (32990, "zilliqa_evm_isolated_server"), + (33033, "entangle"), + (33101, "zilliqa_evm_testnet"), + (33103, "zilliqa_2_evm_proto_testnet"), + (33111, "curtis"), + (33133, "entangle_testnet"), + (33210, "cloudverse_subnet"), + (33333, "aves"), + (33385, "zilliqa_evm_devnet"), + (33401, "slingshot"), + (33469, "zilliqa_2_evm_devnet"), + (33979, "funki"), + (34443, "mode"), + (34504, "zeus"), + (35011, "j2o_taro"), + (35443, "q_testnet"), + (38400, "connectormanager"), + (38401, "connectormanager_robin"), + (39656, "prm"), + (39797, "energi"), + (39815, "oho"), + (40000, "div"), + (41455, "aleph_zero_evm"), + (41500, "opulent_x_beta"), + (42069, "pegglecoin"), + (42072, "agentlayer_testnet"), + (42161, "arbitrum_one"), + (42170, "arbitrum_nova"), + (42220, "celo"), + (42261, "oasis_emerald_testnet"), + (42262, "oasis_emerald"), + (42355, "goldx"), + (42421, "asset_testnet"), + (42766, "zkfair"), + (42793, "etherlink"), + (42801, "gesoten_verse_testnet"), + (42888, "kinto_testnet"), + (43110, "athereum"), + (43111, "hemi"), + (43113, "avalanche_fuji_testnet"), + (43114, "avalanche_c"), + (43288, "boba_avax"), + (43851, "zkfair_testnet"), + (44444, "fren"), + (44445, "quantum"), + (44787, "celo_alfajores_testnet"), + (45000, "autobahn"), + (45454, "swamps_l2"), + (45510, "deelance"), + (45513, "blessnet"), + (46688, "fusion_testnet"), + (47763, "neo_x"), + (47803, "redefi_layer_1"), + (47805, "rei"), + (48795, "space_subnet_testnet"), + (48899, "zircuit_testnet"), + (48900, "zircuit"), + (49049, "wireshape_floripa_testnet"), + (49088, "bifrost_testnet"), + (49321, "gunz_testnet"), + (49797, "energi_testnet"), + (50001, "liveplex_oracleevm"), + (50005, "yooldo_verse"), + (50006, "yooldo_verse_testnet"), + (50021, "gton_testnet"), + (50888, "erbie"), + (51178, "lumoz_testnet_alpha"), + (51712, "sardis"), + (52014, "electroneum"), + (53277, "doid"), + (53302, "superseed_sepolia_testnet"), + (53457, "dodo_testnet"), + (53935, "dfk"), + (54176, "overprotocol"), + (54211, "haqq_testnet"), + (54321, "toronet_testnet"), + (55004, "titan"), + (55551, "photon_aurora_testnet"), + (55556, "rei_testnet"), + (55614, "flamma"), + (56026, "lambda"), + (56288, "boba_bnb"), + (56400, "testnet_zeroone_subnet"), + (56789, "velo_labs"), + (56797, "doid_testnet"), + (57000, "rollux_testnet"), + (57451, "coinsec"), + (58008, "sepolia_pgn_public_goods"), + (58680, "lumoz_quidditch_testnet"), + (59140, "linea_goerli"), + (59141, "linea_sepolia"), + (59144, "linea"), + (59902, "metis_sepolia_testnet"), + (59971, "genesys_code"), + (60000, "thinkium_testnet_0"), + (60001, "thinkium_testnet_1"), + (60002, "thinkium_testnet_2"), + (60103, "thinkium_testnet_103"), + (60808, "bob"), + (61022, "orange"), + (61406, "kai"), + (61800, "axel_dev_net"), + (61803, "etica"), + (61916, "doken_super"), + (62049, "optopia_testnet"), + (62050, "optopia"), + (62298, "citrea_devnet"), + (62320, "celo_baklava_testnet"), + (62621, "multivac"), + (62831, "plyr_tau_testnet"), + (62850, "laos_sigma_testnet"), + (63000, "ecredits"), + (63001, "ecredits_testnet"), + (63002, "esync_testnet"), + (65349, "cratd2c_testnet"), + (65357, "vecno"), + (65450, "scolcoin"), + (65536, "automata"), + (66988, "janus_testnet"), + (67390, "siriusnet"), + (67588, "cosmic"), + (68770, "dm2_verse"), + (69420, "condrieu"), + (70000, "thinkium_0"), + (70001, "thinkium_1"), + (70002, "thinkium_2"), + (70103, "thinkium_103"), + (70700, "proof_of_play___apex"), + (71111, "guapcoinx"), + (71393, "polyjuice_testnet"), + (71401, "godwoken_testnet_v1"), + (71402, "godwoken"), + (72778, "caga_crypto_ankara_testnet"), + (72992, "grok"), + (73114, "icb_testnet"), + (73115, "icb"), + (73799, "energy_web_volta_testnet"), + (73927, "mixin_virtual_machine"), + (75000, "resincoin"), + (75512, "geek_verse"), + (75513, "geek_verse_testnet"), + (77001, "bora"), + (77238, "foundry_testnet"), + (77612, "vention"), + (77677, "cycle_sailboat"), + (77777, "toronet"), + (78110, "firenze_test"), + (78281, "dragonfly_hexapod"), + (78430, "amplify_subnet"), + (78431, "bulletin_subnet"), + (78432, "conduit_subnet"), + (78600, "vanguard"), + (79879, "gold_testnet"), + (80001, "mumbai"), + (80002, "amoy"), + (80008, "polynomia_sepolia"), + (80084, "bera_bartio"), + (80085, "bera_artio"), + (80096, "hizoco"), + (81041, "nordek"), + (81341, "amana_testnet"), + (81342, "amana_mixnet"), + (81343, "amana_privnet"), + (81351, "flana_testnet"), + (81352, "flana_mixnet"), + (81353, "flana_privnet"), + (81361, "mizana_testnet"), + (81362, "mizana_mixnet"), + (81363, "mizana_privnet"), + (82459, "smart_layer_testnet"), + (83144, "xprotocol_testnet"), + (83278, "esa"), + (83872, "zedxion"), + (84531, "base_goerli_testnet"), + (84532, "base_sepolia_testnet"), + (84886, "aerie"), + (85449, "cybertrust"), + (88002, "nautilus_proteus_testnet"), + (88559, "inoai"), + (88800, "zkasino"), + (88817, "unit_zero_testnet"), + (88819, "unit_zero_stagenet"), + (88880, "chiliz_scoville_testnet"), + (88882, "chiliz_spicy_testnet"), + (88888, "chiliz"), + (90001, "fxcore_testnet"), + (90210, "beverly_hills"), + (90354, "camp_testnet"), + (91002, "nautilus_trition"), + (91120, "metadap_enterprise"), + (91715, "combo_testnet"), + (92001, "lambda_testnet"), + (93572, "liquidlayer_testnet"), + (93747, "stratovm_testnet"), + (96970, "mantis_testnet_hexapod"), + (97288, "boba_bnb_old"), + (97435, "slingshot_testnet"), + (97531, "green_testnet"), + (97970, "optimusz7_testnet"), + (98881, "ebi"), + (99099, "eliberty_testnet"), + (99876, "edge_matrix_testnet"), + (99998, "ubtestnet"), + (99999, "ub"), + (100000, "quark_root"), + (100001, "quark_shard_0"), + (100002, "quark_shard_1"), + (100003, "quark_shard_2"), + (100004, "quark_shard_3"), + (100005, "quark_shard_4"), + (100006, "quark_shard_5"), + (100007, "quark_shard_6"), + (100008, "quark_shard_7"), + (100009, "ve"), + (100010, "ve_testnet"), + (100011, "quark_l2"), + (101010, "global_trust"), + (102030, "creditcoin"), + (102031, "creditcoin_testnet"), + (102032, "creditcoin_devnet"), + (103090, "crystaleum"), + (103454, "masa_testnet"), + (104566, "kaspaclassic"), + (105105, "stratis"), + (108801, "bro"), + (110000, "quark_devnet_root"), + (110001, "quark_devnet_shard_0"), + (110002, "quark_devnet_shard_1"), + (110003, "quark_devnet_shard_2"), + (110004, "quark_devnet_shard_3"), + (110005, "quark_devnet_shard_4"), + (110006, "quark_devnet_shard_5"), + (110007, "quark_devnet_shard_6"), + (110008, "quark_devnet_shard_7"), + (110011, "quark_l2_testnet"), + (110110, "mars_credit"), + (111000, "siberium_test"), + (111111, "siberium"), + (111188, "re.al"), + (112358, "meta_one"), + (119139, "metadap_enterprise_testnet"), + (123321, "gem"), + (123456, "adil_devnet"), + (128123, "etherlink_testnet"), + (131313, "odyssey_testnet"), + (131419, "etnds"), + (132902, "form_testnet"), + (141319, "magape_testnet"), + (142857, "icplaza"), + (161212, "playfi"), + (165279, "eclat"), + (167000, "taiko"), + (167004, "taiko_alpha_2_testnet"), + (167005, "taiko_grimsvotn_l2"), + (167006, "taiko_eldfell_l3"), + (167007, "taiko_jolnir_l2"), + (167008, "taiko_katla_l2"), + (167009, "taiko_hekla_l2"), + (168168, "zs"), + (171000, "fair_testnet"), + (175177, "chronicle___lit_protocol_testnet"), + (175188, "chronicle_yellowstone___lit_protocol_testnet"), + (188710, "bitica"), + (188881, "condor_test"), + (199991, "mazze_testnet"), + (200000, "xfair.ai_testnet"), + (200101, "milkomeda_c1_testnet"), + (200202, "milkomeda_a1_testnet"), + (200625, "akroma"), + (200810, "bitlayer_testnet"), + (200901, "bitlayer"), + (201018, "alaya"), + (201030, "alaya_dev_testnet"), + (201804, "mythical"), + (202020, "decimal_testnet"), + (202105, "duck_testnet"), + (202212, "x1_devnet"), + (202401, "ymtech_besu_testnet"), + (202624, "jellie"), + (204005, "x1_network"), + (205205, "auroria_testnet"), + (210049, "gitagi_atlas_testnet"), + (210425, "platon"), + (212013, "litentry"), + (220315, "mas"), + (221230, "reap"), + (221231, "reap_testnet"), + (222222, "hydradx"), + (222555, "deepl"), + (222666, "deepl_testnet"), + (224168, "taf_eco"), + (224422, "conet_sebolia_testnet"), + (224433, "conet_holesky"), + (229772, "abyss_protocol"), + (230315, "hashkey_testnetdiscard"), + (234666, "haymo_testnet"), + (240515, "orange_testnet"), + (246529, "artis_sigma1"), + (246785, "artis_testnet_tau1"), + (247253, "saakuru_testnet"), + (256256, "cmp"), + (262371, "eclat_testnet"), + (266256, "gear_zero_testnet"), + (271271, "egoncoin_testnet"), + (281121, "social"), + (282828, "zillion_sepolia_testnet"), + (292003, "cipherem_testnet"), + (309075, "one_world"), + (313313, "saharaai_testnet"), + (314159, "filecoin___calibration_testnet"), + (322202, "parex"), + (323213, "bloom_genesis_testnet"), + (327126, "waba_testnet"), + (328527, "nal"), + (330844, "ttcoin"), + (333313, "bloom_genesis"), + (333331, "aves_testnet"), + (333333, "nativ3_testnet"), + (333666, "oone_testnet"), + (333777, "oone_devnet"), + (333888, "polis_testnet"), + (333999, "polis"), + (336655, "up_testnet"), + (336666, "up"), + (355110, "bitfinity"), + (355113, "bitfinity_testnet"), + (360890, "lavita"), + (363636, "digit_soul_2"), + (373737, "hap_testnet"), + (381931, "metal_c"), + (381932, "metal_tahoe_c"), + (404040, "tipboxcoin"), + (413413, "aie_testnet"), + (420420, "kek"), + (420666, "kek_kektest"), + (420692, "alterium_l2_testnet"), + (421611, "arbitrum_rinkeby"), + (421613, "arbitrum_goerli"), + (421614, "arbitrum_sepolia"), + (424242, "fastex_testnet"), + (431140, "markr_go"), + (432201, "dexalot_subnet_testnet"), + (432204, "dexalot_subnet"), + (444444, "syndr_l3_sepolia"), + (444900, "weelink_testnet"), + (471100, "patex_sepolia_testnet"), + (473861, "ultra_pro"), + (474142, "open"), + (486487, "gobbl_testnet"), + (490000, "autonomys_testnet_nova_domain"), + (504441, "playdapp"), + (512512, "cmp_testnet"), + (513100, "dis"), + (526916, "docoin_community"), + (534351, "scroll_sepolia_testnet"), + (534352, "scroll"), + (534353, "scroll_alpha_testnet"), + (534354, "scroll_pre_alpha_testnet"), + (534849, "shinarium_beta"), + (535037, "beaneco_smart"), + (541764, "overprotocol_testnet"), + (552981, "one_world_testnet"), + (555555, "pentagon_testnet"), + (555666, "eclipse_testnet"), + (555888, "dustboy_iot"), + (622277, "hypra"), + (622463, "atlas"), + (641230, "bear"), + (651940, "all"), + (656476, "open_campus_codex"), + (660279, "xai"), + (666666, "vision___vpioneer_test"), + (666888, "hela_official_runtime_testnet"), + (686868, "won"), + (696969, "galadriel_devnet"), + (710420, "tiltyard_subnet"), + (713715, "sei_devnet"), + (721529, "eram"), + (743111, "hemi_sepolia"), + (751230, "bear_testnet"), + (752024, "ternoa_testnet"), + (761412, "miexs_smart"), + (764984, "lamina1_testnet"), + (767368, "lamina1_identity_testnet"), + (776877, "modularium"), + (800001, "octaspace"), + (808080, "biz_testnet"), + (808813, "bob_sepolia"), + (810180, "zklink_nova"), + (810181, "zklink_nova_sepolia_testnet"), + (810182, "zklink_nova_goerli_testnet"), + (820522, "tsc_testnet"), + (827431, "curve"), + (839320, "prm_testnet"), + (840000, "runevm_testnet"), + (846000, "4goodnetwork"), + (855456, "dodao"), + (879151, "blocx"), + (888882, "rexx"), + (888888, "vision"), + (900000, "posi_shard_0"), + (910000, "posi_testnet_shard_0"), + (912559, "astria_evm_dusknet"), + (920000, "posi_devnet_shard_0"), + (920001, "posi_devnet_shard_1"), + (923018, "fncy_testnet"), + (955081, "jono12_subnet"), + (955305, "eluvio_content_fabric"), + (978657, "treasure_ruby"), + (984122, "forma"), + (984123, "forma_sketchpad"), + (988207, "ecrox"), + (998899, "supernet_testnet"), + (999999, "am"), + (1100789, "netmind_testnet"), + (1234567, "sharecle"), + (1261120, "zkatana"), + (1313114, "etho_protocol"), + (1313500, "xerom"), + (1337702, "kintsugi"), + (1337802, "kiln"), + (1337803, "zhejiang"), + (1398243, "automata_testnet"), + (1612127, "playfi_albireo_testnet"), + (1637450, "xterio_testnet"), + (1731313, "turkey_demo_dev"), + (2021398, "debank_testnet"), + (2099156, "plian_main"), + (2206132, "platon_dev_testnet2"), + (2611555, "dpu"), + (2702128, "xterio"), + (3132023, "saharaai"), + (3141592, "filecoin___butterfly_testnet"), + (3397901, "funki_sepolia_sandbox"), + (3441005, "manta_pacific_testnet"), + (3441006, "manta_pacific_sepolia_testnet"), + (4000003, "altlayer_zero_gas"), + (4281033, "worlds_caldera"), + (4444444, "altar_testnet"), + (4457845, "zero_testnet_sepolia"), + (5112023, "numblock"), + (5167003, "mxc_wannsee_zkevm_testnet"), + (5167004, "moon_geneva_testnet"), + (5201420, "electroneum_testnet"), + (5318008, "reactive_kopli"), + (5555555, "imversed"), + (5555558, "imversed_testnet"), + (6038361, "astar_zkyoto"), + (6666665, "safeanwang"), + (6666666, "safeanwang_testnet"), + (7225878, "saakuru"), + (7355310, "openvessel"), + (7668378, "ql1_testnet"), + (7762959, "musicoin"), + (7777777, "zora"), + (8007736, "plian_sub_1"), + (8008135, "fhenix_helium"), + (8080808, "hokum"), + (8601152, "waterfall_8_test"), + (8794598, "hap"), + (8888881, "quarix_testnet"), + (8888888, "quarix"), + (9322252, "xcap"), + (9322253, "milvine"), + (9999999, "fluence"), + (10067275, "plian_testnet_sub_1"), + (10101010, "soverun"), + (10241024, "alienx"), + (10241025, "alienx_hal_testnet"), + (11145513, "blessnet_sepolia"), + (11155111, "sepolia"), + (11155420, "op_sepolia_testnet"), + (12052024, "memento_testnet"), + (12227331, "neox_testnet_t3"), + (12227332, "neo_x_testnet_t4"), + (13068200, "coti_devnet"), + (13371337, "pep_churchill"), + (14288640, "andus"), + (16658437, "plian_testnet_main"), + (18071918, "mande"), + (18289463, "iolite"), + (19850818, "deepbrain_testnet"), + (19880818, "deepbrain"), + (20180427, "stability_testnet"), + (20180430, "smartmesh"), + (20181205, "quarkblock"), + (20201022, "pego"), + (20230825, "vcity_testnet"), + (20240324, "debank_sepolia_testnet"), + (20240603, "dbk"), + (20241133, "swan_proxima_testnet"), + (20482050, "hokum_testnet"), + (22052002, "excelon"), + (27082017, "excoincial_volta_testnet"), + (27082022, "excoincial"), + (28122024, "ancient8_testnet"), + (28945486, "auxilium"), + (29032022, "fla"), + (31415926, "filecoin___local_testnet"), + (33626250, "toliman_suave_testnet"), + (35855456, "joys_digital"), + (37084624, "skale_nebula_hub_testnet"), + (39916801, "kingdom"), + (43214913, "maistestsubnet"), + (52164803, "fluence_testnet"), + (61717561, "aqua"), + (65010000, "autonity_bakerloo_thames_testnet"), + (65010001, "autonity_bakerloo_barada_testnet"), + (65010002, "autonity_bakerloo_sumida_testnet"), + (65010003, "autonity_bakerloo_yamuna_testnet"), + (65100000, "autonity_piccadilly_thames_testnet"), + (65100001, "autonity_piccadilly_barada_testnet"), + (65100002, "autonity_piccadilly_sumida_testnet"), + (65100003, "autonity_piccadilly_yamuna_testnet"), + (68840142, "frame_testnet"), + (77787778, "0xhash_testnet"), + (79479957, "sx_toronto_rollup"), + (88558801, "backstop_testnet"), + (88888888, "t.e.a.m_block"), + (94204209, "polygon_blackberry"), + (99415706, "joys_digital_testnet"), + (100000000, "ethos"), + (108160679, "orai"), + (111557560, "cyber_testnet"), + (123420111, "op_celestia_raspberry"), + (161221135, "plume_testnet"), + (168587773, "blast_sepolia_testnet"), + (192837465, "gather"), + (222000222, "kanazawa"), + (245022926, "neon_evm_devnet"), + (245022929, "neon_evm_devnet_rollup"), + (245022934, "neon_evm"), + (245022940, "neon_evm_testnet"), + (278611351, "razor_skale"), + (311752642, "oneledger"), + (328527624, "nal_sepolia_testnet"), + (333000333, "meld"), + (356256156, "gather_testnet"), + (476462898, "skopje_testnet"), + (486217935, "gather_devnet"), + (531050104, "sophon_testnet"), + (666666666, "degen"), + (728126428, "tron"), + (888888888, "ancient8"), + (889910245, "ptcescan_testnet"), + (889910246, "ptcescan"), + (974399131, "skale_calypso_hub_testnet"), + (999999999, "zora_sepolia_testnet"), + (1020352220, "skale_titan_hub_testnet"), + (1122334455, "ipos"), + (1146703430, "cyberdecknet"), + (1273227453, "human_protocol"), + (1313161554, "aurora"), + (1313161555, "aurora_testnet"), + (1313161556, "aurora_betanet"), + (1313161560, "powergold"), + (1350216234, "skale_titan_hub"), + (1351057110, "chaos_skale_testnet"), + (1380012617, "rari"), + (1380996178, "raptor"), + (1444673419, "skale_europa_hub_testnet"), + (1482601649, "skale_nebula_hub"), + (1511670449, "gpt"), + (1564830818, "skale_calypso_hub"), + (1666600000, "harmony_shard_0"), + (1666600001, "harmony_shard_1"), + (1666600002, "harmony_shard_2"), + (1666600003, "harmony_shard_3"), + (1666700000, "harmony_testnet_shard_0"), + (1666700001, "harmony_testnet_shard_1"), + (1666900000, "harmony_devnet_shard_0"), + (1666900001, "harmony_devnet_shard_1"), + (1802203764, "kakarot_sepolia"), + (1903648807, "gemu_testnet"), + (1918988905, "rari_testnet"), + (2021121117, "datahopper"), + (2046399126, "skale_europa_hub"), + (3125659152, "pirl"), + (4216137055, "oneledger_testnet_frankenstein"), + (11297108099, "palm_testnet"), + (28872323069, "gitswarm_test"), + (37714555429, "xai_testnet_v2"), + (88153591557, "arbitrum_blueberry"), + (111222333444, "alphabet"), + (111551119090, "thanos_sepolia"), + (123420000220, "fluence_stage"), + (197710212030, "ntity"), + (197710212031, "haradev_testnet"), + (202402181627, "gm_testnet"), + (383414847825, "zeniq"), + (666301171999, "pdc"), + (6022140761023, "molereum"), + (2713017997578000, "d_testnet"), +]; diff --git a/rust/crates/mesc/src/overrides.rs b/rust/crates/mesc/src/overrides.rs index 835c271..9f0997b 100644 --- a/rust/crates/mesc/src/overrides.rs +++ b/rust/crates/mesc/src/overrides.rs @@ -72,8 +72,7 @@ fn get_network_defaults_override() -> Result>, M for piece in raw.split(' ') { match piece.split('=').collect::>().as_slice() { [chain_id, endpoint] => { - network_defaults - .insert((chain_id.to_string()).try_into_chain_id()?, endpoint.to_string()); + network_defaults.insert(chain_id.try_into_chain_id()?, endpoint.to_string()); } _ => { return Err(MescError::OverrideError( @@ -97,8 +96,7 @@ fn get_network_names_override() -> Result>, Mesc for piece in raw.split(' ') { match piece.split('=').collect::>().as_slice() { [name, chain_id] => { - network_names - .insert(name.to_string(), (chain_id.to_string()).try_into_chain_id()?); + network_names.insert(name.to_string(), chain_id.try_into_chain_id()?); } _ => { return Err(MescError::OverrideError( @@ -190,7 +188,7 @@ pub fn get_default_endpoint_name(url: &str, chain_id: Option) -> Option if let Some(split) = hostname.split('.').last() { split.to_string() } else { hostname }; match chain_id { - Some(chain_id) => Some(format!("{}_{}", hostname, chain_id.as_str())), + Some(chain_id) => Some(format!("{hostname}_{chain_id}")), None => Some(hostname), } } diff --git a/rust/crates/mesc/src/query.rs b/rust/crates/mesc/src/query.rs index 57c1984..8dd61f5 100644 --- a/rust/crates/mesc/src/query.rs +++ b/rust/crates/mesc/src/query.rs @@ -1,7 +1,7 @@ use crate::{ directory, types::{Endpoint, MescError, RpcConfig}, - ChainId, MultiEndpointQuery, TryIntoChainId, + MultiEndpointQuery, TryIntoChainId, }; use std::collections::HashMap; @@ -49,31 +49,12 @@ pub fn get_endpoint_by_network get_endpoint_by_name(config, name.as_str()), None => Ok(None), } } -fn get_by_chain_id( - mapping: &HashMap, - chain_id: T, -) -> Result, MescError> { - let chain_id = chain_id.try_into_chain_id()?; - if let Some(value) = mapping.get(&chain_id) { - Ok(Some(value.clone())) - } else { - let standard_chain_id = chain_id.to_hex_256()?; - let results: Result, _> = mapping - .iter() - .map(|(k, v)| k.to_hex_256().map(|hex| (hex, v.clone()))) - .collect::, _>>() // Collect into a Result, Error> - .map(|pairs| pairs.into_iter().collect::>()); - let standard_mapping = results?; - Ok(standard_mapping.get(&standard_chain_id).cloned()) - } -} - /// get endpoint by name pub fn get_endpoint_by_name(config: &RpcConfig, name: &str) -> Result, MescError> { if let Some(endpoint) = config.endpoints.get(name) { diff --git a/rust/crates/mesc/src/types/chain_ids.rs b/rust/crates/mesc/src/types/chain_ids.rs index 4c3b7fa..3123068 100644 --- a/rust/crates/mesc/src/types/chain_ids.rs +++ b/rust/crates/mesc/src/types/chain_ids.rs @@ -3,100 +3,42 @@ use serde::{Deserialize, Serialize}; /// ChainId is a string representation of an integer chain id /// - TryFrom conversions allow specifying as String, &str, uint, or binary data -#[derive(Serialize, Deserialize, Debug, Clone, Eq)] -pub struct ChainId(String); +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[serde(into = "ChainIdSerde", try_from = "ChainIdSerde")] +pub struct ChainId(u64); impl ChainId { + /// create new chain id + pub fn new(chain_id: u64) -> ChainId { + ChainId(chain_id) + } + + /// parse chain id from string + pub fn parse(chain_id: &str) -> Result { + chain_id.try_into_chain_id() + } + + /// get chain id value + pub fn get(&self) -> u64 { + self.0 + } + /// convert to hex representation - pub fn to_hex(&self) -> Result { + pub fn to_hex(&self) -> String { let ChainId(chain_id) = self; - if chain_id.starts_with("0x") { - Ok(chain_id.clone()) - } else { - match chain_id.parse::() { - Ok(number) => Ok(format!("0x{:x}", number)), - Err(_) => Err(MescError::IntegrityError("bad chain_id".to_string())), - } - } + format!("{chain_id:#x}") } /// convert to hex representation, zero-padded to 256 bits - pub fn to_hex_256(&self) -> Result { + pub fn to_hex_256(&self) -> String { let ChainId(chain_id) = self; - if let Some(stripped) = chain_id.strip_prefix("0x") { - Ok(format!("0x{:0>64}", stripped)) - } else { - match chain_id.parse::() { - Ok(number) => Ok(format!("0x{:064x}", number)), - Err(_) => { - Err(MescError::InvalidChainId("cannot convert chain_id to hex".to_string())) - } - } - } - } - - /// return chain_id as &str - pub fn as_str(&self) -> &str { - let ChainId(chain_id) = self; - chain_id.as_str() - } -} - -impl std::hash::Hash for ChainId { - fn hash(&self, state: &mut H) { - match self.to_hex_256() { - Ok(as_hex) => { - as_hex.hash(state); - } - _ => { - let ChainId(contents) = self; - contents.hash(state); - } - } - } -} - -impl PartialOrd for ChainId { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl PartialEq for ChainId { - fn eq(&self, other: &Self) -> bool { - let self_string: String = match self.to_hex() { - Ok(s) => s[2..].to_string(), - Err(_) => return self == other, - }; - let other_string = match other.to_hex() { - Ok(s) => s[2..].to_string(), - Err(_) => return self == other, - }; - let self_str = format!("{:0>79}", self_string); - let other_str = format!("{:0>79}", other_string); - self_str.eq(&other_str) - } -} - -impl Ord for ChainId { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - let self_string: String = match self.to_hex() { - Ok(s) => s[2..].to_string(), - Err(_) => return std::cmp::Ordering::Greater, - }; - let other_string = match other.to_hex() { - Ok(s) => s[2..].to_string(), - Err(_) => return std::cmp::Ordering::Greater, - }; - let self_str = format!("{:>079}", self_string); - let other_str = format!("{:>079}", other_string); - self_str.cmp(&other_str) + format!("0x{chain_id:064x}") } } impl std::fmt::Display for ChainId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) + self.0.fmt(f) } } @@ -105,14 +47,14 @@ macro_rules! impl_from_uint_for_chainid { $( impl From<$t> for ChainId { fn from(value: $t) -> ChainId { - ChainId(value.to_string()) + ChainId(value as _) } } )* }; } -impl_from_uint_for_chainid!(u8, u16, u32, u64, u128, usize); +impl_from_uint_for_chainid!(u8, u16, u32, u64, usize); /// use custom trait instead of TryInto so that Error type is always the same pub trait TryIntoChainId { @@ -128,27 +70,22 @@ impl TryIntoChainId for ChainId { impl TryIntoChainId for String { fn try_into_chain_id(self) -> Result { - if !self.is_empty() - && (self.chars().all(|c| c.is_ascii_digit()) - || (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) - { - Ok(ChainId(self)) - } else { - Err(MescError::InvalidChainId(self)) - } + self.as_str().try_into_chain_id() } } impl TryIntoChainId for &str { fn try_into_chain_id(self) -> Result { - if !self.is_empty() - && (self.chars().all(|c| c.is_ascii_digit()) - || (self.starts_with("0x") && self[2..].chars().all(|c| c.is_ascii_hexdigit()))) - { - Ok(ChainId(self.to_string())) - } else { - Err(MescError::InvalidChainId(self.to_string())) + if !self.is_empty() { + let (radix, s) = match self.get(0..2) { + Some("0x") => (16, &self[2..]), + _ => (10, self), + }; + if let Ok(chain_id) = u64::from_str_radix(s, radix) { + return Ok(ChainId(chain_id)); + } } + Err(MescError::InvalidChainId(self.to_string())) } } @@ -157,17 +94,34 @@ macro_rules! impl_try_into_chain_id_for_integer { $( impl TryIntoChainId for $t { fn try_into_chain_id(self) -> Result { - Ok(ChainId(self.to_string())) + Ok(ChainId::from(self)) } } )* }; } -impl_try_into_chain_id_for_integer!(u8, u16, u32, u64, u128, usize); +impl_try_into_chain_id_for_integer!(u8, u16, u32, u64, usize); impl TryIntoChainId for &[u8] { fn try_into_chain_id(self) -> Result { Err(MescError::NotImplemented("binary chain_id".to_string())) } } + +#[derive(Serialize, Deserialize)] +struct ChainIdSerde(String); + +impl From for ChainIdSerde { + fn from(chain_id: ChainId) -> ChainIdSerde { + ChainIdSerde(chain_id.to_string()) + } +} + +impl TryFrom for ChainId { + type Error = MescError; + + fn try_from(value: ChainIdSerde) -> Result { + value.0.try_into_chain_id() + } +} diff --git a/rust/crates/mesc/src/validate.rs b/rust/crates/mesc/src/validate.rs index 52b4d19..c5dc9ec 100644 --- a/rust/crates/mesc/src/validate.rs +++ b/rust/crates/mesc/src/validate.rs @@ -1,5 +1,4 @@ use crate::{MescError, RpcConfig}; -use std::collections::HashSet; pub(crate) fn validate_config(config: &RpcConfig) -> Result<(), MescError> { // referenced endpoints exist @@ -70,29 +69,5 @@ pub(crate) fn validate_config(config: &RpcConfig) -> Result<(), MescError> { } } - // chain_id's are valid - for network in config.network_defaults.keys() { - network.to_hex()?; - } - for profile in config.profiles.values() { - for network in profile.network_defaults.keys() { - network.to_hex()?; - } - } - for endpoint in config.endpoints.values() { - if let Some(chain_id) = endpoint.chain_id.as_ref() { - chain_id.to_hex()?; - } - } - - // no duplicate default network entries using decimal vs hex - let hex_networks: Result, MescError> = - config.network_defaults.keys().map(|c| c.to_hex()).collect(); - if hex_networks?.len() != config.network_defaults.len() { - return Err(MescError::IntegrityError( - "colliding network defaults using decimal vs hex".to_string(), - )); - } - Ok(()) } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/set.rs b/rust/crates/mesc_cli/src/cli/subcommands/set.rs index 6c48326..b7b73ec 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/set.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/set.rs @@ -69,9 +69,7 @@ fn determine_kv_pairs(args: &SetArgs) -> Result)>, M return Err(MescCliError::InvalidInput("specify one of key or --keys".to_string())) } (Some(_), _, Some(_), _, _) => { - return Err(MescCliError::InvalidInput( - "cannot specify both key and --keys".to_string(), - )) + return Err(MescCliError::InvalidInput("cannot specify both key and --keys".to_string())) } (_, None, _, None, false) => { return Err(MescCliError::InvalidInput("specify value or --values".to_string())) @@ -131,9 +129,7 @@ fn set_config_value( ["endpoint_metadata", location @ ..] => { set_metadata_entry(&mut endpoint.endpoint_metadata, location, value)?; } - _ => { - return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))) - } + _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), } }; } @@ -166,9 +162,7 @@ fn set_config_value( )) } }, - _ => { - return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))) - } + _ => return Err(MescCliError::InvalidInput(format!("cannot set key: {}", key))), } } } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs index 66c4013..166906a 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/endpoints.rs @@ -40,7 +40,7 @@ pub(crate) async fn add_endpoint(config: &mut RpcConfig) -> Result<(), MescCliEr let chain_id = crate::rpc::request_chain_id(client, url.clone()).await; let chain_id = match chain_id { Ok(chain_id) => { - println!(" {} {}", "Using chain_id".bold(), chain_id.as_str().green()); + println!(" {} {}", "Using chain_id".bold(), chain_id.to_string().green()); Some(chain_id) } _ => { diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs index f8c1375..e7a7dab 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/network_names.rs @@ -90,7 +90,7 @@ fn print_custom_network_names(config: &RpcConfig) { config.network_names.len().to_string().green().bold() ); for (network_name, chain_id) in config.network_names.iter() { - println!(" - {} = {}", network_name.bold(), chain_id.as_str().green().bold()); + println!(" - {} = {}", network_name.bold(), chain_id.to_string().green().bold()); } }; } diff --git a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs index 358f57d..614be51 100644 --- a/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs +++ b/rust/crates/mesc_cli/src/cli/subcommands/setup/selectors.rs @@ -56,9 +56,7 @@ pub(crate) async fn select_chain_id_by_name() -> Result, MescCli } }; let mut pairs: Vec<(ChainId, String)> = network_list.into_iter().collect(); - pairs.sort_by_key(|(chain_id, _)| { - chain_id.to_hex_256().unwrap_or(chain_id.as_str().to_string()) - }); + pairs.sort_by(|(a, _), (b, _)| a.cmp(b)); let options: Vec<_> = pairs.iter().map(|(chain_id, name)| format!("{}) {}", chain_id, name)).collect(); @@ -153,18 +151,18 @@ pub(crate) fn select_config_chain_id( config: &RpcConfig, prompt: &str, ) -> Result, MescCliError> { - let mut chain_ids: HashSet = HashSet::new(); - for endpoint in config.endpoints.values() { - if let Some(chain_id) = endpoint.chain_id.as_ref() { - chain_ids.insert(chain_id.clone()); - } - } - let mut sorted_chain_ids: Vec = chain_ids.into_iter().collect(); - sorted_chain_ids.sort_by_key(|chain_id| chain_id.to_hex_256().unwrap_or("".to_string())); - let options: Vec = sorted_chain_ids + let mut chain_ids = config + .endpoints + .values() + .filter_map(|endpoint| endpoint.chain_id.clone()) + .collect::>() + .into_iter() + .collect::>(); + chain_ids.sort(); + let options: Vec = chain_ids .iter() .map(|chain_id| match mesc::directory::get_network_name(chain_id) { - Some(name) => format!("{}) {}", chain_id.as_str(), name), + Some(name) => format!("{chain_id}) {name}"), None => chain_id.to_string(), }) .collect(); @@ -174,7 +172,7 @@ pub(crate) fn select_config_chain_id( _ => return Err(MescCliError::InvalidInput("invalid input".to_string())), }; match options.iter().position(|x| x == &input) { - Some(index) => Ok(Some(sorted_chain_ids.remove(index))), + Some(index) => Ok(Some(chain_ids[index].clone())), None => Err(MescCliError::Error("invalid input".to_string())), } } diff --git a/rust/crates/mesc_cli/src/printing.rs b/rust/crates/mesc_cli/src/printing.rs index fe4d242..459a763 100644 --- a/rust/crates/mesc_cli/src/printing.rs +++ b/rust/crates/mesc_cli/src/printing.rs @@ -57,11 +57,11 @@ pub(crate) fn print_endpoints( names.push(endpoint.name.clone()); networks.push(endpoint.chain_id_string()); - let network_name = match endpoint.chain_id { - Some(ref chain_id) => all_network_names.get(&chain_id).map(String::clone), - None => None, - }; - let network_name = network_name.unwrap_or(endpoint.chain_id_string().clone()); + let network_name = endpoint + .chain_id + .as_ref() + .and_then(|chain_id| all_network_names.get(&chain_id).map(ToString::to_string)) + .unwrap_or_else(|| endpoint.chain_id_string()); network_names.push(network_name); if reveal { urls.push(endpoint.url.clone()); diff --git a/tests/generate.py b/tests/generate.py index 8bffbda..e1f07c6 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -3,11 +3,11 @@ from __future__ import annotations import copy -from typing import Any, TypeVar, Sequence, Union import typing +from typing import Any, Sequence, TypeVar, Union if typing.TYPE_CHECKING: - from mesc import RpcConfig, Profile, Endpoint + from mesc import Endpoint, Profile, RpcConfig from mesc.types import MescQuery blank_config: RpcConfig = { @@ -68,7 +68,7 @@ full_config: RpcConfig = { "llamanodes_ethereum": { "name": "llamanodes_ethereum", "url": "https://eth.llamarpc.com", - "chain_id": "0x01", + "chain_id": "1", "endpoint_metadata": {}, }, "llamanodes_optimism": { @@ -80,7 +80,7 @@ full_config: RpcConfig = { "llamanodes_base": { "name": "llamanodes_base", "url": "https://base.llamarpc.com", - "chain_id": "0x2105", + "chain_id": "8453", "endpoint_metadata": {}, }, }, @@ -1013,9 +1013,9 @@ def create_invalid_config_tests() -> list[Test]: for profile_name, profile_data in full_config["profiles"].items(): config = copy.deepcopy(full_config) config["profiles"][profile_name]["network_defaults"]["8453"] = "llamanodes_base" - config["profiles"][profile_name]["network_defaults"][ - "0x2105" - ] = "llamanodes_base" + config["profiles"][profile_name]["network_defaults"]["0x2105"] = ( + "llamanodes_base" + ) tests.append( ( "conflicting chain_ids in profile " From 9785240164359319700f60b791ebfc6ecfd5b128 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 18 Sep 2024 13:34:06 -0700 Subject: [PATCH 83/85] bump rust to 0.3.0 --- rust/Cargo.toml | 2 +- rust/crates/mesc_cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 8210660..c27f9e3 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/mesc", "crates/mesc_cli"] resolver = "2" [workspace.package] -version = "0.2.1" +version = "0.3.0" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/paradigmxyz/mesc" diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 3952d7e..06b4259 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -19,7 +19,7 @@ edit = "0.1.4" futures = "0.3.29" inquire = "0.7" ipgeolocate = "0.3.6" -mesc = { version = "0.2.1", path = "../mesc" } +mesc = { version = "0.3.0", path = "../mesc" } reqwest = { version = "0.11", features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } From 9bf6cb47e363bf78fe2106fce3abd6a5a340d068 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Fri, 20 Sep 2024 11:51:31 -0700 Subject: [PATCH 84/85] update network names --- python/generate_network_names.py | 5 +++ python/mesc/network_names.py | 61 +++++++++++++++++++-------- rust/Cargo.lock | 4 +- rust/crates/mesc/src/network_names.rs | 61 +++++++++++++++++++-------- 4 files changed, 93 insertions(+), 38 deletions(-) diff --git a/python/generate_network_names.py b/python/generate_network_names.py index 6a7390e..75a824b 100755 --- a/python/generate_network_names.py +++ b/python/generate_network_names.py @@ -19,6 +19,9 @@ import requests # specialcase the standard name for certain chains special_cases: Mapping[str, str] = { 'OP Mainnet': 'optimism', + 'Avalanche C-Chain': 'avalanche', + 'Arbitrum One': 'arbitrum', + 'BNB Smart Chain Mainnet': 'bsc', 'Genesis Coin': 'genesis_coin', 'X1 Network': 'x1_network', 'ThaiChain 2.0 ThaiFi': 'thaifi', @@ -60,6 +63,8 @@ def standardize_name(name: str) -> str: name = name.lower() name = name.replace(' ', '_') name = name.replace('-', '_') + name = name.replace('___', '_') + name = name.replace('__', '_') name = name.replace('(', '') name = name.replace(')', '') diff --git a/python/mesc/network_names.py b/python/mesc/network_names.py index 426d867..433e0b1 100644 --- a/python/mesc/network_names.py +++ b/python/mesc/network_names.py @@ -62,7 +62,7 @@ network_names = { '53': 'coinex_testnet', '54': 'openpiece', '55': 'zyx', - '56': 'bnb', + '56': 'bsc', '57': 'syscoin', '58': 'ontology', '59': 'eos_evm_legacy', @@ -165,7 +165,7 @@ network_names = { '161': 'armonia_eva_testnet', '162': 'lightstreams_testnet', '163': 'lightstreams', - '164': 'omni_omega', + '164': 'omni_omega_testnet', '166': 'omni', '167': 'atoshi_testnet', '168': 'aioz', @@ -178,6 +178,7 @@ network_names = { '179': 'abey', '180': 'ame', '181': 'waterfall', + '183': 'ethernity', '184': 'dojima_testnet', '185': 'mint', '186': 'seele', @@ -430,6 +431,8 @@ network_names = { '1001': 'kaia_testnet_kairos', '1003': 'tectum_emission_token', '1004': 't_ekta', + '1005': 'lemontestnet', + '1006': 'lemon', '1007': 'newton_testnet', '1008': 'eurus', '1009': 'jumbo', @@ -497,6 +500,7 @@ network_names = { '1246': 'om_platform', '1248': 'dogether', '1252': 'cic_testnet', + '1260': 'metacces_testnet', '1280': 'halo', '1284': 'moonbeam', '1285': 'moonriver', @@ -525,7 +529,6 @@ network_names = { '1388': 'amstar', '1392': 'joseon', '1402': 'polygon_zkevm_testnet_old', - '1414': 'silicon_zkevm_sepolia_testnet', '1422': 'polygon_zkevm_testnet_pre_audit_upgraded', '1433': 'rikeza', '1440': 'living_assets', @@ -643,6 +646,7 @@ network_names = { '2047': 'stratos_testnet', '2048': 'stratos', '2049': 'movo', + '2071': 'metacces', '2077': 'quokkacoin', '2088': 'altair', '2089': 'algol', @@ -675,7 +679,7 @@ network_names = { '2300': 'bomb', '2306': 'ebro', '2309': 'arevia', - '2311': 'chronicle_vesuvius___lit_protocol_testnet', + '2311': 'chronicle_vesuvius_lit_protocol_testnet', '2323': 'soma_testnet', '2330': 'altcoin', '2331': 'rss3_vsl_sepolia_testnet', @@ -714,8 +718,10 @@ network_names = { '2748': 'nanon', '2777': 'gm', '2810': 'morph_holesky', + '2868': 'hyperagi', '2882': 'chips', '2888': 'boba_goerli_testnet', + '2889': 'aarma', '2907': 'elux', '2911': 'hy', '2941': 'xenon_testnet', @@ -733,7 +739,7 @@ network_names = { '3102': 'vulture_evm_beta', '3109': 'satoshivm_alpha', '3110': 'satoshivm_testnet', - '3141': 'filecoin___hyperspace_testnet', + '3141': 'filecoin_hyperspace_testnet', '3269': 'dubxcoin', '3270': 'dubxcoin_testnet', '3306': 'debounce_subnet_testnet', @@ -853,6 +859,7 @@ network_names = { '5424': 'edexa', '5439': 'ego', '5522': 'vex_evm_testnet', + '5545': 'duck', '5551': 'nahmii_2', '5553': 'nahmii_2_testnet', '5555': 'verse', @@ -899,6 +906,7 @@ network_names = { '6805': 'race', '6806': 'race_testnet', '6868': 'pools', + '6880': 'mtt', '6942': 'laika', '6969': 'tomb', '6999': 'polysmart', @@ -924,7 +932,7 @@ network_names = { '7575': 'adil_testnet', '7576': 'adil_v2', '7668': 'the_root', - '7672': 'the_root___porcini_testnet', + '7672': 'the_root_porcini_testnet', '7700': 'canto', '7701': 'canto_tesnet', '7771': 'bitrock_testnet', @@ -946,6 +954,7 @@ network_names = { '8000': 'teleport', '8001': 'teleport_testnet', '8008': 'polynomial', + '8017': 'isuncoin', '8029': 'mdgl_testnet', '8047': 'boat', '8054': 'karak_sepolia', @@ -971,6 +980,7 @@ network_names = { '8329': 'lorenzo', '8333': 'b3', '8387': 'dracones_financial_services', + '8428': 'that', '8453': 'base', '8545': 'chakra_testnet', '8654': 'toki', @@ -1011,8 +1021,8 @@ network_names = { '9012': 'berylbit', '9024': 'nexa_testnet_block', '9025': 'nexa_block', - '9069': 'apex_fusion___nexus', - '9070': 'apex_fusion___nexus_testnet', + '9069': 'apex_fusion_nexus', + '9070': 'apex_fusion_nexus_testnet', '9100': 'genesis_coin', '9170': 'rinia_testnet_old', '9223': 'codefin', @@ -1036,6 +1046,7 @@ network_names = { '9819': 'imperium', '9876': 'binary_testnet', '9888': 'dogelayer', + '9897': 'arena_z_testnet', '9898': 'larissa', '9911': 'espento', '9966': 'uxer_testnet', @@ -1104,6 +1115,7 @@ network_names = { '12898': 'playfair_testnet_subnet', '13000': 'sps', '13337': 'beam_testnet', + '13370': 'cannon_testnet', '13371': 'immutable_zkevm', '13381': 'phoenix', '13396': 'masa', @@ -1115,6 +1127,7 @@ network_names = { '14088': 'zeroth_testnet', '14324': 'evolve_testnet', '14333': 'vitruveo_testnet', + '14800': 'vana_moksha_testnet', '14801': 'vana_satori_testnet', '14853': 'humanode_testnet_5_israfel', '15003': 'immutable_zkevm_devnet', @@ -1192,6 +1205,7 @@ network_names = { '24484': 'web', '24734': 'mintme.com', '25186': 'liquidlayer', + '25327': 'everclear', '25839': 'alvey_testnet', '25888': 'hammer', '25925': 'bitkub_testnet', @@ -1223,7 +1237,7 @@ network_names = { '31224': 'cloudtx_testnet', '31337': 'go_testnet', '31414': 'evoke_testnet', - '31415': 'filecoin___wallaby_testnet', + '31415': 'filecoin_wallaby_testnet', '31753': 'x', '31754': 'x_testnet', '32001': 'w3gamez_holesky_testnet', @@ -1257,7 +1271,7 @@ network_names = { '41500': 'opulent_x_beta', '42069': 'pegglecoin', '42072': 'agentlayer_testnet', - '42161': 'arbitrum_one', + '42161': 'arbitrum', '42170': 'arbitrum_nova', '42220': 'celo', '42261': 'oasis_emerald_testnet', @@ -1271,7 +1285,7 @@ network_names = { '43110': 'athereum', '43111': 'hemi', '43113': 'avalanche_fuji_testnet', - '43114': 'avalanche_c', + '43114': 'avalanche', '43288': 'boba_avax', '43851': 'zkfair_testnet', '44444': 'fren', @@ -1349,16 +1363,18 @@ network_names = { '65357': 'vecno', '65450': 'scolcoin', '65536': 'automata', + '66665': 'creator_testnet', '66988': 'janus_testnet', '67390': 'siriusnet', '67588': 'cosmic', '68770': 'dm2_verse', + '68775': 'dm2_verse_testnet', '69420': 'condrieu', '70000': 'thinkium_0', '70001': 'thinkium_1', '70002': 'thinkium_2', '70103': 'thinkium_103', - '70700': 'proof_of_play___apex', + '70700': 'proof_of_play_apex', '71111': 'guapcoinx', '71393': 'polyjuice_testnet', '71401': 'godwoken_testnet_v1', @@ -1426,6 +1442,8 @@ network_names = { '93572': 'liquidlayer_testnet', '93747': 'stratovm_testnet', '96970': 'mantis_testnet_hexapod', + '97053': 'tetron_testnet', + '97055': 'tetron', '97288': 'boba_bnb_old', '97435': 'slingshot_testnet', '97531': 'green_testnet', @@ -1491,8 +1509,8 @@ network_names = { '167009': 'taiko_hekla_l2', '168168': 'zs', '171000': 'fair_testnet', - '175177': 'chronicle___lit_protocol_testnet', - '175188': 'chronicle_yellowstone___lit_protocol_testnet', + '175177': 'chronicle_lit_protocol_testnet', + '175188': 'chronicle_yellowstone_lit_protocol_testnet', '188710': 'bitica', '188881': 'condor_test', '199991': 'mazze_testnet', @@ -1507,6 +1525,7 @@ network_names = { '201804': 'mythical', '202020': 'decimal_testnet', '202105': 'duck_testnet', + '202202': 'bethel_sydney', '202212': 'x1_devnet', '202401': 'ymtech_besu_testnet', '202624': 'jellie', @@ -1540,7 +1559,7 @@ network_names = { '292003': 'cipherem_testnet', '309075': 'one_world', '313313': 'saharaai_testnet', - '314159': 'filecoin___calibration_testnet', + '314159': 'filecoin_calibration_testnet', '322202': 'parex', '323213': 'bloom_genesis_testnet', '327126': 'waba_testnet', @@ -1602,13 +1621,14 @@ network_names = { '651940': 'all', '656476': 'open_campus_codex', '660279': 'xai', - '666666': 'vision___vpioneer_test', + '666666': 'vision_vpioneer_test', '666888': 'hela_official_runtime_testnet', '686868': 'won', '696969': 'galadriel_devnet', '710420': 'tiltyard_subnet', '713715': 'sei_devnet', '721529': 'eram', + '723107': 'tix_testnet', '743111': 'hemi_sepolia', '751230': 'bear_testnet', '752024': 'ternoa_testnet', @@ -1622,6 +1642,7 @@ network_names = { '810180': 'zklink_nova', '810181': 'zklink_nova_sepolia_testnet', '810182': 'zklink_nova_goerli_testnet', + '812397': 'sg_verse', '820522': 'tsc_testnet', '827431': 'curve', '839320': 'prm_testnet', @@ -1654,6 +1675,7 @@ network_names = { '1337802': 'kiln', '1337803': 'zhejiang', '1398243': 'automata_testnet', + '1398244': 'automata_orbit_testnet', '1612127': 'playfi_albireo_testnet', '1637450': 'xterio_testnet', '1731313': 'turkey_demo_dev', @@ -1663,7 +1685,7 @@ network_names = { '2611555': 'dpu', '2702128': 'xterio', '3132023': 'saharaai', - '3141592': 'filecoin___butterfly_testnet', + '3141592': 'filecoin_butterfly_testnet', '3397901': 'funki_sepolia_sandbox', '3441005': 'manta_pacific_testnet', '3441006': 'manta_pacific_sepolia_testnet', @@ -1681,6 +1703,7 @@ network_names = { '6038361': 'astar_zkyoto', '6666665': 'safeanwang', '6666666': 'safeanwang_testnet', + '7082400': 'coti_testnet', '7225878': 'saakuru', '7355310': 'openvessel', '7668378': 'ql1_testnet', @@ -1724,12 +1747,13 @@ network_names = { '20241133': 'swan_proxima_testnet', '20482050': 'hokum_testnet', '22052002': 'excelon', + '24772477': '6degree_of_outreach_testnet', '27082017': 'excoincial_volta_testnet', '27082022': 'excoincial', '28122024': 'ancient8_testnet', '28945486': 'auxilium', '29032022': 'fla', - '31415926': 'filecoin___local_testnet', + '31415926': 'filecoin_local_testnet', '33626250': 'toliman_suave_testnet', '35855456': 'joys_digital', '37084624': 'skale_nebula_hub_testnet', @@ -1803,6 +1827,7 @@ network_names = { '1666700001': 'harmony_testnet_shard_1', '1666900000': 'harmony_devnet_shard_0', '1666900001': 'harmony_devnet_shard_1', + '1722641160': 'silicon_zkevm_sepolia_testnet', '1802203764': 'kakarot_sepolia', '1903648807': 'gemu_testnet', '1918988905': 'rari_testnet', diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 0ba95c3..a428cd8 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1405,7 +1405,7 @@ dependencies = [ [[package]] name = "mesc" -version = "0.2.1" +version = "0.3.0" dependencies = [ "serde", "serde_json", @@ -1414,7 +1414,7 @@ dependencies = [ [[package]] name = "mesc_cli" -version = "0.2.1" +version = "0.3.0" dependencies = [ "bat", "clap", diff --git a/rust/crates/mesc/src/network_names.rs b/rust/crates/mesc/src/network_names.rs index 8975a84..5c3442a 100644 --- a/rust/crates/mesc/src/network_names.rs +++ b/rust/crates/mesc/src/network_names.rs @@ -71,7 +71,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (53, "coinex_testnet"), (54, "openpiece"), (55, "zyx"), - (56, "bnb"), + (56, "bsc"), (57, "syscoin"), (58, "ontology"), (59, "eos_evm_legacy"), @@ -174,7 +174,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (161, "armonia_eva_testnet"), (162, "lightstreams_testnet"), (163, "lightstreams"), - (164, "omni_omega"), + (164, "omni_omega_testnet"), (166, "omni"), (167, "atoshi_testnet"), (168, "aioz"), @@ -187,6 +187,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (179, "abey"), (180, "ame"), (181, "waterfall"), + (183, "ethernity"), (184, "dojima_testnet"), (185, "mint"), (186, "seele"), @@ -439,6 +440,8 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (1001, "kaia_testnet_kairos"), (1003, "tectum_emission_token"), (1004, "t_ekta"), + (1005, "lemontestnet"), + (1006, "lemon"), (1007, "newton_testnet"), (1008, "eurus"), (1009, "jumbo"), @@ -506,6 +509,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (1246, "om_platform"), (1248, "dogether"), (1252, "cic_testnet"), + (1260, "metacces_testnet"), (1280, "halo"), (1284, "moonbeam"), (1285, "moonriver"), @@ -534,7 +538,6 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (1388, "amstar"), (1392, "joseon"), (1402, "polygon_zkevm_testnet_old"), - (1414, "silicon_zkevm_sepolia_testnet"), (1422, "polygon_zkevm_testnet_pre_audit_upgraded"), (1433, "rikeza"), (1440, "living_assets"), @@ -652,6 +655,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (2047, "stratos_testnet"), (2048, "stratos"), (2049, "movo"), + (2071, "metacces"), (2077, "quokkacoin"), (2088, "altair"), (2089, "algol"), @@ -684,7 +688,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (2300, "bomb"), (2306, "ebro"), (2309, "arevia"), - (2311, "chronicle_vesuvius___lit_protocol_testnet"), + (2311, "chronicle_vesuvius_lit_protocol_testnet"), (2323, "soma_testnet"), (2330, "altcoin"), (2331, "rss3_vsl_sepolia_testnet"), @@ -723,8 +727,10 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (2748, "nanon"), (2777, "gm"), (2810, "morph_holesky"), + (2868, "hyperagi"), (2882, "chips"), (2888, "boba_goerli_testnet"), + (2889, "aarma"), (2907, "elux"), (2911, "hy"), (2941, "xenon_testnet"), @@ -742,7 +748,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (3102, "vulture_evm_beta"), (3109, "satoshivm_alpha"), (3110, "satoshivm_testnet"), - (3141, "filecoin___hyperspace_testnet"), + (3141, "filecoin_hyperspace_testnet"), (3269, "dubxcoin"), (3270, "dubxcoin_testnet"), (3306, "debounce_subnet_testnet"), @@ -862,6 +868,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (5424, "edexa"), (5439, "ego"), (5522, "vex_evm_testnet"), + (5545, "duck"), (5551, "nahmii_2"), (5553, "nahmii_2_testnet"), (5555, "verse"), @@ -908,6 +915,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (6805, "race"), (6806, "race_testnet"), (6868, "pools"), + (6880, "mtt"), (6942, "laika"), (6969, "tomb"), (6999, "polysmart"), @@ -933,7 +941,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (7575, "adil_testnet"), (7576, "adil_v2"), (7668, "the_root"), - (7672, "the_root___porcini_testnet"), + (7672, "the_root_porcini_testnet"), (7700, "canto"), (7701, "canto_tesnet"), (7771, "bitrock_testnet"), @@ -955,6 +963,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (8000, "teleport"), (8001, "teleport_testnet"), (8008, "polynomial"), + (8017, "isuncoin"), (8029, "mdgl_testnet"), (8047, "boat"), (8054, "karak_sepolia"), @@ -980,6 +989,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (8329, "lorenzo"), (8333, "b3"), (8387, "dracones_financial_services"), + (8428, "that"), (8453, "base"), (8545, "chakra_testnet"), (8654, "toki"), @@ -1020,8 +1030,8 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (9012, "berylbit"), (9024, "nexa_testnet_block"), (9025, "nexa_block"), - (9069, "apex_fusion___nexus"), - (9070, "apex_fusion___nexus_testnet"), + (9069, "apex_fusion_nexus"), + (9070, "apex_fusion_nexus_testnet"), (9100, "genesis_coin"), (9170, "rinia_testnet_old"), (9223, "codefin"), @@ -1045,6 +1055,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (9819, "imperium"), (9876, "binary_testnet"), (9888, "dogelayer"), + (9897, "arena_z_testnet"), (9898, "larissa"), (9911, "espento"), (9966, "uxer_testnet"), @@ -1113,6 +1124,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (12898, "playfair_testnet_subnet"), (13000, "sps"), (13337, "beam_testnet"), + (13370, "cannon_testnet"), (13371, "immutable_zkevm"), (13381, "phoenix"), (13396, "masa"), @@ -1124,6 +1136,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (14088, "zeroth_testnet"), (14324, "evolve_testnet"), (14333, "vitruveo_testnet"), + (14800, "vana_moksha_testnet"), (14801, "vana_satori_testnet"), (14853, "humanode_testnet_5_israfel"), (15003, "immutable_zkevm_devnet"), @@ -1201,6 +1214,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (24484, "web"), (24734, "mintme.com"), (25186, "liquidlayer"), + (25327, "everclear"), (25839, "alvey_testnet"), (25888, "hammer"), (25925, "bitkub_testnet"), @@ -1232,7 +1246,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (31224, "cloudtx_testnet"), (31337, "go_testnet"), (31414, "evoke_testnet"), - (31415, "filecoin___wallaby_testnet"), + (31415, "filecoin_wallaby_testnet"), (31753, "x"), (31754, "x_testnet"), (32001, "w3gamez_holesky_testnet"), @@ -1266,7 +1280,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (41500, "opulent_x_beta"), (42069, "pegglecoin"), (42072, "agentlayer_testnet"), - (42161, "arbitrum_one"), + (42161, "arbitrum"), (42170, "arbitrum_nova"), (42220, "celo"), (42261, "oasis_emerald_testnet"), @@ -1280,7 +1294,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (43110, "athereum"), (43111, "hemi"), (43113, "avalanche_fuji_testnet"), - (43114, "avalanche_c"), + (43114, "avalanche"), (43288, "boba_avax"), (43851, "zkfair_testnet"), (44444, "fren"), @@ -1358,16 +1372,18 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (65357, "vecno"), (65450, "scolcoin"), (65536, "automata"), + (66665, "creator_testnet"), (66988, "janus_testnet"), (67390, "siriusnet"), (67588, "cosmic"), (68770, "dm2_verse"), + (68775, "dm2_verse_testnet"), (69420, "condrieu"), (70000, "thinkium_0"), (70001, "thinkium_1"), (70002, "thinkium_2"), (70103, "thinkium_103"), - (70700, "proof_of_play___apex"), + (70700, "proof_of_play_apex"), (71111, "guapcoinx"), (71393, "polyjuice_testnet"), (71401, "godwoken_testnet_v1"), @@ -1435,6 +1451,8 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (93572, "liquidlayer_testnet"), (93747, "stratovm_testnet"), (96970, "mantis_testnet_hexapod"), + (97053, "tetron_testnet"), + (97055, "tetron"), (97288, "boba_bnb_old"), (97435, "slingshot_testnet"), (97531, "green_testnet"), @@ -1500,8 +1518,8 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (167009, "taiko_hekla_l2"), (168168, "zs"), (171000, "fair_testnet"), - (175177, "chronicle___lit_protocol_testnet"), - (175188, "chronicle_yellowstone___lit_protocol_testnet"), + (175177, "chronicle_lit_protocol_testnet"), + (175188, "chronicle_yellowstone_lit_protocol_testnet"), (188710, "bitica"), (188881, "condor_test"), (199991, "mazze_testnet"), @@ -1516,6 +1534,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (201804, "mythical"), (202020, "decimal_testnet"), (202105, "duck_testnet"), + (202202, "bethel_sydney"), (202212, "x1_devnet"), (202401, "ymtech_besu_testnet"), (202624, "jellie"), @@ -1549,7 +1568,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (292003, "cipherem_testnet"), (309075, "one_world"), (313313, "saharaai_testnet"), - (314159, "filecoin___calibration_testnet"), + (314159, "filecoin_calibration_testnet"), (322202, "parex"), (323213, "bloom_genesis_testnet"), (327126, "waba_testnet"), @@ -1611,13 +1630,14 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (651940, "all"), (656476, "open_campus_codex"), (660279, "xai"), - (666666, "vision___vpioneer_test"), + (666666, "vision_vpioneer_test"), (666888, "hela_official_runtime_testnet"), (686868, "won"), (696969, "galadriel_devnet"), (710420, "tiltyard_subnet"), (713715, "sei_devnet"), (721529, "eram"), + (723107, "tix_testnet"), (743111, "hemi_sepolia"), (751230, "bear_testnet"), (752024, "ternoa_testnet"), @@ -1631,6 +1651,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (810180, "zklink_nova"), (810181, "zklink_nova_sepolia_testnet"), (810182, "zklink_nova_goerli_testnet"), + (812397, "sg_verse"), (820522, "tsc_testnet"), (827431, "curve"), (839320, "prm_testnet"), @@ -1663,6 +1684,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (1337802, "kiln"), (1337803, "zhejiang"), (1398243, "automata_testnet"), + (1398244, "automata_orbit_testnet"), (1612127, "playfi_albireo_testnet"), (1637450, "xterio_testnet"), (1731313, "turkey_demo_dev"), @@ -1672,7 +1694,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (2611555, "dpu"), (2702128, "xterio"), (3132023, "saharaai"), - (3141592, "filecoin___butterfly_testnet"), + (3141592, "filecoin_butterfly_testnet"), (3397901, "funki_sepolia_sandbox"), (3441005, "manta_pacific_testnet"), (3441006, "manta_pacific_sepolia_testnet"), @@ -1690,6 +1712,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (6038361, "astar_zkyoto"), (6666665, "safeanwang"), (6666666, "safeanwang_testnet"), + (7082400, "coti_testnet"), (7225878, "saakuru"), (7355310, "openvessel"), (7668378, "ql1_testnet"), @@ -1733,12 +1756,13 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (20241133, "swan_proxima_testnet"), (20482050, "hokum_testnet"), (22052002, "excelon"), + (24772477, "6degree_of_outreach_testnet"), (27082017, "excoincial_volta_testnet"), (27082022, "excoincial"), (28122024, "ancient8_testnet"), (28945486, "auxilium"), (29032022, "fla"), - (31415926, "filecoin___local_testnet"), + (31415926, "filecoin_local_testnet"), (33626250, "toliman_suave_testnet"), (35855456, "joys_digital"), (37084624, "skale_nebula_hub_testnet"), @@ -1812,6 +1836,7 @@ pub(crate) const NETWORKS: &[(u64, &str)] = &[ (1666700001, "harmony_testnet_shard_1"), (1666900000, "harmony_devnet_shard_0"), (1666900001, "harmony_devnet_shard_1"), + (1722641160, "silicon_zkevm_sepolia_testnet"), (1802203764, "kakarot_sepolia"), (1903648807, "gemu_testnet"), (1918988905, "rari_testnet"), From cdc1ca107ed5a3dee725585e6959d4751fe58d37 Mon Sep 17 00:00:00 2001 From: Derek Cofausper <256792747+decofe@users.noreply.github.com> Date: Sat, 17 Oct 2026 09:11:25 +0200 Subject: [PATCH 85/85] chore: remove redundant package homepages (#39) Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- rust/Cargo.toml | 1 - rust/crates/mesc/Cargo.toml | 1 - rust/crates/mesc_cli/Cargo.toml | 1 - 3 files changed, 3 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index c27f9e3..ce713ff 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -10,7 +10,6 @@ resolver = "2" version = "0.3.0" edition = "2021" license = "MIT OR Apache-2.0" -homepage = "https://github.com/paradigmxyz/mesc" repository = "https://github.com/paradigmxyz/mesc" exclude = [".github/"] diff --git a/rust/crates/mesc/Cargo.toml b/rust/crates/mesc/Cargo.toml index 2bd9d68..113aefd 100644 --- a/rust/crates/mesc/Cargo.toml +++ b/rust/crates/mesc/Cargo.toml @@ -4,7 +4,6 @@ description = "libraries for creating, loading, and modifying MESC configuation version.workspace = true edition.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true [dependencies] diff --git a/rust/crates/mesc_cli/Cargo.toml b/rust/crates/mesc_cli/Cargo.toml index 06b4259..ef419b7 100644 --- a/rust/crates/mesc_cli/Cargo.toml +++ b/rust/crates/mesc_cli/Cargo.toml @@ -4,7 +4,6 @@ description = "command line interface for creating, loading, and modifying MESC version.workspace = true edition.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true [[bin]]