Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce --namespace-version CLI flag #1585

Merged
merged 17 commits into from
Apr 19, 2023
Merged
29 changes: 24 additions & 5 deletions x/blob/client/cli/payforblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"os"
"strconv"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -34,11 +35,28 @@ func CmdPayForBlob() *cobra.Command {
return fmt.Errorf("failure to decode hex namespace ID: %w", err)
}

// TODO: allow the user to override the namespace version via a new flag
// See https://github.com/celestiaorg/celestia-app/issues/1528
namespace, err := appns.New(appns.NamespaceVersionZero, append(appns.NamespaceVersionZeroPrefix, namespaceID...))
if err != nil {
return fmt.Errorf("failure to create namespace: %w", err)
nameSpaceFlag, _ := cmd.Flags().GetString("--namespace-version")
amityadav0 marked this conversation as resolved.
Show resolved Hide resolved
var namespace appns.Namespace

if nameSpaceFlag != "" {
// load given namespace version
namespaceflag, err := strconv.Atoi(nameSpaceFlag)
if err != nil {
return fmt.Errorf("failure to convert namespace from string: %w", err)
}
if uint8(namespaceflag) != appns.NamespaceVersionZero {
return fmt.Errorf("unsupported namespace version %v", namespaceflag)
}
namespace, err = appns.New(appns.NamespaceVersionZero, append(appns.NamespaceVersionZeroPrefix, namespaceID...))
if err != nil {
return fmt.Errorf("failure to create namespace: %w", err)
}
} else {
// namespace version should default to the latest supported namespace version.
namespace, err = appns.New(appns.NamespaceVersionZero, append(appns.NamespaceVersionZeroPrefix, namespaceID...))
if err != nil {
return fmt.Errorf("failure to create namespace: %w", err)
}
}

rawblob, err := hex.DecodeString(args[1])
Expand All @@ -57,6 +75,7 @@ func CmdPayForBlob() *cobra.Command {
}

flags.AddTxFlagsToCmd(cmd)
cmd.PersistentFlags().String("namespace-version", "", "User can use this to specify the namespace version when they submit a pay for blob.")
rootulp marked this conversation as resolved.
Show resolved Hide resolved

return cmd
}
Expand Down