## Description fix various linting issues --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... * [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] added `!` to the type prefix if API or client breaking change * [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) * [ ] provided a link to the relevant issue or specification * [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) * [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) * [ ] added a changelog entry to `CHANGELOG.md` * [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) * [ ] updated the relevant documentation or specification * [ ] reviewed "Files changed" and left comments if necessary * [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... * [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] confirmed `!` in the type prefix if API or client breaking change * [ ] confirmed all author checklist items have been addressed * [ ] reviewed state machine logic * [ ] reviewed API design and naming * [ ] reviewed documentation is accurate * [ ] reviewed tests and test coverage * [ ] manually tested (if applicable)
152 lines
4.1 KiB
Go
152 lines
4.1 KiB
Go
package vesting
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
abci "github.com/cometbft/cometbft/abci/types"
|
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
"github.com/spf13/cobra"
|
|
"google.golang.org/grpc"
|
|
|
|
"cosmossdk.io/depinject"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
|
|
modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
|
|
"cosmossdk.io/core/appmodule"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
|
)
|
|
|
|
var (
|
|
_ module.AppModule = AppModule{}
|
|
_ module.AppModuleBasic = AppModuleBasic{}
|
|
)
|
|
|
|
// AppModuleBasic defines the basic application module used by the sub-vesting
|
|
// module. The module itself contain no special logic or state other than message
|
|
// handling.
|
|
type AppModuleBasic struct{}
|
|
|
|
// Name returns the module's name.
|
|
func (AppModuleBasic) Name() string {
|
|
return types.ModuleName
|
|
}
|
|
|
|
// RegisterCodec registers the module's types with the given codec.
|
|
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
|
types.RegisterLegacyAminoCodec(cdc)
|
|
}
|
|
|
|
// RegisterInterfaces registers the module's interfaces and implementations with
|
|
// the given interface registry.
|
|
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
|
types.RegisterInterfaces(registry)
|
|
}
|
|
|
|
// DefaultGenesis returns the module's default genesis state as raw bytes.
|
|
func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage {
|
|
return []byte("{}")
|
|
}
|
|
|
|
// ValidateGenesis performs genesis state validation. Currently, this is a no-op.
|
|
func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
|
|
return nil
|
|
}
|
|
|
|
// RegisterGRPCGatewayRoutes registers the module's gRPC Gateway routes. Currently, this
|
|
// is a no-op.
|
|
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux) {}
|
|
|
|
// GetTxCmd returns the root tx command for the auth module.
|
|
func (AppModuleBasic) GetTxCmd() *cobra.Command {
|
|
return cli.GetTxCmd()
|
|
}
|
|
|
|
// GetQueryCmd returns the module's root query command. Currently, this is a no-op.
|
|
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
|
return nil
|
|
}
|
|
|
|
// AppModule extends the AppModuleBasic implementation by implementing the
|
|
// AppModule interface.
|
|
type AppModule struct {
|
|
AppModuleBasic
|
|
|
|
accountKeeper keeper.AccountKeeper
|
|
bankKeeper types.BankKeeper
|
|
}
|
|
|
|
func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule {
|
|
return AppModule{
|
|
AppModuleBasic: AppModuleBasic{},
|
|
accountKeeper: ak,
|
|
bankKeeper: bk,
|
|
}
|
|
}
|
|
|
|
var (
|
|
_ appmodule.AppModule = AppModule{}
|
|
_ appmodule.HasServices = AppModule{}
|
|
)
|
|
|
|
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
|
|
func (am AppModule) IsOnePerModuleType() {}
|
|
|
|
// IsAppModule implements the appmodule.AppModule interface.
|
|
func (am AppModule) IsAppModule() {}
|
|
|
|
// RegisterServices registers module services.
|
|
func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
|
types.RegisterMsgServer(registrar, NewMsgServerImpl(am.accountKeeper, am.bankKeeper))
|
|
return nil
|
|
}
|
|
|
|
// InitGenesis performs a no-op.
|
|
func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate {
|
|
return []abci.ValidatorUpdate{}
|
|
}
|
|
|
|
// ExportGenesis is always empty, as InitGenesis does nothing either.
|
|
func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
|
return am.DefaultGenesis(cdc)
|
|
}
|
|
|
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
|
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
|
|
|
//
|
|
// App Wiring Setup
|
|
//
|
|
|
|
func init() {
|
|
appmodule.Register(&modulev1.Module{},
|
|
appmodule.Provide(ProvideModule),
|
|
)
|
|
}
|
|
|
|
type ModuleInputs struct {
|
|
depinject.In
|
|
|
|
AccountKeeper keeper.AccountKeeper
|
|
BankKeeper types.BankKeeper
|
|
}
|
|
|
|
type ModuleOutputs struct {
|
|
depinject.Out
|
|
|
|
Module appmodule.AppModule
|
|
}
|
|
|
|
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
|
m := NewAppModule(in.AccountKeeper, in.BankKeeper)
|
|
|
|
return ModuleOutputs{Module: m}
|
|
}
|