From 52db44161536508e242630adb059809b5a0149c1 Mon Sep 17 00:00:00 2001 From: leonz789 Date: Fri, 16 Aug 2024 01:50:08 +0800 Subject: [PATCH] lint --- app/ante/cosmos/authz.go | 3 +-- precompiles/avs/types.go | 2 +- testutil/abci.go | 5 ++--- x/dogfood/types/genesis.go | 2 +- x/oracle/keeper/aggregator/context.go | 4 ++-- x/oracle/types/params.go | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/ante/cosmos/authz.go b/app/ante/cosmos/authz.go index 808c3e900..b15b64fdd 100644 --- a/app/ante/cosmos/authz.go +++ b/app/ante/cosmos/authz.go @@ -3,7 +3,6 @@ package cosmos import ( "fmt" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" @@ -28,7 +27,7 @@ func NewAuthzLimiterDecorator(disabledMsgTypes ...string) AuthzLimiterDecorator func (ald AuthzLimiterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { if err := ald.checkDisabledMsgs(tx.GetMsgs(), false, 1); err != nil { - return ctx, errorsmod.Wrapf(errortypes.ErrUnauthorized, err.Error()) + return ctx, errortypes.ErrUnauthorized.Wrap(err.Error()) } return next(ctx, tx, simulate) } diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index 32ac287f6..dab2cb2c9 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -64,7 +64,7 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* // string, since it is the address_id representation assetID, ok := args[6].([]string) - if !ok || assetID == nil || len(assetID) == 0 { + if !ok || len(assetID) == 0 { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "[]string", assetID) } avsParams.AssetID = assetID diff --git a/testutil/abci.go b/testutil/abci.go index 368446e31..7c8bccbf8 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -3,7 +3,6 @@ package testutil import ( "time" - errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -191,7 +190,7 @@ func BroadcastTxBytes(app *app.ExocoreApp, txEncoder sdk.TxEncoder, tx sdk.Tx) ( req := abci.RequestDeliverTx{Tx: bz} res := app.BaseApp.DeliverTx(req) if res.Code != 0 { - return abci.ResponseDeliverTx{}, errorsmod.Wrapf(errortypes.ErrInvalidRequest, res.Log) + return abci.ResponseDeliverTx{}, errortypes.ErrInvalidRequest.Wrap(res.Log) } return res, nil @@ -238,7 +237,7 @@ func checkTxBytes(app *app.ExocoreApp, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci req := abci.RequestCheckTx{Tx: bz} res := app.BaseApp.CheckTx(req) if res.Code != 0 { - return abci.ResponseCheckTx{}, errorsmod.Wrapf(errortypes.ErrInvalidRequest, res.Log) + return abci.ResponseCheckTx{}, errortypes.ErrInvalidRequest.Wrap(res.Log) } return res, nil diff --git a/x/dogfood/types/genesis.go b/x/dogfood/types/genesis.go index e857b501e..e6dba4e06 100644 --- a/x/dogfood/types/genesis.go +++ b/x/dogfood/types/genesis.go @@ -257,7 +257,7 @@ func (gs GenesisState) Validate() error { } if gs.LastTotalPower.IsNil() { - return errorsmod.Wrapf( + return errorsmod.Wrap( ErrInvalidGenesisData, "nil last total power", ) diff --git a/x/oracle/keeper/aggregator/context.go b/x/oracle/keeper/aggregator/context.go index d4b0f4de0..dc42f8288 100644 --- a/x/oracle/keeper/aggregator/context.go +++ b/x/oracle/keeper/aggregator/context.go @@ -90,12 +90,12 @@ func (agc *AggregatorContext) sanityCheck(msg *types.MsgCreatePrice) error { } // TODO: sanity check for price(no more than maxDetId count for each source, this should be take care in anteHandler) - if msg.Prices == nil || len(msg.Prices) == 0 { + if len(msg.Prices) == 0 { return errors.New("msg should provide at least one price") } for _, pSource := range msg.Prices { - if pSource.Prices == nil || len(pSource.Prices) == 0 || len(pSource.Prices) > int(common.MaxDetID) || !agc.params.IsValidSource(pSource.SourceID) { + if len(pSource.Prices) == 0 || len(pSource.Prices) > int(common.MaxDetID) || !agc.params.IsValidSource(pSource.SourceID) { return errors.New("source should be valid and provide at least one price") } // check with params is coressponding source is deteministic diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 3ab771690..6cf63e0c2 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -529,7 +529,7 @@ func (p Params) CheckRules(feederID uint64, prices []*PriceSource) (bool, error) feeder := p.TokenFeeders[feederID] rule := p.Rules[feeder.RuleID] // specified sources set, v1 use this rule to set `chainlink` as official source - if rule.SourceIDs != nil && len(rule.SourceIDs) > 0 { + if len(rule.SourceIDs) > 0 { if len(rule.SourceIDs) != len(prices) { return false, errors.New("count prices should match rule") }