diff --git a/x/protocolpool/keeper/genesis.go b/x/protocolpool/keeper/genesis.go index bd29d4afce16..2af4fb7ad15b 100644 --- a/x/protocolpool/keeper/genesis.go +++ b/x/protocolpool/keeper/genesis.go @@ -28,11 +28,11 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error } for _, budget := range data.Budget { // Validate StartTime - if budget.StartTime.IsZero() || budget.StartTime == nil { + if budget.StartTime == nil || budget.StartTime.IsZero() { budget.StartTime = ¤tTime } // ignore budget with start time < currentTime - if budget.StartTime != nil && budget.StartTime.Before(currentTime) { + if budget.StartTime.Before(currentTime) { continue } diff --git a/x/protocolpool/keeper/keeper.go b/x/protocolpool/keeper/keeper.go index abac09d30841..53c49a3a5b85 100644 --- a/x/protocolpool/keeper/keeper.go +++ b/x/protocolpool/keeper/keeper.go @@ -111,6 +111,7 @@ func (k Keeper) withdrawContinuousFund(ctx context.Context, recipient sdk.AccAdd if errors.Is(err, collections.ErrNotFound) { return sdk.Coin{}, fmt.Errorf("no continuous fund found for recipient: %s", recipient.String()) } + return sdk.Coin{}, fmt.Errorf("get continuous fund failed for recipient: %s", recipient.String()) } if cf.Expiry != nil && cf.Expiry.Before(sdkCtx.HeaderInfo().Time) { return sdk.Coin{}, fmt.Errorf("cannot withdraw continuous funds: continuous fund expired for recipient: %s", recipient.String()) @@ -412,10 +413,8 @@ func (k Keeper) validateContinuousFund(ctx context.Context, msg types.MsgCreateC // Validate expiry currentTime := sdk.UnwrapSDKContext(ctx).BlockTime() - if msg.Expiry != nil { - if msg.Expiry.Compare(currentTime) == -1 { - return fmt.Errorf("expiry time cannot be less than the current block time") - } + if msg.Expiry != nil && msg.Expiry.Compare(currentTime) == -1 { + return fmt.Errorf("expiry time cannot be less than the current block time") } return nil diff --git a/x/protocolpool/keeper/msg_server.go b/x/protocolpool/keeper/msg_server.go index 475378a6f35f..8f3965e3af3e 100644 --- a/x/protocolpool/keeper/msg_server.go +++ b/x/protocolpool/keeper/msg_server.go @@ -190,10 +190,8 @@ func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCance // withdraw funds if any are allocated withdrawnFunds, err := k.withdrawRecipientFunds(ctx, recipient) - if err != nil { - if !errorspkg.Is(err, types.ErrNoRecipientFund) { - return nil, fmt.Errorf("error while withdrawing already allocated funds for recipient %s: %v", msg.RecipientAddress, err) - } + if err != nil && !errorspkg.Is(err, types.ErrNoRecipientFund) { + return nil, fmt.Errorf("error while withdrawing already allocated funds for recipient %s: %v", msg.RecipientAddress, err) } if err := k.ContinuousFund.Remove(ctx, recipient); err != nil {