Skip to content

Commit

Permalink
Revert changes to empty sdk.Coins{} return type
Browse files Browse the repository at this point in the history
  • Loading branch information
0a1c committed Mar 28, 2023
1 parent 8f23457 commit 2acb14b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 1 addition & 6 deletions testutil/vesting/mock_vesting_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import (
// LockedCoinsFromDelegating prevents the mock vesting account from delegating
// any unvested tokens.
func (mvdva MockVestedDelegateVestingAccount) LockedCoinsFromDelegating(blockTime time.Time) sdk.Coins {
locked := mvdva.ContinuousVestingAccount.GetVestingCoins(blockTime)
if locked == nil {
return sdk.NewCoins()
}

return locked
return mvdva.ContinuousVestingAccount.GetVestingCoins(blockTime)
}

func NewMockVestedDelegateVestingAccount(cva *types.ContinuousVestingAccount) *MockVestedDelegateVestingAccount {
Expand Down
4 changes: 3 additions & 1 deletion x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,9 @@ func (suite *IntegrationTestSuite) TestDelegatableCoins() {

ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
suite.Require().NoError(keeper.DelegateCoins(ctx, testAddr, addrModule, delCoins))
suite.Require().Equal(sdk.NewCoins(), keeper.DelegatableCoins(ctx, testAddr))

var emptyCoins sdk.Coins
suite.Require().Equal(emptyCoins, keeper.DelegatableCoins(ctx, testAddr))

suite.Require().Error(keeper.DelegateCoins(ctx, testAddr, addrModule, delCoins))
}
Expand Down
2 changes: 1 addition & 1 deletion x/bank/keeper/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (k BaseViewKeeper) DelegatableCoins(ctx sdk.Context, addr sdk.AccAddress) s

func (k BaseViewKeeper) unlockedCoins(total, locked sdk.Coins) (spendable sdk.Coins) {
spendable, hasNeg := total.SafeSub(locked...)
if hasNeg || spendable == nil {
if hasNeg {
spendable = sdk.NewCoins()
return
}
Expand Down

0 comments on commit 2acb14b

Please sign in to comment.