* go mod tidy everything.
* Add some third_party proto files that are imported but not included.
* [11859]: Add a new key for the SendEnabled flags and keeper methods for getting, setting, and deleting them.
* [11859]: Remove the send_enabled field from the bank Params proto.
* Revert "Add some third_party proto files that are imported but not included."
This reverts commit 8b7acf89f27825ba25bfef3379fd422a307a5e1b.
* [11859]: Regenerate the bank params stuff from the changed proto.
* [11859]: Add a send_enabled field to the bank genesis proto.
* Revert "[11859]: Remove the send_enabled field from the bank Params proto."
This reverts commit 0bd904c1f6ac0ea2d6e5b7dd43911d596cbf3ac9.
* Revert "[11859]: Regenerate the bank params stuff from the changed proto."
This reverts commit 33d4652696d2c3aefc6937dbf281525c1f86f79e.
* [11859]: Deprecate the bank Params send_enabled field.
* [11859]: Regenerate the bank go code from the updated protos.
* [11859]: Reduce the number of times the store is recreated during IsSendEnabledCoins. Store creation has some overhead.
* [11859]: Add the SendEnabled stuff to the genesis methods. Make a couple TODO notes. Create a way to iterate over the SendEnabled entries and get all of them.
* [11859]: Update the bank sim genesis stuff to create random SendEnabled entries similar to when they were params.
* Remove some of the bank params methods that are no longer meaningful.
* Add a comment about why we're calling a mutation method in a Validate function.
* [11859]: Add some more TODO notes and make the SendEnabled.String() function significantlly simpler.
* [11859]: Get rid of the SendEnabledParams type.
* Fix up a few comments.
* [11859]: Update the bank keeper test due to recent changes.
* [11859]: Tweak the bank Params and SendEnabled String funcs. Params no longer returns {} when there aren't any SendEnabled entries and the default is false. SendEnabled is back to outputting a yaml format.
* [11859]: Fix the params tests and add some new ones to it and key_test.
* [11859]: Create a 1-store method for updating several SendEnabled entries at once.
* [11859]: Create a migration for both the module and genesis state.
* [11859]: Create a new MsgSetSendEnabled for governanance proposals to set SendEnabled.
* [11859]: Add SetAllSendEnabled to the SendKeeper interface.
* [11859]: Add an authority to the bank keeper and create the handler for MsgSetSendEnabled.
* [11859]: Add an rpc endpoint for querying SendEnabled.
* [11859]: Implement the SendEnabled query.
* [11859]: Add a function for decoding a --page-key base64 value so that pagination can work as expected.
* [11859]: Implement a CLI command for querying SendEnabled.
* [11859]: Move the v047 store migration stuff into Migrate3to4 directly to prevent a circular dependency between 047 and the keeper. Not using the keeper for that would be a significant pain in the butt.
* [11869]: Implement the Msg interface for MsgSetSendEnabled.
* [11859]: Fix some unit tests that I broke along the way.
* [11859]: Reorg the funcs added to the SendKeeper interface.
* [11859]: Fix the return values of a couple of the MsgSetSendEnabled LegacyMsg funcs.
* [11859]: Tweak MigrateSendEnabled to add stuff to the existing slice (if there's anything to add). And then use that in the MigrateGenState function.
* [11859]: Don't set the Pagination field when looking up specific entries.
* [11859]: Put validateSendEnabledParams back to the way it was to allow reading the old Params without error.
* [11859]: Write up a bunch of unit tests.
* [11859]: Update the MsgSetSendEnabled.ValidateBasic() function with some extra failure points. Write up some tests.
* Update a test I fixed then broke.
* [11859]: Have the run-tests make target exit with a non-zero status if any of the tests fail.
* [11859]: Add changelog entries.
* [11859]: Add a missing func comment.
* [11859]: Only do a couple assertions if the elements exist to do so.
* [11859]: Add some more missing function comments.
* [11859]: Update the bank spec documentation.
* [11859]: Change name of WithPageKeyDecoded to FlagSetWithPageKeyDecoded, have it return an error and make MustFlagSetWithPageKeyDecoded for the one-liner.
* [11859]: Update the documentation on the SendEnabled query.
* [11859]: Add final newline to query.proto.
* [11859]: Remove the SetSendEnabled msg and endpoint.
* [11859]: Use nil instead of an empty slice of SendEnabled for defaults and where called for.
* [11859]: Update SetParams to migrate entries too.
* [11859]: Remove the spec doc info about the MsgSetSendEnabled that's part of another PR.
* [11859]: Update the changelog.
* Revert "[11859]: Update the changelog."
This reverts commit 85052b8579ec6bfac3411970a1597363329d6d66.
* [11859]: Rename the QuerySendEnabled message to QuerySendEnabledRequest to match the other messages in that proto.
* [11859]: Remove the authority field that is only needed for governance stuff (in the other PR).
* [11859]: Add a version to the deprecation message.
* [11859]: Update the comment on the now-deprecated SendEnabled params proto field to reference 0.46 instead of 0.47.
* Add some spacing to GetCmdQuerySendEnabled -> RunE.
* [11859]: Create banktypes.GenesisState.GetAllSendEnabled() to house the combination logic of the SendEnabled field and Params.SendEnabled. Have MigrateSendEnabled() use that. Remove some calls to MigrateSendEnabled and use GetAllSendEnabled in those cases.
* [11859]: Update Bank's ConsensusVersion to 4.
* [11859]: Add 'Since' comments to the new proto stuff.
* [11859]: Fix a unit test that broke because it assumed the bank module's version was 3.
* [11859]: Remove an empty line.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
* [11859]: Remove movement of SendEnabled from the `ExportGenesis` function too.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
* [11859]: Add a function for getting an entry so that users can differentiate between a missing entry and one that's using the default value.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
272 lines
6.7 KiB
Go
272 lines
6.7 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
)
|
|
|
|
const (
|
|
FlagDenom = "denom"
|
|
)
|
|
|
|
// GetQueryCmd returns the parent command for all x/bank CLi query commands. The
|
|
// provided clientCtx should have, at a minimum, a verifier, Tendermint RPC client,
|
|
// and marshaler set.
|
|
func GetQueryCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: "Querying commands for the bank module",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
cmd.AddCommand(
|
|
GetBalancesCmd(),
|
|
GetCmdQueryTotalSupply(),
|
|
GetCmdDenomsMetadata(),
|
|
GetCmdQuerySendEnabled(),
|
|
)
|
|
|
|
return cmd
|
|
}
|
|
|
|
func GetBalancesCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "balances [address]",
|
|
Short: "Query for account balances by address",
|
|
Long: strings.TrimSpace(
|
|
fmt.Sprintf(`Query the total balance of an account or of a specific denomination.
|
|
|
|
Example:
|
|
$ %s query %s balances [address]
|
|
$ %s query %s balances [address] --denom=[denom]
|
|
`,
|
|
version.AppName, types.ModuleName, version.AppName, types.ModuleName,
|
|
),
|
|
),
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
denom, err := cmd.Flags().GetString(FlagDenom)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
|
|
addr, err := sdk.AccAddressFromBech32(args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
ctx := cmd.Context()
|
|
if denom == "" {
|
|
params := types.NewQueryAllBalancesRequest(addr, pageReq)
|
|
res, err := queryClient.AllBalances(ctx, params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return clientCtx.PrintProto(res)
|
|
}
|
|
|
|
params := types.NewQueryBalanceRequest(addr, denom)
|
|
res, err := queryClient.Balance(ctx, params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res.Balance)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for")
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
flags.AddPaginationFlagsToCmd(cmd, "all balances")
|
|
|
|
return cmd
|
|
}
|
|
|
|
// GetCmdDenomsMetadata defines the cobra command to query client denomination metadata.
|
|
func GetCmdDenomsMetadata() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "denom-metadata",
|
|
Short: "Query the client metadata for coin denominations",
|
|
Long: strings.TrimSpace(
|
|
fmt.Sprintf(`Query the client metadata for all the registered coin denominations
|
|
|
|
Example:
|
|
To query for the client metadata of all coin denominations use:
|
|
$ %s query %s denom-metadata
|
|
|
|
To query for the client metadata of a specific coin denomination use:
|
|
$ %s query %s denom-metadata --denom=[denom]
|
|
`,
|
|
version.AppName, types.ModuleName, version.AppName, types.ModuleName,
|
|
),
|
|
),
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
denom, err := cmd.Flags().GetString(FlagDenom)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
|
|
if denom == "" {
|
|
res, err := queryClient.DenomsMetadata(cmd.Context(), &types.QueryDenomsMetadataRequest{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
}
|
|
|
|
res, err := queryClient.DenomMetadata(cmd.Context(), &types.QueryDenomMetadataRequest{Denom: denom})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().String(FlagDenom, "", "The specific denomination to query client metadata for")
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|
|
|
|
func GetCmdQueryTotalSupply() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "total",
|
|
Short: "Query the total supply of coins of the chain",
|
|
Args: cobra.NoArgs,
|
|
Long: strings.TrimSpace(
|
|
fmt.Sprintf(`Query total supply of coins that are held by accounts in the chain.
|
|
|
|
Example:
|
|
$ %s query %s total
|
|
|
|
To query for the total supply of a specific coin denomination use:
|
|
$ %s query %s total --denom=[denom]
|
|
`,
|
|
version.AppName, types.ModuleName, version.AppName, types.ModuleName,
|
|
),
|
|
),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
denom, err := cmd.Flags().GetString(FlagDenom)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
ctx := cmd.Context()
|
|
|
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if denom == "" {
|
|
res, err := queryClient.TotalSupply(ctx, &types.QueryTotalSupplyRequest{Pagination: pageReq})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
}
|
|
|
|
res, err := queryClient.SupplyOf(ctx, &types.QuerySupplyOfRequest{Denom: denom})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(&res.Amount)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for")
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
flags.AddPaginationFlagsToCmd(cmd, "all supply totals")
|
|
|
|
return cmd
|
|
}
|
|
|
|
func GetCmdQuerySendEnabled() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "send-enabled [denom1 ...]",
|
|
Short: "Query for send enabled entries",
|
|
Long: strings.TrimSpace(`Query for send enabled entries that have been specifically set.
|
|
|
|
To look up one or more specific denoms, supply them as arguments to this command.
|
|
To look up all denoms, do not provide any arguemnts.
|
|
`,
|
|
),
|
|
Example: strings.TrimSpace(
|
|
fmt.Sprintf(`Getting one specific entry:
|
|
$ %[1]s query %[2]s send-enabled foocoin
|
|
|
|
Getting two specific entries:
|
|
$ %[1]s query %[2]s send-enabled foocoin barcoin
|
|
|
|
Getting all entries:
|
|
$ %[1]s query %[2]s send-enabled
|
|
`,
|
|
version.AppName, types.ModuleName,
|
|
),
|
|
),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
reqPag, err := client.ReadPageRequest(client.MustFlagSetWithPageKeyDecoded(cmd.Flags()))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
req := &types.QuerySendEnabledRequest{
|
|
Denoms: args,
|
|
Pagination: reqPag,
|
|
}
|
|
|
|
res, err := queryClient.SendEnabled(cmd.Context(), req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
},
|
|
}
|
|
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
flags.AddPaginationFlagsToCmd(cmd, "send enabled entries")
|
|
|
|
return cmd
|
|
}
|