Skip to content

Commit

Permalink
fix gui missing params
Browse files Browse the repository at this point in the history
- add base58 in the output view
  • Loading branch information
Eduard-Voiculescu committed Oct 31, 2024
1 parent fa54a0a commit 5e31dcd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
36 changes: 26 additions & 10 deletions cmd/substreams/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,31 @@ func runGui(cmd *cobra.Command, args []string) (err error) {
default:
return fmt.Errorf("too many arguments")
}
// TODO: validate that the manifest is a valid substreams package

requestParams := sflags.MustGetStringArray(cmd, "params")

paramsStringMap := make(map[string]struct{})
for _, parameter := range requestParams {
moduleName := strings.Split(parameter, "=")[0]
paramsStringMap[moduleName] = struct{}{}
}

readerOptions := []manifest.Option{}

if len(requestParams) != 0 {
params, err := manifest.ParseParams(requestParams)
if err != nil {
return fmt.Errorf("parsing params: %w", err)
}
readerOptions = append(readerOptions, manifest.WithParams(params))
}

if sflags.MustGetBool(cmd, "skip-package-validation") {
readerOptions = append(readerOptions, manifest.SkipPackageValidationReader())
}

// Safe guard to ensure that the manifest file exists
manifestReader, err := manifest.NewReader(manifestPath)
manifestReader, err := manifest.NewReader(manifestPath, readerOptions...)
if err != nil {
return fmt.Errorf("manifest reader: %w", err)
}
Expand Down Expand Up @@ -102,14 +123,9 @@ func runGui(cmd *cobra.Command, args []string) (err error) {
network := sflags.MustGetString(cmd, "network")
if network == "" {
network = packageBundle.Package.Network
}

requestParams := sflags.MustGetStringArray(cmd, "params")

paramsStringMap := make(map[string]struct{})
for _, parameter := range requestParams {
moduleName := strings.Split(parameter, "=")[0]
paramsStringMap[moduleName] = struct{}{}
if network == "" {
return fmt.Errorf("network not set, please provide a network")
}
}

defaultParams := make([]string, 0)
Expand Down
2 changes: 1 addition & 1 deletion tui2/pages/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (o *Output) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
o.searchEnabled = true
cmds = append(cmds, common.SetModalComponentCmd(o.searchCtx))
case "F":
o.bytesRepresentation = (o.bytesRepresentation + 1) % 3
o.bytesRepresentation = (o.bytesRepresentation + 1) % 4
o.statusBar.SetBytesRepresentation(o.bytesRepresentation)
o.setOutputViewContent(true)
case "N":
Expand Down
2 changes: 2 additions & 0 deletions tui2/pages/request/newinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ func (c *Config) NewInstance() (out *Instance, err error) {
}
readerOptions = append(readerOptions, manifest.WithParams(params))
}

if c.OverrideNetwork != "" {
readerOptions = append(readerOptions, manifest.WithOverrideNetwork(c.OverrideNetwork))
}

if c.SkipPackageValidation {
readerOptions = append(readerOptions, manifest.SkipPackageValidationReader())
}
Expand Down

0 comments on commit 5e31dcd

Please sign in to comment.