diff --git a/app/testsuite/helpers.go b/app/testsuite/helpers.go index 39828006d0..502cc3e7dc 100644 --- a/app/testsuite/helpers.go +++ b/app/testsuite/helpers.go @@ -179,7 +179,7 @@ func genesisStateWithValSet(t *testing.T, type EmptyAppOptions struct{} // Get implements AppOptions -func (ao EmptyAppOptions) Get(o string) interface{} { +func (ao EmptyAppOptions) Get(_ string) interface{} { return nil } diff --git a/x/data/genesis/genesis.go b/x/data/genesis/genesis.go index 2e73f627bd..87ff438de7 100644 --- a/x/data/genesis/genesis.go +++ b/x/data/genesis/genesis.go @@ -42,11 +42,7 @@ func ValidateGenesis(jsonData json.RawMessage) error { return err } - if err := moduleDB.ValidateJSON(jsonSource); err != nil { - return err - } - - return nil + return moduleDB.ValidateJSON(jsonSource) } func validateMsg(m proto.Message) error { diff --git a/x/data/module/module.go b/x/data/module/module.go index 5770b0b803..5286f4027f 100644 --- a/x/data/module/module.go +++ b/x/data/module/module.go @@ -67,7 +67,7 @@ func (a Module) QuerierRoute() string { return data.ModuleName } -func (a Module) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { +func (a Module) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } @@ -97,9 +97,11 @@ func (a Module) RegisterInterfaces(registry types.InterfaceRegistry) { data.RegisterTypes(registry) } -//nolint func (a Module) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - data.RegisterQueryHandlerClient(context.Background(), mux, data.NewQueryClient(clientCtx)) + err := data.RegisterQueryHandlerClient(context.Background(), mux, data.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } } func (a Module) DefaultGenesis(codec.JSONCodec) json.RawMessage { @@ -169,17 +171,17 @@ func (Module) GenerateGenesisState(simState *module.SimulationState) { // ProposalContents returns all the data content functions used to // simulate proposals. -func (Module) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { +func (Module) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { return nil } // RandomizedParams creates randomized data param changes for the simulator. -func (Module) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { +func (Module) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { return nil } // RegisterStoreDecoder registers a decoder for data module's types -func (Module) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (Module) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } // WeightedOperations returns all the data module operations with their respective weights. diff --git a/x/data/server/genesis.go b/x/data/server/genesis.go index 26cd9f96ae..bab6bf2772 100644 --- a/x/data/server/genesis.go +++ b/x/data/server/genesis.go @@ -11,7 +11,7 @@ import ( // InitGenesis performs genesis initialization for the data module. It // returns no validator updates. -func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) { +func (s serverImpl) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) { jsonSource, err := ormjson.NewRawMessageSource(data) if err != nil { return nil, err @@ -26,7 +26,7 @@ func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } // ExportGenesis will dump the data module state into a serializable GenesisState. -func (s serverImpl) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) (json.RawMessage, error) { +func (s serverImpl) ExportGenesis(ctx sdk.Context, _ codec.JSONCodec) (json.RawMessage, error) { jsonTarget := ormjson.NewRawMessageTarget() err := s.db.ExportJSON(sdk.WrapSDKContext(ctx), jsonTarget) if err != nil { diff --git a/x/ecocredit/base/keeper/msg_send.go b/x/ecocredit/base/keeper/msg_send.go index 925207a3d2..2651079bd8 100644 --- a/x/ecocredit/base/keeper/msg_send.go +++ b/x/ecocredit/base/keeper/msg_send.go @@ -190,17 +190,13 @@ func (k Keeper) sendTradable(ctx context.Context, params sendParams) error { } // update recipient balance with new tradable amount - if err := k.stateStore.BatchBalanceTable().Save(ctx, &api.BatchBalance{ + return k.stateStore.BatchBalanceTable().Save(ctx, &api.BatchBalance{ BatchKey: params.batchKey, Address: params.recipient, TradableAmount: newRecipientTradable.String(), RetiredAmount: recipientBalance.RetiredAmount, EscrowedAmount: recipientBalance.EscrowedAmount, - }); err != nil { - return err - } - - return nil + }) } func (k Keeper) sendRetired(ctx sdk.Context, params sendParams) error { @@ -306,14 +302,10 @@ func (k Keeper) sendRetired(ctx sdk.Context, params sendParams) error { } // update batch supply with new tradable and retired amounts - if err := k.stateStore.BatchSupplyTable().Update(ctx, &api.BatchSupply{ + return k.stateStore.BatchSupplyTable().Update(ctx, &api.BatchSupply{ BatchKey: params.batchKey, TradableAmount: newSupplyTradable.String(), RetiredAmount: newSupplyRetired.String(), CancelledAmount: batchSupply.CancelledAmount, - }); err != nil { - return err - } - - return nil + }) } diff --git a/x/ecocredit/base/keeper/query_class_creator_allowlist.go b/x/ecocredit/base/keeper/query_class_creator_allowlist.go index aa35c0e2e3..d2757dbf92 100644 --- a/x/ecocredit/base/keeper/query_class_creator_allowlist.go +++ b/x/ecocredit/base/keeper/query_class_creator_allowlist.go @@ -8,7 +8,7 @@ import ( ) // ClassCreatorAllowlist queries credit class allowlist setting. -func (k Keeper) ClassCreatorAllowlist(ctx context.Context, request *types.QueryClassCreatorAllowlistRequest) (*types.QueryClassCreatorAllowlistResponse, error) { +func (k Keeper) ClassCreatorAllowlist(ctx context.Context, _ *types.QueryClassCreatorAllowlistRequest) (*types.QueryClassCreatorAllowlistResponse, error) { result, err := k.stateStore.ClassCreatorAllowlistTable().Get(ctx) if err != nil { return nil, regenerrors.ErrInternal.Wrapf("failed to get class creator allowlist: %s", err.Error()) diff --git a/x/ecocredit/base/keeper/query_class_fee.go b/x/ecocredit/base/keeper/query_class_fee.go index 0498fd066c..bff46a612b 100644 --- a/x/ecocredit/base/keeper/query_class_fee.go +++ b/x/ecocredit/base/keeper/query_class_fee.go @@ -11,7 +11,7 @@ import ( ) // ClassFee queries credit class creation fees. -func (k Keeper) ClassFee(ctx context.Context, request *types.QueryClassFeeRequest) (*types.QueryClassFeeResponse, error) { +func (k Keeper) ClassFee(ctx context.Context, _ *types.QueryClassFeeRequest) (*types.QueryClassFeeResponse, error) { classFee, err := k.stateStore.ClassFeeTable().Get(ctx) if err != nil { return nil, regenerrors.ErrInternal.Wrapf("failed to get class fee: %s", err.Error()) diff --git a/x/ecocredit/base/simulation/msg_add_class_creator.go b/x/ecocredit/base/simulation/msg_add_class_creator.go index 5b20931872..c82c09cfe3 100644 --- a/x/ecocredit/base/simulation/msg_add_class_creator.go +++ b/x/ecocredit/base/simulation/msg_add_class_creator.go @@ -59,13 +59,13 @@ func SimulateMsgAddClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.BankKee Creator: proposerAddr, } - any, err := codectypes.NewAnyWithValue(&proposalMsg) + anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgAddClassCreator, err.Error()), nil, err } msg := &govtypes.MsgSubmitProposal{ - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/ecocredit/base/simulation/msg_add_credit_type.go b/x/ecocredit/base/simulation/msg_add_credit_type.go index 347331e68d..f8cea64189 100644 --- a/x/ecocredit/base/simulation/msg_add_credit_type.go +++ b/x/ecocredit/base/simulation/msg_add_credit_type.go @@ -70,13 +70,13 @@ func SimulateMsgAddCreditType(ak ecocredit.AccountKeeper, bk ecocredit.BankKeepe }, } - any, err := codectypes.NewAnyWithValue(&proposalMsg) + anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgAddCreditType, err.Error()), nil, err } msg := &govtypes.MsgSubmitProposal{ - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/ecocredit/base/simulation/msg_remove_class_creator.go b/x/ecocredit/base/simulation/msg_remove_class_creator.go index 4e9e22e856..0953e3e825 100644 --- a/x/ecocredit/base/simulation/msg_remove_class_creator.go +++ b/x/ecocredit/base/simulation/msg_remove_class_creator.go @@ -59,13 +59,13 @@ func SimulateMsgRemoveClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.Bank Creator: proposerAddr, } - any, err := codectypes.NewAnyWithValue(&proposalMsg) + anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgRemoveClassCreator, err.Error()), nil, err } msg := &govtypes.MsgSubmitProposal{ - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/ecocredit/base/simulation/msg_set_class_creator_allowlist.go b/x/ecocredit/base/simulation/msg_set_class_creator_allowlist.go index ed7729f524..fe59962f84 100644 --- a/x/ecocredit/base/simulation/msg_set_class_creator_allowlist.go +++ b/x/ecocredit/base/simulation/msg_set_class_creator_allowlist.go @@ -24,7 +24,7 @@ const WeightSetClassCreatorAllowlist = 33 // SimulateMsgSetClassCreatorAllowlist generates a MsgSetClassCreatorAllowlist with random values. func SimulateMsgSetClassCreatorAllowlist(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, govk ecocredit.GovKeeper, - qryClient types.QueryServer, authority sdk.AccAddress) simtypes.Operation { + _ types.QueryServer, authority sdk.AccAddress) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -50,13 +50,13 @@ func SimulateMsgSetClassCreatorAllowlist(ak ecocredit.AccountKeeper, bk ecocredi Enabled: r.Float32() < 0.3, // 30% chance of allowlist being enabled, } - any, err := codectypes.NewAnyWithValue(&proposalMsg) + anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgSetClassCreatorAllowlist, err.Error()), nil, err } msg := &govtypes.MsgSubmitProposal{ - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/ecocredit/base/simulation/msg_update_class_fee.go b/x/ecocredit/base/simulation/msg_update_class_fee.go index 37466ffde2..66c7a4caa6 100644 --- a/x/ecocredit/base/simulation/msg_update_class_fee.go +++ b/x/ecocredit/base/simulation/msg_update_class_fee.go @@ -24,7 +24,7 @@ const WeightUpdateClassFee = 33 // SimulateMsgUpdateClassFee generates a MsgToggleClassAllowlist with random values. func SimulateMsgUpdateClassFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, govk ecocredit.GovKeeper, - qryClient types.QueryServer, authority sdk.AccAddress) simtypes.Operation { + _ types.QueryServer, authority sdk.AccAddress) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -55,13 +55,13 @@ func SimulateMsgUpdateClassFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeep Fee: &fee, } - any, err := codectypes.NewAnyWithValue(&proposalMsg) + anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgUpdateClassFee, err.Error()), nil, err } msg := &govtypes.MsgSubmitProposal{ - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/ecocredit/base/simulation/operations.go b/x/ecocredit/base/simulation/operations.go index 390f1d526f..bf8ac7ed4d 100644 --- a/x/ecocredit/base/simulation/operations.go +++ b/x/ecocredit/base/simulation/operations.go @@ -29,8 +29,8 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, govk ecocredit.GovKeeper, - qryClient types.QueryServer, basketQryClient baskettypes.QueryServer, - mktQryClient markettypes.QueryServer, authority sdk.AccAddress) simulation.WeightedOperations { + qryClient types.QueryServer, _ baskettypes.QueryServer, + _ markettypes.QueryServer, authority sdk.AccAddress) simulation.WeightedOperations { var ( weightMsgCreateClass int diff --git a/x/ecocredit/base/types/v1/msg_bridge_receive.go b/x/ecocredit/base/types/v1/msg_bridge_receive.go index d3e2dcda8e..cdd363fb24 100644 --- a/x/ecocredit/base/types/v1/msg_bridge_receive.go +++ b/x/ecocredit/base/types/v1/msg_bridge_receive.go @@ -122,11 +122,7 @@ func (m *MsgBridgeReceive) ValidateBasic() error { } // basic origin tx validation (includes valid ethereum contract address if contract is not empty) - if err := m.OriginTx.Validate(); err != nil { - return err - } - - return nil + return m.OriginTx.Validate() } // GetSigners returns the expected signers for MsgCancel. diff --git a/x/ecocredit/base/types/v1/params.go b/x/ecocredit/base/types/v1/params.go index 6effaa3754..fb63c39806 100644 --- a/x/ecocredit/base/types/v1/params.go +++ b/x/ecocredit/base/types/v1/params.go @@ -52,11 +52,7 @@ func (p Params) Validate() error { return err } - if err := validateBasketFee(p.BasketFee); err != nil { - return err - } - - return nil + return validateBasketFee(p.BasketFee) } func validateCreditClassFee(i interface{}) error { @@ -65,11 +61,7 @@ func validateCreditClassFee(i interface{}) error { return sdkerrors.ErrInvalidType.Wrapf("invalid parameter type: %T", i) } - if err := v.Validate(); err != nil { - return err - } - - return nil + return v.Validate() } func validateAllowedClassCreators(i interface{}) error { @@ -101,11 +93,7 @@ func validateBasketFee(i interface{}) error { return sdkerrors.ErrInvalidType.Wrapf("invalid parameter type: %T", i) } - if err := v.Validate(); err != nil { - return err - } - - return nil + return v.Validate() } // NewParams creates a new Params object. diff --git a/x/ecocredit/basket/keeper/msg_put.go b/x/ecocredit/basket/keeper/msg_put.go index 1f36223710..4be20e9349 100644 --- a/x/ecocredit/basket/keeper/msg_put.go +++ b/x/ecocredit/basket/keeper/msg_put.go @@ -212,8 +212,6 @@ func (k Keeper) transferToBasket(ctx context.Context, sender sdk.AccAddress, amt } bal.Balance = newBalance.String() } - if err = k.stateStore.BasketBalanceTable().Save(ctx, bal); err != nil { - return err - } - return nil + + return k.stateStore.BasketBalanceTable().Save(ctx, bal) } diff --git a/x/ecocredit/basket/keeper/msg_take.go b/x/ecocredit/basket/keeper/msg_take.go index 955d6b2a68..0bb2ec05c6 100644 --- a/x/ecocredit/basket/keeper/msg_take.go +++ b/x/ecocredit/basket/keeper/msg_take.go @@ -141,39 +141,39 @@ func (k Keeper) Take(ctx context.Context, msg *types.MsgTake) (*types.MsgTakeRes } break - } else { - credits = append(credits, &types.BasketCredit{ - BatchDenom: basketBalance.BatchDenom, - Amount: balance.String(), - }) + } - err = k.addCreditBalance( - ctx, - acct, - basketBalance.BatchDenom, - balance, - retire, - retirementJurisdiction, - msg.RetirementReason, - ) - if err != nil { - return nil, err - } + credits = append(credits, &types.BasketCredit{ + BatchDenom: basketBalance.BatchDenom, + Amount: balance.String(), + }) - err = k.stateStore.BasketBalanceTable().Delete(ctx, basketBalance) - if err != nil { - return nil, err - } + err = k.addCreditBalance( + ctx, + acct, + basketBalance.BatchDenom, + balance, + retire, + retirementJurisdiction, + msg.RetirementReason, + ) + if err != nil { + return nil, err + } - // basket balance == credits needed - if cmp == 0 { - break - } + err = k.stateStore.BasketBalanceTable().Delete(ctx, basketBalance) + if err != nil { + return nil, err + } - amountCreditsNeeded, err = amountCreditsNeeded.Sub(balance) - if err != nil { - return nil, err - } + // basket balance == credits needed + if cmp == 0 { + break + } + + amountCreditsNeeded, err = amountCreditsNeeded.Sub(balance) + if err != nil { + return nil, err } sdkCtx.GasMeter().ConsumeGas(ecocredit.GasCostPerIteration, "ecocredit/basket/MsgTake balance iteration") diff --git a/x/ecocredit/basket/keeper/query_fees.go b/x/ecocredit/basket/keeper/query_fees.go index 83ca366a27..d2ccf0ca60 100644 --- a/x/ecocredit/basket/keeper/query_fees.go +++ b/x/ecocredit/basket/keeper/query_fees.go @@ -10,7 +10,7 @@ import ( types "github.com/regen-network/regen-ledger/x/ecocredit/v3/basket/types/v1" ) -func (k Keeper) BasketFee(ctx context.Context, req *types.QueryBasketFeeRequest) (*types.QueryBasketFeeResponse, error) { +func (k Keeper) BasketFee(ctx context.Context, _ *types.QueryBasketFeeRequest) (*types.QueryBasketFeeResponse, error) { basketFee, err := k.stateStore.BasketFeeTable().Get(ctx) if err != nil { return nil, regenerrors.ErrInternal.Wrap(err.Error()) diff --git a/x/ecocredit/basket/simulation/msg_take.go b/x/ecocredit/basket/simulation/msg_take.go index 9ab1bf1527..0f5995fdc1 100644 --- a/x/ecocredit/basket/simulation/msg_take.go +++ b/x/ecocredit/basket/simulation/msg_take.go @@ -25,7 +25,7 @@ var TypeMsgTake = types.MsgTake{}.Route() // SimulateMsgTake generates a Basket/MsgTake with random values. func SimulateMsgTake(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, - qryClient basetypes.QueryServer, bsktQryClient types.QueryServer) simtypes.Operation { + _ basetypes.QueryServer, bsktQryClient types.QueryServer) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { diff --git a/x/ecocredit/basket/simulation/msg_update_basket_fees.go b/x/ecocredit/basket/simulation/msg_update_basket_fees.go index bd97bb1447..60fb20c976 100644 --- a/x/ecocredit/basket/simulation/msg_update_basket_fees.go +++ b/x/ecocredit/basket/simulation/msg_update_basket_fees.go @@ -24,8 +24,8 @@ var TypeMsgUpdateBasketFee = types.MsgUpdateBasketFee{}.Route() const WeightUpdateBasketFees = 100 // SimulateMsgUpdateBasketFee generates a Basket/MsgUpdateBasketFee with random values. -func SimulateMsgUpdateBasketFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, qryClient basetypes.QueryServer, - basketQryClient types.QueryServer, govk ecocredit.GovKeeper, authority sdk.AccAddress) simtypes.Operation { +func SimulateMsgUpdateBasketFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, _ basetypes.QueryServer, + _ types.QueryServer, govk ecocredit.GovKeeper, authority sdk.AccAddress) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -57,7 +57,7 @@ func SimulateMsgUpdateBasketFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKee Fee: &fee, } - any, err := codectypes.NewAnyWithValue(&msg) + anyMsg, err := codectypes.NewAnyWithValue(&msg) if err != nil { return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgUpdateBasketFee, err.Error()), nil, err } @@ -66,7 +66,7 @@ func SimulateMsgUpdateBasketFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKee InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, } txCtx := simulation.OperationInput{ diff --git a/x/ecocredit/genesis/genesis.go b/x/ecocredit/genesis/genesis.go index d04eb5a0b5..50eba85c88 100644 --- a/x/ecocredit/genesis/genesis.go +++ b/x/ecocredit/genesis/genesis.go @@ -233,11 +233,7 @@ func ValidateGenesis(data json.RawMessage) error { } // verify calculated total amount of each credit batch matches the total supply - if err := validateSupply(batchIDToCalSupply, batchIDToSupply); err != nil { - return err - } - - return nil + return validateSupply(batchIDToCalSupply, batchIDToSupply) } func validateMsg(m proto.Message) error { diff --git a/x/ecocredit/marketplace/simulation/msg_add_allowed_denom.go b/x/ecocredit/marketplace/simulation/msg_add_allowed_denom.go index 495ad8e547..55103e80da 100644 --- a/x/ecocredit/marketplace/simulation/msg_add_allowed_denom.go +++ b/x/ecocredit/marketplace/simulation/msg_add_allowed_denom.go @@ -63,7 +63,7 @@ func SimulateMsgAddAllowedDenom(ak ecocredit.AccountKeeper, bk ecocredit.BankKee Exponent: 6, } - any, err := codectypes.NewAnyWithValue(&msg) + anyMsg, err := codectypes.NewAnyWithValue(&msg) if err != nil { return simtypes.NoOpMsg(TypeMsgAddAllowedDenom, TypeMsgAddAllowedDenom, err.Error()), nil, err } @@ -72,7 +72,7 @@ func SimulateMsgAddAllowedDenom(ak ecocredit.AccountKeeper, bk ecocredit.BankKee InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, } txCtx := simulation.OperationInput{ diff --git a/x/ecocredit/marketplace/simulation/msg_buy_direct.go b/x/ecocredit/marketplace/simulation/msg_buy_direct.go index a3115dec7b..6c041e3488 100644 --- a/x/ecocredit/marketplace/simulation/msg_buy_direct.go +++ b/x/ecocredit/marketplace/simulation/msg_buy_direct.go @@ -24,7 +24,7 @@ var TypeMsgBuyDirect = types.MsgBuyDirect{}.Route() // SimulateMsgBuyDirect generates a Marketplace/MsgBuyDirect with random values. func SimulateMsgBuyDirect(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, - qryClient basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { + _ basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { diff --git a/x/ecocredit/marketplace/simulation/msg_cancel_sell_order.go b/x/ecocredit/marketplace/simulation/msg_cancel_sell_order.go index 0418ea5cec..2570e29a24 100644 --- a/x/ecocredit/marketplace/simulation/msg_cancel_sell_order.go +++ b/x/ecocredit/marketplace/simulation/msg_cancel_sell_order.go @@ -23,7 +23,7 @@ var TypeMsgCancelSellOrder = types.MsgCancelSellOrder{}.Route() // SimulateMsgCancelSellOrder generates a Marketplace/MsgCancelSellOrder with random values. func SimulateMsgCancelSellOrder(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, - qryClient basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { + _ basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { diff --git a/x/ecocredit/marketplace/simulation/msg_remove_allowed_denom.go b/x/ecocredit/marketplace/simulation/msg_remove_allowed_denom.go index 90b874b9f6..e71ed2073e 100644 --- a/x/ecocredit/marketplace/simulation/msg_remove_allowed_denom.go +++ b/x/ecocredit/marketplace/simulation/msg_remove_allowed_denom.go @@ -59,7 +59,7 @@ func SimulateMsgRemoveAllowedDenom(ak ecocredit.AccountKeeper, bk ecocredit.Bank Denom: response.AllowedDenoms[r.Intn(len(response.AllowedDenoms))].BankDenom, } - any, err := codectypes.NewAnyWithValue(&msg) + anyMsg, err := codectypes.NewAnyWithValue(&msg) if err != nil { return simtypes.NoOpMsg(TypeMsgAddAllowedDenom, TypeMsgAddAllowedDenom, err.Error()), nil, err } @@ -68,7 +68,7 @@ func SimulateMsgRemoveAllowedDenom(ak ecocredit.AccountKeeper, bk ecocredit.Bank InitialDeposit: deposit, Proposer: proposerAddr, Metadata: simtypes.RandStringOfLength(r, 10), - Messages: []*codectypes.Any{any}, + Messages: []*codectypes.Any{anyMsg}, } txCtx := simulation.OperationInput{ diff --git a/x/ecocredit/marketplace/simulation/msg_update_sell_order.go b/x/ecocredit/marketplace/simulation/msg_update_sell_order.go index e8d614abb3..68682e7ab9 100644 --- a/x/ecocredit/marketplace/simulation/msg_update_sell_order.go +++ b/x/ecocredit/marketplace/simulation/msg_update_sell_order.go @@ -25,7 +25,7 @@ var TypeMsgUpdateSellOrder = types.MsgUpdateSellOrders{}.Route() // SimulateMsgUpdateSellOrder generates a Marketplace/MsgUpdateSellOrder with random values. func SimulateMsgUpdateSellOrder(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, - baseQryClient basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { + _ basetypes.QueryServer, mktQryClient types.QueryServer) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { diff --git a/x/ecocredit/module/abci.go b/x/ecocredit/module/abci.go index f78605cc3b..31d25201df 100644 --- a/x/ecocredit/module/abci.go +++ b/x/ecocredit/module/abci.go @@ -14,9 +14,5 @@ import ( func BeginBlocker(ctx sdk.Context, k server.Keeper) error { defer telemetry.ModuleMeasureSince(ecocredit.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - if err := k.PruneOrders(ctx); err != nil { - return err - } - - return nil + return k.PruneOrders(ctx) } diff --git a/x/ecocredit/orderbook/orderbook.go b/x/ecocredit/orderbook/orderbook.go index dbd1508a6a..6e412091ac 100644 --- a/x/ecocredit/orderbook/orderbook.go +++ b/x/ecocredit/orderbook/orderbook.go @@ -62,14 +62,14 @@ func (o orderbook) OnInsertBuyOrder(ctx context.Context, buyOrder *marketplacev1 } */ -func (o orderbook) OnInsertSellOrder(ctx context.Context, sellOrder *marketplacev1.SellOrder, batch *ecocreditv1.Batch) error { +func (o orderbook) OnInsertSellOrder(_ context.Context, _ *marketplacev1.SellOrder, _ *ecocreditv1.Batch) error { return nil } -func (o orderbook) ProcessBatch(ctx context.Context) error { +func (o orderbook) ProcessBatch(_ context.Context) error { return nil } -func (o orderbook) Reload(ctx context.Context) error { +func (o orderbook) Reload(_ context.Context) error { return nil } diff --git a/x/ecocredit/server/genesis.go b/x/ecocredit/server/genesis.go index fd7e6f0fe6..4e3f784468 100644 --- a/x/ecocredit/server/genesis.go +++ b/x/ecocredit/server/genesis.go @@ -12,7 +12,7 @@ import ( // InitGenesis performs genesis initialization for the ecocredit module. It // returns no validator updates. -func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) { +func (s serverImpl) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) { jsonSource, err := ormjson.NewRawMessageSource(data) if err != nil { return nil, err @@ -27,7 +27,7 @@ func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } // ExportGenesis will dump the ecocredit module state into a serializable GenesisState. -func (s serverImpl) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) (json.RawMessage, error) { +func (s serverImpl) ExportGenesis(ctx sdk.Context, _ codec.JSONCodec) (json.RawMessage, error) { jsonTarget := ormjson.NewRawMessageTarget() err := s.db.ExportJSON(sdk.WrapSDKContext(ctx), jsonTarget) if err != nil { diff --git a/x/ecocredit/simulation/genesis.go b/x/ecocredit/simulation/genesis.go index a476752be0..80a67da7f0 100644 --- a/x/ecocredit/simulation/genesis.go +++ b/x/ecocredit/simulation/genesis.go @@ -430,11 +430,7 @@ func genGenesisState(ctx context.Context, simState *module.SimulationState, ss a return err } - if err := ss.AllowedBridgeChainTable().Insert(ctx, &api.AllowedBridgeChain{ + return ss.AllowedBridgeChainTable().Insert(ctx, &api.AllowedBridgeChain{ ChainName: "polygon", - }); err != nil { - return err - } - - return nil + }) } diff --git a/x/ecocredit/simulation/utils/utils.go b/x/ecocredit/simulation/utils/utils.go index a8de086dd2..6a18d70529 100644 --- a/x/ecocredit/simulation/utils/utils.go +++ b/x/ecocredit/simulation/utils/utils.go @@ -84,7 +84,7 @@ func GenAndDeliverTx(r *rand.Rand, txCtx simulation.OperationInput, fees sdk.Coi return simtypes.NewOperationMsg(txCtx.Msg, true, "", txCtx.Cdc), nil, nil } -func GetClasses(sdkCtx sdk.Context, r *rand.Rand, qryClient basetypes.QueryServer, msgType string) ([]*basetypes.ClassInfo, simtypes.OperationMsg, error) { +func GetClasses(sdkCtx sdk.Context, _ *rand.Rand, qryClient basetypes.QueryServer, msgType string) ([]*basetypes.ClassInfo, simtypes.OperationMsg, error) { ctx := sdk.WrapSDKContext(sdkCtx) res, err := qryClient.Classes(ctx, &basetypes.QueryClassesRequest{}) if err != nil { diff --git a/x/intertx/module/ibc_module.go b/x/intertx/module/ibc_module.go index e9e614a39e..6f8ac3cba7 100644 --- a/x/intertx/module/ibc_module.go +++ b/x/intertx/module/ibc_module.go @@ -32,12 +32,12 @@ func NewIBCModule(k keeper.Keeper) IBCModule { // OnChanOpenInit implements the IBCModule interface func (im IBCModule) OnChanOpenInit( ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, + _ channeltypes.Order, + _ []string, portID string, channelID string, chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, + _ channeltypes.Counterparty, version string, ) (string, error) { // Claim channel capability passed back by IBC module @@ -50,52 +50,52 @@ func (im IBCModule) OnChanOpenInit( // OnChanOpenTry implements the IBCModule interface func (im IBCModule) OnChanOpenTry( - ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, - portID, - channelID string, - chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, - counterpartyVersion string, + _ sdk.Context, + _ channeltypes.Order, + _ []string, + _ string, + _ string, + _ *capabilitytypes.Capability, + _ channeltypes.Counterparty, + _ string, ) (string, error) { return "", errors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanOpenAck implements the IBCModule interface func (im IBCModule) OnChanOpenAck( - ctx sdk.Context, - portID, - channelID string, - counterpartyChannelID string, - counterpartyVersion string, + _ sdk.Context, + _ string, + _ string, + _ string, + _ string, ) error { return nil } // OnChanOpenConfirm implements the IBCModule interface func (im IBCModule) OnChanOpenConfirm( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _ string, + _ string, ) error { return errors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanCloseInit implements the IBCModule interface func (im IBCModule) OnChanCloseInit( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _ string, + _ string, ) error { return errors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") } // OnChanCloseConfirm implements the IBCModule interface func (im IBCModule) OnChanCloseConfirm( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _ string, + _ string, ) error { return nil } @@ -104,40 +104,40 @@ func (im IBCModule) OnChanCloseConfirm( // is returned if the packet data is successfully decoded and the receive application // logic returns without error. func (im IBCModule) OnRecvPacket( - ctx sdk.Context, - packet channeltypes.Packet, - relayer sdk.AccAddress, + _ sdk.Context, + _ channeltypes.Packet, + _ sdk.AccAddress, ) ibcexported.Acknowledgement { return channeltypes.NewErrorAcknowledgement(errors.Wrapf(sdkerrors.ErrInvalidRequest, "cannot receive packet via interchain accounts authentication module")) } // OnAcknowledgementPacket implements the IBCModule interface func (im IBCModule) OnAcknowledgementPacket( - ctx sdk.Context, - packet channeltypes.Packet, - acknowledgement []byte, - relayer sdk.AccAddress, + _ sdk.Context, + _ channeltypes.Packet, + _ []byte, + _ sdk.AccAddress, ) error { return nil } // OnTimeoutPacket implements the IBCModule interface. func (im IBCModule) OnTimeoutPacket( - ctx sdk.Context, - packet channeltypes.Packet, - relayer sdk.AccAddress, + _ sdk.Context, + _ channeltypes.Packet, + _ sdk.AccAddress, ) error { return nil } // NegotiateAppVersion implements the IBCModule interface func (im IBCModule) NegotiateAppVersion( - ctx sdk.Context, - order channeltypes.Order, - connectionID string, - portID string, - counterparty channeltypes.Counterparty, - proposedVersion string, + _ sdk.Context, + _ channeltypes.Order, + _ string, + _ string, + _ channeltypes.Counterparty, + _ string, ) (string, error) { return "", nil } diff --git a/x/intertx/module/module.go b/x/intertx/module/module.go index 1d4e1bf4b8..2951747fa0 100644 --- a/x/intertx/module/module.go +++ b/x/intertx/module/module.go @@ -78,17 +78,17 @@ func (a AppModule) GetQueryCmd() *cobra.Command { } // InitGenesis implements AppModule/InitGenesis. -func (a AppModule) InitGenesis(context sdk.Context, jsonCodec codec.JSONCodec, message json.RawMessage) []types.ValidatorUpdate { +func (a AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []types.ValidatorUpdate { return []types.ValidatorUpdate{} } // ExportGenesis implements AppModule/ExportGenesis. -func (a AppModule) ExportGenesis(context sdk.Context, jsonCodec codec.JSONCodec) json.RawMessage { +func (a AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONCodec) json.RawMessage { return nil } // RegisterInvariants implements AppModule/RegisterInvariants. -func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {} +func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // Route implements AppModule/Route. func (a AppModule) Route() sdk.Route { @@ -101,7 +101,7 @@ func (a AppModule) QuerierRoute() string { } // LegacyQuerierHandler implements AppModule/LegacyQuerierHandler. -func (a AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { +func (a AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil }