Skip to content

Commit

Permalink
feat: agd query vstorage trailing slash for children
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 8, 2023
1 parent bc4a41c commit 19fb806
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions golang/cosmos/x/vstorage/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/gogo/protobuf/proto"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -38,9 +39,20 @@ func GetCmdGetData(queryRoute string) *cobra.Command {

path := args[0]

res, err := queryClient.Data(cmd.Context(), &types.QueryDataRequest{
Path: path,
})
var res proto.Message

// if path ends with '/' then remove it
if path[len(path)-1] == '/' {
path = path[:len(path)-1]
res, err = queryClient.Children(cmd.Context(), &types.QueryChildrenRequest{
Path: path,
})
} else {
res, err = queryClient.Data(cmd.Context(), &types.QueryDataRequest{
Path: path,
})
}

if err != nil {
return err
}
Expand Down

0 comments on commit 19fb806

Please sign in to comment.