From 2f75b51d0684fe891ef007c3e264ec0affd23dc6 Mon Sep 17 00:00:00 2001 From: yys Date: Fri, 18 Oct 2019 17:09:33 +0900 Subject: [PATCH] updates for goreport (#255) --- app/app.go | 18 ++++---- app/utils.go | 1 - cli_test/cli_test.go | 4 +- cli_test/test_helpers.go | 6 +-- cmd/terrad/testnet.go | 2 +- x/auth/client/rest/multisigntx.go | 2 +- x/auth/client/utils/feeutils.go | 8 ++-- x/auth/internal/types/codec.go | 2 +- x/auth/internal/types/lazy_vesting.go | 5 +- x/auth/module.go | 41 +++++++++-------- x/auth/simulation/fake.go | 2 +- x/bank/internal/types/codec.go | 4 +- x/bank/module.go | 41 +++++++++-------- x/crisis/internal/types/codec.go | 4 +- x/crisis/module.go | 43 +++++++++--------- x/distribution/internal/types/codec.go | 4 +- x/distribution/module.go | 42 +++++++++-------- x/genaccounts/expected.go | 2 +- x/genaccounts/export.go | 2 +- x/genaccounts/genesis_account.go | 4 +- x/genaccounts/genesis_state.go | 4 +- x/genaccounts/init.go | 2 +- x/genaccounts/module.go | 29 ++++++------ x/genutil/genesis_state.go | 2 +- x/genutil/internal/types/codec.go | 2 +- x/genutil/internal/types/expected_keepers.go | 6 +-- x/genutil/module.go | 41 +++++++++-------- x/gov/internal/types/codec.go | 2 +- x/gov/module.go | 43 +++++++++--------- x/market/client/rest/rest.go | 2 +- x/market/client/rest/tx.go | 2 +- x/market/internal/keeper/querier_test.go | 4 +- x/market/internal/types/codec.go | 2 +- x/market/internal/types/expected_keepers.go | 4 +- x/market/module.go | 48 +++++++++----------- x/oracle/abci_test.go | 30 +++++++++++- x/oracle/internal/types/params.go | 2 +- x/oracle/internal/types/querier.go | 1 + x/oracle/module.go | 42 +++++++++-------- x/params/internal/types/codec.go | 2 +- x/params/module.go | 17 +++---- x/slashing/internal/types/codec.go | 4 +- x/slashing/module.go | 43 +++++++++--------- x/staking/internal/types/codec.go | 4 +- x/staking/module.go | 44 +++++++++--------- x/supply/module.go | 41 +++++++++-------- x/treasury/client/rest/rest.go | 1 + x/treasury/internal/types/codec.go | 4 +- x/treasury/internal/types/params.go | 2 +- x/treasury/internal/types/querier.go | 6 +++ x/treasury/module.go | 40 ++++++++-------- 51 files changed, 388 insertions(+), 325 deletions(-) diff --git a/app/app.go b/app/app.go index 8d6d5390b..7e694a05d 100644 --- a/app/app.go +++ b/app/app.go @@ -39,13 +39,13 @@ import ( const appName = "TerraApp" var ( - // default home directories for terracli + // DefaultCLIHome defines default home directories for terracli DefaultCLIHome = os.ExpandEnv("$HOME/.terracli") - // default home directories for terrad + // DefaultNodeHome defines default home directories for terrad DefaultNodeHome = os.ExpandEnv("$HOME/.terrad") - // The ModuleBasicManager is in charge of setting up basic, + // ModuleBasics = The ModuleBasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration // and genesis verification. ModuleBasics = module.NewBasicManager( @@ -78,7 +78,7 @@ var ( } ) -// custom tx codec +// MakeCodec builds application codec func MakeCodec() *codec.Codec { var cdc = codec.New() ModuleBasics.RegisterCodec(cdc) @@ -88,7 +88,7 @@ func MakeCodec() *codec.Codec { return cdc } -// Extended ABCI application +// TerraApp is Extended ABCI application type TerraApp struct { *bam.BaseApp cdc *codec.Codec @@ -244,24 +244,24 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest return app } -// application updates every begin block +// BeginBlocker defines application updates at every begin block func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { return app.mm.BeginBlock(ctx, req) } -// application updates every end block +// EndBlocker defines application updates at every end block func (app *TerraApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } -// application update at chain initialization +// InitChainer defines application update at chain initialization func (app *TerraApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { var genesisState simapp.GenesisState app.cdc.MustUnmarshalJSON(req.AppStateBytes, &genesisState) return app.mm.InitGenesis(ctx, genesisState) } -// load a particular height +// LoadHeight loads a particular height func (app *TerraApp) LoadHeight(height int64) error { return app.LoadVersion(height, app.keys[bam.MainStoreKey]) } diff --git a/app/utils.go b/app/utils.go index b8fa6361e..c3400044b 100644 --- a/app/utils.go +++ b/app/utils.go @@ -1,4 +1,3 @@ -//nolint package app import ( diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index d463c0a56..71e9658f3 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -451,6 +451,7 @@ func TestTerraCLIQueryRewards(t *testing.T) { genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) + require.NoError(t, err) require.NoError(t, genDoc.SaveAs(genFile)) // start terrad server @@ -772,6 +773,7 @@ func TestTerraCLISubmitCommunityPoolSpendProposal(t *testing.T) { genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) + require.NoError(t, err) require.NoError(t, genDoc.SaveAs(genFile)) proc := f.TDStart() @@ -1016,7 +1018,7 @@ func TestTerraCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) // Test broadcast - success, stdOut, _ = f.TxBroadcast(signedTxFile.Name()) + success, _, _ = f.TxBroadcast(signedTxFile.Name()) require.True(t, success) tests.WaitForNextNBlocksTM(1, f.Port) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 0139b4f9c..b56cf2d8d 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -121,7 +121,7 @@ func (f Fixtures) GenesisFile() string { return filepath.Join(f.TerradHome, "config", "genesis.json") } -// GenesisFile returns the application's genesis state +// GenesisState returns the application's genesis state func (f Fixtures) GenesisState() simapp.GenesisState { cdc := codec.New() genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile()) @@ -352,7 +352,7 @@ func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string, return executeWriteRetStdStreams(f.T, cmd) } -// TxEstimateFee +// TxEstimateFee is terracli tx estimate-fee func (f *Fixtures) TxEstimateFee(fileName string, flags ...string) (bool, string, string) { cmd := fmt.Sprintf("%s tx estimate-fee %v %v", f.TerracliBinary, f.Flags(), fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags)) @@ -757,7 +757,7 @@ func queryTags(tags []string) (out string) { return strings.TrimSuffix(out, "&") } -// Write the given string to a new temporary file +// WriteToNewTempFile writes the given string to a new temporary file func WriteToNewTempFile(t *testing.T, s string) *os.File { fp, err := ioutil.TempFile(os.TempDir(), "cosmos_cli_test_") require.Nil(t, err) diff --git a/cmd/terrad/testnet.go b/cmd/terrad/testnet.go index 4331f771a..360ac8324 100644 --- a/cmd/terrad/testnet.go +++ b/cmd/terrad/testnet.go @@ -101,7 +101,7 @@ Example: const nodeDirPerm = 0755 -// Initialize the testnet +// InitTestnet initializes the testnet func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec, mbm module.BasicManager, genAccIterator genutiltypes.GenesisAccountsIterator, outputDir, chainID, minGasPrices, nodeDirPrefix, nodeDaemonHome, diff --git a/x/auth/client/rest/multisigntx.go b/x/auth/client/rest/multisigntx.go index 7127c1941..502e91472 100644 --- a/x/auth/client/rest/multisigntx.go +++ b/x/auth/client/rest/multisigntx.go @@ -26,7 +26,7 @@ type MultiSignReq struct { Pubkey MultiSignPubKey `json:"pubkey"` // (optional) In case the multisig account never reveals its pubkey, it is required. } -// MultiSignPubkey defines the properties of a multisig account's public key +// MultiSignPubKey defines the properties of a multisig account's public key type MultiSignPubKey struct { Threshold int `json:"threshold"` PubKeys []string `json:"pubkeys"` diff --git a/x/auth/client/utils/feeutils.go b/x/auth/client/utils/feeutils.go index 93b87c09a..15a1cfef5 100644 --- a/x/auth/client/utils/feeutils.go +++ b/x/auth/client/utils/feeutils.go @@ -18,14 +18,14 @@ import ( ) type ( - // EstimateReq defines a tx encoding request. + // EstimateFeeReq defines a tx encoding request. EstimateFeeReq struct { Tx auth.StdTx `json:"tx"` GasAdjustment string `json:"gas_adjustment"` GasPrices sdk.DecCoins `json:"gas_prices"` } - // EstimateResp defines a tx encoding response. + // EstimateFeeResp defines a tx encoding response. EstimateFeeResp struct { Fees sdk.Coins `json:"fees"` Gas uint64 `json:"gas"` @@ -104,7 +104,7 @@ type ComputeReqParams struct { Msgs []sdk.Msg } -// ComputeFee returns fee amount with given transfer, gas, gas prices, and fees amount. +// ComputeFees returns fee amount with given transfer, gas, gas prices, and fees amount. func ComputeFees( cliCtx context.CLIContext, req ComputeReqParams) (fees sdk.Coins, gas uint64, err error) { @@ -265,7 +265,7 @@ func queryTaxCap(cliCtx context.CLIContext, denom string) (sdk.Int, error) { return taxCap, nil } -// parse string to float64 +// ParseFloat64 parses string to float64 func ParseFloat64(s string, defaultIfEmpty float64) (n float64, err error) { if len(s) == 0 { return defaultIfEmpty, nil diff --git a/x/auth/internal/types/codec.go b/x/auth/internal/types/codec.go index 8ac3aada4..90390eac5 100644 --- a/x/auth/internal/types/codec.go +++ b/x/auth/internal/types/codec.go @@ -19,7 +19,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&BaseLazyGradedVestingAccount{}, "core/LazyGradedVestingAccount", nil) } -// module wide codec +// ModuleCdc defines module wide codec var ModuleCdc *codec.Codec func init() { diff --git a/x/auth/internal/types/lazy_vesting.go b/x/auth/internal/types/lazy_vesting.go index 630bd29c2..68290447d 100644 --- a/x/auth/internal/types/lazy_vesting.go +++ b/x/auth/internal/types/lazy_vesting.go @@ -11,13 +11,14 @@ import ( //----------------------------------------------------------------------------- // Schedule -// Schedule no-lint +// LazySchedule defines a vesting schedule which is used for LazyGradedVestingAccount type LazySchedule struct { StartTime int64 `json:"start_time"` EndTime int64 `json:"end_time"` Ratio sdk.Dec `json:"ratio"` } +// NewLazySchedule returns new LazySchedule instance func NewLazySchedule(startTime, endTime int64, ratio sdk.Dec) LazySchedule { return LazySchedule{ StartTime: startTime, @@ -152,7 +153,7 @@ type BaseLazyGradedVestingAccount struct { VestingSchedules []VestingSchedule `json:"vesting_schedules"` } -// NewBaseLazyGradedVestingAccount creates a new BaseLazyGradedVestingAccount object from BaseVestingAccount +// NewBaseLazyGradedVestingAccountRaw creates a new BaseLazyGradedVestingAccount object from BaseVestingAccount func NewBaseLazyGradedVestingAccountRaw(baseVestingAcc *auth.BaseVestingAccount, lazyVestingSchedules []VestingSchedule) *BaseLazyGradedVestingAccount { return &BaseLazyGradedVestingAccount{baseVestingAcc, lazyVestingSchedules} } diff --git a/x/auth/module.go b/x/auth/module.go index a5f634463..f92f1bd9c 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -18,47 +18,49 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the auth module. type AppModuleBasic struct{} -// module name +// Name returns the auth module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the auth module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint (DO NOT TOUCH) } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the auth +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the auth module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the auth module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the auth module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the auth module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module object + +// AppModule implements an application module for the auth module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -72,48 +74,49 @@ func NewAppModule(accountKeeper AccountKeeper) AppModule { } } -// module name +// Name returns the auth module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the auth module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the auth module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the auth module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the auth module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the auth module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the auth module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the auth +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the auth module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the auth module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/auth/simulation/fake.go b/x/auth/simulation/fake.go index 262176e4d..5c667421b 100644 --- a/x/auth/simulation/fake.go +++ b/x/auth/simulation/fake.go @@ -12,8 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" ) -// This simulation is forked because of the absence of the Mint Module // SimulateDeductFee generates simulation cases that accounts send token to FeeCollector module account +// This simulation is forked to cover the absence of the Mint Module func SimulateDeductFee(ak auth.AccountKeeper, supplyKeeper types.SupplyKeeper) simulation.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account) ( diff --git a/x/bank/internal/types/codec.go b/x/bank/internal/types/codec.go index 67360b66a..2c44bcd1f 100644 --- a/x/bank/internal/types/codec.go +++ b/x/bank/internal/types/codec.go @@ -5,13 +5,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(bank.MsgSend{}, "bank/MsgSend", nil) cdc.RegisterConcrete(bank.MsgMultiSend{}, "bank/MsgMultiSend", nil) } -// module codec +// ModuleCdc defines module codec var ModuleCdc *codec.Codec func init() { diff --git a/x/bank/module.go b/x/bank/module.go index 8c9d730ec..c795f0b21 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -23,47 +23,49 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the bank module. type AppModuleBasic struct{} -// module name +// Name returns the bank module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the bank module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the bank +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the bank module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the bank module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { rest.RegisterRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the bank module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return cli.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the bank module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module + +// AppModule implements an application module for the bank module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -77,48 +79,49 @@ func NewAppModule(keeper Keeper, accountKeeper types.AccountKeeper) AppModule { } } -// module name +// Name returns the bank module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the bank module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the bank module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the bank module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the bank module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the bank module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the bank module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the bank +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the bank module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the bank module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/crisis/internal/types/codec.go b/x/crisis/internal/types/codec.go index c0e683cb4..969661b25 100644 --- a/x/crisis/internal/types/codec.go +++ b/x/crisis/internal/types/codec.go @@ -5,12 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(crisis.MsgVerifyInvariant{}, "crisis/MsgVerifyInvariant", nil) } -// generic sealed codec to be used throughout module +// ModuleCdc is generic sealed codec to be used throughout module var ModuleCdc *codec.Codec func init() { diff --git a/x/crisis/module.go b/x/crisis/module.go index 53743585e..a23b96175 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -21,23 +21,22 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the crisis module. type AppModuleBasic struct{} -var _ module.AppModuleBasic = AppModuleBasic{} - -// module name +// Name returns the crisis module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the crisis module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the crisis +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { // customize to set default genesis state constant fee denom to uluna defaultGenesisState := DefaultGenesisState() @@ -46,28 +45,29 @@ func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(defaultGenesisState) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the crisis module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the crisis module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the crisis module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the crisis module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module for bank + +// AppModule implements an application module for the crisis module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -81,48 +81,49 @@ func NewAppModule(keeper *Keeper) AppModule { } } -// module name +// Name returns the crisis module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the crisis module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the crisis module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the crisis module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the crisis module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the crisis module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the crisis module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the crisis +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the crisis module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the crisis module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/distribution/internal/types/codec.go b/x/distribution/internal/types/codec.go index 8fc5f94fe..1262e8ae4 100644 --- a/x/distribution/internal/types/codec.go +++ b/x/distribution/internal/types/codec.go @@ -7,7 +7,7 @@ import ( "github.com/terra-project/core/x/gov" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(distribution.MsgWithdrawDelegatorReward{}, "distribution/MsgWithdrawDelegationReward", nil) cdc.RegisterConcrete(distribution.MsgWithdrawValidatorCommission{}, "distribution/MsgWithdrawValidatorCommission", nil) @@ -15,7 +15,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(distribution.CommunityPoolSpendProposal{}, "distribution/CommunityPoolSpendProposal", nil) } -// generic sealed codec to be used throughout module +// ModuleCdc is generic sealed codec to be used throughout module var ModuleCdc *codec.Codec func init() { diff --git a/x/distribution/module.go b/x/distribution/module.go index 3742f1cef..a9cb48c7d 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -20,48 +20,51 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the distribution module. type AppModuleBasic struct{} var _ module.AppModuleBasic = AppModuleBasic{} -// module name +// Name returns the distribution module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the distribution module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the distribution +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the distribution module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the distribution module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the distribution module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the distribution module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } -// app module +//___________________________ + +// AppModule implements an application module for the distribution module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -75,48 +78,49 @@ func NewAppModule(keeper Keeper, supplyKeeper types.SupplyKeeper) AppModule { } } -// module name +// Name returns the distribution module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the distribution module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the distribution module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the distribution module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the distribution module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the distribution module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the distribution module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the distribution +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the distribution module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the distribution module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/genaccounts/expected.go b/x/genaccounts/expected.go index 2f38b62e3..03eaecf27 100644 --- a/x/genaccounts/expected.go +++ b/x/genaccounts/expected.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/exported" ) -// expected account keeper +// AccountKeeper defines expected account keeper type AccountKeeper interface { NewAccount(sdk.Context, exported.Account) exported.Account SetAccount(sdk.Context, exported.Account) diff --git a/x/genaccounts/export.go b/x/genaccounts/export.go index 767cc8e17..30777c49e 100644 --- a/x/genaccounts/export.go +++ b/x/genaccounts/export.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/exported" ) -// export genesis for all accounts +// ExportGenesis exports genesis for all accounts func ExportGenesis(ctx sdk.Context, accountKeeper AccountKeeper) GenesisState { // iterate to get the accounts diff --git a/x/genaccounts/genesis_account.go b/x/genaccounts/genesis_account.go index 85eaaafa2..e9336978a 100644 --- a/x/genaccounts/genesis_account.go +++ b/x/genaccounts/genesis_account.go @@ -156,9 +156,11 @@ func (ga *GenesisAccount) ToAccount() auth.Account { } //___________________________________ + +// GenesisAccounts is genesis account array type GenesisAccounts []GenesisAccount -// genesis accounts contain an address +// Contains check whether genesis accounts contain an address func (gaccs GenesisAccounts) Contains(acc sdk.AccAddress) bool { for _, gacc := range gaccs { if gacc.Address.Equals(acc) { diff --git a/x/genaccounts/genesis_state.go b/x/genaccounts/genesis_state.go index 834ee5301..609838f6b 100644 --- a/x/genaccounts/genesis_state.go +++ b/x/genaccounts/genesis_state.go @@ -12,7 +12,7 @@ import ( // State to Unmarshal type GenesisState GenesisAccounts -// get the genesis state from the expected app state +// GetGenesisStateFromAppState returns the genesis state from the expected app state func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState { var genesisState GenesisState if appState[ModuleName] != nil { @@ -22,7 +22,7 @@ func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawM return genesisState } -// set the genesis state within the expected app state +// SetGenesisStateInAppState sets the genesis state within the expected app state func SetGenesisStateInAppState(cdc *codec.Codec, appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage { diff --git a/x/genaccounts/init.go b/x/genaccounts/init.go index e58beef1d..54081ca77 100644 --- a/x/genaccounts/init.go +++ b/x/genaccounts/init.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// initialize accounts and deliver genesis transactions +// InitGenesis initializes accounts and deliver genesis transactions func InitGenesis(ctx sdk.Context, _ *codec.Codec, accountKeeper AccountKeeper, genesisState GenesisState) { genesisState.Sanitize() diff --git a/x/genaccounts/module.go b/x/genaccounts/module.go index 351ebd405..975104b31 100644 --- a/x/genaccounts/module.go +++ b/x/genaccounts/module.go @@ -20,26 +20,27 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// module name +// ModuleName accounts module name const ModuleName = "accounts" -// app module basics object +// AppModuleBasic defines the basic application module used by the genaccounts module. type AppModuleBasic struct{} -// module name +// Name returns the genaccounts module's name func (AppModuleBasic) Name() string { return ModuleName } -// register module codec +// RegisterCodec registers the genaccounts module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {} -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the genaccounts +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return moduleCdc.MustMarshalJSON(GenesisState{}) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the genaccounts module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { var data GenesisState err := moduleCdc.UnmarshalJSON(bz, &data) @@ -49,16 +50,16 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return ValidateGenesis(data) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the genaccounts module. func (AppModuleBasic) RegisterRESTRoutes(_ context.CLIContext, _ *mux.Router) {} -// get the root tx command of this module +// GetTxCmd returns the root tx command for the genaccounts module. func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { return nil } -// get the root query command of this module +// GetQueryCmd returns the root query command for the genaccounts module. func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command { return nil } -// extra function from sdk.AppModuleBasic +// IterateGenesisAccounts is extra function from sdk.AppModuleBasic // iterate the genesis accounts and perform an operation at each of them // - to used by other modules func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[string]json.RawMessage, @@ -74,7 +75,8 @@ func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[st } //___________________________ -// app module + +// AppModule implements an application module for the genaccounts module. type AppModule struct { AppModuleBasic accountKeeper AccountKeeper @@ -89,7 +91,7 @@ func NewAppModule(accountKeeper AccountKeeper) module.AppModule { }) } -// module init-genesis +// InitGenesis performs genesis initialization for the genaccounts module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState moduleCdc.MustUnmarshalJSON(data, &genesisState) @@ -97,7 +99,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the genaccounts +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { gs := ExportGenesis(ctx, am.accountKeeper) return moduleCdc.MustMarshalJSON(gs) diff --git a/x/genutil/genesis_state.go b/x/genutil/genesis_state.go index 6d5f3ecda..d7eb1573f 100644 --- a/x/genutil/genesis_state.go +++ b/x/genutil/genesis_state.go @@ -8,7 +8,7 @@ import ( "github.com/terra-project/core/x/auth" ) -// validate GenTx transactions +// ValidateGenesis validates GenTx transactions func ValidateGenesis(genesisState GenesisState) error { for i, genTx := range genesisState.GenTxs { var tx auth.StdTx diff --git a/x/genutil/internal/types/codec.go b/x/genutil/internal/types/codec.go index 422e7b91a..60cd739af 100644 --- a/x/genutil/internal/types/codec.go +++ b/x/genutil/internal/types/codec.go @@ -8,7 +8,7 @@ import ( "github.com/terra-project/core/x/staking" ) -// generic sealed codec to be used throughout this module +// ModuleCdc defines generic sealed codec to be used throughout this module var ModuleCdc *codec.Codec // TODO abstract genesis transactions registration back to staking diff --git a/x/genutil/internal/types/expected_keepers.go b/x/genutil/internal/types/expected_keepers.go index 98e720b9b..62ac62914 100644 --- a/x/genutil/internal/types/expected_keepers.go +++ b/x/genutil/internal/types/expected_keepers.go @@ -10,19 +10,19 @@ import ( "github.com/terra-project/core/x/auth" ) -// expected staking keeper +// StakingKeeper defeins expected staking keeper type StakingKeeper interface { ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate) } -// expected account keeper +// AccountKeeper defines expected account keeper type AccountKeeper interface { NewAccount(sdk.Context, auth.Account) auth.Account SetAccount(sdk.Context, auth.Account) IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool)) } -// The expected interface for iterating genesis accounts object +// GenesisAccountsIterator defines the expected interface for iterating genesis accounts object type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.Codec, diff --git a/x/genutil/module.go b/x/genutil/module.go index 9a7bf1ffa..058ecf995 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -20,25 +20,26 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the genutil module. type AppModuleBasic struct{} -// module name +// Name returns the genutil module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the genutil module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the genutil +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(GenesisState{}) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the genutil module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { var data GenesisState err := ModuleCdc.UnmarshalJSON(bz, &data) @@ -48,23 +49,24 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return ValidateGenesis(data) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the genutil module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the genutil module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the genutil module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module + +// AppModule implements an application module for the genutil module. type AppModule struct { AppModuleBasic accountKeeper AccountKeeper @@ -86,50 +88,51 @@ func NewAppModule(accountKeeper AccountKeeper, }) } -// module name +// Name returns the genutil module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants performs a no-op. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the genutil module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the genutil module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the genutil module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the genutil module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the genutil module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState ModuleCdc.MustUnmarshalJSON(data, &genesisState) return InitGenesis(ctx, ModuleCdc, am.stakingKeeper, am.deliverTx, genesisState) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the genutil +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the genutil module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the genutil module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/gov/internal/types/codec.go b/x/gov/internal/types/codec.go index 81e428244..a3a92620b 100644 --- a/x/gov/internal/types/codec.go +++ b/x/gov/internal/types/codec.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov" ) -// module codec +// ModuleCdc defines module codec var ModuleCdc = codec.New() // RegisterCodec registers all the necessary types and interfaces for diff --git a/x/gov/module.go b/x/gov/module.go index 76c4845e1..d2e65d99f 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -23,7 +23,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the gov module. type AppModuleBasic struct { CosmosAppModuleBasic } @@ -35,20 +35,19 @@ func NewAppModuleBasic(proposalHandlers ...client.ProposalHandler) AppModuleBasi } } -var _ module.AppModuleBasic = AppModuleBasic{} - -// module name +// Name returns the gov module's name func (am AppModuleBasic) Name() string { return am.CosmosAppModuleBasic.Name() } -// register module codec +// RegisterCodec registers the gov module's types for the given codec. func (am AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the gov +// module. func (am AppModuleBasic) DefaultGenesis() json.RawMessage { // customize to set default genesis state deposit denom to uluna defaultGenesisState := DefaultGenesisState() @@ -57,28 +56,29 @@ func (am AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(defaultGenesisState) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the gov module. func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return am.CosmosAppModuleBasic.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the gov module. func (am AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { am.CosmosAppModuleBasic.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the gov module. func (am AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return am.CosmosAppModuleBasic.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the gov module. func (am AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return am.CosmosAppModuleBasic.GetQueryCmd(cdc) } //___________________________ -// app module for gov + +// AppModule implements an application module for the gov module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -92,48 +92,49 @@ func NewAppModule(keeper Keeper, supplyKeeper types.SupplyKeeper) AppModule { } } -// module name +// Name returns the gov module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants performs a no-op. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the gov module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the gov module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the gov module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the gov module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the gov module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the gov +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the gov module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the gov module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/market/client/rest/rest.go b/x/market/client/rest/rest.go index 47f5ba98b..90bbcc04d 100644 --- a/x/market/client/rest/rest.go +++ b/x/market/client/rest/rest.go @@ -5,7 +5,7 @@ import ( "github.com/gorilla/mux" ) -// RestDenom +// RestDenom is the whildcard part of the request path const RestDenom = "denom" // RegisterRoutes - Central function to define routes that get registered by the main application diff --git a/x/market/client/rest/tx.go b/x/market/client/rest/tx.go index d246ab1a1..35c822daf 100644 --- a/x/market/client/rest/tx.go +++ b/x/market/client/rest/tx.go @@ -17,7 +17,7 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) { r.HandleFunc("/market/swap", submitSwapHandlerFn(cliCtx)).Methods("POST") } -//nolint +// SwapReq defines request body for swap operation type SwapReq struct { BaseReq rest.BaseReq `json:"base_req"` OfferCoin sdk.Coin `json:"offer_coin"` diff --git a/x/market/internal/keeper/querier_test.go b/x/market/internal/keeper/querier_test.go index b742e8cbf..c510d7b57 100644 --- a/x/market/internal/keeper/querier_test.go +++ b/x/market/internal/keeper/querier_test.go @@ -60,7 +60,7 @@ func TestQuerySwap(t *testing.T) { Data: []byte{}, } - res, err := querier(input.Ctx, []string{types.QuerySwap}, query) + _, err = querier(input.Ctx, []string{types.QuerySwap}, query) require.Error(t, err) // recursive query @@ -74,7 +74,7 @@ func TestQuerySwap(t *testing.T) { Data: bz, } - res, err = querier(input.Ctx, []string{types.QuerySwap}, query) + res, err := querier(input.Ctx, []string{types.QuerySwap}, query) require.Error(t, err) // valid query diff --git a/x/market/internal/types/codec.go b/x/market/internal/types/codec.go index 8ef0d6ea2..06b30dce7 100644 --- a/x/market/internal/types/codec.go +++ b/x/market/internal/types/codec.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// Internal Module Codec +// ModuleCdc defines internal Module Codec var ModuleCdc = codec.New() // RegisterCodec concretes types on codec codec diff --git a/x/market/internal/types/expected_keepers.go b/x/market/internal/types/expected_keepers.go index e382ed254..edb736edb 100644 --- a/x/market/internal/types/expected_keepers.go +++ b/x/market/internal/types/expected_keepers.go @@ -5,7 +5,7 @@ import ( supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" ) -// expected supply keeper +// SupplyKeeper defines expected supply keeper type SupplyKeeper interface { GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI) @@ -17,7 +17,7 @@ type SupplyKeeper interface { MintCoins(ctx sdk.Context, name string, amt sdk.Coins) sdk.Error } -// expected oracle keeper +// OracleKeeper defines expected oracle keeper type OracleKeeper interface { GetLunaPrice(ctx sdk.Context, denom string) (price sdk.Dec, err sdk.Error) } diff --git a/x/market/module.go b/x/market/module.go index 044372c10..13d3cdad2 100644 --- a/x/market/module.go +++ b/x/market/module.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth/exported" "github.com/terra-project/core/x/market/client/cli" "github.com/terra-project/core/x/market/client/rest" @@ -23,25 +22,26 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the market module. type AppModuleBasic struct{} -// module name +// Name returns the market module's name func (AppModuleBasic) Name() string { return ModuleName } -// register module codec +// RegisterCodec registers the market module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the market +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the market module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { var data GenesisState err := ModuleCdc.UnmarshalJSON(bz, &data) @@ -51,29 +51,24 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return ValidateGenesis(data) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the market module. func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { rest.RegisterRoutes(ctx, rtr) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the market module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return cli.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the market module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(StoreKey, cdc) } -// extra function from sdk.AppModuleBasic -// iterate the genesis accounts and perform an operation at each of them -// - to used by other modules -func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[string]json.RawMessage, iterateFn func(exported.Account) (stop bool)) { -} - //___________________________ -// app module + +// AppModule implements an application module for the market module. type AppModule struct { AppModuleBasic @@ -88,29 +83,29 @@ func NewAppModule(keeper Keeper) AppModule { } } -// module name +// Name returns the market module's name. func (AppModule) Name() string { return ModuleName } -// register invariants +// RegisterInvariants performs a no-op. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// module message route name +// Route returns the message routing key for the market module. func (AppModule) Route() string { return RouterKey } -// module handler +// NewHandler returns an sdk.Handler for the market module. func (am AppModule) NewHandler() sdk.Handler { return NewHandler(am.keeper) } -// module querier route name +// QuerierRoute returns the market module's querier route name. func (AppModule) QuerierRoute() string { return RouterKey } -// module querier +// NewQuerierHandler returns the market module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return NewQuerier(am.keeper) } -// module init-genesis +// InitGenesis performs genesis initialization for the market module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState ModuleCdc.MustUnmarshalJSON(data, &genesisState) @@ -118,17 +113,18 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the market +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { genesisState := ExportGenesis(ctx, am.keeper) data := ModuleCdc.MustMarshalJSON(genesisState) return data } -// module begin-block +// BeginBlock returns the begin blocker for the market module. func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {} -// module end-block +// EndBlock returns the end blocker for the market module. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go index c99f3ec02..0851780bd 100644 --- a/x/oracle/abci_test.go +++ b/x/oracle/abci_test.go @@ -20,6 +20,8 @@ func TestOracleThreshold(t *testing.T) { // Prevote without price salt := "1" bz, err := VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[0]) + require.NoError(t, err) + prevoteMsg := NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[0], keeper.ValAddrs[0]) res := h(input.Ctx.WithBlockHeight(0), prevoteMsg) require.True(t, res.IsOK()) @@ -37,6 +39,8 @@ func TestOracleThreshold(t *testing.T) { // More than the threshold signs, msg succeeds salt = "1" bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[0]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[0], keeper.ValAddrs[0]) h(input.Ctx.WithBlockHeight(0), prevoteMsg) @@ -45,6 +49,8 @@ func TestOracleThreshold(t *testing.T) { salt = "2" bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[1]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[1], keeper.ValAddrs[1]) h(input.Ctx.WithBlockHeight(0), prevoteMsg) @@ -53,6 +59,8 @@ func TestOracleThreshold(t *testing.T) { salt = "3" bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[2]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[2], keeper.ValAddrs[2]) h(input.Ctx.WithBlockHeight(0), prevoteMsg) @@ -70,6 +78,8 @@ func TestOracleThreshold(t *testing.T) { salt = "1" bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[0]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[0], keeper.ValAddrs[0]) h(input.Ctx.WithBlockHeight(0), prevoteMsg) @@ -78,6 +88,8 @@ func TestOracleThreshold(t *testing.T) { salt = "2" bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[1]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[1], keeper.ValAddrs[1]) h(input.Ctx.WithBlockHeight(0), prevoteMsg) @@ -96,31 +108,43 @@ func TestOracleMultiVote(t *testing.T) { // Less than the threshold signs, msg fails salt := "1" bz, err := VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[0]) + require.NoError(t, err) + prevoteMsg := NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[0], keeper.ValAddrs[0]) res := h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[1]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[1], keeper.ValAddrs[1]) res = h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) bz, err = VoteHash(salt, randomPrice, core.MicroSDRDenom, keeper.ValAddrs[2]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[2], keeper.ValAddrs[2]) res = h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) bz, err = VoteHash(salt, anotherRandomPrice, core.MicroSDRDenom, keeper.ValAddrs[0]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[0], keeper.ValAddrs[0]) res = h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) bz, err = VoteHash(salt, anotherRandomPrice, core.MicroSDRDenom, keeper.ValAddrs[1]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[1], keeper.ValAddrs[1]) res = h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) bz, err = VoteHash(salt, anotherRandomPrice, core.MicroSDRDenom, keeper.ValAddrs[2]) + require.NoError(t, err) + prevoteMsg = NewMsgPricePrevote(hex.EncodeToString(bz), core.MicroSDRDenom, keeper.Addrs[2], keeper.ValAddrs[2]) res = h(input.Ctx, prevoteMsg) require.True(t, res.IsOK()) @@ -174,7 +198,7 @@ func TestOracleTally(t *testing.T) { salt := string(i) bz, err := VoteHash(salt, decPrice, core.MicroSDRDenom, valAddrs[i]) - require.Nil(t, err) + require.NoError(t, err) prevoteMsg := NewMsgPricePrevote( hex.EncodeToString(bz), @@ -317,7 +341,9 @@ func TestOracleMultiRewardDistribution(t *testing.T) { func makePrevoteAndVote(t *testing.T, input keeper.TestInput, h sdk.Handler, height int64, denom string, price sdk.Dec, idx int) { // Account 1, SDR salt := "1" - bz, _ := VoteHash(salt, price, denom, keeper.ValAddrs[idx]) + bz, err := VoteHash(salt, price, denom, keeper.ValAddrs[idx]) + require.NoError(t, err) + prevoteMsg := NewMsgPricePrevote(hex.EncodeToString(bz), denom, keeper.Addrs[idx], keeper.ValAddrs[idx]) res := h(input.Ctx.WithBlockHeight(height), prevoteMsg) require.True(t, res.IsOK()) diff --git a/x/oracle/internal/types/params.go b/x/oracle/internal/types/params.go index 4609fa83c..3dc8f3671 100644 --- a/x/oracle/internal/types/params.go +++ b/x/oracle/internal/types/params.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/params/subspace" ) -// DefaultParamspace +// DefaultParamspace defines default space for oracle params const DefaultParamspace = ModuleName // Parameter keys diff --git a/x/oracle/internal/types/querier.go b/x/oracle/internal/types/querier.go index e75476a57..9f4b23a55 100644 --- a/x/oracle/internal/types/querier.go +++ b/x/oracle/internal/types/querier.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// Defines the prefix of each query path const ( QueryParameters = "parameters" QueryPrice = "price" diff --git a/x/oracle/module.go b/x/oracle/module.go index 4994fa1bc..8d6e8ba7a 100644 --- a/x/oracle/module.go +++ b/x/oracle/module.go @@ -22,25 +22,26 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the oracle module. type AppModuleBasic struct{} -// module name +// Name returns the oracle module's name func (AppModuleBasic) Name() string { return ModuleName } -// register module codec +// RegisterCodec registers the oracle module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the oracle +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the oracle module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { var data GenesisState err := ModuleCdc.UnmarshalJSON(bz, &data) @@ -50,23 +51,24 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return ValidateGenesis(data) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the oracle module. func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { rest.RegisterRoutes(ctx, rtr) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the oracle module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return cli.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the oracle module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(cdc) } //___________________________ -// app module + +// AppModule implements an application module for the oracle module. type AppModule struct { AppModuleBasic keeper Keeper @@ -80,29 +82,29 @@ func NewAppModule(keeper Keeper) AppModule { } } -// module name +// Name returns the oracle module's name. func (AppModule) Name() string { return ModuleName } -// register invariants +// RegisterInvariants performs a no-op. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// module message route name +// Route returns the message routing key for the oracle module. func (AppModule) Route() string { return RouterKey } -// module handler +// NewHandler returns an sdk.Handler for the oracle module. func (am AppModule) NewHandler() sdk.Handler { return NewHandler(am.keeper) } -// module querier route name +// QuerierRoute returns the oracle module's querier route name. func (AppModule) QuerierRoute() string { return RouterKey } -// module querier +// NewQuerierHandler returns the oracle module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return NewQuerier(am.keeper) } -// module init-genesis +// InitGenesis performs genesis initialization for the oracle module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState ModuleCdc.MustUnmarshalJSON(data, &genesisState) @@ -111,18 +113,18 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the oracle +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { genesisState := ExportGenesis(ctx, am.keeper) data := ModuleCdc.MustMarshalJSON(genesisState) return data } -// module begin-block +// BeginBlock returns the begin blocker for the oracle module. func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} -// module end-block this should be called before staking module's EndBlock -// staking EndBlock will apply oracle slash validator update +// EndBlock returns the end blocker for the oracle module. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} diff --git a/x/params/internal/types/codec.go b/x/params/internal/types/codec.go index 72723877a..cc1cc352e 100644 --- a/x/params/internal/types/codec.go +++ b/x/params/internal/types/codec.go @@ -12,7 +12,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(params.ParameterChangeProposal{}, "params/ParameterChangeProposal", nil) } -// module codec +// ModuleCdc is the module codec var ModuleCdc *codec.Codec func init() { diff --git a/x/params/module.go b/x/params/module.go index 89344b9b9..3f7bc10f9 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -11,43 +11,44 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -// app module basics object +// AppModuleBasic defines the basic application module used by the slashing module. type AppModuleBasic struct{} var _ module.AppModuleBasic = AppModuleBasic{} -// module name +// Name returns the slashing module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the slashing module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the slashing +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the slashing module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the slashing module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the slashing module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the slashing module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } diff --git a/x/slashing/internal/types/codec.go b/x/slashing/internal/types/codec.go index 973f856cb..5e60ef867 100644 --- a/x/slashing/internal/types/codec.go +++ b/x/slashing/internal/types/codec.go @@ -5,12 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(slashing.MsgUnjail{}, "cosmos/MsgUnjail", nil) } -// module codec +// ModuleCdc defines module codec var ModuleCdc *codec.Codec func init() { diff --git a/x/slashing/module.go b/x/slashing/module.go index 3ae0ca8cd..2223e9fb6 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -21,49 +21,49 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the slashing module. type AppModuleBasic struct{} -var _ module.AppModuleBasic = AppModuleBasic{} - -// module name +// Name returns the slashing module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the slashing module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the slashing +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the slashing module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the slashing module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the slashing module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the slashing module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module for slashing + +// AppModule implements an application module for the slashing module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -77,48 +77,49 @@ func NewAppModule(keeper Keeper, stakingKeeper types.StakingKeeper) AppModule { } } -// module name +// Name returns the slashing module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the slashing module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the slashing module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the slashing module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the slashing module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the slashing module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the slashing module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the slashing +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the slashing module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the slashing module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/staking/internal/types/codec.go b/x/staking/internal/types/codec.go index ecf3805cb..d049a1643 100644 --- a/x/staking/internal/types/codec.go +++ b/x/staking/internal/types/codec.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(staking.MsgCreateValidator{}, "staking/MsgCreateValidator", nil) cdc.RegisterConcrete(staking.MsgEditValidator{}, "staking/MsgEditValidator", nil) @@ -14,7 +14,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(staking.MsgBeginRedelegate{}, "staking/MsgBeginRedelegate", nil) } -// generic sealed codec to be used throughout this module +// ModuleCdc is generic sealed codec to be used throughout this module var ModuleCdc *codec.Codec func init() { diff --git a/x/staking/module.go b/x/staking/module.go index f281b45dd..8ef57974e 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -26,23 +26,22 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the staking module. type AppModuleBasic struct{} -var _ module.AppModuleBasic = AppModuleBasic{} - -// module name +// Name returns the staking module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the staking module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the staking +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { // customize to set default genesis state bond denom to uluna defaultGenesisState := DefaultGenesisState() @@ -51,22 +50,22 @@ func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(defaultGenesisState) } -// module validate genesis +// ValidateGenesis performs genesis state validation for the staking module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the staking module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the staking module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the staking module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } @@ -93,7 +92,8 @@ func (AppModuleBasic) BuildCreateValidatorMsg(cliCtx context.CLIContext, } //___________________________ -// app module for staking + +// AppModule implements an application module for the staking module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -108,48 +108,50 @@ func NewAppModule(keeper Keeper, distrKeeper types.DistributionKeeper, accKeeper } } -// module name +// Name returns the staking module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the staking module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the staking module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the staking module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the staking module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the staking module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the staking module. It returns +// validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the staking +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the staking module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the staking module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/supply/module.go b/x/supply/module.go index f0faab192..7cb321c38 100644 --- a/x/supply/module.go +++ b/x/supply/module.go @@ -21,49 +21,51 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// app module basics object +// AppModuleBasic defines the basic application module used by the supply module. type AppModuleBasic struct{} var _ module.AppModuleBasic = AppModuleBasic{} -// module name +// Name returns the supply module's name func (AppModuleBasic) Name() string { return CosmosAppModuleBasic{}.Name() } -// register module codec +// RegisterCodec registers the supply module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) *CosmosModuleCdc = *ModuleCdc // nolint } -// default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the supply +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return CosmosAppModuleBasic{}.DefaultGenesis() } -// module validate genesis +// ValidateGenesis performs genesis state validation for the supply module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return CosmosAppModuleBasic{}.ValidateGenesis(bz) } -// register rest routes +// RegisterRESTRoutes registers the REST routes for the supply module. func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) } -// get the root tx command of this module +// GetTxCmd returns the root tx command for the supply module. func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetTxCmd(cdc) } -// get the root query command of this module +// GetQueryCmd returns the root query command for the supply module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return CosmosAppModuleBasic{}.GetQueryCmd(cdc) } //___________________________ -// app module for supply + +// AppModule implements an application module for the supply module. type AppModule struct { AppModuleBasic cosmosAppModule CosmosAppModule @@ -77,48 +79,49 @@ func NewAppModule(keeper Keeper, ak types.AccountKeeper) AppModule { } } -// module name +// Name returns the supply module's name. func (am AppModule) Name() string { return am.cosmosAppModule.Name() } -// register invariants +// RegisterInvariants registers the supply module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { am.cosmosAppModule.RegisterInvariants(ir) } -// module querier route name +// Route returns the message routing key for the supply module. func (am AppModule) Route() string { return am.cosmosAppModule.Route() } -// module handler +// NewHandler returns an sdk.Handler for the supply module. func (am AppModule) NewHandler() sdk.Handler { return am.cosmosAppModule.NewHandler() } -// module querier route name +// QuerierRoute returns the supply module's querier route name. func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } -// module querier +// NewQuerierHandler returns the supply module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } -// module init-genesis +// InitGenesis performs genesis initialization for the supply module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { return am.cosmosAppModule.InitGenesis(ctx, data) } -// module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the supply +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { return am.cosmosAppModule.ExportGenesis(ctx) } -// module begin-block +// BeginBlock returns the begin blocker for the supply module. func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { am.cosmosAppModule.BeginBlock(ctx, rbb) } -// module end-block +// EndBlock returns the end blocker for the supply module. func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { return am.cosmosAppModule.EndBlock(ctx, rbb) } diff --git a/x/treasury/client/rest/rest.go b/x/treasury/client/rest/rest.go index 9dc900136..6db3060b7 100644 --- a/x/treasury/client/rest/rest.go +++ b/x/treasury/client/rest/rest.go @@ -7,6 +7,7 @@ import ( govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" ) +// Defines whildcard part of the request paths const ( RestDenom = "denom" RestEpoch = "epoch" diff --git a/x/treasury/internal/types/codec.go b/x/treasury/internal/types/codec.go index 9a6fdd6bc..c43f511fe 100644 --- a/x/treasury/internal/types/codec.go +++ b/x/treasury/internal/types/codec.go @@ -6,13 +6,13 @@ import ( "github.com/terra-project/core/x/gov" ) -// Register concrete types on codec codec +// RegisterCodec registers concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(TaxRateUpdateProposal{}, "treasury/TaxRateUpdateProposal", nil) cdc.RegisterConcrete(RewardWeightUpdateProposal{}, "treasury/RewardWeightUpdateProposal", nil) } -// generic sealed codec to be used throughout module +// ModuleCdc defines generic sealed codec to be used throughout module var ModuleCdc *codec.Codec func init() { diff --git a/x/treasury/internal/types/params.go b/x/treasury/internal/types/params.go index c423da198..b5e6f0311 100644 --- a/x/treasury/internal/types/params.go +++ b/x/treasury/internal/types/params.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/params/subspace" ) -// DefaultParamspace +// DefaultParamspace defines default space for treasury params const DefaultParamspace = ModuleName // Parameter keys diff --git a/x/treasury/internal/types/querier.go b/x/treasury/internal/types/querier.go index 07520dc08..7649f91cf 100644 --- a/x/treasury/internal/types/querier.go +++ b/x/treasury/internal/types/querier.go @@ -18,6 +18,7 @@ type QueryTaxCapParams struct { Denom string } +// NewQueryTaxCapParams returns new QueryTaxCapParams instance func NewQueryTaxCapParams(denom string) QueryTaxCapParams { return QueryTaxCapParams{ Denom: denom, @@ -30,6 +31,7 @@ type QueryTaxRateParams struct { Epoch int64 } +// NewQueryTaxRateParams returns new QueryTaxRateParams instance func NewQueryTaxRateParams(epoch int64) QueryTaxRateParams { return QueryTaxRateParams{ Epoch: epoch, @@ -42,6 +44,7 @@ type QueryRewardWeightParams struct { Epoch int64 } +// NewQueryRewardWeightParams returns new QueryRewardWeightParams instance func NewQueryRewardWeightParams(epoch int64) QueryRewardWeightParams { return QueryRewardWeightParams{ Epoch: epoch, @@ -54,6 +57,7 @@ type QuerySeigniorageProceedsParams struct { Epoch int64 } +// NewQuerySeigniorageParams returns new QuerySeigniorageProceedsParams instance func NewQuerySeigniorageParams(epoch int64) QuerySeigniorageProceedsParams { return QuerySeigniorageProceedsParams{ Epoch: epoch, @@ -66,6 +70,7 @@ type QueryTaxProceedsParams struct { Epoch int64 } +// NewQueryTaxProceedsParams returns new QueryTaxProceedsParams instance func NewQueryTaxProceedsParams(epoch int64) QueryTaxProceedsParams { return QueryTaxProceedsParams{ Epoch: epoch, @@ -78,6 +83,7 @@ type QueryHistoricalIssuanceParams struct { Epoch int64 } +// NewQueryHistoricalIssuanceParams returns new QueryHistoricalIssuanceParams instance func NewQueryHistoricalIssuanceParams(epoch int64) QueryHistoricalIssuanceParams { return QueryHistoricalIssuanceParams{ Epoch: epoch, diff --git a/x/treasury/module.go b/x/treasury/module.go index fb469c8a5..30b2da9b1 100644 --- a/x/treasury/module.go +++ b/x/treasury/module.go @@ -22,25 +22,26 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// AppModuleBasic app module basics object +// AppModuleBasic defines the basic application module used by the treasury module. type AppModuleBasic struct{} -// Name returns module name +// Name returns the treasury module's name func (AppModuleBasic) Name() string { return ModuleName } -// RegisterCodec registers module codec +// RegisterCodec registers the treasury module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { RegisterCodec(cdc) } -// DefaultGenesis returns default genesis state +// DefaultGenesis returns default genesis state as raw bytes for the treasury +// module. func (AppModuleBasic) DefaultGenesis() json.RawMessage { return ModuleCdc.MustMarshalJSON(DefaultGenesisState()) } -// ValidateGenesis validates genesis +// ValidateGenesis performs genesis state validation for the treasury module. func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { var data GenesisState err := ModuleCdc.UnmarshalJSON(bz, &data) @@ -50,20 +51,20 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { return ValidateGenesis(data) } -// RegisterRESTRoutes registers rest routes +// RegisterRESTRoutes registers the REST routes for the treasury module. func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { rest.RegisterRoutes(ctx, rtr) } -// GetTxCmd gets the root tx command of this module +// GetTxCmd returns the root tx command for the treasury module. func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { return nil } -// GetQueryCmd gets the root query command of this module +// GetQueryCmd returns the root query command for the treasury module. func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(cdc) } -// AppModule app module +// AppModule implements an application module for the treasury module. type AppModule struct { AppModuleBasic @@ -78,29 +79,29 @@ func NewAppModule(keeper Keeper) AppModule { } } -// Name returns module name +// Name returns the treasury module's name. func (AppModule) Name() string { return ModuleName } -// RegisterInvariants registers invariants +// RegisterInvariants registers the treasury module invariants. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Route module message route name +// Route returns the message routing key for the treasury module. func (AppModule) Route() string { return RouterKey } -// NewHandler module handler +// NewHandler returns an sdk.Handler for the treasury module. func (am AppModule) NewHandler() sdk.Handler { return nil } -// QuerierRoute module querier route name +// QuerierRoute returns the treasury module's querier route name. func (AppModule) QuerierRoute() string { return RouterKey } -// NewQuerierHandler module querier +// NewQuerierHandler returns the treasury module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { return NewQuerier(am.keeper) } -// InitGenesis module init-genesis +// InitGenesis performs genesis initialization for the treasury module. func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState ModuleCdc.MustUnmarshalJSON(data, &genesisState) @@ -108,17 +109,18 @@ func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.Va return []abci.ValidatorUpdate{} } -// ExportGenesis module export genesis +// ExportGenesis returns the exported genesis state as raw bytes for the treasury +// module. func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { genesisState := ExportGenesis(ctx, am.keeper) data := ModuleCdc.MustMarshalJSON(genesisState) return data } -// BeginBlock module begin-block +// BeginBlock returns the begin blocker for the treasury module. func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {} -// EndBlock module end-block +// EndBlock returns the end blocker for the treasury module. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{}