Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ConsensusParams upgrade and query #84

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/upgrades/v200/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/TERITORI/teritori-chain/app/keepers"
minttypes "github.com/TERITORI/teritori-chain/x/mint/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -72,6 +74,14 @@ func CreateUpgradeHandler(
v = reflect.Indirect(reflect.ValueOf(params.TotalBurntAmount)).Interface()
subspace.Set(ctx, minttypes.KeyTotalBurntAmount, v)

cp := tmtypes.DefaultConsensusParams().ToProto()
keepers.ConsensusParamsKeeper.Set(ctx, &tmproto.ConsensusParams{
Block: cp.Block,
Validator: cp.Validator,
Evidence: cp.Evidence,
Version: cp.Version,
})

return mm.RunMigrations(ctx, configurator, vm)
}
}
44 changes: 44 additions & 0 deletions x/mint/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package cli
import (
"context"
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/TERITORI/teritori-chain/x/mint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
)

// GetQueryCmd returns the cli query commands for the minting module.
Expand All @@ -27,6 +30,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryBlockProvisions(),
GetCmdQueryInflation(),
GetCmdQueryStakingAPR(),
GetConsensusParamsCmd(),
)

return mintingQueryCmd
Expand Down Expand Up @@ -143,3 +147,43 @@ func GetCmdQueryStakingAPR() *cobra.Command {
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

func GetConsensusParamsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "consensus-params",
Short: "Query consensus params",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the total balance of an account or of a specific denomination.
n0izn0iz marked this conversation as resolved.
Show resolved Hide resolved

Example:
$ %s query %s consensus-params
`,
version.AppName, types.ModuleName,
),
),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := consensustypes.NewQueryClient(clientCtx)

ctx := cmd.Context()

params := consensustypes.QueryParamsRequest{}

res, err := queryClient.Params(ctx, &params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}