Skip to content

Commit

Permalink
fix!: patch barberry (backport)
Browse files Browse the repository at this point in the history
(cherry picked from commit 29d4879895c9a4270f80783bc5318f27f309d81e)
  • Loading branch information
crypin committed Jun 8, 2023
1 parent cd29fbb commit 860615f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions x/auth/vesting/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
return nil, err
}

if bk.BlockedAddr(to) {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
}

if acc := ak.GetAccount(ctx, to); acc != nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress)
}
Expand All @@ -124,6 +128,10 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
totalCoins = totalCoins.Add(period.Amount...)
}

if err := bk.IsSendEnabledCoins(ctx, totalCoins...); err != nil {
return nil, err
}

baseAccount := ak.NewAccountWithAddress(ctx, to)

acc := types.NewPeriodicVestingAccount(baseAccount.(*authtypes.BaseAccount), totalCoins.Sort(), msg.StartTime, msg.VestingPeriods)
Expand Down
8 changes: 8 additions & 0 deletions x/auth/vesting/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ func (msg MsgCreatePeriodicVestingAccount) ValidateBasic() error {
}

for i, period := range msg.VestingPeriods {
if !period.Amount.IsValid() {
return sdkerrors.ErrInvalidCoins.Wrap(period.Amount.String())
}

if !period.Amount.IsAllPositive() {
return sdkerrors.ErrInvalidCoins.Wrap(period.Amount.String())
}

if period.Length < 1 {
return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", period.Length, i)
}
Expand Down

0 comments on commit 860615f

Please sign in to comment.