diff --git a/x/dymns/client/cli/tx_update_resolve_address.go b/x/dymns/client/cli/tx_update_resolve_address.go index e524a9342..3f3023025 100644 --- a/x/dymns/client/cli/tx_update_resolve_address.go +++ b/x/dymns/client/cli/tx_update_resolve_address.go @@ -4,8 +4,7 @@ import ( "fmt" "time" - "cosmossdk.io/errors" - + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -43,14 +42,14 @@ func NewUpdateResolveDymNameAddressTxCmd() *cobra.Command { subName, dymName, chainIdOrAlias, err := dymnskeeper.ParseDymNameAddress(dymNameAddress) if err != nil { - return errors.Wrap(err, "failed to parse input Dym-Name-Address") + return errorsmod.Wrap(err, "failed to parse input Dym-Name-Address") } respTranslateChainId, err := queryClient.TranslateAliasOrChainIdToChainId(cmd.Context(), &dymnstypes.QueryTranslateAliasOrChainIdToChainIdRequest{ AliasOrChainId: chainIdOrAlias, }) if err != nil || respTranslateChainId.ChainId == "" { - return errors.Wrapf(err, "failed to translate alias to chain-id: %s", chainIdOrAlias) + return errorsmod.Wrapf(err, "failed to translate alias to chain-id: %s", chainIdOrAlias) } chainId := respTranslateChainId.ChainId diff --git a/x/lockup/keeper/grpc_query.go b/x/lockup/keeper/grpc_query.go index b1c8ee639..9d4bcbe95 100644 --- a/x/lockup/keeper/grpc_query.go +++ b/x/lockup/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "google.golang.org/grpc/codes" @@ -42,7 +43,7 @@ func (q Querier) AccountUnlockableCoins(goCtx context.Context, req *types.Accoun return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -61,7 +62,7 @@ func (q Querier) AccountUnlockingCoins(goCtx context.Context, req *types.Account return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -80,7 +81,7 @@ func (q Querier) AccountLockedCoins(goCtx context.Context, req *types.AccountLoc return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -99,7 +100,7 @@ func (q Querier) AccountLockedPastTime(goCtx context.Context, req *types.Account return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -118,7 +119,7 @@ func (q Querier) AccountUnlockedBeforeTime(goCtx context.Context, req *types.Acc return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -138,7 +139,7 @@ func (q Querier) AccountLockedPastTimeDenom(goCtx context.Context, req *types.Ac return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -181,7 +182,7 @@ func (q Querier) AccountLockedLongerDuration(goCtx context.Context, req *types.A return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -201,7 +202,7 @@ func (q Querier) AccountLockedLongerDurationDenom(goCtx context.Context, req *ty return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -221,7 +222,7 @@ func (q Querier) AccountLockedDuration(goCtx context.Context, req *types.Account return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -242,7 +243,7 @@ func (q Querier) AccountLockedPastTimeNotUnlockingOnly(goCtx context.Context, re return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -262,7 +263,7 @@ func (q Querier) AccountLockedLongerDurationNotUnlockingOnly(goCtx context.Conte return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Owner) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty owner") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -281,7 +282,7 @@ func (q Querier) LockedDenom(goCtx context.Context, req *types.LockedDenomReques return nil, status.Error(codes.InvalidArgument, "empty request") } if len(req.Denom) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty denom") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty denom") } ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index 02be56912..c48b68e5b 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -5,6 +5,7 @@ import ( "sort" "time" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -55,7 +56,7 @@ func (k Keeper) AddToExistingLock(ctx sdk.Context, owner sdk.AccAddress, coin sd // if no lock exists for the given owner + denom + duration, return an error if len(locks) < 1 { - return 0, sdkerrors.Wrapf(types.ErrLockupNotFound, "lock with denom %s before duration %s does not exist", coin.Denom, duration.String()) + return 0, errorsmod.Wrapf(types.ErrLockupNotFound, "lock with denom %s before duration %s does not exist", coin.Denom, duration.String()) } // if existing lock with same duration and denom exists, add to the existing lock @@ -63,7 +64,7 @@ func (k Keeper) AddToExistingLock(ctx sdk.Context, owner sdk.AccAddress, coin sd lock := locks[0] _, err := k.AddTokensToLockByID(ctx, lock.ID, owner, coin) if err != nil { - return 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + return 0, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } return lock.ID, nil diff --git a/x/lockup/keeper/msg_server.go b/x/lockup/keeper/msg_server.go index 30287019b..075ff56dd 100644 --- a/x/lockup/keeper/msg_server.go +++ b/x/lockup/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/osmosis-labs/osmosis/v15/osmoutils" @@ -60,7 +61,7 @@ func (server msgServer) LockTokens(goCtx context.Context, msg *types.MsgLockToke // if the owner + duration combination is new, create a new lock. lock, err := server.keeper.CreateLock(ctx, owner, msg.Coins, msg.Duration) if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } ctx.EventManager().EmitEvents(sdk.Events{ @@ -84,16 +85,16 @@ func (server msgServer) BeginUnlocking(goCtx context.Context, msg *types.MsgBegi lock, err := server.keeper.GetLockByID(ctx, msg.ID) if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } if msg.Owner != lock.Owner { - return nil, sdkerrors.Wrap(types.ErrNotLockOwner, fmt.Sprintf("msg sender (%s) and lock owner (%s) does not match", msg.Owner, lock.Owner)) + return nil, errorsmod.Wrap(types.ErrNotLockOwner, fmt.Sprintf("msg sender (%s) and lock owner (%s) does not match", msg.Owner, lock.Owner)) } unlockingLock, err := server.keeper.BeginUnlock(ctx, lock.ID, msg.Coins) if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } // N.B. begin unlock event is emitted downstream in the keeper method. @@ -112,7 +113,7 @@ func (server msgServer) BeginUnlockingAll(goCtx context.Context, msg *types.MsgB unlocks, err := server.keeper.BeginUnlockAllNotUnlockings(ctx, owner) if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } // Create the events for this message @@ -156,12 +157,12 @@ func (server msgServer) ExtendLockup(goCtx context.Context, msg *types.MsgExtend err = server.keeper.ExtendLockup(ctx, msg.ID, owner, msg.Duration) if err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } lock, err := server.keeper.GetLockByID(ctx, msg.ID) if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } ctx.EventManager().EmitEvents(sdk.Events{ @@ -184,12 +185,12 @@ func (server msgServer) ForceUnlock(goCtx context.Context, msg *types.MsgForceUn lock, err := server.keeper.GetLockByID(ctx, msg.ID) if err != nil { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return &types.MsgForceUnlockResponse{Success: false}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } // check if message sender matches lock owner if lock.Owner != msg.Owner { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) does not match lock owner (%s)", msg.Owner, lock.Owner) + return &types.MsgForceUnlockResponse{Success: false}, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) does not match lock owner (%s)", msg.Owner, lock.Owner) } // check for chain parameter that the address is allowed to force unlock @@ -203,7 +204,7 @@ func (server msgServer) ForceUnlock(goCtx context.Context, msg *types.MsgForceUn } } if !found { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) not allowed to force unlock", lock.Owner) + return &types.MsgForceUnlockResponse{Success: false}, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "Sender (%s) not allowed to force unlock", lock.Owner) } // force unlock given lock @@ -211,7 +212,7 @@ func (server msgServer) ForceUnlock(goCtx context.Context, msg *types.MsgForceUn // provided is empty. err = server.keeper.PartialForceUnlock(ctx, *lock, msg.Coins) if err != nil { - return &types.MsgForceUnlockResponse{Success: false}, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + return &types.MsgForceUnlockResponse{Success: false}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } return &types.MsgForceUnlockResponse{Success: true}, nil diff --git a/x/lockup/keeper/store.go b/x/lockup/keeper/store.go index 4f0949e43..26e8eba20 100644 --- a/x/lockup/keeper/store.go +++ b/x/lockup/keeper/store.go @@ -5,8 +5,8 @@ import ( "fmt" "time" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/gogoproto/proto" "github.com/dymensionxyz/dymension/v3/x/lockup/types" @@ -226,7 +226,7 @@ func (k Keeper) GetLockByID(ctx sdk.Context, lockID uint64) (*types.PeriodLock, store := ctx.KVStore(k.storeKey) lockKey := lockStoreKey(lockID) if !store.Has(lockKey) { - return nil, sdkerrors.Wrap(types.ErrLockupNotFound, fmt.Sprintf("lock with ID %d does not exist", lockID)) + return nil, errorsmod.Wrap(types.ErrLockupNotFound, fmt.Sprintf("lock with ID %d does not exist", lockID)) } bz := store.Get(lockKey) err := proto.Unmarshal(bz, &lock) diff --git a/x/lockup/types/msgs.go b/x/lockup/types/msgs.go index 0a76ab36f..71c696cd7 100644 --- a/x/lockup/types/msgs.go +++ b/x/lockup/types/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -32,7 +33,7 @@ func (m MsgLockTokens) Type() string { return TypeMsgLockTokens } func (m MsgLockTokens) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Owner) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) } if m.Duration <= 0 { @@ -74,7 +75,7 @@ func (m MsgBeginUnlockingAll) Type() string { return TypeMsgBeginUnlockingAll } func (m MsgBeginUnlockingAll) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Owner) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) } return nil } @@ -104,7 +105,7 @@ func (m MsgBeginUnlocking) Type() string { return TypeMsgBeginUnlocking } func (m MsgBeginUnlocking) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Owner) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) } if m.ID == 0 { @@ -146,7 +147,7 @@ func (m MsgExtendLockup) Type() string { return TypeMsgExtendLockup } func (m MsgExtendLockup) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Owner) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) } if m.ID == 0 { return fmt.Errorf("id is empty") @@ -182,15 +183,15 @@ func (m MsgForceUnlock) Type() string { return TypeMsgBeginUnlockingAll } func (m MsgForceUnlock) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Owner) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid owner address (%s)", err) } if m.ID <= 0 { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "lock id should be bigger than 1 (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "lock id should be bigger than 1 (%s)", err) } if !m.Coins.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Coins.String()) + return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, m.Coins.String()) } return nil } diff --git a/x/sequencer/keeper/rotation.go b/x/sequencer/keeper/rotation.go index 440cff138..b54b1e558 100644 --- a/x/sequencer/keeper/rotation.go +++ b/x/sequencer/keeper/rotation.go @@ -4,7 +4,7 @@ import ( "sort" "time" - "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" @@ -111,11 +111,11 @@ func (k Keeper) startRotation(ctx sdk.Context, rollappId string) { func (k Keeper) CompleteRotation(ctx sdk.Context, rollappId string) error { proposer, ok := k.GetProposer(ctx, rollappId) if !ok { - return errors.Wrapf(gerrc.ErrInternal, "proposer not set for rollapp %s", rollappId) + return errorsmod.Wrapf(gerrc.ErrInternal, "proposer not set for rollapp %s", rollappId) } nextProposer, ok := k.GetNextProposer(ctx, rollappId) if !ok { - return errors.Wrapf(gerrc.ErrInternal, "next proposer not set for rollapp %s", rollappId) + return errorsmod.Wrapf(gerrc.ErrInternal, "next proposer not set for rollapp %s", rollappId) } // start unbonding the current proposer