JSON Codec Updates (#6444)
* Initial commit * More updates * Fix tests * CLI test updates * Updates * Updates
This commit is contained in:
parent
6a05b83069
commit
35312d098e
@ -370,10 +370,10 @@ func (ctx Context) PrintOutput(toPrint interface{}) error {
|
||||
out, err = yaml.Marshal(&toPrint)
|
||||
|
||||
case "json":
|
||||
out, err = ctx.JSONMarshaler.MarshalJSON(toPrint)
|
||||
|
||||
if ctx.Indent {
|
||||
out, err = ctx.Codec.MarshalJSONIndent(toPrint, "", " ")
|
||||
} else {
|
||||
out, err = ctx.Codec.MarshalJSON(toPrint)
|
||||
out, err = codec.MarshalIndentFromJSON(out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ $ <appcli> tx broadcast ./mytxn.json
|
||||
`),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
if clientCtx.Offline {
|
||||
return errors.New("cannot broadcast tx during offline mode")
|
||||
|
||||
@ -29,9 +29,9 @@ func GetDecodeCommand(codec *codec.Codec) *cobra.Command {
|
||||
return flags.PostCommands(cmd)[0]
|
||||
}
|
||||
|
||||
func runDecodeTxString(codec *codec.Codec) func(cmd *cobra.Command, args []string) (err error) {
|
||||
func runDecodeTxString(cdc *codec.Codec) func(cmd *cobra.Command, args []string) (err error) {
|
||||
return func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.NewContext().WithCodec(codec).WithOutput(cmd.OutOrStdout())
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithOutput(cmd.OutOrStdout()).WithJSONMarshaler(cdc)
|
||||
var txBytes []byte
|
||||
|
||||
if viper.GetBool(flagHex) {
|
||||
|
||||
@ -29,7 +29,7 @@ Read a transaction from <file>, serialize it to the Amino wire protocol, and out
|
||||
If you supply a dash (-) argument in place of an input filename, the command reads from standard input.`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
stdTx, err := authclient.ReadStdTxFromFile(clientCtx.Codec, args[0])
|
||||
if err != nil {
|
||||
|
||||
@ -51,7 +51,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, clientCtx client.Context,
|
||||
return
|
||||
}
|
||||
|
||||
output, err := clientCtx.Codec.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo))
|
||||
output, err := clientCtx.JSONMarshaler.MarshalJSON(types.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo))
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ func BroadcastTxRequest(clientCtx client.Context) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
if err := clientCtx.Codec.UnmarshalJSON(body, &req); rest.CheckBadRequestError(w, err) {
|
||||
if err := clientCtx.JSONMarshaler.UnmarshalJSON(body, &req); rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func DecodeTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
err = clientCtx.Codec.UnmarshalJSON(body, &req)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(body, &req)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ func EncodeTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
err = clientCtx.Codec.UnmarshalJSON(body, &req)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(body, &req)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -85,14 +85,12 @@ func CompleteAndBroadcastTxCLI(txBldr authtypes.TxBuilder, clientCtx client.Cont
|
||||
return err
|
||||
}
|
||||
|
||||
var json []byte
|
||||
json := clientCtx.JSONMarshaler.MustMarshalJSON(stdSignMsg)
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
json, err = clientCtx.Codec.MarshalJSONIndent(stdSignMsg, "", " ")
|
||||
json, err = codec.MarshalIndentFromJSON(json)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
json = clientCtx.Codec.MustMarshalJSON(stdSignMsg)
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(os.Stderr, "%s\n\n", json)
|
||||
@ -161,16 +159,18 @@ func PrintUnsignedStdTx(txBldr authtypes.TxBuilder, clientCtx client.Context, ms
|
||||
return err
|
||||
}
|
||||
|
||||
var json []byte
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
json, err = clientCtx.Codec.MarshalJSONIndent(stdTx, "", " ")
|
||||
} else {
|
||||
json, err = clientCtx.Codec.MarshalJSON(stdTx)
|
||||
}
|
||||
json, err := clientCtx.JSONMarshaler.MarshalJSON(stdTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
json, err = codec.MarshalIndentFromJSON(json)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(clientCtx.Output, "%s\n", json)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ func GetBalancesCmd(cdc *codec.Codec) *cobra.Command {
|
||||
Short: "Query for account balances by address",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
addr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -135,7 +135,7 @@ $ %s query %s total stake
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
if len(args) == 0 {
|
||||
return queryTotalSupply(clientCtx, cdc)
|
||||
|
||||
@ -85,7 +85,7 @@ func totalSupplyHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQueryTotalSupplyParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
@ -112,7 +112,7 @@ func supplyOfHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQuerySupplyOfParams(denom)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
|
||||
@ -45,7 +45,7 @@ func GetCmdQueryParams(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Query distribution params",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
@ -80,7 +80,7 @@ $ %s query distribution validator-outstanding-rewards cosmosvaloper1lwjmdnks33xw
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -127,7 +127,7 @@ $ %s query distribution commission cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9l
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
validatorAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -162,7 +162,7 @@ $ %s query distribution slashes cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmq
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
validatorAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -216,7 +216,7 @@ $ %s query distribution rewards cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// query for rewards from a particular delegation
|
||||
if len(args) == 2 {
|
||||
@ -277,7 +277,7 @@ $ %s query distribution community-pool
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
res, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/community_pool", queryRoute), nil)
|
||||
if err != nil {
|
||||
|
||||
@ -22,7 +22,7 @@ func QueryDelegationRewards(clientCtx client.Context, queryRoute, delAddr, valAd
|
||||
}
|
||||
|
||||
params := types.NewQueryDelegationRewardsParams(delegatorAddr, validatorAddr)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal params: %w", err)
|
||||
}
|
||||
@ -36,7 +36,7 @@ func QueryDelegationRewards(clientCtx client.Context, queryRoute, delAddr, valAd
|
||||
func QueryDelegatorValidators(clientCtx client.Context, queryRoute string, delegatorAddr sdk.AccAddress) ([]byte, error) {
|
||||
res, _, err := clientCtx.QueryWithData(
|
||||
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorValidators),
|
||||
clientCtx.Codec.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)),
|
||||
clientCtx.JSONMarshaler.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)),
|
||||
)
|
||||
return res, err
|
||||
}
|
||||
@ -45,7 +45,7 @@ func QueryDelegatorValidators(clientCtx client.Context, queryRoute string, deleg
|
||||
func QueryValidatorCommission(clientCtx client.Context, queryRoute string, validatorAddr sdk.ValAddress) ([]byte, error) {
|
||||
res, _, err := clientCtx.QueryWithData(
|
||||
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorCommission),
|
||||
clientCtx.Codec.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)),
|
||||
clientCtx.JSONMarshaler.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)),
|
||||
)
|
||||
return res, err
|
||||
}
|
||||
@ -61,7 +61,7 @@ func WithdrawAllDelegatorRewards(clientCtx client.Context, queryRoute string, de
|
||||
}
|
||||
|
||||
var validators []sdk.ValAddress
|
||||
if err := clientCtx.Codec.UnmarshalJSON(bz, &validators); err != nil {
|
||||
if err := clientCtx.JSONMarshaler.UnmarshalJSON(bz, &validators); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@ -8,17 +8,18 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
func TestQueryDelegationRewardsAddrValidation(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
viper.Set(flags.FlagOffline, true)
|
||||
ctx := client.NewContext().WithCodec(cdc)
|
||||
ctx := client.NewContext().WithJSONMarshaler(types.ModuleCdc)
|
||||
|
||||
type args struct {
|
||||
delAddr string
|
||||
valAddr string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
@ -30,6 +31,7 @@ func TestQueryDelegationRewardsAddrValidation(t *testing.T) {
|
||||
{"invalid validator address", args{"cosmos1zxcsu7l5qxs53lvp0fqgd09a9r2g6kqrk2cdpa", "invalid"}, nil, true},
|
||||
{"empty validator address", args{"cosmos1zxcsu7l5qxs53lvp0fqgd09a9r2g6kqrk2cdpa", ""}, nil, true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
@ -79,7 +79,7 @@ func delegatorRewardsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQueryDelegatorParams(delegatorAddr)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal params: %s", err))
|
||||
return
|
||||
@ -131,7 +131,7 @@ func delegatorWithdrawalAddrHandlerFn(clientCtx client.Context) http.HandlerFunc
|
||||
return
|
||||
}
|
||||
|
||||
bz := clientCtx.Codec.MustMarshalJSON(types.NewQueryDelegatorWithdrawAddrParams(delegatorAddr))
|
||||
bz := clientCtx.JSONMarshaler.MustMarshalJSON(types.NewQueryDelegatorWithdrawAddrParams(delegatorAddr))
|
||||
res, height, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/withdraw_addr", types.QuerierRoute), bz)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
@ -180,7 +180,7 @@ func validatorInfoHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var commission types.ValidatorAccumulatedCommission
|
||||
if rest.CheckInternalServerError(w, clientCtx.Codec.UnmarshalJSON(bz, &commission)) {
|
||||
if rest.CheckInternalServerError(w, clientCtx.JSONMarshaler.UnmarshalJSON(bz, &commission)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -192,11 +192,11 @@ func validatorInfoHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var rewards sdk.DecCoins
|
||||
if rest.CheckInternalServerError(w, clientCtx.Codec.UnmarshalJSON(bz, &rewards)) {
|
||||
if rest.CheckInternalServerError(w, clientCtx.JSONMarshaler.UnmarshalJSON(bz, &rewards)) {
|
||||
return
|
||||
}
|
||||
|
||||
bz, err = clientCtx.Codec.MarshalJSON(NewValidatorDistInfo(delAddr, rewards, commission))
|
||||
bz, err = clientCtx.JSONMarshaler.MarshalJSON(NewValidatorDistInfo(delAddr, rewards, commission))
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -263,7 +263,7 @@ func communityPoolHandler(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var result sdk.DecCoins
|
||||
if rest.CheckInternalServerError(w, clientCtx.Codec.UnmarshalJSON(res, &result)) {
|
||||
if rest.CheckInternalServerError(w, clientCtx.JSONMarshaler.UnmarshalJSON(res, &result)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ func outstandingRewardsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
bin := clientCtx.Codec.MustMarshalJSON(types.NewQueryValidatorOutstandingRewardsParams(validatorAddr))
|
||||
bin := clientCtx.JSONMarshaler.MustMarshalJSON(types.NewQueryValidatorOutstandingRewardsParams(validatorAddr))
|
||||
res, height, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/validator_outstanding_rewards", types.QuerierRoute), bin)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
|
||||
@ -52,7 +52,7 @@ func QueryEvidenceCmd(cdc *codec.Codec) func(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
if hash := args[0]; hash != "" {
|
||||
return queryEvidence(cdc, clientCtx, hash)
|
||||
|
||||
@ -40,7 +40,7 @@ func queryEvidenceHandler(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQueryEvidenceParams(evidenceHash)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
@ -70,7 +70,7 @@ func queryAllEvidenceHandler(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQueryAllEvidenceParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
|
||||
@ -121,7 +121,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
|
||||
}
|
||||
|
||||
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
|
||||
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
|
||||
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// Set the generate-only flag here after the CLI context has
|
||||
// been created. This allows the from name/key to be correctly populated.
|
||||
|
||||
@ -34,7 +34,7 @@ func QueryGenesisTxs(clientCtx client.Context, w http.ResponseWriter) {
|
||||
genState := types.GetGenesisStateFromAppState(clientCtx.Codec, appState)
|
||||
genTxs := make([]sdk.Tx, len(genState.GenTxs))
|
||||
for i, tx := range genState.GenTxs {
|
||||
err := clientCtx.Codec.UnmarshalJSON(tx, &genTxs[i])
|
||||
err := clientCtx.JSONMarshaler.UnmarshalJSON(tx, &genTxs[i])
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(
|
||||
w, http.StatusInternalServerError,
|
||||
|
||||
@ -60,7 +60,7 @@ $ %s query gov proposal 1
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -140,7 +140,7 @@ $ %s query gov proposals --page=2 --limit=100
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
res, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/proposals", queryRoute), bz)
|
||||
if err != nil {
|
||||
@ -187,7 +187,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -257,7 +257,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -321,7 +321,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -384,7 +384,7 @@ $ %s query gov deposits 1
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -442,7 +442,7 @@ $ %s query gov tally 1
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposal id is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
@ -492,7 +492,7 @@ $ %s query gov params
|
||||
),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
tp, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/params/tallying", queryRoute), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -536,7 +536,7 @@ $ %s query gov param deposit
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// Query store
|
||||
res, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/params/%s", queryRoute, args[0]), nil)
|
||||
@ -582,7 +582,7 @@ $ %s query gov proposer 1
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// validate that the proposalID is a uint
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
|
||||
@ -69,7 +69,7 @@ func queryProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryProposalParams(proposalID)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -101,7 +101,7 @@ func queryDepositsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryProposalParams(proposalID)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -112,7 +112,7 @@ func queryDepositsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var proposal types.Proposal
|
||||
if rest.CheckInternalServerError(w, clientCtx.Codec.UnmarshalJSON(res, &proposal)) {
|
||||
if rest.CheckInternalServerError(w, clientCtx.JSONMarshaler.UnmarshalJSON(res, &proposal)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ func queryDepositHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryDepositParams(proposalID, depositorAddr)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -203,7 +203,7 @@ func queryDepositHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var deposit types.Deposit
|
||||
if rest.CheckBadRequestError(w, clientCtx.Codec.UnmarshalJSON(res, &deposit)) {
|
||||
if rest.CheckBadRequestError(w, clientCtx.JSONMarshaler.UnmarshalJSON(res, &deposit)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ func queryDepositHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
// which case the deposit would be removed from state and should be queried
|
||||
// for directly via a txs query.
|
||||
if deposit.Empty() {
|
||||
bz, err := clientCtx.Codec.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -269,7 +269,7 @@ func queryVoteHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryVoteParams(proposalID, voterAddr)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -280,7 +280,7 @@ func queryVoteHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var vote types.Vote
|
||||
if rest.CheckBadRequestError(w, clientCtx.Codec.UnmarshalJSON(res, &vote)) {
|
||||
if rest.CheckBadRequestError(w, clientCtx.JSONMarshaler.UnmarshalJSON(res, &vote)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ func queryVoteHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
// which case the vote would be removed from state and should be queried for
|
||||
// directly via a txs query.
|
||||
if vote.Empty() {
|
||||
bz, err := clientCtx.Codec.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -339,7 +339,7 @@ func queryVotesOnProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryProposalVotesParams(proposalID, page, limit)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -350,7 +350,7 @@ func queryVotesOnProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
var proposal types.Proposal
|
||||
if rest.CheckInternalServerError(w, clientCtx.Codec.UnmarshalJSON(res, &proposal)) {
|
||||
if rest.CheckInternalServerError(w, clientCtx.JSONMarshaler.UnmarshalJSON(res, &proposal)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ func queryProposalsWithParameterFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQueryProposalsParams(page, limit, proposalStatus, voterAddr, depositorAddr)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -452,7 +452,7 @@ func queryTallyOnProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryProposalParams(proposalID)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -65,11 +66,16 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal
|
||||
}
|
||||
}
|
||||
|
||||
if clientCtx.Indent {
|
||||
return clientCtx.Codec.MarshalJSONIndent(deposits, "", " ")
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(deposits)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return clientCtx.Codec.MarshalJSON(deposits)
|
||||
if clientCtx.Indent {
|
||||
return codec.MarshalIndentFromJSON(bz)
|
||||
}
|
||||
|
||||
return bz, nil
|
||||
}
|
||||
|
||||
// QueryVotesByTxQuery will query for votes via a direct txs tags query. It
|
||||
@ -115,10 +121,17 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot
|
||||
} else {
|
||||
votes = votes[start:end]
|
||||
}
|
||||
if clientCtx.Indent {
|
||||
return clientCtx.Codec.MarshalJSONIndent(votes, "", " ")
|
||||
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(votes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clientCtx.Codec.MarshalJSON(votes)
|
||||
|
||||
if clientCtx.Indent {
|
||||
return codec.MarshalIndentFromJSON(bz)
|
||||
}
|
||||
|
||||
return bz, nil
|
||||
}
|
||||
|
||||
// QueryVoteByTxQuery will query for a single vote via a direct txs tags query.
|
||||
@ -147,11 +160,16 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams)
|
||||
Option: voteMsg.Option,
|
||||
}
|
||||
|
||||
if clientCtx.Indent {
|
||||
return clientCtx.Codec.MarshalJSONIndent(vote, "", " ")
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(vote)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return clientCtx.Codec.MarshalJSON(vote)
|
||||
if clientCtx.Indent {
|
||||
return codec.MarshalIndentFromJSON(bz)
|
||||
}
|
||||
|
||||
return bz, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,11 +205,16 @@ func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositPa
|
||||
Amount: depMsg.Amount,
|
||||
}
|
||||
|
||||
if clientCtx.Indent {
|
||||
return clientCtx.Codec.MarshalJSONIndent(deposit, "", " ")
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(deposit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return clientCtx.Codec.MarshalJSON(deposit)
|
||||
if clientCtx.Indent {
|
||||
return codec.MarshalIndentFromJSON(bz)
|
||||
}
|
||||
|
||||
return bz, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,7 +253,7 @@ func QueryProposerByTxQuery(clientCtx client.Context, proposalID uint64) (Propos
|
||||
// QueryProposalByID takes a proposalID and returns a proposal
|
||||
func QueryProposalByID(proposalID uint64, clientCtx client.Context, queryRoute string) ([]byte, error) {
|
||||
params := types.NewQueryProposalParams(proposalID)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -129,25 +129,33 @@ func TestGetPaginatedVotes(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
var (
|
||||
marshalled = make([]tmtypes.Tx, len(tc.txs))
|
||||
cdc = newTestCodec()
|
||||
)
|
||||
|
||||
for i := range tc.txs {
|
||||
tx, err := cdc.MarshalBinaryBare(&tc.txs[i])
|
||||
require.NoError(t, err)
|
||||
marshalled[i] = tx
|
||||
}
|
||||
|
||||
cli := TxSearchMock{txs: marshalled}
|
||||
clientCtx := client.Context{}.WithCodec(cdc).WithTrustNode(true).WithClient(cli)
|
||||
clientCtx := client.Context{}.
|
||||
WithJSONMarshaler(cdc).
|
||||
WithCodec(cdc).
|
||||
WithTrustNode(true).
|
||||
WithClient(cli)
|
||||
|
||||
params := types.NewQueryProposalVotesParams(0, tc.page, tc.limit)
|
||||
votesData, err := QueryVotesByTxQuery(clientCtx, params)
|
||||
require.NoError(t, err)
|
||||
votes := []types.Vote{}
|
||||
require.NoError(t, clientCtx.Codec.UnmarshalJSON(votesData, &votes))
|
||||
require.NoError(t, clientCtx.JSONMarshaler.UnmarshalJSON(votesData, &votes))
|
||||
require.Equal(t, len(tc.votes), len(votes))
|
||||
for i := range votes {
|
||||
require.Equal(t, tc.votes[i], votes[i])
|
||||
|
||||
@ -145,7 +145,7 @@ func queryHeaderHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
res := clientCtx.Codec.MustMarshalJSON(header)
|
||||
res := clientCtx.JSONMarshaler.MustMarshalJSON(header)
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, clientCtx, res)
|
||||
}
|
||||
@ -166,7 +166,7 @@ func queryNodeConsensusStateHandlerFn(clientCtx client.Context) http.HandlerFunc
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
res := clientCtx.Codec.MustMarshalJSON(state)
|
||||
res := clientCtx.JSONMarshaler.MustMarshalJSON(state)
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, clientCtx, res)
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ import (
|
||||
// any merkle proof.
|
||||
func QueryAllClientStates(clientCtx client.Context, page, limit int) ([]exported.ClientState, int64, error) {
|
||||
params := types.NewQueryAllClientsParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
@ -30,7 +30,7 @@ func QueryAllClientStates(clientCtx client.Context, page, limit int) ([]exported
|
||||
}
|
||||
|
||||
var clients []exported.ClientState
|
||||
err = clientCtx.Codec.UnmarshalJSON(res, &clients)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &clients)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal light clients: %w", err)
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
// any merkle proof.
|
||||
func QueryAllConnections(clientCtx client.Context, page, limit int) ([]types.ConnectionEnd, int64, error) {
|
||||
params := types.NewQueryAllConnectionsParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
@ -31,7 +31,7 @@ func QueryAllConnections(clientCtx client.Context, page, limit int) ([]types.Con
|
||||
}
|
||||
|
||||
var connections []types.ConnectionEnd
|
||||
err = clientCtx.Codec.UnmarshalJSON(res, &connections)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connections)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal connections: %w", err)
|
||||
}
|
||||
@ -68,7 +68,7 @@ func QueryConnection(
|
||||
// _does not_ return any merkle proof.
|
||||
func QueryAllClientConnectionPaths(clientCtx client.Context, page, limit int) ([]types.ConnectionPaths, int64, error) {
|
||||
params := types.NewQueryAllConnectionsParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
@ -80,7 +80,7 @@ func QueryAllClientConnectionPaths(clientCtx client.Context, page, limit int) ([
|
||||
}
|
||||
|
||||
var connectionPaths []types.ConnectionPaths
|
||||
err = clientCtx.Codec.UnmarshalJSON(res, &connectionPaths)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connectionPaths)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal client connection paths: %w", err)
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func QueryChannel(
|
||||
// a Channel.
|
||||
func QueryChannelClientState(clientCtx client.Context, portID, channelID string) (clientexported.ClientState, int64, error) {
|
||||
params := types.NewQueryChannelClientStateParams(portID, channelID)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
@ -88,7 +88,7 @@ func QueryChannelClientState(clientCtx client.Context, portID, channelID string)
|
||||
}
|
||||
|
||||
var clientState clientexported.ClientState
|
||||
err = clientCtx.Codec.UnmarshalJSON(res, &clientState)
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &clientState)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal connections: %w", err)
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ func GetCmdQueryParams(cdc *codec.Codec) *cobra.Command {
|
||||
Short: "Query the current minting parameters",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
@ -67,7 +67,7 @@ func GetCmdQueryInflation(cdc *codec.Codec) *cobra.Command {
|
||||
Short: "Query the current minting inflation value",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryInflation)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
@ -93,7 +93,7 @@ func GetCmdQueryAnnualProvisions(cdc *codec.Codec) *cobra.Command {
|
||||
Short: "Query the current minting annual provisions value",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAnnualProvisions)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
|
||||
@ -47,7 +47,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
|
||||
`),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, args[0])
|
||||
if err != nil {
|
||||
@ -88,7 +88,7 @@ func GetCmdQueryParams(cdc *codec.Codec) *cobra.Command {
|
||||
$ <appcli> query slashing params
|
||||
`),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/parameters", types.QuerierRoute)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
|
||||
@ -45,7 +45,7 @@ func signingInfoHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQuerySigningInfoParams(sdk.ConsAddress(pk.Address()))
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -75,7 +75,7 @@ func signingInfoHandlerListFn(clientCtx client.Context) http.HandlerFunc {
|
||||
}
|
||||
|
||||
params := types.NewQuerySigningInfosParams(page, limit)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
addr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -102,7 +102,7 @@ $ %s query staking validators
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
resKVs, _, err := clientCtx.QuerySubspace(types.ValidatorsKey, storeName)
|
||||
if err != nil {
|
||||
@ -140,7 +140,7 @@ $ %s query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj6
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -187,7 +187,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
valSrcAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -231,7 +231,7 @@ $ %s query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosm
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -281,7 +281,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -326,7 +326,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -376,7 +376,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[1])
|
||||
if err != nil {
|
||||
@ -426,7 +426,7 @@ $ %s query staking unbonding-delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
delegatorAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -471,7 +471,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -526,7 +526,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@ -570,7 +570,7 @@ $ %s query staking historical-info 5
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
height, err := strconv.ParseInt(args[0], 10, 64)
|
||||
if err != nil || height < 0 {
|
||||
@ -614,7 +614,7 @@ $ %s query staking pool
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
bz, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/pool", storeName), nil)
|
||||
if err != nil {
|
||||
@ -647,7 +647,7 @@ $ %s query staking params
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", storeName, types.QueryParameters)
|
||||
bz, _, err := clientCtx.QueryWithData(route, nil)
|
||||
|
||||
@ -179,7 +179,7 @@ func delegatorTxsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
txs = append(txs, foundTxs)
|
||||
}
|
||||
|
||||
res, err := clientCtx.Codec.MarshalJSON(txs)
|
||||
res, err := clientCtx.JSONMarshaler.MarshalJSON(txs)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -234,7 +234,7 @@ func redelegationsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
params.DstValidatorAddr = dstValidatorAddr
|
||||
}
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -284,7 +284,7 @@ func validatorsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryValidatorsParams(page, limit, status)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -330,7 +330,7 @@ func historicalInfoHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryHistoricalInfoParams(height)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckInternalServerError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ func queryBonds(clientCtx client.Context, endpoint string) http.HandlerFunc {
|
||||
|
||||
params := types.NewQueryBondsParams(delegatorAddr, validatorAddr)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -91,7 +91,7 @@ func queryDelegator(clientCtx client.Context, endpoint string) http.HandlerFunc
|
||||
|
||||
params := types.NewQueryDelegatorParams(delegatorAddr)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
@ -128,7 +128,7 @@ func queryValidator(clientCtx client.Context, endpoint string) http.HandlerFunc
|
||||
|
||||
params := types.NewQueryValidatorParams(validatorAddr, page, limit)
|
||||
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ func GetPlanCmd(storeName string, cdc *codec.Codec) *cobra.Command {
|
||||
Long: "Gets the currently scheduled upgrade plan, if one exists",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
// ignore height for now
|
||||
res, _, err := clientCtx.Query(fmt.Sprintf("custom/%s/%s", types.QuerierKey, types.QueryCurrent))
|
||||
@ -51,11 +51,11 @@ func GetAppliedHeightCmd(storeName string, cdc *codec.Codec) *cobra.Command {
|
||||
"This helps a client determine which binary was valid over a given range of blocks, as well as more context to understand past migrations.",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc).WithJSONMarshaler(cdc)
|
||||
|
||||
name := args[0]
|
||||
params := types.NewQueryAppliedParams(name)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ func getDonePlanHandler(clientCtx client.Context) func(http.ResponseWriter, *htt
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
params := types.NewQueryAppliedParams(name)
|
||||
bz, err := clientCtx.Codec.MarshalJSON(params)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user