refactor: fix lint issues + gofumpt (#15062)

This commit is contained in:
Facundo Medica 2023-02-19 07:31:49 -03:00 committed by GitHub
parent 2b484a241f
commit 4a6a1e3cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
234 changed files with 1249 additions and 1077 deletions

View File

@ -16,6 +16,7 @@ import (
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"
errorsmod "cosmossdk.io/errors"
snapshottypes "cosmossdk.io/store/snapshots/types"
storetypes "cosmossdk.io/store/types"
@ -507,7 +508,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
// ref: https://github.com/cosmos/cosmos-sdk/pull/8039
defer func() {
if r := recover(); r != nil {
res = sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r), app.trace)
res = sdkerrors.QueryResult(errorsmod.Wrapf(sdkerrors.ErrPanic, "%v", r), app.trace)
}
}()
@ -521,7 +522,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
defer telemetry.MeasureSince(time.Now(), req.Path)
if req.Path == "/cosmos.tx.v1beta1.Service/BroadcastTx" {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "can't route a broadcast tx message"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "can't route a broadcast tx message"), app.trace)
}
// handle gRPC routes first rather than calling splitPath because '/' characters
@ -532,7 +533,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
path := SplitABCIQueryPath(req.Path)
if len(path) == 0 {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no query path provided"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "no query path provided"), app.trace)
}
switch path[0] {
@ -547,7 +548,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
return handleQueryP2P(app, path)
}
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown query path"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "unknown query path"), app.trace)
}
// ListSnapshots implements the ABCI interface. It delegates to app.snapshotManager if set.
@ -693,27 +694,27 @@ func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req abci.RequestQu
func gRPCErrorToSDKError(err error) error {
status, ok := grpcstatus.FromError(err)
if !ok {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
switch status.Code() {
case codes.NotFound:
return sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, err.Error())
return errorsmod.Wrap(sdkerrors.ErrKeyNotFound, err.Error())
case codes.InvalidArgument:
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
case codes.FailedPrecondition:
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
case codes.Unauthenticated:
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, err.Error())
return errorsmod.Wrap(sdkerrors.ErrUnauthorized, err.Error())
default:
return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, err.Error())
return errorsmod.Wrap(sdkerrors.ErrUnknownRequest, err.Error())
}
}
func checkNegativeHeight(height int64) error {
if height < 0 {
// Reject invalid heights.
return sdkerrors.Wrap(
return errorsmod.Wrap(
sdkerrors.ErrInvalidRequest,
"cannot query with height < 0; please provide a valid height",
)
@ -736,12 +737,12 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
lastBlockHeight := qms.LatestVersion()
if lastBlockHeight == 0 {
return sdk.Context{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "%s is not ready; please wait for first block", app.Name())
return sdk.Context{}, errorsmod.Wrapf(sdkerrors.ErrInvalidHeight, "%s is not ready; please wait for first block", app.Name())
}
if height > lastBlockHeight {
return sdk.Context{},
sdkerrors.Wrap(
errorsmod.Wrap(
sdkerrors.ErrInvalidHeight,
"cannot query with height in the future; please provide a valid height",
)
@ -754,7 +755,7 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
if height <= 1 && prove {
return sdk.Context{},
sdkerrors.Wrap(
errorsmod.Wrap(
sdkerrors.ErrInvalidRequest,
"cannot query with proof when height <= 1; please provide a valid height",
)
@ -763,7 +764,7 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
cacheMS, err := qms.CacheMultiStoreWithVersion(height)
if err != nil {
return sdk.Context{},
sdkerrors.Wrapf(
errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"failed to load state at height %d; %s (latest height: %d)", height, err, lastBlockHeight,
)
@ -858,7 +859,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
gInfo, res, err := app.Simulate(txBytes)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(err, "failed to simulate tx"), app.trace)
}
simRes := &sdk.SimulationResponse{
@ -868,7 +869,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
bz, err := codec.ProtoMarshalJSON(simRes, app.interfaceRegistry)
if err != nil {
return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to JSON encode simulation response"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(err, "failed to JSON encode simulation response"), app.trace)
}
return abci.ResponseQuery{
@ -885,12 +886,12 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
}
default:
return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query: %s", path), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query: %s", path), app.trace)
}
}
return sdkerrors.QueryResult(
sdkerrors.Wrap(
errorsmod.Wrap(
sdkerrors.ErrUnknownRequest,
"expected second parameter to be either 'simulate' or 'version', neither was present",
), app.trace)
@ -900,14 +901,14 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) abci.R
// "/store" prefix for store queries
queryable, ok := app.cms.(storetypes.Queryable)
if !ok {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries"), app.trace)
return sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries"), app.trace)
}
req.Path = "/" + strings.Join(path[1:], "/")
if req.Height <= 1 && req.Prove {
return sdkerrors.QueryResult(
sdkerrors.Wrap(
errorsmod.Wrap(
sdkerrors.ErrInvalidRequest,
"cannot query with proof when height <= 1; please provide a valid height",
), app.trace)
@ -923,7 +924,7 @@ func handleQueryP2P(app *BaseApp, path []string) abci.ResponseQuery {
// "/p2p" prefix for p2p queries
if len(path) < 4 {
return sdkerrors.QueryResult(
sdkerrors.Wrap(
errorsmod.Wrap(
sdkerrors.ErrUnknownRequest, "path should be p2p filter <addr|id> <parameter>",
), app.trace)
}
@ -942,7 +943,7 @@ func handleQueryP2P(app *BaseApp, path []string) abci.ResponseQuery {
}
default:
resp = sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'"), app.trace)
resp = sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'"), app.trace)
}
return resp

View File

@ -14,6 +14,7 @@ import (
"github.com/cosmos/gogoproto/jsonpb"
"github.com/stretchr/testify/require"
errorsmod "cosmossdk.io/errors"
pruningtypes "cosmossdk.io/store/pruning/types"
"cosmossdk.io/store/snapshots"
snapshottypes "cosmossdk.io/store/snapshots/types"
@ -835,7 +836,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
require.Error(t, err)
require.Nil(t, result)
space, code, _ := sdkerrors.ABCIInfo(err, false)
space, code, _ := errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrInvalidRequest.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrInvalidRequest.ABCICode(), code, err)
}
@ -863,7 +864,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
if testCase.fail {
require.Error(t, err)
space, code, _ := sdkerrors.ABCIInfo(err, false)
space, code, _ := errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrInvalidSequence.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrInvalidSequence.ABCICode(), code, err)
} else {
@ -883,7 +884,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
require.Error(t, err)
require.Nil(t, result)
space, code, _ := sdkerrors.ABCIInfo(err, false)
space, code, _ := errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrUnknownRequest.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrUnknownRequest.ABCICode(), code, err)
@ -896,7 +897,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
require.Error(t, err)
require.Nil(t, result)
space, code, _ = sdkerrors.ABCIInfo(err, false)
space, code, _ = errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrUnknownRequest.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrUnknownRequest.ABCICode(), code, err)
}
@ -930,7 +931,7 @@ func TestABCI_TxGasLimits(t *testing.T) {
if r := recover(); r != nil {
switch rType := r.(type) {
case storetypes.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
err = errorsmod.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
}
@ -992,7 +993,7 @@ func TestABCI_TxGasLimits(t *testing.T) {
require.Error(t, err)
require.Nil(t, result)
space, code, _ := sdkerrors.ABCIInfo(err, false)
space, code, _ := errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
}
@ -1009,7 +1010,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) {
if r := recover(); r != nil {
switch rType := r.(type) {
case storetypes.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
err = errorsmod.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
}
@ -1074,7 +1075,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) {
require.Error(t, err, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
require.Nil(t, result, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
space, code, _ := sdkerrors.ABCIInfo(err, false)
space, code, _ := errorsmod.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
require.True(t, ctx.BlockGasMeter().IsOutOfGas())
@ -1105,7 +1106,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) {
switch rType := r.(type) {
case storetypes.ErrorOutOfGas:
log := fmt.Sprintf("out of gas in location: %v", rType.Descriptor)
err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log)
err = errorsmod.Wrap(sdkerrors.ErrOutOfGas, log)
default:
panic(r)
}
@ -1115,7 +1116,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) {
counter, failOnAnte := parseTxMemo(t, tx)
newCtx.GasMeter().ConsumeGas(uint64(counter), "counter-ante")
if failOnAnte {
return newCtx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure")
return newCtx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure")
}
return

View File

@ -14,6 +14,7 @@ import (
"github.com/cosmos/gogoproto/proto"
"golang.org/x/exp/maps"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store"
storemetrics "cosmossdk.io/store/metrics"
"cosmossdk.io/store/snapshots"
@ -523,7 +524,7 @@ func (app *BaseApp) validateHeight(req abci.RequestBeginBlock) error {
// validateBasicTxMsgs executes basic validator calls for messages.
func validateBasicTxMsgs(msgs []sdk.Msg) error {
if len(msgs) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message")
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message")
}
for _, msg := range msgs {
@ -623,7 +624,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
// only run the tx if there is block gas remaining
if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() {
return gInfo, nil, nil, 0, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx")
return gInfo, nil, nil, 0, errorsmod.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx")
}
defer func() {
@ -784,13 +785,13 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
handler := app.msgServiceRouter.Handler(msg)
if handler == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
}
// ADR 031 request type routing
msgResult, err := handler(ctx, msg)
if err != nil {
return nil, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i)
return nil, errorsmod.Wrapf(err, "failed to execute message; message index: %d", i)
}
// create message events
@ -820,7 +821,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
data, err := makeABCIData(msgResponses)
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to marshal tx data")
return nil, errorsmod.Wrap(err, "failed to marshal tx data")
}
return &sdk.Result{

View File

@ -6,6 +6,7 @@ import (
"testing"
"time"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/store/metrics"
pruningtypes "cosmossdk.io/store/pruning/types"
@ -25,7 +26,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
)
@ -426,10 +426,10 @@ func TestTxDecoder(t *testing.T) {
func TestCustomRunTxPanicHandler(t *testing.T) {
customPanicMsg := "test panic"
anteErr := sdkerrors.Register("fakeModule", 100500, "fakeError")
anteErr := errorsmod.Register("fakeModule", 100500, "fakeError")
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
panic(sdkerrors.Wrap(anteErr, "anteHandler"))
panic(errorsmod.Wrap(anteErr, "anteHandler"))
})
}
suite := NewBaseAppSuite(t, anteOpt)

View File

@ -4,6 +4,7 @@ import (
"context"
"strconv"
errorsmod "cosmossdk.io/errors"
gogogrpc "github.com/cosmos/gogoproto/grpc"
grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpcrecovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
@ -36,7 +37,7 @@ func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) {
if heightHeaders := md.Get(grpctypes.GRPCBlockHeightHeader); len(heightHeaders) == 1 {
height, err = strconv.ParseInt(heightHeaders[0], 10, 64)
if err != nil {
return nil, sdkerrors.Wrapf(
return nil, errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"Baseapp.RegisterGRPCServer: invalid height header %q: %v", grpctypes.GRPCBlockHeightHeader, err)
}

View File

@ -8,6 +8,8 @@ import (
"github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc"
errorsmod "cosmossdk.io/errors"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -132,7 +134,7 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter
resMsg, ok := res.(proto.Message)
if !ok {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting proto.Message, got %T", resMsg)
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "Expecting proto.Message, got %T", resMsg)
}
return sdk.WrapServiceResult(ctx, resMsg, err)

View File

@ -4,6 +4,7 @@ import (
"fmt"
"runtime/debug"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -54,7 +55,7 @@ func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recov
return nil
}
return sdkerrors.Wrap(
return errorsmod.Wrap(
sdkerrors.ErrOutOfGas, fmt.Sprintf(
"out of gas in location: %v; gasWanted: %d, gasUsed: %d",
err.Descriptor, gasWanted, ctx.GasMeter().GasConsumed(),
@ -68,7 +69,7 @@ func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recov
// newDefaultRecoveryMiddleware creates a default (last in chain) recovery middleware for app.runTx method.
func newDefaultRecoveryMiddleware() recoveryMiddleware {
handler := func(recoveryObj interface{}) error {
return sdkerrors.Wrap(
return errorsmod.Wrap(
sdkerrors.ErrPanic, fmt.Sprintf(
"recovered: %v\nstack:\n%v", recoveryObj, string(debug.Stack()),
),

View File

@ -3,6 +3,8 @@ package baseapp
import (
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -14,7 +16,7 @@ func (app *BaseApp) SimCheck(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *
// this helper is only used in tests/simulation, it's fine.
bz, err := txEncoder(tx)
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
gasInfo, result, _, _, err := app.runTx(runTxModeCheck, bz)
return gasInfo, result, err
@ -30,7 +32,7 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo,
// See comment for Check().
bz, err := txEncoder(tx)
if err != nil {
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err)
}
gasInfo, result, _, _, err := app.runTx(runTxModeDeliver, bz)
return gasInfo, result, err

View File

@ -1,6 +1,8 @@
package testutil
import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -29,7 +31,7 @@ func (msg *MsgCounter) ValidateBasic() error {
if msg.Counter >= 0 {
return nil
}
return sdkerrors.Wrap(sdkerrors.ErrInvalidSequence, "counter should be a non-negative integer")
return errorsmod.Wrap(sdkerrors.ErrInvalidSequence, "counter should be a non-negative integer")
}
var _ sdk.Msg = &MsgCounter2{}
@ -39,7 +41,7 @@ func (msg *MsgCounter2) ValidateBasic() error {
if msg.Counter >= 0 {
return nil
}
return sdkerrors.Wrap(sdkerrors.ErrInvalidSequence, "counter should be a non-negative integer")
return errorsmod.Wrap(sdkerrors.ErrInvalidSequence, "counter should be a non-negative integer")
}
var _ sdk.Msg = &MsgKeyValue{}
@ -54,10 +56,10 @@ func (msg *MsgKeyValue) GetSigners() []sdk.AccAddress {
func (msg *MsgKeyValue) ValidateBasic() error {
if msg.Key == nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "key cannot be nil")
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "key cannot be nil")
}
if msg.Value == nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "value cannot be nil")
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "value cannot be nil")
}
return nil
}

View File

@ -18,15 +18,15 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"github.com/cometbft/cometbft/libs/log"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/baseapp"
baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil"
"github.com/cosmos/cosmos-sdk/client"
@ -178,12 +178,12 @@ func incrementCounter(ctx context.Context,
switch m := msg.(type) {
case *baseapptestutil.MsgCounter:
if m.FailOnHandler {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message handler failure")
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "message handler failure")
}
msgCount = m.Counter
case *baseapptestutil.MsgCounter2:
if m.FailOnHandler {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message handler failure")
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "message handler failure")
}
msgCount = m.Counter
}
@ -215,7 +215,7 @@ func anteHandlerTxTest(t *testing.T, capKey storetypes.StoreKey, storeKey []byte
counter, failOnAnte := parseTxMemo(t, tx)
if failOnAnte {
return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure")
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure")
}
_, err := incrementingCounter(t, store, storeKey, counter)

View File

@ -9,6 +9,8 @@ import (
"github.com/spf13/cobra"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@ -143,7 +145,7 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
}
pubkeyType = strings.ToLower(pubkeyType)
if pubkeyType != "secp256k1" && pubkeyType != ed {
return errors.Wrapf(errors.ErrInvalidType, "invalid pubkey type, expected oneof ed25519 or secp256k1")
return errorsmod.Wrapf(errors.ErrInvalidType, "invalid pubkey type, expected oneof ed25519 or secp256k1")
}
pk, err := getPubKeyFromRawString(args[0], pubkeyType)

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
errorsmod "cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
gogogrpc "github.com/cosmos/gogoproto/grpc"
"google.golang.org/grpc"
@ -39,14 +40,14 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i
// In both cases, we don't allow empty request args (it will panic unexpectedly).
if reflect.ValueOf(req).IsNil() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "request cannot be nil")
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "request cannot be nil")
}
// Case 1. Broadcasting a Tx.
if reqProto, ok := req.(*tx.BroadcastTxRequest); ok {
res, ok := reply.(*tx.BroadcastTxResponse)
if !ok {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxResponse)(nil), req)
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxResponse)(nil), req)
}
broadcastRes, err := TxServiceBroadcast(grpcCtx, ctx, reqProto)
@ -77,7 +78,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i
return err
}
if height < 0 {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"client.Context.Invoke: height (%d) from %q must be >= 0", height, grpctypes.GRPCBlockHeightHeader)
}

View File

@ -7,6 +7,8 @@ import (
"github.com/cometbft/cometbft/libs/cli"
"github.com/spf13/cobra"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
@ -173,7 +175,7 @@ func fetchKey(kb keyring.Keyring, keyref string) (*keyring.Record, error) {
// if the key is not there or if we have a problem with a keyring itself then we move to a
// fallback: searching for key by address.
if err == nil || !sdkerr.IsOf(err, sdkerr.ErrIO, sdkerr.ErrKeyNotFound) {
if err == nil || !errorsmod.IsOf(err, sdkerr.ErrIO, sdkerr.ErrKeyNotFound) {
return k, err
}
@ -183,7 +185,7 @@ func fetchKey(kb keyring.Keyring, keyref string) (*keyring.Record, error) {
}
k, err = kb.KeyByAddress(accAddr)
return k, sdkerr.Wrap(err, "Invalid key")
return k, errorsmod.Wrap(err, "Invalid key")
}
func validateMultisigThreshold(k, nKeys int) error {

View File

@ -6,6 +6,8 @@ import (
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
"github.com/spf13/pflag"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client/flags"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
@ -57,7 +59,7 @@ func ReadPageRequest(flagSet *pflag.FlagSet) (*query.PageRequest, error) {
reverse, _ := flagSet.GetBool(flags.FlagReverse)
if page > 1 && offset > 0 {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "page and offset cannot be used together")
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "page and offset cannot be used together")
}
if page > 1 {

View File

@ -6,6 +6,8 @@ import (
"github.com/cosmos/gogoproto/proto"
errorsmod "cosmossdk.io/errors"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -58,7 +60,7 @@ type Any struct {
// unmarshaling
func NewAnyWithValue(v proto.Message) (*Any, error) {
if v == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrPackAny, "Expecting non nil value to create a new Any")
return nil, errorsmod.Wrap(sdkerrors.ErrPackAny, "Expecting non nil value to create a new Any")
}
bz, err := proto.Marshal(v)

View File

@ -2,6 +2,7 @@ package indexes
import (
"context"
"cosmossdk.io/collections"
)
@ -23,7 +24,8 @@ type Iterator[K any] interface {
func CollectKeyValues[K, V any, I Iterator[K], Idx collections.Indexes[K, V]](
ctx context.Context,
indexedMap *collections.IndexedMap[K, V, Idx],
iter I) (kvs []collections.KeyValue[K, V], err error) {
iter I,
) (kvs []collections.KeyValue[K, V], err error) {
err = ScanKeyValues(ctx, indexedMap, iter, func(kv collections.KeyValue[K, V]) bool {
kvs = append(kvs, kv)
return false
@ -38,8 +40,8 @@ func ScanKeyValues[K, V any, I Iterator[K], Idx collections.Indexes[K, V]](
ctx context.Context,
indexedMap *collections.IndexedMap[K, V, Idx],
iter I,
do func(kv collections.KeyValue[K, V]) (stop bool)) (err error) {
do func(kv collections.KeyValue[K, V]) (stop bool),
) (err error) {
defer iter.Close()
for ; iter.Valid(); iter.Next() {
@ -71,7 +73,8 @@ func ScanKeyValues[K, V any, I Iterator[K], Idx collections.Indexes[K, V]](
func CollectValues[K, V any, I Iterator[K], Idx collections.Indexes[K, V]](
ctx context.Context,
indexedMap *collections.IndexedMap[K, V, Idx],
iter I) (values []V, err error) {
iter I,
) (values []V, err error) {
err = ScanValues(ctx, indexedMap, iter, func(value V) (stop bool) {
values = append(values, value)
return false

View File

@ -1,9 +1,10 @@
package indexes
import (
"testing"
"cosmossdk.io/collections"
"github.com/stretchr/testify/require"
"testing"
)
func TestHelpers(t *testing.T) {

View File

@ -2,6 +2,7 @@ package indexes
import (
"context"
"cosmossdk.io/core/store"
db "github.com/cosmos/cosmos-db"
)

View File

@ -2,6 +2,7 @@ package indexes
import (
"context"
"cosmossdk.io/collections"
)

View File

@ -2,6 +2,7 @@ package indexes
import (
"context"
"cosmossdk.io/collections"
)

View File

@ -1,14 +1,17 @@
package indexes
import (
"testing"
"cosmossdk.io/collections"
"github.com/stretchr/testify/require"
"testing"
)
type Address = string
type Denom = string
type Amount = uint64
type (
Address = string
Denom = string
Amount = uint64
)
// our balance index, allows us to efficiently create an index between the key that maps
// balances which is a collections.Pair[Address, Denom] and the Denom.

View File

@ -1,9 +1,10 @@
package indexes
import (
"testing"
"cosmossdk.io/collections"
"github.com/stretchr/testify/require"
"testing"
)
func TestMultiIndex(t *testing.T) {

View File

@ -2,6 +2,7 @@ package indexes
import (
"context"
"cosmossdk.io/collections"
)
@ -84,9 +85,11 @@ func (i UniqueIterator[ReferenceKey, PrimaryKey]) FullKeys() ([]collections.Pair
func (i UniqueIterator[ReferenceKey, PrimaryKey]) Next() {
(collections.Iterator[ReferenceKey, PrimaryKey])(i).Next()
}
func (i UniqueIterator[ReferenceKey, PrimaryKey]) Valid() bool {
return (collections.Iterator[ReferenceKey, PrimaryKey])(i).Valid()
}
func (i UniqueIterator[ReferenceKey, PrimaryKey]) Close() error {
return (collections.Iterator[ReferenceKey, PrimaryKey])(i).Close()
}

View File

@ -1,9 +1,10 @@
package indexes
import (
"testing"
"cosmossdk.io/collections"
"github.com/stretchr/testify/require"
"testing"
)
func TestUniqueIndex(t *testing.T) {

View File

@ -29,7 +29,6 @@ func expectJSON(t *testing.T, source appmodule.GenesisSource, field, contents st
bz, err := io.ReadAll(r)
require.NoError(t, err)
require.Equal(t, contents, string(bz))
}
const (

View File

@ -9,6 +9,8 @@ import (
"github.com/cometbft/cometbft/crypto"
"golang.org/x/crypto/openpgp/armor" //nolint:staticcheck
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/crypto/keys/bcrypt"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -149,7 +151,7 @@ func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes [
saltBytes = crypto.CRandBytes(16)
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
if err != nil {
panic(sdkerrors.Wrap(err, "error generating bcrypt key from passphrase"))
panic(errorsmod.Wrap(err, "error generating bcrypt key from passphrase"))
}
key = crypto.Sha256(key) // get 32 bytes
@ -194,7 +196,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptoty
func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) {
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
if err != nil {
return privKey, sdkerrors.Wrap(err, "error generating bcrypt key from passphrase")
return privKey, errorsmod.Wrap(err, "error generating bcrypt key from passphrase")
}
key = crypto.Sha256(key) // Get 32 bytes

View File

@ -1,11 +1,12 @@
package codec
import (
"cosmossdk.io/errors"
cmtcrypto "github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/encoding"
cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

View File

@ -14,6 +14,10 @@ import (
"github.com/cockroachdb/errors"
cmtcrypto "github.com/cometbft/cometbft/crypto"
"github.com/cosmos/go-bip39"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto"
@ -24,7 +28,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/go-bip39"
)
// Backend options for Keyring
@ -194,7 +197,7 @@ func New(
case BackendPass:
db, err = keyring.Open(newPassBackendKeyringConfig(appName, rootDir, userInput))
default:
return nil, errors.Wrap(ErrUnknownBacked, backend)
return nil, errorsmod.Wrap(ErrUnknownBacked, backend)
}
if err != nil {
@ -317,13 +320,13 @@ func (ks keystore) ExportPrivKeyArmorByAddress(address sdk.Address, encryptPassp
func (ks keystore) ImportPrivKey(uid, armor, passphrase string) error {
if k, err := ks.Key(uid); err == nil {
if uid == k.Name {
return errors.Wrap(ErrOverwriteKey, uid)
return errorsmod.Wrap(ErrOverwriteKey, uid)
}
}
privKey, _, err := crypto.UnarmorDecryptPrivKey(armor, passphrase)
if err != nil {
return errors.Wrap(err, "failed to decrypt private key")
return errorsmod.Wrap(err, "failed to decrypt private key")
}
_, err = ks.writeLocalKey(uid, privKey)
@ -336,7 +339,7 @@ func (ks keystore) ImportPrivKey(uid, armor, passphrase string) error {
func (ks keystore) ImportPubKey(uid, armor string) error {
if _, err := ks.Key(uid); err == nil {
return errors.Wrap(ErrOverwriteKey, uid)
return errorsmod.Wrap(ErrOverwriteKey, uid)
}
pubBytes, _, err := crypto.UnarmorPubKeyBytes(armor)
@ -401,7 +404,7 @@ func (ks keystore) SignByAddress(address sdk.Address, msg []byte, signMode signi
func (ks keystore) SaveLedgerKey(uid string, algo SignatureAlgo, hrp string, coinType, account, index uint32) (*Record, error) {
if !ks.options.SupportedAlgosLedger.Contains(algo) {
return nil, errors.Wrap(ErrUnsupportedSigningAlgo, fmt.Sprintf("signature algo %s is not defined in the keyring options", algo.Name()))
return nil, errorsmod.Wrap(ErrUnsupportedSigningAlgo, fmt.Sprintf("signature algo %s is not defined in the keyring options", algo.Name()))
}
hdPath := hd.NewFundraiserParams(account, coinType, index)
@ -448,7 +451,7 @@ func (ks keystore) DeleteByAddress(address sdk.Address) error {
func (ks keystore) Rename(oldName, newName string) error {
_, err := ks.Key(newName)
if err == nil {
return errors.Wrap(ErrKeyAlreadyExists, fmt.Sprintf("rename failed, %s", newName))
return errorsmod.Wrap(ErrKeyAlreadyExists, fmt.Sprintf("rename failed, %s", newName))
}
armor, err := ks.ExportPrivKeyArmor(oldName, passPhrase)
@ -508,7 +511,7 @@ func (ks keystore) KeyByAddress(address sdk.Address) (*Record, error) {
func wrapKeyNotFound(err error, msg string) error {
if err == keyring.ErrKeyNotFound {
return errors.Wrap(sdkerrors.ErrKeyNotFound, msg)
return errorsmod.Wrap(sdkerrors.ErrKeyNotFound, msg)
}
return err
}
@ -620,7 +623,7 @@ func SignWithLedger(k *Record, msg []byte, signMode signing.SignMode) (sig []byt
return nil, nil, err
}
default:
return nil, nil, errors.Wrap(ErrInvalidSignMode, fmt.Sprintf("%v", signMode))
return nil, nil, errorsmod.Wrap(ErrInvalidSignMode, fmt.Sprintf("%v", signMode))
}
if !priv.PubKey().VerifySignature(msg, sig) {
@ -693,7 +696,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
case err == nil:
keyhash, err = os.ReadFile(keyhashFilePath)
if err != nil {
return "", errors.Wrap(err, fmt.Sprintf("failed to read %s", keyhashFilePath))
return "", errorsmod.Wrap(err, fmt.Sprintf("failed to read %s", keyhashFilePath))
}
keyhashStored = true
@ -702,7 +705,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
keyhashStored = false
default:
return "", errors.Wrap(err, fmt.Sprintf("failed to open %s", keyhashFilePath))
return "", errorsmod.Wrap(err, fmt.Sprintf("failed to open %s", keyhashFilePath))
}
failureCounter := 0
@ -791,7 +794,7 @@ func (ks keystore) writeRecord(k *Record) error {
return err
}
if exists {
return errors.Wrap(ErrKeyAlreadyExists, key)
return errorsmod.Wrap(ErrKeyAlreadyExists, key)
}
serializedRecord, err := ks.cdc.Marshal(k)
@ -923,7 +926,7 @@ func (ks keystore) migrate(key string) (*Record, error) {
}
if len(item.Data) == 0 {
return nil, errors.Wrap(sdkerrors.ErrKeyNotFound, key)
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, key)
}
// 2. Try to deserialize using proto
@ -936,13 +939,13 @@ func (ks keystore) migrate(key string) (*Record, error) {
// 4. Try to decode with amino
legacyInfo, err := unMarshalLegacyInfo(item.Data)
if err != nil {
return nil, errors.Wrap(err, "unable to unmarshal item.Data")
return nil, errorsmod.Wrap(err, "unable to unmarshal item.Data")
}
// 5. Convert and serialize info using proto
k, err = ks.convertFromLegacyInfo(legacyInfo)
if err != nil {
return nil, errors.Wrap(err, "convertFromLegacyInfo")
return nil, errorsmod.Wrap(err, "convertFromLegacyInfo")
}
serializedRecord, err := ks.cdc.Marshal(k)
@ -957,7 +960,7 @@ func (ks keystore) migrate(key string) (*Record, error) {
// 6. Overwrite the keyring entry with the new proto-encoded key.
if err := ks.SetItem(item); err != nil {
return nil, errors.Wrap(err, "unable to set keyring.Item")
return nil, errorsmod.Wrap(err, "unable to set keyring.Item")
}
fmt.Printf("Successfully migrated key %s.\n", key)
@ -980,7 +983,7 @@ func (ks keystore) SetItem(item keyring.Item) error {
func (ks keystore) convertFromLegacyInfo(info LegacyInfo) (*Record, error) {
if info == nil {
return nil, errors.Wrap(ErrLegacyToRecord, "info is nil")
return nil, errorsmod.Wrap(ErrLegacyToRecord, "info is nil")
}
name := info.GetName()

View File

@ -269,7 +269,6 @@ func TestGetPub(t *testing.T) {
keyS, err := kb.List()
require.NoError(t, err)
require.Equal(t, 1, len(keyS))
})
}
}

View File

@ -10,6 +10,8 @@ import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/crypto/hd"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -215,7 +217,7 @@ func (s *MigrationTestSuite) TestMigrateErrUnknownItemKey() {
incorrectItemKey := n1 + "1"
_, err := s.ks.migrate(incorrectItemKey)
s.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, infoKey(incorrectItemKey)).Error())
s.Require().EqualError(err, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, infoKey(incorrectItemKey)).Error())
}
func (s *MigrationTestSuite) TestMigrateErrEmptyItemData() {
@ -228,7 +230,7 @@ func (s *MigrationTestSuite) TestMigrateErrEmptyItemData() {
s.Require().NoError(s.ks.SetItem(item))
_, err := s.ks.migrate(n1)
s.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, n1).Error())
s.Require().EqualError(err, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, n1).Error())
}
func TestMigrationTestSuite(t *testing.T) {

View File

@ -3,6 +3,8 @@ package keyring
import (
"github.com/cockroachdb/errors"
errorsmod "cosmossdk.io/errors"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -69,7 +71,7 @@ func NewMultiRecord(name string, pk cryptotypes.PubKey) (*Record, error) {
func (k *Record) GetPubKey() (cryptotypes.PubKey, error) {
pk, ok := k.PubKey.GetCachedValue().(cryptotypes.PubKey)
if !ok {
return nil, errors.Wrap(ErrCastAny, "PubKey")
return nil, errorsmod.Wrap(ErrCastAny, "PubKey")
}
return pk, nil
@ -131,7 +133,7 @@ func extractPrivKeyFromLocal(rl *Record_Local) (cryptotypes.PrivKey, error) {
priv, ok := rl.PrivKey.GetCachedValue().(cryptotypes.PrivKey)
if !ok {
return nil, errors.Wrap(ErrCastAny, "PrivKey")
return nil, errorsmod.Wrap(ErrCastAny, "PrivKey")
}
return priv, nil

View File

@ -82,7 +82,6 @@ func TestDerive(t *testing.T) {
decodedPriv, err := hex.DecodeString(tt.derivedPriv)
require.NoError(t, err)
require.Equal(t, derivedPriv, decodedPriv)
})
}
}

View File

@ -10,6 +10,8 @@ import (
"github.com/cometbft/cometbft/crypto/tmhash"
"github.com/hdevalence/ed25519consensus"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types/errors"
@ -209,7 +211,7 @@ func (pubKey PubKey) MarshalAmino() ([]byte, error) {
// UnmarshalAmino overrides Amino binary marshalling.
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PubKeySize {
return errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
}
pubKey.Key = bz

View File

@ -9,6 +9,8 @@ import (
cmtcrypto "github.com/cometbft/cometbft/crypto"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/errors"
)
@ -95,12 +97,12 @@ func (pk *PubKey) MarshalTo(dAtA []byte) (int, error) {
// Unmarshal implements proto.Marshaler interface.
func (pk *PubKey) Unmarshal(bz []byte, curve elliptic.Curve, expectedSize int) error {
if len(bz) != expectedSize {
return errors.Wrapf(errors.ErrInvalidPubKey, "wrong ECDSA PK bytes, expecting %d bytes, got %d", expectedSize, len(bz))
return errorsmod.Wrapf(errors.ErrInvalidPubKey, "wrong ECDSA PK bytes, expecting %d bytes, got %d", expectedSize, len(bz))
}
cpk := ecdsa.PublicKey{Curve: curve}
cpk.X, cpk.Y = elliptic.UnmarshalCompressed(curve, bz)
if cpk.X == nil || cpk.Y == nil {
return errors.Wrapf(errors.ErrInvalidPubKey, "wrong ECDSA PK bytes, unknown curve type: %d", bz[0])
return errorsmod.Wrapf(errors.ErrInvalidPubKey, "wrong ECDSA PK bytes, unknown curve type: %d", bz[0])
}
pk.PublicKey = cpk
return nil

View File

@ -1,6 +1,8 @@
package multisig
import (
errorsmod "cosmossdk.io/errors"
types "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -36,7 +38,7 @@ func protoToTm(protoPk *LegacyAminoPubKey) (tmMultisig, error) {
for i, pk := range protoPk.PubKeys {
pks[i], ok = pk.GetCachedValue().(cryptotypes.PubKey)
if !ok {
return tmMultisig{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (cryptotypes.PubKey)(nil), pk.GetCachedValue())
return tmMultisig{}, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (cryptotypes.PubKey)(nil), pk.GetCachedValue())
}
}

View File

@ -6,17 +6,17 @@
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
// * The name of ThePiachu may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// - Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// - Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// - Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
// - The name of ThePiachu may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -29,7 +29,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//nolint // this nolint lets us use this file in its original and unmodified form.
// nolint // this nolint lets us use this file in its original and unmodified form.
package secp256k1
import (

View File

@ -5,7 +5,7 @@
//go:build !gofuzz && cgo
// +build !gofuzz,cgo
//nolint // this nolint lets us use this file in its original and unmodified form.
// nolint // this nolint lets us use this file in its original and unmodified form.
package secp256k1
import (

View File

@ -5,7 +5,7 @@
//go:build gofuzz || !cgo
// +build gofuzz !cgo
//nolint // this nolint lets us use this file in its original and unmodified form.
// nolint // this nolint lets us use this file in its original and unmodified form.
package secp256k1
import "math/big"

View File

@ -8,6 +8,7 @@ import (
"io"
"math/big"
errorsmod "cosmossdk.io/errors"
"github.com/cometbft/cometbft/crypto"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"golang.org/x/crypto/ripemd160" //nolint: staticcheck
@ -186,7 +187,7 @@ func (pubKey PubKey) MarshalAmino() ([]byte, error) {
// UnmarshalAmino overrides Amino binary marshalling.
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PubKeySize {
return errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
}
pubKey.Key = bz

View File

@ -107,7 +107,7 @@ func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recov
err, ok := recoveryObj.(sdk.ErrorOutOfGas)
if !ok { return nil }
return sdkerrors.Wrap(
return errorsmod.Wrap(
sdkerrors.ErrOutOfGas, fmt.Sprintf(
"out of gas in location: %v; gasWanted: %d, gasUsed: %d", err.Descriptor, gasWanted, ctx.GasMeter().GasConsumed(),
),
@ -123,7 +123,7 @@ func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recov
```go
func newDefaultRecoveryMiddleware() recoveryMiddleware {
handler := func(recoveryObj interface{}) error {
return sdkerrors.Wrap(
return errorsmod.Wrap(
sdkerrors.ErrPanic, fmt.Sprintf("recovered: %v\nstack:\n%v", recoveryObj, string(debug.Stack())),
)
}

View File

@ -199,7 +199,7 @@ First a new function to create a private key from a secret number is needed in t
func NewPrivKeyFromSecret(secret []byte) (*PrivKey, error) {
var d = new(big.Int).SetBytes(secret)
if d.Cmp(secp256r1.Params().N) >= 1 {
return nil, sdkerrors.Wrap(errors.ErrInvalidRequest, "secret not in the curve base field")
return nil, errorsmod.Wrap(errors.ErrInvalidRequest, "secret not in the curve base field")
}
sk := new(ecdsa.PrivKey)
return &PrivKey{&ecdsaSK{*sk}}, nil

View File

@ -39,7 +39,7 @@ We have a module keeper that panics:
func (k FooKeeper) Do(obj interface{}) {
if obj == nil {
// that shouldn't happen, we need to crash the app
err := sdkErrors.Wrap(fooTypes.InternalError, "obj is nil")
err := errorsmod.Wrap(fooTypes.InternalError, "obj is nil")
panic(err)
}
}

View File

@ -93,7 +93,7 @@ type HandlerOptions struct {
// MyPostHandler returns a posthandler chain with the TipDecorator.
func MyPostHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for posthandler")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for posthandler")
}
postDecorators := []sdk.AnteDecorator{

View File

@ -18,7 +18,7 @@ information by using Wrap function, for example:
func safeDiv(val, div int) (int, err) {
if div == 0 {
return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
return 0, errorsmod.Wrapf(ErrZeroDivision, "cannot divide %d", val)
}
return val / div, nil
}

View File

@ -67,12 +67,12 @@ func (s *errorsTestSuite) TestErrorIs() {
},
"successful comparison to a wrapped error": {
a: ErrUnauthorized,
b: errors.Wrap(ErrUnauthorized, "gone"),
b: errorsmod.Wrap(ErrUnauthorized, "gone"),
wantIs: true,
},
"unsuccessful comparison to a wrapped error": {
a: ErrUnauthorized,
b: errors.Wrap(ErrInsufficientFee, "too big"),
b: errorsmod.Wrap(ErrInsufficientFee, "too big"),
wantIs: false,
},
"not equal to stdlib error": {
@ -82,7 +82,7 @@ func (s *errorsTestSuite) TestErrorIs() {
},
"not equal to a wrapped stdlib error": {
a: ErrUnauthorized,
b: errors.Wrap(fmt.Errorf("stdlib error"), "wrapped"),
b: errorsmod.Wrap(fmt.Errorf("stdlib error"), "wrapped"),
wantIs: false,
},
"nil is nil": {
@ -226,7 +226,7 @@ func (s *errorsTestSuite) TestGRPCStatus() {
func ExampleWrap() {
err1 := Wrap(ErrInsufficientFunds, "90 is smaller than 100")
err2 := errors.Wrap(ErrInsufficientFunds, "90 is smaller than 100")
err2 := errorsmod.Wrap(ErrInsufficientFunds, "90 is smaller than 100")
fmt.Println(err1.Error())
fmt.Println(err2.Error())
// Output:
@ -236,7 +236,7 @@ func ExampleWrap() {
func ExampleWrapf() {
err1 := Wrap(ErrInsufficientFunds, "90 is smaller than 100")
err2 := errors.Wrap(ErrInsufficientFunds, "90 is smaller than 100")
err2 := errorsmod.Wrap(ErrInsufficientFunds, "90 is smaller than 100")
fmt.Println(err1.Error())
fmt.Println(err2.Error())
// Output:

View File

@ -96,7 +96,7 @@ func (t TimestampCodec) Decode(r Reader) (protoreflect.Value, error) {
return protoreflect.Value{}, io.EOF
}
var seconds = int64(b0)
seconds := int64(b0)
for i := 0; i < 4; i++ {
seconds <<= 8
seconds |= int64(secondsBz[i])
@ -124,7 +124,7 @@ func (t TimestampCodec) Decode(r Reader) (protoreflect.Value, error) {
return protoreflect.Value{}, io.EOF
}
var nanos = int32(b0) & 0x3F // clear first two bits
nanos := int32(b0) & 0x3F // clear first two bits
for i := 0; i < 3; i++ {
nanos <<= 8
nanos |= int32(nanosBz[i])

View File

@ -212,6 +212,7 @@ func (m moduleDB) EncodeEntry(entry ormkv.Entry) (k, v []byte, err error) {
func (m moduleDB) GetTable(message proto.Message) ormtable.Table {
return m.tablesByName[message.ProtoReflect().Descriptor().FullName()]
}
func (m moduleDB) GenesisHandler() appmodule.HasGenesis {
return appModuleGenesisWrapper{m}
}

View File

@ -6,6 +6,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
errorsmod "cosmossdk.io/errors"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -126,7 +128,7 @@ func decodeTx(txBytes []byte) (sdk.Tx, error) {
k, v := split[0], split[1]
tx = &KVStoreTx{k, v, txBytes, nil}
} else {
return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "too many '='")
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, "too many '='")
}
return tx, nil

View File

@ -200,8 +200,6 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z
cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU=
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE=
cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8=
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA=
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8=
cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE=

View File

@ -48,7 +48,7 @@ func (app SimApp) RegisterUpgradeHandlers() {
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable()
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable()
keyTable = govv1.ParamKeyTable() //nolint:staticcheck // we still need this for upgrades
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable()
}

View File

@ -12,7 +12,7 @@ import (
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/iavl"
sdkerrors "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/cachekv"
"cosmossdk.io/store/internal/kv"
"cosmossdk.io/store/metrics"
@ -275,7 +275,7 @@ func (st *Store) SetInitialVersion(version int64) {
func (st *Store) Export(version int64) (*iavl.Exporter, error) {
istore, err := st.GetImmutable(version)
if err != nil {
return nil, sdkerrors.Wrapf(err, "iavl export failed for version %v", version)
return nil, errorsmod.Wrapf(err, "iavl export failed for version %v", version)
}
tree, ok := istore.tree.(*immutableTree)
if !ok || tree == nil {
@ -322,7 +322,7 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
defer st.metrics.MeasureSince("store", "iavl", "query")
if len(req.Data) == 0 {
return types.QueryResult(sdkerrors.Wrap(types.ErrTxDecode, "query cannot be zero length"), false)
return types.QueryResult(errorsmod.Wrap(types.ErrTxDecode, "query cannot be zero length"), false)
}
tree := st.tree
@ -387,7 +387,7 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
res.Value = bz
default:
return types.QueryResult(sdkerrors.Wrapf(types.ErrUnknownRequest, "unexpected query path: %v", req.Path), false)
return types.QueryResult(errorsmod.Wrapf(types.ErrUnknownRequest, "unexpected query path: %v", req.Path), false)
}
return res

View File

@ -16,7 +16,7 @@ import (
gogotypes "github.com/cosmos/gogoproto/types"
iavltree "github.com/cosmos/iavl"
sdkerrors "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/cachemulti"
"cosmossdk.io/store/dbadapter"
"cosmossdk.io/store/iavl"
@ -258,7 +258,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {
store, err := rs.loadCommitStoreFromParams(key, commitID, storeParams)
if err != nil {
return sdkerrors.Wrap(err, "failed to load store")
return errorsmod.Wrap(err, "failed to load store")
}
newStores[key] = store
@ -266,7 +266,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {
// If it was deleted, remove all data
if upgrades.IsDeleted(key.Name()) {
if err := deleteKVStore(store.(types.KVStore)); err != nil {
return sdkerrors.Wrapf(err, "failed to delete store %s", key.Name())
return errorsmod.Wrapf(err, "failed to delete store %s", key.Name())
}
rs.removalMap[key] = true
} else if oldName := upgrades.RenamedFrom(key.Name()); oldName != "" {
@ -278,12 +278,12 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {
// load from the old name
oldStore, err := rs.loadCommitStoreFromParams(oldKey, rs.getCommitID(infos, oldName), oldParams)
if err != nil {
return sdkerrors.Wrapf(err, "failed to load old store %s", oldName)
return errorsmod.Wrapf(err, "failed to load old store %s", oldName)
}
// move all data
if err := moveKVStoreData(oldStore.(types.KVStore), store.(types.KVStore)); err != nil {
return sdkerrors.Wrapf(err, "failed to move store %s -> %s", oldName, key.Name())
return errorsmod.Wrapf(err, "failed to move store %s -> %s", oldName, key.Name())
}
// add the old key so its deletion is committed
@ -654,12 +654,12 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery {
store := rs.GetStoreByName(storeName)
if store == nil {
return types.QueryResult(sdkerrors.Wrapf(types.ErrUnknownRequest, "no such store: %s", storeName), false)
return types.QueryResult(errorsmod.Wrapf(types.ErrUnknownRequest, "no such store: %s", storeName), false)
}
queryable, ok := store.(types.Queryable)
if !ok {
return types.QueryResult(sdkerrors.Wrapf(types.ErrUnknownRequest, "store %s (type %T) doesn't support queries", storeName, store), false)
return types.QueryResult(errorsmod.Wrapf(types.ErrUnknownRequest, "store %s (type %T) doesn't support queries", storeName, store), false)
}
// trim the path and make the query
@ -671,7 +671,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery {
}
if res.ProofOps == nil || len(res.ProofOps.Ops) == 0 {
return types.QueryResult(sdkerrors.Wrap(types.ErrInvalidRequest, "proof is unexpectedly empty; ensure height has not been pruned"), false)
return types.QueryResult(errorsmod.Wrap(types.ErrInvalidRequest, "proof is unexpectedly empty; ensure height has not been pruned"), false)
}
// If the request's height is the latest height we've committed, then utilize
@ -718,7 +718,7 @@ func (rs *Store) SetInitialVersion(version int64) error {
// Returns error if it doesn't start with /
func parsePath(path string) (storeName string, subpath string, err error) {
if !strings.HasPrefix(path, "/") {
return storeName, subpath, sdkerrors.Wrapf(types.ErrUnknownRequest, "invalid path: %s", path)
return storeName, subpath, errorsmod.Wrapf(types.ErrUnknownRequest, "invalid path: %s", path)
}
paths := strings.SplitN(path[1:], "/", 2)
@ -739,10 +739,10 @@ func parsePath(path string) (storeName string, subpath string, err error) {
// TestMultistoreSnapshot_Checksum test.
func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error {
if height == 0 {
return sdkerrors.Wrap(types.ErrLogic, "cannot snapshot height 0")
return errorsmod.Wrap(types.ErrLogic, "cannot snapshot height 0")
}
if height > uint64(GetLatestVersion(rs.db)) {
return sdkerrors.Wrapf(types.ErrLogic, "cannot snapshot future height %v", height)
return errorsmod.Wrapf(types.ErrLogic, "cannot snapshot future height %v", height)
}
// Collect stores to snapshot (only IAVL stores are supported)
@ -760,7 +760,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error {
// Non-persisted stores shouldn't be snapshotted
continue
default:
return sdkerrors.Wrapf(types.ErrLogic,
return errorsmod.Wrapf(types.ErrLogic,
"don't know how to snapshot store %q of type %T", key.Name(), store)
}
}
@ -842,7 +842,7 @@ loop:
if err == io.EOF {
break
} else if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "invalid protobuf message")
}
switch item := snapshotItem.Item.(type) {
@ -850,26 +850,26 @@ loop:
if importer != nil {
err = importer.Commit()
if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL commit failed")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "IAVL commit failed")
}
importer.Close()
}
store, ok := rs.GetStoreByName(item.Store.Name).(*iavl.Store)
if !ok || store == nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrapf(types.ErrLogic, "cannot import into non-IAVL store %q", item.Store.Name)
return snapshottypes.SnapshotItem{}, errorsmod.Wrapf(types.ErrLogic, "cannot import into non-IAVL store %q", item.Store.Name)
}
importer, err = store.Import(int64(height))
if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "import failed")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "import failed")
}
defer importer.Close()
case *snapshottypes.SnapshotItem_IAVL:
if importer == nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(types.ErrLogic, "received IAVL node item before store item")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(types.ErrLogic, "received IAVL node item before store item")
}
if item.IAVL.Height > math.MaxInt8 {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrapf(types.ErrLogic, "node height %v cannot exceed %v",
return snapshottypes.SnapshotItem{}, errorsmod.Wrapf(types.ErrLogic, "node height %v cannot exceed %v",
item.IAVL.Height, math.MaxInt8)
}
node := &iavltree.ExportNode{
@ -888,7 +888,7 @@ loop:
}
err := importer.Add(node)
if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL node import failed")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "IAVL node import failed")
}
default:
@ -899,7 +899,7 @@ loop:
if importer != nil {
err := importer.Commit()
if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL commit failed")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "IAVL commit failed")
}
importer.Close()
}
@ -1116,14 +1116,14 @@ func getCommitInfo(db dbm.DB, ver int64) (*types.CommitInfo, error) {
bz, err := db.Get([]byte(cInfoKey))
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to get commit info")
return nil, errorsmod.Wrap(err, "failed to get commit info")
} else if bz == nil {
return nil, errors.New("no commit info found")
}
cInfo := &types.CommitInfo{}
if err = cInfo.Unmarshal(bz); err != nil {
return nil, sdkerrors.Wrap(err, "failed unmarshal commit info")
return nil, errorsmod.Wrap(err, "failed unmarshal commit info")
}
return cInfo, nil

View File

@ -5,7 +5,6 @@ import (
"math"
"cosmossdk.io/errors"
snapshottypes "cosmossdk.io/store/snapshots/types"
storetypes "cosmossdk.io/store/types"
)

View File

@ -16,7 +16,7 @@ import (
protoio "github.com/cosmos/gogoproto/io"
"github.com/stretchr/testify/require"
sdkerrors "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/snapshots"
snapshottypes "cosmossdk.io/store/snapshots/types"
"cosmossdk.io/store/types"
@ -130,7 +130,7 @@ func (m *mockSnapshotter) Restore(
if err == io.EOF {
break
} else if err != nil {
return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message")
return snapshottypes.SnapshotItem{}, errorsmod.Wrap(err, "invalid protobuf message")
}
payload := item.GetExtensionPayload()
if payload == nil {

View File

@ -10,9 +10,9 @@ import (
"sort"
"sync"
sdkerrors "cosmossdk.io/errors"
"cosmossdk.io/log"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/snapshots/types"
storetypes "cosmossdk.io/store/types"
)
@ -111,10 +111,10 @@ func (m *Manager) begin(op operation) error {
// beginLocked begins an operation while already holding the mutex.
func (m *Manager) beginLocked(op operation) error {
if op == opNone {
return sdkerrors.Wrap(storetypes.ErrLogic, "can't begin a none operation")
return errorsmod.Wrap(storetypes.ErrLogic, "can't begin a none operation")
}
if m.operation != opNone {
return sdkerrors.Wrapf(storetypes.ErrConflict, "a %v operation is in progress", m.operation)
return errorsmod.Wrapf(storetypes.ErrConflict, "a %v operation is in progress", m.operation)
}
m.operation = op
return nil
@ -160,7 +160,7 @@ func (m *Manager) GetSnapshotBlockRetentionHeights() int64 {
// Create creates a snapshot and returns its metadata.
func (m *Manager) Create(height uint64) (*types.Snapshot, error) {
if m == nil {
return nil, sdkerrors.Wrap(storetypes.ErrLogic, "no snapshot store configured")
return nil, errorsmod.Wrap(storetypes.ErrLogic, "no snapshot store configured")
}
defer m.multistore.PruneSnapshotHeight(int64(height))
@ -173,10 +173,10 @@ func (m *Manager) Create(height uint64) (*types.Snapshot, error) {
latest, err := m.store.GetLatest()
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to examine latest snapshot")
return nil, errorsmod.Wrap(err, "failed to examine latest snapshot")
}
if latest != nil && latest.Height >= height {
return nil, sdkerrors.Wrapf(storetypes.ErrConflict,
return nil, errorsmod.Wrapf(storetypes.ErrConflict,
"a more recent snapshot already exists at height %v", latest.Height)
}
@ -263,10 +263,10 @@ func (m *Manager) Prune(retain uint32) (uint64, error) {
// via RestoreChunk() until the restore is complete or a chunk fails.
func (m *Manager) Restore(snapshot types.Snapshot) error {
if snapshot.Chunks == 0 {
return sdkerrors.Wrap(types.ErrInvalidMetadata, "no chunks")
return errorsmod.Wrap(types.ErrInvalidMetadata, "no chunks")
}
if uint32(len(snapshot.Metadata.ChunkHashes)) != snapshot.Chunks {
return sdkerrors.Wrapf(types.ErrInvalidMetadata, "snapshot has %v chunk hashes, but %v chunks",
return errorsmod.Wrapf(types.ErrInvalidMetadata, "snapshot has %v chunk hashes, but %v chunks",
uint32(len(snapshot.Metadata.ChunkHashes)),
snapshot.Chunks)
}
@ -275,13 +275,13 @@ func (m *Manager) Restore(snapshot types.Snapshot) error {
// check multistore supported format preemptive
if snapshot.Format != types.CurrentFormat {
return sdkerrors.Wrapf(types.ErrUnknownFormat, "snapshot format %v", snapshot.Format)
return errorsmod.Wrapf(types.ErrUnknownFormat, "snapshot format %v", snapshot.Format)
}
if snapshot.Height == 0 {
return sdkerrors.Wrap(storetypes.ErrLogic, "cannot restore snapshot at height 0")
return errorsmod.Wrap(storetypes.ErrLogic, "cannot restore snapshot at height 0")
}
if snapshot.Height > uint64(math.MaxInt64) {
return sdkerrors.Wrapf(types.ErrInvalidMetadata,
return errorsmod.Wrapf(types.ErrInvalidMetadata,
"snapshot height %v cannot exceed %v", snapshot.Height, int64(math.MaxInt64))
}
@ -335,7 +335,7 @@ func (m *Manager) restoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.Re
nextItem, err = m.multistore.Restore(snapshot.Height, snapshot.Format, streamReader)
if err != nil {
return sdkerrors.Wrap(err, "multistore restore")
return errorsmod.Wrap(err, "multistore restore")
}
for {
@ -345,22 +345,22 @@ func (m *Manager) restoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.Re
}
metadata := nextItem.GetExtension()
if metadata == nil {
return sdkerrors.Wrapf(storetypes.ErrLogic, "unknown snapshot item %T", nextItem.Item)
return errorsmod.Wrapf(storetypes.ErrLogic, "unknown snapshot item %T", nextItem.Item)
}
extension, ok := m.extensions[metadata.Name]
if !ok {
return sdkerrors.Wrapf(storetypes.ErrLogic, "unknown extension snapshotter %s", metadata.Name)
return errorsmod.Wrapf(storetypes.ErrLogic, "unknown extension snapshotter %s", metadata.Name)
}
if !IsFormatSupported(extension, metadata.Format) {
return sdkerrors.Wrapf(types.ErrUnknownFormat, "format %v for extension %s", metadata.Format, metadata.Name)
return errorsmod.Wrapf(types.ErrUnknownFormat, "format %v for extension %s", metadata.Format, metadata.Name)
}
if err := extension.RestoreExtension(snapshot.Height, metadata.Format, payloadReader); err != nil {
return sdkerrors.Wrapf(err, "extension %s restore", metadata.Name)
return errorsmod.Wrapf(err, "extension %s restore", metadata.Name)
}
if nextItem.GetExtensionPayload() != nil {
return sdkerrors.Wrapf(err, "extension %s don't exhausted payload stream", metadata.Name)
return errorsmod.Wrapf(err, "extension %s don't exhausted payload stream", metadata.Name)
}
}
return nil
@ -372,11 +372,11 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) {
m.mtx.Lock()
defer m.mtx.Unlock()
if m.operation != opRestore {
return false, sdkerrors.Wrap(storetypes.ErrLogic, "no restore operation in progress")
return false, errorsmod.Wrap(storetypes.ErrLogic, "no restore operation in progress")
}
if int(m.restoreChunkIndex) >= len(m.restoreChunkHashes) {
return false, sdkerrors.Wrap(storetypes.ErrLogic, "received unexpected chunk")
return false, errorsmod.Wrap(storetypes.ErrLogic, "received unexpected chunk")
}
// Check if any errors have occurred yet.
@ -386,7 +386,7 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) {
if done.err != nil {
return false, done.err
}
return false, sdkerrors.Wrap(storetypes.ErrLogic, "restore ended unexpectedly")
return false, errorsmod.Wrap(storetypes.ErrLogic, "restore ended unexpectedly")
default:
}
@ -394,7 +394,7 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) {
hash := sha256.Sum256(chunk)
expected := m.restoreChunkHashes[m.restoreChunkIndex]
if !bytes.Equal(hash[:], expected) {
return false, sdkerrors.Wrapf(types.ErrChunkHashMismatch,
return false, errorsmod.Wrapf(types.ErrChunkHashMismatch,
"expected %x, got %x", hash, expected)
}
@ -411,7 +411,7 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) {
return false, done.err
}
if !done.complete {
return false, sdkerrors.Wrap(storetypes.ErrLogic, "restore ended prematurely")
return false, errorsmod.Wrap(storetypes.ErrLogic, "restore ended prematurely")
}
return true, nil
}

View File

@ -10,10 +10,10 @@ import (
"strconv"
"sync"
"cosmossdk.io/errors"
db "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"cosmossdk.io/errors"
"cosmossdk.io/store/snapshots/types"
storetypes "cosmossdk.io/store/types"
)

View File

@ -6,7 +6,6 @@ import (
"io"
"cosmossdk.io/errors"
protoio "github.com/cosmos/gogoproto/io"
"github.com/cosmos/gogoproto/proto"
)

View File

@ -1,10 +1,9 @@
package types
import (
"cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
proto "github.com/cosmos/gogoproto/proto"
"cosmossdk.io/errors"
)
// Converts an ABCI snapshot to a snapshot. Mainly to decode the SDK metadata.

View File

@ -6,6 +6,7 @@ import (
"io"
"cosmossdk.io/errors"
"cosmossdk.io/store/types"
)

View File

@ -7,7 +7,7 @@ import (
cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
ics23 "github.com/confio/ics23/go"
sdkerrors "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors"
sdkmaps "cosmossdk.io/store/internal/maps"
sdkproofs "cosmossdk.io/store/internal/proofs"
)
@ -73,7 +73,7 @@ func CommitmentOpDecoder(pop cmtprotocrypto.ProofOp) (merkle.ProofOperator, erro
case ProofOpSMTCommitment:
spec = ics23.SmtSpec
default:
return nil, sdkerrors.Wrapf(ErrInvalidProof, "unexpected ProofOp.Type; got %s, want supported ics23 subtypes 'ProofOpSimpleMerkleCommitment', 'ProofOpIAVLCommitment', or 'ProofOpSMTCommitment'", pop.Type)
return nil, errorsmod.Wrapf(ErrInvalidProof, "unexpected ProofOp.Type; got %s, want supported ics23 subtypes 'ProofOpSimpleMerkleCommitment', 'ProofOpIAVLCommitment', or 'ProofOpSMTCommitment'", pop.Type)
}
proof := &ics23.CommitmentProof{}
@ -108,7 +108,7 @@ func (op CommitmentOp) Run(args [][]byte) ([][]byte, error) {
// calculate root from proof
root, err := op.Proof.Calculate()
if err != nil {
return nil, sdkerrors.Wrapf(ErrInvalidProof, "could not calculate root for proof: %v", err)
return nil, errorsmod.Wrapf(ErrInvalidProof, "could not calculate root for proof: %v", err)
}
// Only support an existence proof or nonexistence proof (batch proofs currently unsupported)
switch len(args) {
@ -116,16 +116,16 @@ func (op CommitmentOp) Run(args [][]byte) ([][]byte, error) {
// Args are nil, so we verify the absence of the key.
absent := ics23.VerifyNonMembership(op.Spec, root, op.Proof, op.Key)
if !absent {
return nil, sdkerrors.Wrapf(ErrInvalidProof, "proof did not verify absence of key: %s", string(op.Key))
return nil, errorsmod.Wrapf(ErrInvalidProof, "proof did not verify absence of key: %s", string(op.Key))
}
case 1:
// Args is length 1, verify existence of key with value args[0]
if !ics23.VerifyMembership(op.Spec, root, op.Proof, op.Key, args[0]) {
return nil, sdkerrors.Wrapf(ErrInvalidProof, "proof did not verify existence of key %s with given value %x", op.Key, args[0])
return nil, errorsmod.Wrapf(ErrInvalidProof, "proof did not verify existence of key %s with given value %x", op.Key, args[0])
}
default:
return nil, sdkerrors.Wrapf(ErrInvalidProof, "args must be length 0 or 1, got: %d", len(args))
return nil, errorsmod.Wrapf(ErrInvalidProof, "args must be length 0 or 1, got: %d", len(args))
}
return [][]byte{root}, nil

View File

@ -22,13 +22,13 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/genutil"
)
@ -227,7 +227,7 @@ func createConfigFolder(dir string) error {
func saveGenesisFile(genDoc *cmttypes.GenesisDoc, dir string) error {
err := genutil.ExportGenesisFile(genDoc, dir)
if err != nil {
return errors.Wrap(err, "error creating file")
return errorsmod.Wrap(err, "error creating file")
}
return nil

View File

@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
@ -1155,7 +1155,7 @@ type protoTxProvider interface {
func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { // nolint
protoProvider, ok := txBuilder.(protoTxProvider)
if !ok {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected proto tx builder, got %T", txBuilder)
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expected proto tx builder, got %T", txBuilder)
}
return protoProvider.GetProtoTx(), nil

View File

@ -5,6 +5,7 @@ go 1.20
require (
cosmossdk.io/api v0.3.0
cosmossdk.io/depinject v1.0.0-alpha.3
cosmossdk.io/errors v1.0.0-beta.7
cosmossdk.io/log v0.0.0
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4
cosmossdk.io/simapp v0.0.0-00010101000000-000000000000
@ -36,7 +37,6 @@ require (
cosmossdk.io/client/v2 v2.0.0-20230104083136-11f46a0bae58 // indirect
cosmossdk.io/collections v0.0.0-20230204135315-697871069999 // indirect
cosmossdk.io/core v0.5.1 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/x/tx v0.2.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect

View File

@ -6,7 +6,9 @@ import (
"fmt"
"strconv"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -154,7 +156,7 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) {
panic(err)
}
if len(pkBytes) != ed25519.PubKeySize {
panic(errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size"))
panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size"))
}
return &ed25519.PubKey{Key: pkBytes}
}

View File

@ -1,6 +1,6 @@
package testdata
import "github.com/cosmos/cosmos-sdk/types/errors"
import "cosmossdk.io/errors"
var ErrTest = errors.Register("table_testdata", 2, "test")

View File

@ -19,15 +19,13 @@ const (
// MigrationMap defines a mapping from a version to a transformation plan.
type MigrationMap map[string]func(from *tomledit.Document, to string) transform.Plan
var (
Migrations = MigrationMap{
"v0.45": NoPlan, // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45.
"v0.46": PlanBuilder,
"v0.47": PlanBuilder,
"v0.48": PlanBuilder,
// "v0.xx.x": PlanBuilder, // add specific migration in case of configuration changes in minor versions
}
)
var Migrations = MigrationMap{
"v0.45": NoPlan, // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45.
"v0.46": PlanBuilder,
"v0.47": PlanBuilder,
"v0.48": PlanBuilder,
// "v0.xx.x": PlanBuilder, // add specific migration in case of configuration changes in minor versions
}
// PlanBuilder is a function that returns a transformation plan for a given diff between two files.
func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
@ -58,7 +56,8 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
Block: parser.Comments{
"###############################################################################",
fmt.Sprintf("### %s Configuration ###", strings.Title(kv.Key)),
"###############################################################################"},
"###############################################################################",
},
Name: keys,
},
})
@ -73,7 +72,8 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
Block: kv.Block,
Name: parser.Key{keys[0]},
Value: parser.MustValue(kv.Value),
})}
}),
}
} else if len(keys) > 1 {
step = transform.Step{
Desc: fmt.Sprintf("add %s key", kv.Key),
@ -81,7 +81,8 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
Block: kv.Block,
Name: parser.Key{keys[1]},
Value: parser.MustValue(kv.Value),
})}
}),
}
}
default:
panic(fmt.Errorf("unknown diff type: %s", diff.Type))

View File

@ -59,7 +59,7 @@ func Upgrade(ctx context.Context, plan transform.Plan, configPath, outputPath st
if outputPath == "" {
_, err = os.Stdout.Write(buf.Bytes())
} else {
err = atomicfile.WriteData(outputPath, buf.Bytes(), 0600)
err = atomicfile.WriteData(outputPath, buf.Bytes(), 0o600)
}
return err

View File

@ -198,8 +198,6 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z
cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU=
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
cosmossdk.io/math v1.0.0-beta.6 h1:WF29SiFYNde5eYvqO2kdOM9nYbDb44j3YW5B8M1m9KE=
cosmossdk.io/math v1.0.0-beta.6/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8=
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA=
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8=
cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 h1:IwyDN/YaQmF+Pmuv8d7vRWMM/k2RjSmPBycMcmd3ICE=

View File

@ -49,12 +49,12 @@ func SaveConfig(configDir string, config *Config) error {
return err
}
if err := os.MkdirAll(configDir, 0755); err != nil {
if err := os.MkdirAll(configDir, 0o755); err != nil {
return err
}
configPath := configFilename(configDir)
if err := os.WriteFile(configPath, buf.Bytes(), 0644); err != nil {
if err := os.WriteFile(configPath, buf.Bytes(), 0o644); err != nil {
return err
}

View File

@ -44,7 +44,7 @@ func NewChainInfo(configDir string, chain string, config *ChainConfig) *ChainInf
func (c *ChainInfo) getCacheDir() (string, error) {
cacheDir := path.Join(c.ConfigDir, "cache")
return cacheDir, os.MkdirAll(cacheDir, 0755)
return cacheDir, os.MkdirAll(cacheDir, 0o755)
}
func (c *ChainInfo) fdsCacheFilename() (string, error) {
@ -92,7 +92,7 @@ func (c *ChainInfo) Load(reload bool) error {
return err
}
if err = os.WriteFile(fdsFilename, bz, 0644); err != nil {
if err = os.WriteFile(fdsFilename, bz, 0o644); err != nil {
return err
}
} else {
@ -133,7 +133,7 @@ func (c *ChainInfo) Load(reload bool) error {
return err
}
err = os.WriteFile(appOptsFilename, bz, 0644)
err = os.WriteFile(appOptsFilename, bz, 0o644)
if err != nil {
return err
}

View File

@ -187,8 +187,10 @@ type dynamicTypeResolver struct {
*ChainInfo
}
var _ protoregistry.MessageTypeResolver = dynamicTypeResolver{}
var _ protoregistry.ExtensionTypeResolver = dynamicTypeResolver{}
var (
_ protoregistry.MessageTypeResolver = dynamicTypeResolver{}
_ protoregistry.ExtensionTypeResolver = dynamicTypeResolver{}
)
func (d dynamicTypeResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
desc, err := d.ProtoFiles.FindDescriptorByName(message)

View File

@ -12,6 +12,8 @@ import (
"github.com/hashicorp/golang-lru/simplelru"
"sigs.k8s.io/yaml"
errorsmod "cosmossdk.io/errors"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/internal/conv"
"github.com/cosmos/cosmos-sdk/types/address"
@ -153,11 +155,11 @@ func VerifyAddressFormat(bz []byte) error {
}
if len(bz) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
return errorsmod.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
}
if len(bz) > address.MaxAddrLen {
return sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bz))
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bz))
}
return nil

View File

@ -8,8 +8,9 @@ import (
"github.com/cometbft/cometbft/crypto"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/internal/conv"
"github.com/cosmos/cosmos-sdk/types/errors"
)
// Len is the length of base addresses

View File

@ -1,6 +1,8 @@
package address
import (
errorsmod "cosmossdk.io/errors"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -16,7 +18,7 @@ func LengthPrefix(bz []byte) ([]byte, error) {
}
if bzLen > MaxAddrLen {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "address length should be max %d bytes, got %d", MaxAddrLen, bzLen)
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address length should be max %d bytes, got %d", MaxAddrLen, bzLen)
}
return append([]byte{byte(bzLen)}, bz...), nil

View File

@ -2,9 +2,10 @@ package types_test
import (
"bytes"
"crypto/rand"
"encoding/hex"
"fmt"
"math/rand"
mathrand "math/rand"
"strings"
"testing"
@ -211,7 +212,7 @@ const letterBytes = "abcdefghijklmnopqrstuvwxyz"
func RandString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
b[i] = letterBytes[mathrand.Intn(len(letterBytes))]
}
return string(b)
}

View File

@ -1,13 +1,14 @@
package errors
import (
errorsmod "cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
)
// ResponseCheckTxWithEvents returns an ABCI ResponseCheckTx object with fields filled in
// from the given error, gas values and events.
func ResponseCheckTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) abci.ResponseCheckTx {
space, code, log := ABCIInfo(err, debug)
space, code, log := errorsmod.ABCIInfo(err, debug)
return abci.ResponseCheckTx{
Codespace: space,
Code: code,
@ -21,7 +22,7 @@ func ResponseCheckTxWithEvents(err error, gw, gu uint64, events []abci.Event, de
// ResponseDeliverTxWithEvents returns an ABCI ResponseDeliverTx object with fields filled in
// from the given error, gas values and events.
func ResponseDeliverTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) abci.ResponseDeliverTx {
space, code, log := ABCIInfo(err, debug)
space, code, log := errorsmod.ABCIInfo(err, debug)
return abci.ResponseDeliverTx{
Codespace: space,
Code: code,
@ -35,7 +36,7 @@ func ResponseDeliverTxWithEvents(err error, gw, gu uint64, events []abci.Event,
// QueryResult returns a ResponseQuery from an error. It will try to parse ABCI
// info from the error.
func QueryResult(err error, debug bool) abci.ResponseQuery {
space, code, log := ABCIInfo(err, debug)
space, code, log := errorsmod.ABCIInfo(err, debug)
return abci.ResponseQuery{
Codespace: space,
Code: code,

View File

@ -37,135 +37,135 @@ const RootCodespace = "sdk"
var (
// ErrTxDecode is returned if we cannot parse a transaction
ErrTxDecode = Register(RootCodespace, 2, "tx parse error")
ErrTxDecode = errorsmod.Register(RootCodespace, 2, "tx parse error")
// ErrInvalidSequence is used the sequence number (nonce) is incorrect
// for the signature
ErrInvalidSequence = Register(RootCodespace, 3, "invalid sequence")
ErrInvalidSequence = errorsmod.Register(RootCodespace, 3, "invalid sequence")
// ErrUnauthorized is used whenever a request without sufficient
// authorization is handled.
ErrUnauthorized = Register(RootCodespace, 4, "unauthorized")
ErrUnauthorized = errorsmod.Register(RootCodespace, 4, "unauthorized")
// ErrInsufficientFunds is used when the account cannot pay requested amount.
ErrInsufficientFunds = Register(RootCodespace, 5, "insufficient funds")
ErrInsufficientFunds = errorsmod.Register(RootCodespace, 5, "insufficient funds")
// ErrUnknownRequest to doc
ErrUnknownRequest = Register(RootCodespace, 6, "unknown request")
ErrUnknownRequest = errorsmod.Register(RootCodespace, 6, "unknown request")
// ErrInvalidAddress to doc
ErrInvalidAddress = Register(RootCodespace, 7, "invalid address")
ErrInvalidAddress = errorsmod.Register(RootCodespace, 7, "invalid address")
// ErrInvalidPubKey to doc
ErrInvalidPubKey = Register(RootCodespace, 8, "invalid pubkey")
ErrInvalidPubKey = errorsmod.Register(RootCodespace, 8, "invalid pubkey")
// ErrUnknownAddress to doc
ErrUnknownAddress = Register(RootCodespace, 9, "unknown address")
ErrUnknownAddress = errorsmod.Register(RootCodespace, 9, "unknown address")
// ErrInvalidCoins to doc
ErrInvalidCoins = Register(RootCodespace, 10, "invalid coins")
ErrInvalidCoins = errorsmod.Register(RootCodespace, 10, "invalid coins")
// ErrOutOfGas to doc
ErrOutOfGas = Register(RootCodespace, 11, "out of gas")
ErrOutOfGas = errorsmod.Register(RootCodespace, 11, "out of gas")
// ErrMemoTooLarge to doc
ErrMemoTooLarge = Register(RootCodespace, 12, "memo too large")
ErrMemoTooLarge = errorsmod.Register(RootCodespace, 12, "memo too large")
// ErrInsufficientFee to doc
ErrInsufficientFee = Register(RootCodespace, 13, "insufficient fee")
ErrInsufficientFee = errorsmod.Register(RootCodespace, 13, "insufficient fee")
// ErrTooManySignatures to doc
ErrTooManySignatures = Register(RootCodespace, 14, "maximum number of signatures exceeded")
ErrTooManySignatures = errorsmod.Register(RootCodespace, 14, "maximum number of signatures exceeded")
// ErrNoSignatures to doc
ErrNoSignatures = Register(RootCodespace, 15, "no signatures supplied")
ErrNoSignatures = errorsmod.Register(RootCodespace, 15, "no signatures supplied")
// ErrJSONMarshal defines an ABCI typed JSON marshalling error
ErrJSONMarshal = Register(RootCodespace, 16, "failed to marshal JSON bytes")
ErrJSONMarshal = errorsmod.Register(RootCodespace, 16, "failed to marshal JSON bytes")
// ErrJSONUnmarshal defines an ABCI typed JSON unmarshalling error
ErrJSONUnmarshal = Register(RootCodespace, 17, "failed to unmarshal JSON bytes")
ErrJSONUnmarshal = errorsmod.Register(RootCodespace, 17, "failed to unmarshal JSON bytes")
// ErrInvalidRequest defines an ABCI typed error where the request contains
// invalid data.
ErrInvalidRequest = Register(RootCodespace, 18, "invalid request")
ErrInvalidRequest = errorsmod.Register(RootCodespace, 18, "invalid request")
// ErrTxInMempoolCache defines an ABCI typed error where a tx already exists
// in the mempool.
ErrTxInMempoolCache = Register(RootCodespace, 19, "tx already in mempool")
ErrTxInMempoolCache = errorsmod.Register(RootCodespace, 19, "tx already in mempool")
// ErrMempoolIsFull defines an ABCI typed error where the mempool is full.
ErrMempoolIsFull = Register(RootCodespace, 20, "mempool is full")
ErrMempoolIsFull = errorsmod.Register(RootCodespace, 20, "mempool is full")
// ErrTxTooLarge defines an ABCI typed error where tx is too large.
ErrTxTooLarge = Register(RootCodespace, 21, "tx too large")
ErrTxTooLarge = errorsmod.Register(RootCodespace, 21, "tx too large")
// ErrKeyNotFound defines an error when the key doesn't exist
ErrKeyNotFound = Register(RootCodespace, 22, "key not found")
ErrKeyNotFound = errorsmod.Register(RootCodespace, 22, "key not found")
// ErrWrongPassword defines an error when the key password is invalid.
ErrWrongPassword = Register(RootCodespace, 23, "invalid account password")
ErrWrongPassword = errorsmod.Register(RootCodespace, 23, "invalid account password")
// ErrorInvalidSigner defines an error when the tx intended signer does not match the given signer.
ErrorInvalidSigner = Register(RootCodespace, 24, "tx intended signer does not match the given signer")
ErrorInvalidSigner = errorsmod.Register(RootCodespace, 24, "tx intended signer does not match the given signer")
// ErrorInvalidGasAdjustment defines an error for an invalid gas adjustment
ErrorInvalidGasAdjustment = Register(RootCodespace, 25, "invalid gas adjustment")
ErrorInvalidGasAdjustment = errorsmod.Register(RootCodespace, 25, "invalid gas adjustment")
// ErrInvalidHeight defines an error for an invalid height
ErrInvalidHeight = Register(RootCodespace, 26, "invalid height")
ErrInvalidHeight = errorsmod.Register(RootCodespace, 26, "invalid height")
// ErrInvalidVersion defines a general error for an invalid version
ErrInvalidVersion = Register(RootCodespace, 27, "invalid version")
ErrInvalidVersion = errorsmod.Register(RootCodespace, 27, "invalid version")
// ErrInvalidChainID defines an error when the chain-id is invalid.
ErrInvalidChainID = Register(RootCodespace, 28, "invalid chain-id")
ErrInvalidChainID = errorsmod.Register(RootCodespace, 28, "invalid chain-id")
// ErrInvalidType defines an error an invalid type.
ErrInvalidType = Register(RootCodespace, 29, "invalid type")
ErrInvalidType = errorsmod.Register(RootCodespace, 29, "invalid type")
// ErrTxTimeoutHeight defines an error for when a tx is rejected out due to an
// explicitly set timeout height.
ErrTxTimeoutHeight = Register(RootCodespace, 30, "tx timeout height")
ErrTxTimeoutHeight = errorsmod.Register(RootCodespace, 30, "tx timeout height")
// ErrUnknownExtensionOptions defines an error for unknown extension options.
ErrUnknownExtensionOptions = Register(RootCodespace, 31, "unknown extension options")
ErrUnknownExtensionOptions = errorsmod.Register(RootCodespace, 31, "unknown extension options")
// ErrWrongSequence defines an error where the account sequence defined in
// the signer info doesn't match the account's actual sequence number.
ErrWrongSequence = Register(RootCodespace, 32, "incorrect account sequence")
ErrWrongSequence = errorsmod.Register(RootCodespace, 32, "incorrect account sequence")
// ErrPackAny defines an error when packing a protobuf message to Any fails.
ErrPackAny = Register(RootCodespace, 33, "failed packing protobuf message to Any")
ErrPackAny = errorsmod.Register(RootCodespace, 33, "failed packing protobuf message to Any")
// ErrUnpackAny defines an error when unpacking a protobuf message from Any fails.
ErrUnpackAny = Register(RootCodespace, 34, "failed unpacking protobuf message from Any")
ErrUnpackAny = errorsmod.Register(RootCodespace, 34, "failed unpacking protobuf message from Any")
// ErrLogic defines an internal logic error, e.g. an invariant or assertion
// that is violated. It is a programmer error, not a user-facing error.
ErrLogic = Register(RootCodespace, 35, "internal logic error")
ErrLogic = errorsmod.Register(RootCodespace, 35, "internal logic error")
// ErrConflict defines a conflict error, e.g. when two goroutines try to access
// the same resource and one of them fails.
ErrConflict = Register(RootCodespace, 36, "conflict")
ErrConflict = errorsmod.Register(RootCodespace, 36, "conflict")
// ErrNotSupported is returned when we call a branch of a code which is currently not
// supported.
ErrNotSupported = Register(RootCodespace, 37, "feature not supported")
ErrNotSupported = errorsmod.Register(RootCodespace, 37, "feature not supported")
// ErrNotFound defines an error when requested entity doesn't exist in the state.
ErrNotFound = Register(RootCodespace, 38, "not found")
ErrNotFound = errorsmod.Register(RootCodespace, 38, "not found")
// ErrIO should be used to wrap internal errors caused by external operation.
// Examples: not DB domain error, file writing etc...
ErrIO = Register(RootCodespace, 39, "Internal IO error")
ErrIO = errorsmod.Register(RootCodespace, 39, "Internal IO error")
// ErrAppConfig defines an error occurred if min-gas-prices field in BaseConfig is empty.
ErrAppConfig = Register(RootCodespace, 40, "error in app.toml")
ErrAppConfig = errorsmod.Register(RootCodespace, 40, "error in app.toml")
// ErrInvalidGasLimit defines an error when an invalid GasWanted value is
// supplied.
ErrInvalidGasLimit = Register(RootCodespace, 41, "invalid gas limit")
ErrInvalidGasLimit = errorsmod.Register(RootCodespace, 41, "invalid gas limit")
// ErrPanic should only be set when we recovering from a panic
ErrPanic = errorsmod.ErrPanic

View File

@ -5,6 +5,8 @@ import (
"github.com/cosmos/gogoproto/grpc"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -70,7 +72,7 @@ func (c configurator) QueryServer() grpc.Server {
// RegisterMigration implements the Configurator.RegisterMigration method
func (c configurator) RegisterMigration(moduleName string, fromVersion uint64, handler MigrationHandler) error {
if fromVersion == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "module migration versions should start at 1")
return errorsmod.Wrap(sdkerrors.ErrInvalidVersion, "module migration versions should start at 1")
}
if c.migrations[moduleName] == nil {
@ -78,7 +80,7 @@ func (c configurator) RegisterMigration(moduleName string, fromVersion uint64, h
}
if c.migrations[moduleName][fromVersion] != nil {
return sdkerrors.Wrapf(sdkerrors.ErrLogic, "another migration for module %s and version %d already exists", moduleName, fromVersion)
return errorsmod.Wrapf(sdkerrors.ErrLogic, "another migration for module %s and version %d already exists", moduleName, fromVersion)
}
c.migrations[moduleName][fromVersion] = handler
@ -96,14 +98,14 @@ func (c configurator) runModuleMigrations(ctx sdk.Context, moduleName string, fr
moduleMigrationsMap, found := c.migrations[moduleName]
if !found {
return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no migrations found for module %s", moduleName)
return errorsmod.Wrapf(sdkerrors.ErrNotFound, "no migrations found for module %s", moduleName)
}
// Run in-place migrations for the module sequentially until toVersion.
for i := fromVersion; i < toVersion; i++ {
migrateFn, found := moduleMigrationsMap[i]
if !found {
return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no migration found for module %s from version %d to version %d", moduleName, i, i+1)
return errorsmod.Wrapf(sdkerrors.ErrNotFound, "no migration found for module %s from version %d to version %d", moduleName, i, i+1)
}
ctx.Logger().Info(fmt.Sprintf("migrating module %s from version %d to version %d", moduleName, i, i+1))

View File

@ -43,6 +43,8 @@ import (
storetypes "cosmossdk.io/store/types"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
@ -586,7 +588,7 @@ type VersionMap map[string]uint64
func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM VersionMap) (VersionMap, error) {
c, ok := cfg.(configurator)
if !ok {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", configurator{}, cfg)
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", configurator{}, cfg)
}
modules := m.OrderMigrations
if modules == nil {
@ -622,7 +624,7 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM Version
// The module manager assumes only one module will update the
// validator set, and it can't be a new module.
if len(moduleValUpdates) > 0 {
return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "validator InitGenesis update is already set by another module")
return nil, errorsmod.Wrapf(sdkerrors.ErrLogic, "validator InitGenesis update is already set by another module")
}
}
}

View File

@ -3,6 +3,8 @@ package tx
import (
"fmt"
errorsmod "cosmossdk.io/errors"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -54,21 +56,21 @@ func (t *Tx) ValidateBasic() error {
}
if fee.GasLimit > MaxGasWanted {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"invalid gas supplied; %d > %d", fee.GasLimit, MaxGasWanted,
)
}
if fee.Amount.IsAnyNil() {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInsufficientFee,
"invalid fee provided: null",
)
}
if fee.Amount.IsAnyNegative() {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInsufficientFee,
"invalid fee provided: %s", fee.Amount,
)
@ -77,7 +79,7 @@ func (t *Tx) ValidateBasic() error {
if fee.Payer != "" {
_, err := sdk.AccAddressFromBech32(fee.Payer)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid fee payer address (%s)", err)
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid fee payer address (%s)", err)
}
}
@ -88,7 +90,7 @@ func (t *Tx) ValidateBasic() error {
}
if len(sigs) != len(t.GetSigners()) {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", len(t.GetSigners()), len(sigs),
)

View File

@ -3,6 +3,8 @@ package ante
import (
storetypes "cosmossdk.io/store/types"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
@ -26,15 +28,15 @@ type HandlerOptions struct {
// signer.
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}
anteDecorators := []sdk.AnteDecorator{

View File

@ -13,6 +13,8 @@ import (
storetypes "cosmossdk.io/store/types"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@ -1376,7 +1378,7 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) {
meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519")
return nil
default:
return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
}
},
},

View File

@ -3,6 +3,8 @@ package ante
import (
storetypes "cosmossdk.io/store/types"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -52,14 +54,14 @@ func NewValidateMemoDecorator(ak AccountKeeper) ValidateMemoDecorator {
func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
memoTx, ok := tx.(sdk.TxWithMemo)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
}
memoLength := len(memoTx.GetMemo())
if memoLength > 0 {
params := vmd.ak.GetParams(ctx)
if uint64(memoLength) > params.MaxMemoCharacters {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrMemoTooLarge,
return ctx, errorsmod.Wrapf(sdkerrors.ErrMemoTooLarge,
"maximum number of characters is %d but received %d characters",
params.MaxMemoCharacters, memoLength,
)
@ -91,7 +93,7 @@ func NewConsumeGasForTxSizeDecorator(ak AccountKeeper) ConsumeTxSizeGasDecorator
func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid tx type")
}
params := cgts.ak.GetParams(ctx)
@ -195,12 +197,12 @@ func NewTxTimeoutHeightDecorator() TxTimeoutHeightDecorator {
func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
timeoutTx, ok := tx.(TxWithTimeoutHeight)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "expected tx to implement TxWithTimeoutHeight")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "expected tx to implement TxWithTimeoutHeight")
}
timeoutHeight := timeoutTx.GetTimeoutHeight()
if timeoutHeight > 0 && uint64(ctx.BlockHeight()) > timeoutHeight {
return ctx, sdkerrors.Wrapf(
return ctx, errorsmod.Wrapf(
sdkerrors.ErrTxTimeoutHeight, "block height: %d, timeout height: %d", ctx.BlockHeight(), timeoutHeight,
)
}

View File

@ -3,6 +3,8 @@ package ante
import (
"fmt"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@ -39,11 +41,11 @@ func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKee
func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}
if !simulate && ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidGasLimit, "must provide positive gas")
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidGasLimit, "must provide positive gas")
}
var (
@ -70,7 +72,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error {
feeTx, ok := sdkTx.(sdk.FeeTx)
if !ok {
return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}
if addr := dfd.accountKeeper.GetModuleAddress(types.FeeCollectorName); addr == nil {
@ -89,7 +91,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
} else if !feeGranter.Equals(feePayer) {
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, sdkTx.GetMsgs())
if err != nil {
return sdkerrors.Wrapf(err, "%s does not allow to pay fees for %s", feeGranter, feePayer)
return errorsmod.Wrapf(err, "%s does not allow to pay fees for %s", feeGranter, feePayer)
}
}
@ -124,12 +126,12 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
// DeductFees deducts fees from the given account.
func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error {
if !fees.IsValid() {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
return errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
}
err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
}
return nil

View File

@ -5,6 +5,8 @@ import (
storetypes "cosmossdk.io/store/types"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
@ -36,7 +38,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
// Set a gas meter with limit 0 as to prevent an infinite gas meter attack
// during runTx.
newCtx = SetGasMeter(simulate, ctx, 0)
return newCtx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx")
return newCtx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx")
}
newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas())
@ -54,7 +56,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
"out of gas in location: %v; gasWanted: %d, gasUsed: %d",
rType.Descriptor, gasTx.GetGas(), newCtx.GasMeter().GasConsumed())
err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log)
err = errorsmod.Wrap(sdkerrors.ErrOutOfGas, log)
default:
panic(r)
}

View File

@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@ -59,7 +60,7 @@ func NewSetPubKeyDecorator(ak AccountKeeper) SetPubKeyDecorator {
func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid tx type")
}
pubkeys, err := sigTx.GetPubKeys()
@ -78,7 +79,7 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
}
// Only make check if simulate=false
if !simulate && !bytes.Equal(pk.Address(), signers[i]) {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey,
return ctx, errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey,
"pubKey does not match signer address %s with signer index: %d", signers[i], i)
}
@ -92,7 +93,7 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
}
err = acc.SetPubKey(pk)
if err != nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error())
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, err.Error())
}
spkd.ak.SetAccount(ctx, acc)
}
@ -151,7 +152,7 @@ func NewSigGasConsumeDecorator(ak AccountKeeper, sigGasConsumer SignatureVerific
func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
}
params := sgcd.ak.GetParams(ctx)
@ -237,7 +238,7 @@ func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool {
func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
}
// stdSigs contains the sequence number, account number, and signatures.
@ -251,7 +252,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
// check that signer length and signature length are the same
if len(sigs) != len(signerAddrs) {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signerAddrs), len(sigs))
return ctx, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signerAddrs), len(sigs))
}
for i, sig := range sigs {
@ -263,12 +264,12 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
// retrieve pubkey
pubKey := acc.GetPubKey()
if !simulate && pubKey == nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set")
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set")
}
// Check account sequence number.
if sig.Sequence != acc.GetSequence() {
return ctx, sdkerrors.Wrapf(
return ctx, errorsmod.Wrapf(
sdkerrors.ErrWrongSequence,
"account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.Sequence,
)
@ -301,7 +302,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
} else {
errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s)", accNum, chainID)
}
return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, errMsg)
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, errMsg)
}
}
@ -332,7 +333,7 @@ func NewIncrementSequenceDecorator(ak AccountKeeper) IncrementSequenceDecorator
func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type")
}
// increment sequence of all signers
@ -365,7 +366,7 @@ func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator {
func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a sigTx")
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a sigTx")
}
params := vscd.ak.GetParams(ctx)
@ -378,7 +379,7 @@ func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
for _, pk := range pubKeys {
sigCount += CountSubKeys(pk)
if uint64(sigCount) > params.TxSigLimit {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrTooManySignatures,
return ctx, errorsmod.Wrapf(sdkerrors.ErrTooManySignatures,
"signatures: %d, limit: %d", sigCount, params.TxSigLimit)
}
}
@ -396,7 +397,7 @@ func DefaultSigVerificationGasConsumer(
switch pubkey := pubkey.(type) {
case *ed25519.PubKey:
meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519")
return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported")
return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported")
case *secp256k1.PubKey:
meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1")
@ -418,7 +419,7 @@ func DefaultSigVerificationGasConsumer(
return nil
default:
return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
}
}
@ -456,7 +457,7 @@ func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (sdk.A
return acc, nil
}
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
}
// CountSubKeys counts the total number of keys for a multi-sig public key.

View File

@ -3,7 +3,9 @@ package ante
import (
"math"
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -13,7 +15,7 @@ import (
func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return nil, 0, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}
feeCoins := feeTx.GetFee()
@ -36,7 +38,7 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins,
}
if !feeCoins.IsAnyGTE(requiredFees) {
return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}
}
}

View File

@ -9,6 +9,8 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
"github.com/spf13/cobra"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -116,7 +118,7 @@ func GetAccountCmd() *cobra.Command {
}
catchingUp := status.SyncInfo.CatchingUp
if !catchingUp {
return errors.Wrapf(err, "your node may be syncing, please check node status using `/status`")
return errorsmod.Wrapf(err, "your node may be syncing, please check node status using `/status`")
}
return err
}

View File

@ -9,6 +9,8 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
@ -16,7 +18,6 @@ import (
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
@ -420,7 +421,7 @@ func getMultisigRecord(clientCtx client.Context, name string) (*keyring.Record,
kb := clientCtx.Keyring
multisigRecord, err := kb.Key(name)
if err != nil {
return nil, errors.Wrap(err, "error getting keybase multisig account")
return nil, errorsmod.Wrap(err, "error getting keybase multisig account")
}
return multisigRecord, nil

View File

@ -17,7 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)
@ -52,7 +52,7 @@ func SignTx(txFactory tx.Factory, clientCtx client.Context, name string, txBuild
}
addr := sdk.AccAddress(pubKey.Address())
if !isTxSigner(addr, txBuilder.GetTx().GetSigners()) {
return fmt.Errorf("%s: %s", sdkerrors.ErrorInvalidSigner, name)
return fmt.Errorf("%s: %s", errors.ErrorInvalidSigner, name)
}
if !offline {
txFactory, err = populateAccountFromState(txFactory, clientCtx, addr)
@ -80,7 +80,7 @@ func SignTxWithSignerAddress(txFactory tx.Factory, clientCtx client.Context, add
// check whether the address is a signer
if !isTxSigner(addr, txBuilder.GetTx().GetSigners()) {
return fmt.Errorf("%s: %s", sdkerrors.ErrorInvalidSigner, name)
return fmt.Errorf("%s: %s", errors.ErrorInvalidSigner, name)
}
if !offline {

View File

@ -1,6 +1,8 @@
package keeper
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/bech32"
@ -25,7 +27,7 @@ func (bc bech32Codec) StringToBytes(text string) ([]byte, error) {
}
if hrp != bc.bech32Prefix {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "hrp does not match bech32Prefix")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "hrp does not match bech32Prefix")
}
if err := sdk.VerifyAddressFormat(bz); err != nil {

View File

@ -6,6 +6,7 @@ import (
"cosmossdk.io/log"
gogotypes "github.com/cosmos/gogoproto/types"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
@ -111,7 +112,7 @@ func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger {
func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) {
acc := ak.GetAccount(ctx, addr)
if acc == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
}
return acc.GetPubKey(), nil
@ -121,7 +122,7 @@ func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptot
func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, error) {
acc := ak.GetAccount(ctx, addr)
if acc == nil {
return 0, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
return 0, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
}
return acc.GetSequence(), nil

View File

@ -3,8 +3,9 @@ package keeper
import (
"context"
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

View File

@ -3,10 +3,11 @@ package legacytx
import (
"fmt"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@ -80,7 +81,7 @@ func MultiSignatureDataToAminoMultisignature(cdc *codec.LegacyAmino, mSig *signi
var err error
sigs[i], err = SignatureDataToAminoSignature(cdc, mSig.Signatures[i])
if err != nil {
return multisig.AminoMultisignature{}, sdkerrors.Wrapf(err, "Unable to convert Signature Data to signature %d", i)
return multisig.AminoMultisignature{}, errors.Wrapf(err, "Unable to convert Signature Data to signature %d", i)
}
}

View File

@ -6,13 +6,14 @@ import (
"sigs.k8s.io/yaml"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
)
@ -167,7 +168,7 @@ func pubKeySigToSigData(cdc *codec.LegacyAmino, key cryptotypes.PubKey, sig []by
if bitArray.GetIndex(i) {
data, err := pubKeySigToSigData(cdc, pubKeys[i], multiSig.Sigs[sigIdx])
if err != nil {
return nil, sdkerrors.Wrapf(err, "Unable to convert Signature to SigData %d", sigIdx)
return nil, errors.Wrapf(err, "Unable to convert Signature to SigData %d", sigIdx)
}
sigDatas[sigIdx] = data

View File

@ -1,7 +1,9 @@
package legacytx
import (
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -113,13 +115,13 @@ func (stdTx StdTx) ValidateBasic() error {
stdSigs := stdTx.GetSignatures()
if stdTx.Fee.Gas > tx.MaxGasWanted {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"invalid gas supplied; %d > %d", stdTx.Fee.Gas, tx.MaxGasWanted,
)
}
if stdTx.Fee.Amount.IsAnyNegative() {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrInsufficientFee,
"invalid fee provided: %s", stdTx.Fee.Amount,
)
@ -128,7 +130,7 @@ func (stdTx StdTx) ValidateBasic() error {
return sdkerrors.ErrNoSignatures
}
if len(stdSigs) != len(stdTx.GetSigners()) {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", len(stdTx.GetSigners()), len(stdSigs),
)
@ -196,7 +198,7 @@ func (tx StdTx) GetSignaturesV2() ([]signing.SignatureV2, error) {
var err error
res[i], err = StdSignatureToSignatureV2(legacy.Cdc, sig)
if err != nil {
return nil, sdkerrors.Wrapf(err, "Unable to convert signature %v to V2", sig)
return nil, errorsmod.Wrapf(err, "Unable to convert signature %v to V2", sig)
}
}

View File

@ -3,6 +3,8 @@ package legacytx
import (
"fmt"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -188,14 +190,14 @@ type Unmarshaler func(bytes []byte, ptr interface{}) error
func mkDecoder(unmarshaler Unmarshaler) sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, error) {
if len(txBytes) == 0 {
return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "tx bytes are empty")
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, "tx bytes are empty")
}
tx := StdTx{}
// StdTx.Msg is an interface. The concrete types
// are registered by MakeTxCodec
err := unmarshaler(txBytes, &tx)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error())
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, err.Error())
}
return tx, nil
}

View File

@ -8,6 +8,8 @@ import (
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@ -169,7 +171,7 @@ func TestTxValidateBasic(t *testing.T) {
err := tx.ValidateBasic()
require.Error(t, err)
_, code, _ := sdkerrors.ABCIInfo(err, false)
_, code, _ := errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrInsufficientFee.ABCICode(), code)
// require to fail validation when no signatures exist
@ -178,7 +180,7 @@ func TestTxValidateBasic(t *testing.T) {
err = tx.ValidateBasic()
require.Error(t, err)
_, code, _ = sdkerrors.ABCIInfo(err, false)
_, code, _ = errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrNoSignatures.ABCICode(), code)
// require to fail validation when signatures do not match expected signers
@ -187,7 +189,7 @@ func TestTxValidateBasic(t *testing.T) {
err = tx.ValidateBasic()
require.Error(t, err)
_, code, _ = sdkerrors.ABCIInfo(err, false)
_, code, _ = errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrUnauthorized.ABCICode(), code)
// require to fail with invalid gas supplied
@ -197,7 +199,7 @@ func TestTxValidateBasic(t *testing.T) {
err = tx.ValidateBasic()
require.Error(t, err)
_, code, _ = sdkerrors.ABCIInfo(err, false)
_, code, _ = errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrInvalidRequest.ABCICode(), code)
// require to pass when above criteria are matched

View File

@ -3,6 +3,8 @@ package tx
import (
"github.com/cosmos/gogoproto/proto"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -122,7 +124,7 @@ func (w *wrapper) GetPubKeys() ([]cryptotypes.PubKey, error) {
if ok {
pks[i] = pk
} else {
return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "Expecting PubKey, got: %T", pkAny)
return nil, errorsmod.Wrapf(sdkerrors.ErrLogic, "Expecting PubKey, got: %T", pkAny)
}
}

View File

@ -5,6 +5,8 @@ import (
"github.com/stretchr/testify/require"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -165,7 +167,7 @@ func TestBuilderValidateBasic(t *testing.T) {
txBuilder.SetFeeAmount(badFeeAmount)
err = txBuilder.ValidateBasic()
require.Error(t, err)
_, code, _ := sdkerrors.ABCIInfo(err, false)
_, code, _ := errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrInsufficientFee.ABCICode(), code)
// require to fail validation when no signatures exist
@ -174,7 +176,7 @@ func TestBuilderValidateBasic(t *testing.T) {
txBuilder.SetFeeAmount(feeAmount)
err = txBuilder.ValidateBasic()
require.Error(t, err)
_, code, _ = sdkerrors.ABCIInfo(err, false)
_, code, _ = errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrNoSignatures.ABCICode(), code)
// require to fail with nil values for tx, authinfo
@ -189,7 +191,7 @@ func TestBuilderValidateBasic(t *testing.T) {
err = txBuilder.ValidateBasic()
require.Error(t, err)
_, code, _ = sdkerrors.ABCIInfo(err, false)
_, code, _ = errorsmod.ABCIInfo(err, false)
require.Equal(t, sdkerrors.ErrUnauthorized.ABCICode(), code)
require.Error(t, err)

Some files were not shown because too many files have changed in this diff Show More