From d87d2e1b7dc6c2cda1415f8f1fed2086784c8750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duchesneau?= Date: Fri, 13 Sep 2024 09:45:21 -0400 Subject: [PATCH] add substreams tools default-endpoint --- docs/release-notes/change-log.md | 4 ++++ tools/default-endpoint.go | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tools/default-endpoint.go diff --git a/docs/release-notes/change-log.md b/docs/release-notes/change-log.md index 40a75333..5d0531c2 100644 --- a/docs/release-notes/change-log.md +++ b/docs/release-notes/change-log.md @@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * Fix handling of 'special case' substreams module with only "params" as its input: should not skip this execution (used in graph-node for head tracking) -> empty files in module cache with hash `d3b1920483180cbcd2fd10abcabbee431146f4c8` should be deleted for consistency +### CLI + +* Add `substreams tools default-endpoint {network-name}` to help with auto-configuration tools + ## v1.10.2 * `substreams gui`: fix panic in some conditions when streaming from block 0 diff --git a/tools/default-endpoint.go b/tools/default-endpoint.go new file mode 100644 index 00000000..02d88678 --- /dev/null +++ b/tools/default-endpoint.go @@ -0,0 +1,27 @@ +package tools + +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/streamingfast/substreams/manifest" +) + +var defaultEndpointCmd = &cobra.Command{ + Use: "default-endpoint {network-name}", + Short: "returns the default endpoint for a given network (the one used by default by the substreams CLI tool)", + Args: cobra.ExactArgs(1), + RunE: defaultEndpointE, +} + +func init() { + Cmd.AddCommand(defaultEndpointCmd) +} + +func defaultEndpointE(cmd *cobra.Command, args []string) error { + if endpoint := manifest.HardcodedEndpoints[args[0]]; endpoint != "" { + fmt.Println(endpoint) + return nil + } + return fmt.Errorf("no endpoint found for network %s", args[0]) +}