From 88f0db3905a9a6bb38f31402899a43c5a9dbb126 Mon Sep 17 00:00:00 2001 From: John Letey Date: Mon, 4 Jul 2022 10:42:59 +0200 Subject: [PATCH] fix: throw a custom error --- x/gov/keeper/deposit.go | 3 +-- x/gov/types/errors.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index 2dc65c09d424..3b708aea761b 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -118,7 +118,6 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd } // Check if deposit is enough. - // TODO: Return an error message. depositParams := keeper.GetDepositParams(ctx) minDepositAmount := proposal.GetMinDepositFromParams(depositParams) @@ -129,7 +128,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd } if !depositAmount.IsAllGTE(adjustedMinDeposit) { - return false, nil + return false, sdkerrors.Wrapf(types.ErrInvalidDeposit, "%s", depositAmount.String()) } // update the governance module's account coins pool diff --git a/x/gov/types/errors.go b/x/gov/types/errors.go index 96973f1751a2..3e60500fc4ab 100644 --- a/x/gov/types/errors.go +++ b/x/gov/types/errors.go @@ -14,4 +14,5 @@ var ( ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option") ErrInvalidGenesis = sdkerrors.Register(ModuleName, 8, "invalid genesis state") ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type") + ErrInvalidDeposit = sdkerrors.Register(ModuleName, 1000, "invalid deposit amount") )