diff --git a/cmd/substreams/gui.go b/cmd/substreams/gui.go index 3098a4a7..aad45790 100644 --- a/cmd/substreams/gui.go +++ b/cmd/substreams/gui.go @@ -25,7 +25,6 @@ func init() { guiCmd.Flags().String("network", "", "Specify the network to use for params and initialBlocks, overriding the 'network' field in the substreams package") guiCmd.Flags().Bool("insecure", false, "Skip certificate validation on GRPC connection") guiCmd.Flags().Bool("plaintext", false, "Establish GRPC connection in plaintext") - guiCmd.Flags().String("spkg-registry", "https://spkg.io", "Substreams package registry") guiCmd.Flags().StringSliceP("header", "H", nil, "Additional headers to be sent in the substreams request") guiCmd.Flags().StringP("start-block", "s", "", "Start block to stream from. If empty, will be replaced by initialBlock of the first module you are streaming. If negative, will be resolved by the server relative to the chain head") guiCmd.Flags().StringP("cursor", "c", "", "Cursor to stream from. Leave blank for no cursor") @@ -93,7 +92,7 @@ func runGui(cmd *cobra.Command, args []string) (err error) { } readerOptions := []manifest.Option{ - manifest.WithRegistryURL(sflags.MustGetString(cmd, "spkg-registry")), + manifest.WithRegistryURL(getSubstreamsRegistryEndpoint()), } if len(requestParams) != 0 { diff --git a/cmd/substreams/init.go b/cmd/substreams/init.go index 2c152c81..c90e0ca2 100644 --- a/cmd/substreams/init.go +++ b/cmd/substreams/init.go @@ -106,10 +106,7 @@ func runSubstreamsInitE(cmd *cobra.Command, args []string) error { connect.WithGRPC(), } - codegenEndpoint := "https://codegen.substreams.dev" - if newValue := os.Getenv("SUBSTREAMS_CODEGEN_ENDPOINT"); newValue != "" { - codegenEndpoint = newValue - } + codegenEndpoint := getSubstreamsCodegenEndpoint() initConvoURL := codegenEndpoint stateFile, stateFileFlagProvided := sflags.MustGetStringProvided(cmd, "state-file") diff --git a/cmd/substreams/registry-login.go b/cmd/substreams/registry-login.go index a7350e9f..02b41247 100644 --- a/cmd/substreams/registry-login.go +++ b/cmd/substreams/registry-login.go @@ -3,11 +3,12 @@ package main import ( "errors" "fmt" - "github.com/charmbracelet/huh" - "github.com/charmbracelet/lipgloss" "os" "path/filepath" + "github.com/charmbracelet/huh" + "github.com/charmbracelet/lipgloss" + "github.com/spf13/cobra" ) @@ -25,10 +26,7 @@ func init() { } func runRegistryLoginE(cmd *cobra.Command, args []string) error { - registryURL := "https://substreams.dev" - if newValue := os.Getenv("SUBSTREAMS_REGISTRY_ENDPOINT"); newValue != "" { - registryURL = newValue - } + registryURL := getSubstreamsRegistryEndpoint() linkStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("12")) token, err := copyPasteTokenForm(registryURL, linkStyle) @@ -92,4 +90,4 @@ func runConfirmForm(title string) (bool, error) { } return confirmOverwrite, nil -} \ No newline at end of file +} diff --git a/cmd/substreams/registry-publish.go b/cmd/substreams/registry-publish.go index 22d2253a..326993ca 100644 --- a/cmd/substreams/registry-publish.go +++ b/cmd/substreams/registry-publish.go @@ -19,9 +19,6 @@ import ( ) func init() { - registryPublish.PersistentFlags().String("spkg-registry", "https://spkg.io", "Substreams package registry") - registryPublish.PersistentFlags().String("setup-mode", "production", "Setup mode (production, staging, local-development). Default: production") - registryCmd.AddCommand(registryPublish) } @@ -33,10 +30,7 @@ var registryPublish = &cobra.Command{ } func runRegistryPublish(cmd *cobra.Command, args []string) error { - apiEndpoint := "https://substreams.dev" - if newValue := os.Getenv("SUBSTREAMS_REGISTRY_ENDPOINT"); newValue != "" { - apiEndpoint = newValue - } + apiEndpoint := getSubstreamsRegistryEndpoint() var apiKey string registryTokenBytes, err := os.ReadFile(registryTokenFilename) @@ -81,10 +75,7 @@ func runRegistryPublish(cmd *cobra.Command, args []string) error { manifestPath = args[0] } - spkgRegistry := "https://spkg.io" - if newValue := os.Getenv("SUBSTREAMS_DOWNLOAD_ENDPOINT"); newValue != "" { - apiEndpoint = newValue - } + spkgRegistry := getSubstreamsDownloadEndpoint() readerOptions := []manifest.Option{ manifest.WithRegistryURL(spkgRegistry), @@ -102,7 +93,6 @@ func runRegistryPublish(cmd *cobra.Command, args []string) error { spkg := pkgBundle.Package - style := lipgloss.NewStyle().Foreground(lipgloss.Color("12")) headerStyle := lipgloss.NewStyle().Bold(true) fmt.Println() diff --git a/cmd/substreams/registry.go b/cmd/substreams/registry.go index f1e705ed..32c182f7 100644 --- a/cmd/substreams/registry.go +++ b/cmd/substreams/registry.go @@ -1,6 +1,9 @@ package main import ( + "fmt" + "os" + "github.com/spf13/cobra" "github.com/streamingfast/cli" ) @@ -17,3 +20,30 @@ var registryCmd = &cobra.Command{ func init() { rootCmd.AddCommand(registryCmd) } + +func getSubstreamsRegistryEndpoint() string { + endpoint := "https://substreams.dev" + if newValue := os.Getenv("SUBSTREAMS_REGISTRY_ENDPOINT"); newValue != "" { + fmt.Println("Using registry endpoint: " + newValue) + endpoint = newValue + } + return endpoint +} + +func getSubstreamsDownloadEndpoint() string { + endpoint := "https://spkg.io" + if newValue := os.Getenv("SUBSTREAMS_DOWNLOAD_ENDPOINT"); newValue != "" { + fmt.Println("Using download endpoint: " + newValue) + endpoint = newValue + } + return endpoint +} + +func getSubstreamsCodegenEndpoint() string { + endpoint := "https://codegen.substreams.dev" + if newValue := os.Getenv("SUBSTREAMS_CODEGEN_ENDPOINT"); newValue != "" { + fmt.Println("Using codegen endpoint: " + newValue) + endpoint = newValue + } + return endpoint +} diff --git a/cmd/substreams/run.go b/cmd/substreams/run.go index 9a1998cb..5f3852b7 100644 --- a/cmd/substreams/run.go +++ b/cmd/substreams/run.go @@ -28,7 +28,6 @@ func init() { runCmd.Flags().Bool("final-blocks-only", false, "Only process blocks that have pass finality, to prevent any reorg and undo signal by staying further away from the chain HEAD") runCmd.Flags().Bool("insecure", false, "Skip certificate validation on GRPC connection") runCmd.Flags().Bool("plaintext", false, "Establish GRPC connection in plaintext") - runCmd.Flags().String("spkg-registry", "https://spkg.io", "Substreams package registry") runCmd.Flags().StringP("output", "o", "", "Output mode, one of: [ui, json, jsonl, clock] Defaults to 'ui' when in a TTY is present, and 'json' otherwise") runCmd.Flags().StringSlice("debug-modules-initial-snapshot", nil, "List of 'store' modules from which to print the initial data snapshot (Unavailable in Production Mode)") runCmd.Flags().StringSlice("debug-modules-output", nil, "List of modules from which to print outputs, deltas and logs (Unavailable in Production Mode)") @@ -72,7 +71,7 @@ func runRun(cmd *cobra.Command, args []string) error { manifest.WithOverrideOutputModule(outputModule), manifest.WithOverrideNetwork(network), manifest.WithParams(params), - manifest.WithRegistryURL(sflags.MustGetString(cmd, "spkg-registry")), + manifest.WithRegistryURL(getSubstreamsRegistryEndpoint()), } if sflags.MustGetBool(cmd, "skip-package-validation") { readerOptions = append(readerOptions, manifest.SkipPackageValidationReader()) diff --git a/docs/release-notes/change-log.md b/docs/release-notes/change-log.md index f99b9b6c..f8149d9a 100644 --- a/docs/release-notes/change-log.md +++ b/docs/release-notes/change-log.md @@ -11,13 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased -* In `substreams run`, the two positional parameters now align with `gui`: `[package [module_name]]`. Before, it was using fuzzy heuristics to see if a single param was a module name or a package name. You need to be more explicit now, like `gui`. - -## v1.10.12 - -* Add `substreams publish` to `publish` a package on the substreams registry (check on `https://substreams.dev`). -* Add `substreams registry` to `login` and `publish` on the substreams registry (check on `https://substreams.dev`). - +* Changed `substreams run`: the two positional parameters now align with `gui`: `[package [module_name]]`. Before, it was using fuzzy heuristics to see if a single param was a module name or a package name. You need to be more explicit now, like `gui`. +* Added `substreams publish` to `publish` a package on the substreams registry (check on `https://substreams.dev`). +* Added `substreams registry` to `login` and `publish` on the substreams registry (check on `https://substreams.dev`). ## v1.10.11