cosmos-sdk/x/upgrade/handler.go
Jacob Gadikian b0e82f9640
chore: Db linting (#12141)
* mainly sdk.int to cosmossdk.io/math

* staking keys

* fumpt

* var-naming linter errors and a fumpt

* Update CHANGELOG.md

* Update .golangci.yml

* Update CHANGELOG.md

* Update test_helpers.go

* Update test_helpers.go

* fumpt and lint

* this lints the db module, and makes it easier to use.  It adds breaking name changes

* DBConnection -> Connection

* previous commit contained a merge error

* Update test_helpers.go

* Update test_helpers.go

* db renamings

* merge master

* changelog

* DBWriter -> Writer

* consistent multistore reciever

* standard recievers for multistore v2alpha1

* general cleanup of linting issues

* more linter fixes

* remove prealloc linter

* nolint the secp256k1 import

* nolint the secp256k1 package

* completenolint resulting in a diff that has only nolints
2022-06-08 19:02:01 +02:00

40 lines
1.5 KiB
Go

package upgrade
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// NewSoftwareUpgradeProposalHandler creates a governance handler to manage new proposal types.
// It enables SoftwareUpgradeProposal to propose an Upgrade, and CancelSoftwareUpgradeProposal
// to abort a previously voted upgrade.
//nolint: staticcheck // we are intentionally using a deprecated proposal here.
func NewSoftwareUpgradeProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
switch c := content.(type) {
case *types.SoftwareUpgradeProposal:
return handleSoftwareUpgradeProposal(ctx, k, c)
case *types.CancelSoftwareUpgradeProposal:
return handleCancelSoftwareUpgradeProposal(ctx, k, c)
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized software upgrade proposal content type: %T", c)
}
}
}
//nolint:staticcheck // we are intentionally using a deprecated proposal here.
func handleSoftwareUpgradeProposal(ctx sdk.Context, k keeper.Keeper, p *types.SoftwareUpgradeProposal) error {
return k.ScheduleUpgrade(ctx, p.Plan)
}
//nolint:staticcheck // we are intentionally using a deprecated proposal here.
func handleCancelSoftwareUpgradeProposal(ctx sdk.Context, k keeper.Keeper, _ *types.CancelSoftwareUpgradeProposal) error {
k.ClearUpgradePlan(ctx)
return nil
}