Skip to content

Commit

Permalink
[1760]: Fix the wasm instantiate2 aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpicyLemon committed May 15, 2024
1 parent 583fba1 commit cea6659
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/provenanced/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"path/filepath"
"strings"
"time"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -143,6 +144,8 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) {
panic(err)
}

fixTxWasmInstantiate2Aliases(rootCmd)

return rootCmd, encodingConfig
}

Expand Down Expand Up @@ -400,6 +403,23 @@ func fixDebugPubkeyRawTypeFlag(rootCmd *cobra.Command) {
})
}

// fixTxWasmInstantiate2Aliases fixes the tx wasm instantiate2 aliases so that they're different
// from the instantiate aliases by adding a 2 to the end (if it doesn't yet have one).
func fixTxWasmInstantiate2Aliases(rootCmd *cobra.Command) {
cmd, _, err := rootCmd.Find([]string{"tx", "wasm", "instantiate2"})
if err != nil || cmd == nil {
// If the command doesn't exist, there's nothing to do.
return
}

// Go through all the aliases and makes sure they end with a "2"
for i, alias := range cmd.Aliases {
if !strings.HasSuffix(alias, "2") {
cmd.Aliases[i] = alias + "2"
}
}
}

func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
set := func(s *pflag.FlagSet, key, val string) {
if f := s.Lookup(key); f != nil {
Expand Down

0 comments on commit cea6659

Please sign in to comment.