@agoric/cosmos 0.34.2-dev-d61be8d.0 → 0.34.2-dev-624ac4a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- d61be8d
1
+ 624ac4a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-d61be8d.0+d61be8d",
3
+ "version": "0.34.2-dev-624ac4a.0+624ac4a",
4
4
  "description": "Connect JS to the Cosmos blockchain SDK",
5
5
  "parsers": {
6
6
  "js": "mjs"
@@ -38,5 +38,5 @@
38
38
  "typeCoverage": {
39
39
  "atLeast": 0
40
40
  },
41
- "gitHead": "d61be8d7fbda7dd3846cba38f8829e36bfae92a4"
41
+ "gitHead": "624ac4ada84ea24a4d30428bde7a0bfa1d7b12bb"
42
42
  }
@@ -37,22 +37,20 @@ This is used by the SwingSet "bridge".
37
37
 
38
38
  ## CLI
39
39
 
40
- A blockchain node may be interrogated by RPC using `agd [--node $url] query vstorage $command` via [client/cli](./client/cli/query.go).
41
- * `children [--height $blockHeight] [-o {text,json}] [$path]`
42
- * `data [--height $blockHeight] [-o {text,json}] $path`
40
+ A blockchain node may be interrogated by RPC using `agd [--node $url] query vstorage path` via [client/cli](./client/cli/query.go). (See command help for options and variants `data` and `children`.)
43
41
 
44
42
  Examples:
45
43
  ```sh
46
- $ agd --node https://main.rpc.agoric.net:443/ query vstorage children published.reserve
44
+ $ agd --node https://main.rpc.agoric.net:443/ query vstorage path published.reserve.
47
45
  children:
48
46
  - governance
49
47
  - metrics
50
48
  pagination: null
51
49
 
52
- $ agd --node https://main.rpc.agoric.net:443/ query vstorage children -o json published.reserve
50
+ $ agd --node https://main.rpc.agoric.net:443/ query vstorage path -o json published.reserve.
53
51
  {"children":["governance","metrics"],"pagination":null}
54
52
 
55
- $ agd --node https://main.rpc.agoric.net:443/ query vstorage data published.reserve.metrics
53
+ $ agd --node https://main.rpc.agoric.net:443/ query vstorage path published.reserve.metrics
56
54
  value: '{"blockHeight":"11030240","values":["{\"body\":\"#{\\\"allocations\\\":{\\\"Fee\\\":{\\\"brand\\\":\\\"$0.Alleged:
57
55
  IST brand\\\",\\\"value\\\":\\\"+20053582387\\\"}},\\\"shortfallBalance\\\":{\\\"brand\\\":\\\"$0\\\",\\\"value\\\":\\\"+0\\\"},\\\"totalFeeBurned\\\":{\\\"brand\\\":\\\"$0\\\",\\\"value\\\":\\\"+0\\\"},\\\"totalFeeMinted\\\":{\\\"brand\\\":\\\"$0\\\",\\\"value\\\":\\\"+0\\\"}}\",\"slots\":[\"board0257\"]}"]}'
58
56
  ```
@@ -4,6 +4,7 @@ import (
4
4
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
5
5
  "github.com/cosmos/cosmos-sdk/client"
6
6
  "github.com/cosmos/cosmos-sdk/client/flags"
7
+ "github.com/gogo/protobuf/proto"
7
8
  "github.com/spf13/cobra"
8
9
  )
9
10
 
@@ -18,6 +19,7 @@ func GetQueryCmd(storeKey string) *cobra.Command {
18
19
  swingsetQueryCmd.AddCommand(
19
20
  GetCmdGetData(storeKey),
20
21
  GetCmdGetChildren(storeKey),
22
+ GetCmdGetPath(storeKey),
21
23
  )
22
24
 
23
25
  return swingsetQueryCmd
@@ -86,3 +88,44 @@ func GetCmdGetChildren(queryRoute string) *cobra.Command {
86
88
  flags.AddQueryFlagsToCmd(cmd)
87
89
  return cmd
88
90
  }
91
+
92
+ // GetCmdGetPath queries vstorage data or children, depending on the path
93
+ func GetCmdGetPath(queryRoute string) *cobra.Command {
94
+ cmd := &cobra.Command{
95
+ Use: "path [path]",
96
+ Short: "get vstorage data, or children if path ends with '.'",
97
+ Args: cobra.ExactArgs(1),
98
+ RunE: func(cmd *cobra.Command, args []string) error {
99
+ clientCtx, err := client.GetClientQueryContext(cmd)
100
+ if err != nil {
101
+ return err
102
+ }
103
+ queryClient := types.NewQueryClient(clientCtx)
104
+
105
+ path := args[0]
106
+
107
+ var res proto.Message
108
+
109
+ // if path ends with '.' then remove it and query children
110
+ if path[len(path)-1] == '.' {
111
+ path = path[:len(path)-1]
112
+ res, err = queryClient.Children(cmd.Context(), &types.QueryChildrenRequest{
113
+ Path: path,
114
+ })
115
+ } else {
116
+ res, err = queryClient.Data(cmd.Context(), &types.QueryDataRequest{
117
+ Path: path,
118
+ })
119
+ }
120
+
121
+ if err != nil {
122
+ return err
123
+ }
124
+
125
+ return clientCtx.PrintProto(res)
126
+ },
127
+ }
128
+
129
+ flags.AddQueryFlagsToCmd(cmd)
130
+ return cmd
131
+ }