Skip to content

Commit

Permalink
feat(vbank): add governance and query methods
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 13, 2021
1 parent 968b78e commit c80912e
Show file tree
Hide file tree
Showing 18 changed files with 1,837 additions and 70 deletions.
32 changes: 31 additions & 1 deletion golang/cosmos/x/vbank/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ entirely at the ERTP level.
## Parameters

- `feeCollectorName`: the module which handles fee distribution to stakers.
- `feeEpochDurationBlocks`: the duration (in blocks) over which fees should be given to the fee collector.
- `fee_epoch_duration_blocks`: the duration (in blocks) over which fees should be given to the fee collector.

## State

Expand Down Expand Up @@ -50,3 +50,33 @@ Test the following transfer scenarios:

The initial BLD and RUN purses are bank purses, but newly-created purses will
not be bank purses by default.

## Governance

To use Cosmos governance to change the `fee_epoch_duration_blocks` value:

```sh
$ ag-cosmos-helper query vbank params
{"fee_epoch_duration_blocks":"720"}
$ cat <<\EOF > epoch-duration-proposal.json
{
"title": "Vbank param-change test",
"description": "Decrease the fee disbursal epoch parameter to 30 blocks.",
"changes": [
{
"subspace": "vbank",
"key": "feeepochdurationblocks",
"value": "30"
}
],
"deposit": "1000000ubld"
}
EOF
$ ag-cosmos-helper tx gov submit-proposal param-change epochdur.json --from=mykey --chain-id=agoric
# Then vote on the proposal.
$ ag-cosmos-helper tx vote ...
# After passing,
$ ag-cosmos-helper query vbank params
{"fee_epoch_duration_blocks":"30"}
$
```
79 changes: 79 additions & 0 deletions golang/cosmos/x/vbank/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package cli

import (
"github.com/spf13/cobra"

"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd() *cobra.Command {
vbankQueryCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Querying commands for the vbank module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

vbankQueryCmd.AddCommand(
GetCmdQueryParams(),
GetCmdQueryState(),
)

return vbankQueryCmd
}

// GetCmdQueryParams implements the query params command.
func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Args: cobra.NoArgs,
Short: "Query vbank params",
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}

// GetCmdQueryState implements the query state command.
func GetCmdQueryState() *cobra.Command {
cmd := &cobra.Command{
Use: "state",
Args: cobra.NoArgs,
Short: "Query vbank state",
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.State(cmd.Context(), &types.QueryStateRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(&res.State)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}
Loading

0 comments on commit c80912e

Please sign in to comment.