Skip to content

Commit

Permalink
Fix golint (#135)
Browse files Browse the repository at this point in the history
* fix golint

* fix golint

* gofmt

* unused-para

* unused-para

* math.Int

* warning
  • Loading branch information
anhductn2001 committed May 26, 2023
1 parent 4ee958f commit 806f431
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 39 deletions.
1 change: 0 additions & 1 deletion x/mint/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio

// send the minted coins to the fee collector account
err := k.AddCollectedFees(ctx, mintedCoins)

if err != nil {
return
}
Expand Down
5 changes: 3 additions & 2 deletions x/mint/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand All @@ -10,10 +11,10 @@ import (
// bondedRatio and returns the newly calculated inflation rate.
// It can be used to specify a custom inflation calculation logic, instead of relying on the
// default logic provided by the sdk.
type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, totalStakingSupply sdk.Int) sdk.Dec
type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, totalStakingSupply math.Int) sdk.Dec

// DefaultInflationCalculationFn is the default function used to calculate inflation.
func DefaultInflationCalculationFn(_ sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, totalStakingSupply sdk.Int) sdk.Dec {
func DefaultInflationCalculationFn(_ sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, totalStakingSupply math.Int) sdk.Dec {
return minter.NextInflationRate(params, bondedRatio, totalStakingSupply)
}

Expand Down
2 changes: 1 addition & 1 deletion x/mint/types/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ValidateMinter(minter Minter) error {
}

// NextInflationRate returns the new inflation rate for the next hour.
func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec, totalStakingSupply sdk.Int) sdk.Dec {
func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec, totalStakingSupply math.Int) sdk.Dec {
totalStakingSupplyDec := sdk.NewDecFromInt(totalStakingSupply)

// The target annual inflation rate is recalculated for each previsions cycle. The
Expand Down
65 changes: 33 additions & 32 deletions x/mint/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"sigs.k8s.io/yaml"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
Expand All @@ -28,7 +29,7 @@ func ParamKeyTable() paramtypes.KeyTable {
}

func NewParams(
mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, tokenPerYear sdk.Int,
mintDenom string, inflationRateChange, _, _, goalBonded sdk.Dec, blocksPerYear uint64, tokenPerYear math.Int,
) Params {
return Params{
MintDenom: mintDenom,
Expand Down Expand Up @@ -126,37 +127,37 @@ func validateInflationRateChange(i interface{}) error {
return nil
}

func validateInflationMax(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v.IsNegative() {
return fmt.Errorf("max inflation cannot be negative: %s", v)
}
if v.GT(sdk.OneDec()) {
return fmt.Errorf("max inflation too large: %s", v)
}

return nil
}

func validateInflationMin(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v.IsNegative() {
return fmt.Errorf("min inflation cannot be negative: %s", v)
}
if v.GT(sdk.OneDec()) {
return fmt.Errorf("min inflation too large: %s", v)
}

return nil
}
// func validateInflationMax(i interface{}) error {
// v, ok := i.(sdk.Dec)
// if !ok {
// return fmt.Errorf("invalid parameter type: %T", i)
// }

// if v.IsNegative() {
// return fmt.Errorf("max inflation cannot be negative: %s", v)
// }
// if v.GT(sdk.OneDec()) {
// return fmt.Errorf("max inflation too large: %s", v)
// }

// return nil
// }

// func validateInflationMin(i interface{}) error {
// v, ok := i.(sdk.Dec)
// if !ok {
// return fmt.Errorf("invalid parameter type: %T", i)
// }

// if v.IsNegative() {
// return fmt.Errorf("min inflation cannot be negative: %s", v)
// }
// if v.GT(sdk.OneDec()) {
// return fmt.Errorf("min inflation too large: %s", v)
// }

// return nil
// }

func validateGoalBonded(i interface{}) error {
v, ok := i.(sdk.Dec)
Expand Down
2 changes: 1 addition & 1 deletion x/transfermiddleware/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GetCmdParaTokenInfo() *cobra.Command {
Use: "para-token-info",
Short: "Query the current transfer middleware para-token-info based on denom",
Long: "Query the current transfer middleware para-token-info based on denom",
Args: cobra.ExactValidArgs(1),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Example: fmt.Sprintf("%s query transfermiddleware para-token-info atom", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand Down
2 changes: 1 addition & 1 deletion x/transfermiddleware/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
}

// ValidateGenesis performs genesis state validation for the mint module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
var data types.GenesisState
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
Expand Down
2 changes: 1 addition & 1 deletion x/transfermiddleware/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ func DefaultGenesisState() *GenesisState {

// ValidateGenesis validates the provided genesis state to ensure the
// expected invariants holds.
func ValidateGenesis(data GenesisState) error {
func ValidateGenesis(_ GenesisState) error {
return nil
}

0 comments on commit 806f431

Please sign in to comment.