Skip to content

Commit

Permalink
fix(mint): make linter more happy
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Nov 30, 2022
1 parent fb52e07 commit 35bed9f
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions x/mint/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
)

// InitGenesis new mint genesis.
func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
keeper.SetMinter(ctx, data.Minter)
keeper.SetParams(ctx, data.Params)
func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
k.SetMinter(ctx, data.Minter)
k.SetParams(ctx, data.Params)
ak.GetModuleAccount(ctx, types.ModuleName)
}

// ExportGenesis returns a GenesisState for a given context and keeper.
func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
minter := keeper.GetMinter(ctx)
params := keeper.GetParams(ctx)
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
minter := k.GetMinter(ctx)
params := k.GetParams(ctx)
return types.NewGenesisState(minter, params)
}
3 changes: 2 additions & 1 deletion x/mint/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func (k Keeper) Inflation(c context.Context, _ *types.QueryInflationRequest) (*t
}

// AnnualProvisions returns minter.AnnualProvisions of the mint module.
func (k Keeper) AnnualProvisions(c context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) {
func (k Keeper) AnnualProvisions(c context.Context,
_ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
minter := k.GetMinter(ctx)

Expand Down
4 changes: 2 additions & 2 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+types.ModuleName)
}

// get the minter.
// GetMinter get the minter.
func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
store := ctx.KVStore(k.storeKey)
b := store.Get(types.MinterKey)
Expand All @@ -64,7 +64,7 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
return
}

// set the minter.
// SetMinter set the minter.
func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) {
store := ctx.KVStore(k.storeKey)
b := k.cdc.MustMarshal(&minter)
Expand Down
10 changes: 9 additions & 1 deletion x/mint/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import (
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
db := dbm.NewMemDB()
encCdc := simapp.MakeTestEncodingConfig()
app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 5, encCdc, simapp.EmptyAppOptions{})
app := simapp.NewSimApp(log.NewNopLogger(),
db,
nil,
true,
map[int64]bool{},
simapp.DefaultNodeHome,
5,
encCdc,
simapp.EmptyAppOptions{})

genesisState := simapp.GenesisStateWithSingleValidator(t, app)
stateBytes, err := tmjson.Marshal(genesisState)
Expand Down
1 change: 1 addition & 0 deletions x/mint/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GenAnnualReductionFactorMax(r *rand.Rand) sdk.Dec {
}

// RandomizedGenState generates a random GenesisState for mint.
//nolint: forbidigo
func RandomizedGenState(simState *module.SimulationState) {
// minter
var inflation sdk.Dec
Expand Down
7 changes: 5 additions & 2 deletions x/mint/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint: gosec
package simulation_test

import (
Expand Down Expand Up @@ -46,8 +47,10 @@ func TestRandomizedGenState(t *testing.T) {
require.Equal(t, uint64(6311520), mintGenesis.Params.BlocksPerYear)
require.Equal(t, dec1, mintGenesis.Params.AnnualReductionFactor)
require.Equal(t, "stake", mintGenesis.Params.MintDenom)
require.Equal(t, "0stake", mintGenesis.Minter.BlockProvision(mintGenesis.Params, simState.InitialStake).String())
require.Equal(t, "170.000000000000000000", mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, simState.InitialStake).String())
require.Equal(t, "0stake",
mintGenesis.Minter.BlockProvision(mintGenesis.Params, simState.InitialStake).String())
require.Equal(t, "170.000000000000000000",
mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, simState.InitialStake).String())
require.Equal(t, "0.136000000000000000", mintGenesis.Minter.NextInflation(mintGenesis.Params).String())
require.Equal(t, "0.170000000000000000", mintGenesis.Minter.Inflation.String())
require.Equal(t, "170.000000000000000000", mintGenesis.Minter.AnnualProvisions.String())
Expand Down
1 change: 1 addition & 0 deletions x/mint/simulation/params_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// nolint: gosec
package simulation_test

import (
Expand Down
1 change: 1 addition & 0 deletions x/mint/types/minter_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// nolint: gosec
package types

import (
Expand Down

0 comments on commit 35bed9f

Please sign in to comment.