diff --git a/scripts/automation_scripts/update_lava_spec.py b/scripts/automation_scripts/update_cosmos_spec_from_grpc.py similarity index 85% rename from scripts/automation_scripts/update_lava_spec.py rename to scripts/automation_scripts/update_cosmos_spec_from_grpc.py index fdd68a5be1..ad28a01046 100644 --- a/scripts/automation_scripts/update_lava_spec.py +++ b/scripts/automation_scripts/update_cosmos_spec_from_grpc.py @@ -3,7 +3,7 @@ import os import re -LAVA_PUBLIC_RPC = "" +LAVA_PUBLIC_RPC = "grpcbin.pulsar.scrttestnet.com:9099" def parse_endpoints_from_spec(lava_spec_file: str) -> dict[str, list[str]]: @@ -35,11 +35,11 @@ def parse_endpoints_from_spec(lava_spec_file: str) -> dict[str, list[str]]: return endpoints -def parse_endpoints_from_grpcurl() -> dict[str, list[str]]: +def parse_endpoints_from_grpcurl(grpc_url: str) -> dict[str, list[str]]: print("### Parsing endpoints from gRPC service") endpoints: dict[str, list[str]] = {"grpc": [], "rest": []} - content = os.popen(f"grpcurl -plaintext {LAVA_PUBLIC_RPC} describe").read() + content = os.popen(f"grpcurl -plaintext {grpc_url} describe").read() # Regex pattern to find services starting with their corresponding rpc and rest paths grpc_pattern = re.compile( @@ -54,7 +54,7 @@ def parse_endpoints_from_grpcurl() -> dict[str, list[str]]: for service_match in grpc_pattern.finditer(content): service_name, service_content = service_match.groups() - if "cosmos" in service_content or "cosmwasm" in service_content or "ibc" in service_content: + if "cosmos" in service_content or "cosmwasm" in service_content or "ibc" in service_content or "grpc.reflection.v1alpha" in service_content: continue # Extracting all grpc paths @@ -120,18 +120,18 @@ def create_api_entry(endpoint: str) -> dict: if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Update Lava's spec file") - parser.add_argument("lava_spec_file", help="Path to the Lava spec file.") + parser = argparse.ArgumentParser(description="Update Cosmos-based spec file") + parser.add_argument("spec_file", help="Path to the spec file to update") + parser.add_argument("grpc_url", help="GRPC URL to fetch the endpoints from") parser.add_argument( "--dry-run", action="store_true", help="Perform a dry run without making any changes.", ) args = parser.parse_args() - try: - grpcurl_endpoints = parse_endpoints_from_grpcurl() - spec_endpoints = parse_endpoints_from_spec(args.lava_spec_file) + grpcurl_endpoints = parse_endpoints_from_grpcurl(args.grpc_url) + spec_endpoints = parse_endpoints_from_spec(args.spec_file) grpc_endpoints_to_update = set(grpcurl_endpoints["grpc"]) - set( spec_endpoints["grpc"] @@ -146,7 +146,7 @@ def create_api_entry(endpoint: str) -> dict: exit(1) else: update_spec_file( - args.lava_spec_file, grpc_endpoints_to_update, rest_endpoints_to_update + args.spec_file, grpc_endpoints_to_update, rest_endpoints_to_update ) print("### Done")