Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Aug 3, 2023
1 parent 145ea98 commit 84ede8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
25 changes: 18 additions & 7 deletions cmd/celestia/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ type response struct {
Result interface{} `json:"result"`
}

func init() {
blobCmd.AddCommand(getCmd, getAllCmd, submitCmd, getProofCmd)
}

var blobCmd = &cobra.Command{
Use: "blob [command]",
Short: "Allows to interact with the Blob Service via JSON-RPC",
Args: cobra.NoArgs,
}

var getCmd = &cobra.Command{
Use: "get [params]",
Use: "get [height, namespace, commitment]",
Args: cobra.ExactArgs(3),
Short: "Returns the blob for the given namespace by commitment at a particular height.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -33,7 +37,7 @@ var getCmd = &cobra.Command{
return err
}

num, err := strconv.ParseUint(args[0], 10, 64)
height, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return fmt.Errorf("error parsing a height:%v", err)
}
Expand All @@ -49,7 +53,7 @@ var getCmd = &cobra.Command{
}

var output []byte
blob, err := client.Blob.Get(cmd.Context(), num, namespace, commitment)
blob, err := client.Blob.Get(cmd.Context(), height, namespace, commitment)
if err != nil {
output, err = prepareOutput(err)
if err != nil {
Expand All @@ -68,7 +72,7 @@ var getCmd = &cobra.Command{
}

var getAllCmd = &cobra.Command{
Use: "getAll [params]",
Use: "get-all [height, namespace]",
Args: cobra.ExactArgs(2),
Short: "Returns all blobs for the given namespace at a particular height.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -107,7 +111,7 @@ var getAllCmd = &cobra.Command{
}

var submitCmd = &cobra.Command{
Use: "submit [params]",
Use: "submit [namespace, blobData]",
Args: cobra.ExactArgs(2),
Short: "Submit the blob at the given namespace. Note: only one blob is allowed to submit through the RPC.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -134,7 +138,14 @@ var submitCmd = &cobra.Command{
return err
}
} else {
output, err = prepareOutput(height)
response := struct {
Height uint64 `json:"uint64"`
Commitment blob.Commitment `json:"commitment"`
}{
Height: height,
Commitment: parsedBlob.Commitment,
}
output, err = prepareOutput(response)
if err != nil {
return err
}
Expand All @@ -146,7 +157,7 @@ var submitCmd = &cobra.Command{
}

var getProofCmd = &cobra.Command{
Use: "getProof [params]",
Use: "get-proof [height, namespace, commitment]",
Args: cobra.ExactArgs(3),
Short: "Retrieves the blob in the given namespaces at the given height by commitment and returns its Proof.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
1 change: 0 additions & 1 deletion cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func init() {
false,
"Print JSON-RPC request along with the response",
)
blobCmd.AddCommand(getCmd, getAllCmd, submitCmd, getProofCmd)
rpcCmd.AddCommand(blobCmd)
rootCmd.AddCommand(rpcCmd)
}
Expand Down

0 comments on commit 84ede8e

Please sign in to comment.