Merge PR #3679: Consistent Operators

* Minus->Sub Plus->Add Div->Quo

* pending

* Update PENDING.md

Co-Authored-By: rigelrozanski <rigel.rozanski@gmail.com>

* fix

* typo
This commit is contained in:
frog power 4000 2019-02-21 12:35:55 -05:00 committed by GitHub
parent 992dc8b2dc
commit a814e5ce66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 188 additions and 186 deletions

View File

@ -45,6 +45,8 @@
### SDK ### SDK
* \#3679 Consistent operators across Coins, DecCoins, Int, Dec
replaced: Minus->Sub Plus->Add Div->Quo
* [\#3665] Overhaul sdk.Uint type in preparation for Coins Int -> Uint migration. * [\#3665] Overhaul sdk.Uint type in preparation for Coins Int -> Uint migration.
* \#3691 Cleanup error messages * \#3691 Cleanup error messages
* \#3456 Integrate in the Int.ToDec() convenience function * \#3456 Integrate in the Int.ToDec() convenience function

View File

@ -127,7 +127,7 @@ func TestCoinSend(t *testing.T) {
// query sender // query sender
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins := acc.GetCoins() coins := acc.GetCoins()
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom) require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom)
require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount) require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount)
@ -186,7 +186,7 @@ func TestCoinSend(t *testing.T) {
require.Equal(t, uint32(0), resultTx.Code) require.Equal(t, uint32(0), resultTx.Code)
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
} }
@ -209,7 +209,7 @@ func TestCoinSendAccAuto(t *testing.T) {
// query sender // query sender
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins := acc.GetCoins() coins := acc.GetCoins()
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom) require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom)
require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount) require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount)
@ -465,7 +465,7 @@ func TestBonding(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins := acc.GetCoins() coins := acc.GetCoins()
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom))
expectedBalance = coins[0] expectedBalance = coins[0]
@ -499,7 +499,7 @@ func TestBonding(t *testing.T) {
// sender should have not received any coins as the unbonding has only just begun // sender should have not received any coins as the unbonding has only just begun
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins = acc.GetCoins() coins = acc.GetCoins()
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.True(t, require.True(t,
expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) || expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) ||
expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)), expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)),
@ -517,7 +517,7 @@ func TestBonding(t *testing.T) {
ubd := getUnbondingDelegation(t, port, addr, operAddrs[0]) ubd := getUnbondingDelegation(t, port, addr, operAddrs[0])
require.Len(t, ubd.Entries, 1) require.Len(t, ubd.Entries, 1)
require.Equal(t, delTokens.DivRaw(2), ubd.Entries[0].Balance) require.Equal(t, delTokens.QuoRaw(2), ubd.Entries[0].Balance)
// test redelegation // test redelegation
rdTokens := sdk.TokensFromTendermintPower(30) rdTokens := sdk.TokensFromTendermintPower(30)
@ -528,7 +528,7 @@ func TestBonding(t *testing.T) {
// verify balance after paying fees // verify balance after paying fees
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.True(t, require.True(t,
expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) || expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) ||
expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)), expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)),
@ -612,7 +612,7 @@ func TestSubmitProposal(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
// query proposal // query proposal
@ -648,7 +648,7 @@ func TestDeposit(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins := acc.GetCoins() coins := acc.GetCoins()
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom))
expectedBalance = coins[0] expectedBalance = coins[0]
@ -663,7 +663,7 @@ func TestDeposit(t *testing.T) {
// verify balance after deposit and fee // verify balance after deposit and fee
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(depositTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(depositTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
// query tx // query tx
@ -705,7 +705,7 @@ func TestVote(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins := acc.GetCoins() coins := acc.GetCoins()
expectedBalance := initialBalance[0].Minus(fees[0]) expectedBalance := initialBalance[0].Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom))
expectedBalance = coins[0] expectedBalance = coins[0]
@ -721,7 +721,7 @@ func TestVote(t *testing.T) {
// verify balance after vote and fee // verify balance after vote and fee
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins = acc.GetCoins() coins = acc.GetCoins()
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.Equal(t, expectedBalance.Amount, coins.AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount, coins.AmountOf(sdk.DefaultBondDenom))
expectedBalance = coins[0] expectedBalance = coins[0]
@ -745,7 +745,7 @@ func TestVote(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
coins = acc.GetCoins() coins = acc.GetCoins()
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom))
expectedBalance = coins[0] expectedBalance = coins[0]
@ -758,7 +758,7 @@ func TestVote(t *testing.T) {
// verify balance // verify balance
acc = getAccount(t, port, addr) acc = getAccount(t, port, addr)
expectedBalance = expectedBalance.Minus(fees[0]) expectedBalance = expectedBalance.Sub(fees[0])
require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(sdk.DefaultBondDenom)) require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
tally = getTally(t, port, proposalID) tally = getTally(t, port, proposalID)
@ -792,7 +792,7 @@ func TestProposalsQuery(t *testing.T) {
defer cleanup() defer cleanup()
depositParam := getDepositParam(t, port) depositParam := getDepositParam(t, port)
halfMinDeposit := depositParam.MinDeposit.AmountOf(sdk.DefaultBondDenom).DivRaw(2) halfMinDeposit := depositParam.MinDeposit.AmountOf(sdk.DefaultBondDenom).QuoRaw(2)
getVotingParam(t, port) getVotingParam(t, port)
getTallyingParam(t, port) getTallyingParam(t, port)

View File

@ -151,7 +151,7 @@ func handleFrom(store sdk.KVStore, from sdk.AccAddress, amt sdk.Coins) sdk.Resul
} }
// Deduct msg amount from sender account. // Deduct msg amount from sender account.
senderCoins := acc.Coins.Minus(amt) senderCoins := acc.Coins.Sub(amt)
// If any coin has negative amount, return insufficient coins error. // If any coin has negative amount, return insufficient coins error.
if senderCoins.IsAnyNegative() { if senderCoins.IsAnyNegative() {
@ -188,7 +188,7 @@ func handleTo(store sdk.KVStore, to sdk.AccAddress, amt sdk.Coins) sdk.Result {
} }
// Add amount to receiver's old coins // Add amount to receiver's old coins
receiverCoins := acc.Coins.Plus(amt) receiverCoins := acc.Coins.Add(amt)
// Update receiver account // Update receiver account
acc.Coins = receiverCoins acc.Coins = receiverCoins

View File

@ -86,7 +86,7 @@ func (coin Coin) IsEqual(other Coin) bool {
// Adds amounts of two coins with same denom. If the coins differ in denom then // Adds amounts of two coins with same denom. If the coins differ in denom then
// it panics. // it panics.
func (coin Coin) Plus(coinB Coin) Coin { func (coin Coin) Add(coinB Coin) Coin {
if coin.Denom != coinB.Denom { if coin.Denom != coinB.Denom {
panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, coinB.Denom)) panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, coinB.Denom))
} }
@ -96,7 +96,7 @@ func (coin Coin) Plus(coinB Coin) Coin {
// Subtracts amounts of two coins with same denom. If the coins differ in denom // Subtracts amounts of two coins with same denom. If the coins differ in denom
// then it panics. // then it panics.
func (coin Coin) Minus(coinB Coin) Coin { func (coin Coin) Sub(coinB Coin) Coin {
if coin.Denom != coinB.Denom { if coin.Denom != coinB.Denom {
panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, coinB.Denom)) panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, coinB.Denom))
} }
@ -178,27 +178,27 @@ func (coins Coins) IsValid() bool {
} }
} }
// Plus adds two sets of coins. // Add adds two sets of coins.
// //
// e.g. // e.g.
// {2A} + {A, 2B} = {3A, 2B} // {2A} + {A, 2B} = {3A, 2B}
// {2A} + {0B} = {2A} // {2A} + {0B} = {2A}
// //
// NOTE: Plus operates under the invariant that coins are sorted by // NOTE: Add operates under the invariant that coins are sorted by
// denominations. // denominations.
// //
// CONTRACT: Plus will never return Coins where one Coin has a non-positive // CONTRACT: Add will never return Coins where one Coin has a non-positive
// amount. In otherwords, IsValid will always return true. // amount. In otherwords, IsValid will always return true.
func (coins Coins) Plus(coinsB Coins) Coins { func (coins Coins) Add(coinsB Coins) Coins {
return coins.safePlus(coinsB) return coins.safeAdd(coinsB)
} }
// safePlus will perform addition of two coins sets. If both coin sets are // safeAdd will perform addition of two coins sets. If both coin sets are
// empty, then an empty set is returned. If only a single set is empty, the // empty, then an empty set is returned. If only a single set is empty, the
// other set is returned. Otherwise, the coins are compared in order of their // other set is returned. Otherwise, the coins are compared in order of their
// denomination and addition only occurs when the denominations match, otherwise // denomination and addition only occurs when the denominations match, otherwise
// the coin is simply added to the sum assuming it's not zero. // the coin is simply added to the sum assuming it's not zero.
func (coins Coins) safePlus(coinsB Coins) Coins { func (coins Coins) safeAdd(coinsB Coins) Coins {
sum := ([]Coin)(nil) sum := ([]Coin)(nil)
indexA, indexB := 0, 0 indexA, indexB := 0, 0
lenA, lenB := len(coins), len(coinsB) lenA, lenB := len(coins), len(coinsB)
@ -228,7 +228,7 @@ func (coins Coins) safePlus(coinsB Coins) Coins {
indexA++ indexA++
case 0: // coin A denom == coin B denom case 0: // coin A denom == coin B denom
res := coinA.Plus(coinB) res := coinA.Add(coinB)
if !res.IsZero() { if !res.IsZero() {
sum = append(sum, res) sum = append(sum, res)
} }
@ -246,17 +246,17 @@ func (coins Coins) safePlus(coinsB Coins) Coins {
} }
} }
// Minus subtracts a set of coins from another. // Sub subtracts a set of coins from another.
// //
// e.g. // e.g.
// {2A, 3B} - {A} = {A, 3B} // {2A, 3B} - {A} = {A, 3B}
// {2A} - {0B} = {2A} // {2A} - {0B} = {2A}
// {A, B} - {A} = {B} // {A, B} - {A} = {B}
// //
// CONTRACT: Minus will never return Coins where one Coin has a non-positive // CONTRACT: Sub will never return Coins where one Coin has a non-positive
// amount. In otherwords, IsValid will always return true. // amount. In otherwords, IsValid will always return true.
func (coins Coins) Minus(coinsB Coins) Coins { func (coins Coins) Sub(coinsB Coins) Coins {
diff, hasNeg := coins.SafeMinus(coinsB) diff, hasNeg := coins.SafeSub(coinsB)
if hasNeg { if hasNeg {
panic("negative coin amount") panic("negative coin amount")
} }
@ -264,17 +264,17 @@ func (coins Coins) Minus(coinsB Coins) Coins {
return diff return diff
} }
// SafeMinus performs the same arithmetic as Minus but returns a boolean if any // SafeSub performs the same arithmetic as Sub but returns a boolean if any
// negative coin amount was returned. // negative coin amount was returned.
func (coins Coins) SafeMinus(coinsB Coins) (Coins, bool) { func (coins Coins) SafeSub(coinsB Coins) (Coins, bool) {
diff := coins.safePlus(coinsB.negative()) diff := coins.safeAdd(coinsB.negative())
return diff, diff.IsAnyNegative() return diff, diff.IsAnyNegative()
} }
// IsAllGT returns true if for every denom in coins, the denom is present at a // IsAllGT returns true if for every denom in coins, the denom is present at a
// greater amount in coinsB. // greater amount in coinsB.
func (coins Coins) IsAllGT(coinsB Coins) bool { func (coins Coins) IsAllGT(coinsB Coins) bool {
diff, _ := coins.SafeMinus(coinsB) diff, _ := coins.SafeSub(coinsB)
if len(diff) == 0 { if len(diff) == 0 {
return false return false
} }
@ -285,7 +285,7 @@ func (coins Coins) IsAllGT(coinsB Coins) bool {
// IsAllGTE returns true iff for every denom in coins, the denom is present at // IsAllGTE returns true iff for every denom in coins, the denom is present at
// an equal or greater amount in coinsB. // an equal or greater amount in coinsB.
func (coins Coins) IsAllGTE(coinsB Coins) bool { func (coins Coins) IsAllGTE(coinsB Coins) bool {
diff, _ := coins.SafeMinus(coinsB) diff, _ := coins.SafeSub(coinsB)
if len(diff) == 0 { if len(diff) == 0 {
return true return true
} }

View File

@ -21,7 +21,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
coinsA.Plus(coinsB) coinsA.Add(coinsB)
} }
} }
} }
@ -50,7 +50,7 @@ func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
coinsA.Plus(coinsB) coinsA.Add(coinsB)
} }
} }
} }

View File

@ -47,7 +47,7 @@ func TestIsEqualCoin(t *testing.T) {
} }
} }
func TestPlusCoin(t *testing.T) { func TestAddCoin(t *testing.T) {
cases := []struct { cases := []struct {
inputOne Coin inputOne Coin
inputTwo Coin inputTwo Coin
@ -61,15 +61,15 @@ func TestPlusCoin(t *testing.T) {
for tcIndex, tc := range cases { for tcIndex, tc := range cases {
if tc.shouldPanic { if tc.shouldPanic {
require.Panics(t, func() { tc.inputOne.Plus(tc.inputTwo) }) require.Panics(t, func() { tc.inputOne.Add(tc.inputTwo) })
} else { } else {
res := tc.inputOne.Plus(tc.inputTwo) res := tc.inputOne.Add(tc.inputTwo)
require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex) require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex)
} }
} }
} }
func TestMinusCoin(t *testing.T) { func TestSubCoin(t *testing.T) {
cases := []struct { cases := []struct {
inputOne Coin inputOne Coin
inputTwo Coin inputTwo Coin
@ -85,9 +85,9 @@ func TestMinusCoin(t *testing.T) {
for tcIndex, tc := range cases { for tcIndex, tc := range cases {
if tc.shouldPanic { if tc.shouldPanic {
require.Panics(t, func() { tc.inputOne.Minus(tc.inputTwo) }) require.Panics(t, func() { tc.inputOne.Sub(tc.inputTwo) })
} else { } else {
res := tc.inputOne.Minus(tc.inputTwo) res := tc.inputOne.Sub(tc.inputTwo)
require.Equal(t, tc.expected, res, "difference of coins is incorrect, tc #%d", tcIndex) require.Equal(t, tc.expected, res, "difference of coins is incorrect, tc #%d", tcIndex)
} }
} }
@ -97,7 +97,7 @@ func TestMinusCoin(t *testing.T) {
inputTwo Coin inputTwo Coin
expected int64 expected int64
}{NewInt64Coin(testDenom1, 1), NewInt64Coin(testDenom1, 1), 0} }{NewInt64Coin(testDenom1, 1), NewInt64Coin(testDenom1, 1), 0}
res := tc.inputOne.Minus(tc.inputTwo) res := tc.inputOne.Sub(tc.inputTwo)
require.Equal(t, tc.expected, res.Amount.Int64()) require.Equal(t, tc.expected, res.Amount.Int64())
} }
@ -205,7 +205,7 @@ func TestEqualCoins(t *testing.T) {
} }
} }
func TestPlusCoins(t *testing.T) { func TestAddCoins(t *testing.T) {
zero := NewInt(0) zero := NewInt(0)
one := NewInt(1) one := NewInt(1)
two := NewInt(2) two := NewInt(2)
@ -223,13 +223,13 @@ func TestPlusCoins(t *testing.T) {
} }
for tcIndex, tc := range cases { for tcIndex, tc := range cases {
res := tc.inputOne.Plus(tc.inputTwo) res := tc.inputOne.Add(tc.inputTwo)
assert.True(t, res.IsValid()) assert.True(t, res.IsValid())
require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex) require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex)
} }
} }
func TestMinusCoins(t *testing.T) { func TestSubCoins(t *testing.T) {
zero := NewInt(0) zero := NewInt(0)
one := NewInt(1) one := NewInt(1)
two := NewInt(2) two := NewInt(2)
@ -249,9 +249,9 @@ func TestMinusCoins(t *testing.T) {
for i, tc := range testCases { for i, tc := range testCases {
if tc.shouldPanic { if tc.shouldPanic {
require.Panics(t, func() { tc.inputOne.Minus(tc.inputTwo) }) require.Panics(t, func() { tc.inputOne.Sub(tc.inputTwo) })
} else { } else {
res := tc.inputOne.Minus(tc.inputTwo) res := tc.inputOne.Sub(tc.inputTwo)
assert.True(t, res.IsValid()) assert.True(t, res.IsValid())
require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", i) require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", i)
} }

View File

@ -99,7 +99,7 @@ func (coin DecCoin) IsEqual(other DecCoin) bool {
} }
// Adds amounts of two coins with same denom // Adds amounts of two coins with same denom
func (coin DecCoin) Plus(coinB DecCoin) DecCoin { func (coin DecCoin) Add(coinB DecCoin) DecCoin {
if coin.Denom != coinB.Denom { if coin.Denom != coinB.Denom {
panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom)) panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom))
} }
@ -107,7 +107,7 @@ func (coin DecCoin) Plus(coinB DecCoin) DecCoin {
} }
// Subtracts amounts of two coins with same denom // Subtracts amounts of two coins with same denom
func (coin DecCoin) Minus(coinB DecCoin) DecCoin { func (coin DecCoin) Sub(coinB DecCoin) DecCoin {
if coin.Denom != coinB.Denom { if coin.Denom != coinB.Denom {
panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom)) panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom))
} }
@ -179,29 +179,29 @@ func (coins DecCoins) TruncateDecimal() (Coins, DecCoins) {
for i, coin := range coins { for i, coin := range coins {
truncated, change := coin.TruncateDecimal() truncated, change := coin.TruncateDecimal()
out[i] = truncated out[i] = truncated
changeSum = changeSum.Plus(DecCoins{change}) changeSum = changeSum.Add(DecCoins{change})
} }
return out, changeSum return out, changeSum
} }
// Plus adds two sets of DecCoins. // Add adds two sets of DecCoins.
// //
// NOTE: Plus operates under the invariant that coins are sorted by // NOTE: Add operates under the invariant that coins are sorted by
// denominations. // denominations.
// //
// CONTRACT: Plus will never return Coins where one Coin has a non-positive // CONTRACT: Add will never return Coins where one Coin has a non-positive
// amount. In otherwords, IsValid will always return true. // amount. In otherwords, IsValid will always return true.
func (coins DecCoins) Plus(coinsB DecCoins) DecCoins { func (coins DecCoins) Add(coinsB DecCoins) DecCoins {
return coins.safePlus(coinsB) return coins.safeAdd(coinsB)
} }
// safePlus will perform addition of two DecCoins sets. If both coin sets are // safeAdd will perform addition of two DecCoins sets. If both coin sets are
// empty, then an empty set is returned. If only a single set is empty, the // empty, then an empty set is returned. If only a single set is empty, the
// other set is returned. Otherwise, the coins are compared in order of their // other set is returned. Otherwise, the coins are compared in order of their
// denomination and addition only occurs when the denominations match, otherwise // denomination and addition only occurs when the denominations match, otherwise
// the coin is simply added to the sum assuming it's not zero. // the coin is simply added to the sum assuming it's not zero.
func (coins DecCoins) safePlus(coinsB DecCoins) DecCoins { func (coins DecCoins) safeAdd(coinsB DecCoins) DecCoins {
sum := ([]DecCoin)(nil) sum := ([]DecCoin)(nil)
indexA, indexB := 0, 0 indexA, indexB := 0, 0
lenA, lenB := len(coins), len(coinsB) lenA, lenB := len(coins), len(coinsB)
@ -231,7 +231,7 @@ func (coins DecCoins) safePlus(coinsB DecCoins) DecCoins {
indexA++ indexA++
case 0: // coin A denom == coin B denom case 0: // coin A denom == coin B denom
res := coinA.Plus(coinB) res := coinA.Add(coinB)
if !res.IsZero() { if !res.IsZero() {
sum = append(sum, res) sum = append(sum, res)
} }
@ -261,9 +261,9 @@ func (coins DecCoins) negative() DecCoins {
return res return res
} }
// Minus subtracts a set of DecCoins from another (adds the inverse). // Sub subtracts a set of DecCoins from another (adds the inverse).
func (coins DecCoins) Minus(coinsB DecCoins) DecCoins { func (coins DecCoins) Sub(coinsB DecCoins) DecCoins {
diff, hasNeg := coins.SafeMinus(coinsB) diff, hasNeg := coins.SafeSub(coinsB)
if hasNeg { if hasNeg {
panic("negative coin amount") panic("negative coin amount")
} }
@ -271,10 +271,10 @@ func (coins DecCoins) Minus(coinsB DecCoins) DecCoins {
return diff return diff
} }
// SafeMinus performs the same arithmetic as Minus but returns a boolean if any // SafeSub performs the same arithmetic as Sub but returns a boolean if any
// negative coin amount was returned. // negative coin amount was returned.
func (coins DecCoins) SafeMinus(coinsB DecCoins) (DecCoins, bool) { func (coins DecCoins) SafeSub(coinsB DecCoins) (DecCoins, bool) {
diff := coins.safePlus(coinsB.negative()) diff := coins.safeAdd(coinsB.negative())
return diff, diff.IsAnyNegative() return diff, diff.IsAnyNegative()
} }

View File

@ -60,22 +60,22 @@ func TestDecCoinIsPositive(t *testing.T) {
require.False(t, dc.IsPositive()) require.False(t, dc.IsPositive())
} }
func TestPlusDecCoin(t *testing.T) { func TestAddDecCoin(t *testing.T) {
decCoinA1 := NewDecCoinFromDec(testDenom1, NewDecWithPrec(11, 1)) decCoinA1 := NewDecCoinFromDec(testDenom1, NewDecWithPrec(11, 1))
decCoinA2 := NewDecCoinFromDec(testDenom1, NewDecWithPrec(22, 1)) decCoinA2 := NewDecCoinFromDec(testDenom1, NewDecWithPrec(22, 1))
decCoinB1 := NewDecCoinFromDec(testDenom2, NewDecWithPrec(11, 1)) decCoinB1 := NewDecCoinFromDec(testDenom2, NewDecWithPrec(11, 1))
// regular add // regular add
res := decCoinA1.Plus(decCoinA1) res := decCoinA1.Add(decCoinA1)
require.Equal(t, decCoinA2, res, "sum of coins is incorrect") require.Equal(t, decCoinA2, res, "sum of coins is incorrect")
// bad denom add // bad denom add
require.Panics(t, func() { require.Panics(t, func() {
decCoinA1.Plus(decCoinB1) decCoinA1.Add(decCoinB1)
}, "expected panic on sum of different denoms") }, "expected panic on sum of different denoms")
} }
func TestPlusDecCoins(t *testing.T) { func TestAddDecCoins(t *testing.T) {
one := NewDec(1) one := NewDec(1)
zero := NewDec(0) zero := NewDec(0)
two := NewDec(2) two := NewDec(2)
@ -91,7 +91,7 @@ func TestPlusDecCoins(t *testing.T) {
} }
for tcIndex, tc := range cases { for tcIndex, tc := range cases {
res := tc.inputOne.Plus(tc.inputTwo) res := tc.inputOne.Add(tc.inputTwo)
require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex) require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex)
} }
} }

View File

@ -157,7 +157,7 @@ func TestDecsEqual(t *testing.T) {
func TestArithmetic(t *testing.T) { func TestArithmetic(t *testing.T) {
tests := []struct { tests := []struct {
d1, d2 Dec d1, d2 Dec
expMul, expDiv, expAdd, expSub Dec expMul, expQuo, expAdd, expSub Dec
}{ }{
// d1 d2 MUL DIV ADD SUB // d1 d2 MUL DIV ADD SUB
{NewDec(0), NewDec(0), NewDec(0), NewDec(0), NewDec(0), NewDec(0)}, {NewDec(0), NewDec(0), NewDec(0), NewDec(0), NewDec(0), NewDec(0)},
@ -192,8 +192,8 @@ func TestArithmetic(t *testing.T) {
if tc.d2.IsZero() { // panic for divide by zero if tc.d2.IsZero() { // panic for divide by zero
require.Panics(t, func() { tc.d1.Quo(tc.d2) }) require.Panics(t, func() { tc.d1.Quo(tc.d2) })
} else { } else {
resDiv := tc.d1.Quo(tc.d2) resQuo := tc.d1.Quo(tc.d2)
require.True(t, tc.expDiv.Equal(resDiv), "exp %v, res %v, tc %d", tc.expDiv.String(), resDiv.String(), tcIndex) require.True(t, tc.expQuo.Equal(resQuo), "exp %v, res %v, tc %d", tc.expQuo.String(), resQuo.String(), tcIndex)
} }
} }
} }

View File

@ -31,7 +31,7 @@ func sub(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Sub(i, i2) }
func mul(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mul(i, i2) } func mul(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mul(i, i2) }
func div(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Div(i, i2) } func div(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Quo(i, i2) }
func mod(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) } func mod(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) }
@ -276,8 +276,8 @@ func (i Int) MulRaw(i2 int64) Int {
return i.Mul(NewInt(i2)) return i.Mul(NewInt(i2))
} }
// Div divides Int with Int // Quo divides Int with Int
func (i Int) Div(i2 Int) (res Int) { func (i Int) Quo(i2 Int) (res Int) {
// Check division-by-zero // Check division-by-zero
if i2.i.Sign() == 0 { if i2.i.Sign() == 0 {
panic("Division by zero") panic("Division by zero")
@ -285,9 +285,9 @@ func (i Int) Div(i2 Int) (res Int) {
return Int{div(i.i, i2.i)} return Int{div(i.i, i2.i)}
} }
// DivRaw divides Int with int64 // QuoRaw divides Int with int64
func (i Int) DivRaw(i2 int64) Int { func (i Int) QuoRaw(i2 int64) Int {
return i.Div(NewInt(i2)) return i.Quo(NewInt(i2))
} }
// Mod returns remainder after dividing with Int // Mod returns remainder after dividing with Int

View File

@ -69,7 +69,7 @@ func TestIntPanic(t *testing.T) {
require.Panics(t, func() { intmin.Sub(OneInt()) }) require.Panics(t, func() { intmin.Sub(OneInt()) })
// Division-by-zero check // Division-by-zero check
require.Panics(t, func() { i1.Div(NewInt(0)) }) require.Panics(t, func() { i1.Quo(NewInt(0)) })
} }
// Tests below uses randomness // Tests below uses randomness
@ -126,11 +126,11 @@ func TestArithInt(t *testing.T) {
{i1.Add(i2), n1 + n2}, {i1.Add(i2), n1 + n2},
{i1.Sub(i2), n1 - n2}, {i1.Sub(i2), n1 - n2},
{i1.Mul(i2), n1 * n2}, {i1.Mul(i2), n1 * n2},
{i1.Div(i2), n1 / n2}, {i1.Quo(i2), n1 / n2},
{i1.AddRaw(n2), n1 + n2}, {i1.AddRaw(n2), n1 + n2},
{i1.SubRaw(n2), n1 - n2}, {i1.SubRaw(n2), n1 - n2},
{i1.MulRaw(n2), n1 * n2}, {i1.MulRaw(n2), n1 * n2},
{i1.DivRaw(n2), n1 / n2}, {i1.QuoRaw(n2), n1 / n2},
{MinInt(i1, i2), minint(n1, n2)}, {MinInt(i1, i2), minint(n1, n2)},
{MaxInt(i1, i2), maxint(n1, n2)}, {MaxInt(i1, i2), maxint(n1, n2)},
{i1.Neg(), -n1}, {i1.Neg(), -n1},
@ -188,11 +188,11 @@ func TestImmutabilityAllInt(t *testing.T) {
func(i *Int) { _ = i.Add(randint()) }, func(i *Int) { _ = i.Add(randint()) },
func(i *Int) { _ = i.Sub(randint()) }, func(i *Int) { _ = i.Sub(randint()) },
func(i *Int) { _ = i.Mul(randint()) }, func(i *Int) { _ = i.Mul(randint()) },
func(i *Int) { _ = i.Div(randint()) }, func(i *Int) { _ = i.Quo(randint()) },
func(i *Int) { _ = i.AddRaw(rand.Int63()) }, func(i *Int) { _ = i.AddRaw(rand.Int63()) },
func(i *Int) { _ = i.SubRaw(rand.Int63()) }, func(i *Int) { _ = i.SubRaw(rand.Int63()) },
func(i *Int) { _ = i.MulRaw(rand.Int63()) }, func(i *Int) { _ = i.MulRaw(rand.Int63()) },
func(i *Int) { _ = i.DivRaw(rand.Int63()) }, func(i *Int) { _ = i.QuoRaw(rand.Int63()) },
func(i *Int) { _ = i.Neg() }, func(i *Int) { _ = i.Neg() },
func(i *Int) { _ = i.IsZero() }, func(i *Int) { _ = i.IsZero() },
func(i *Int) { _ = i.Sign() }, func(i *Int) { _ = i.Sign() },
@ -240,11 +240,11 @@ func TestImmutabilityArithInt(t *testing.T) {
intarith(Int.Add, (*big.Int).Add), intarith(Int.Add, (*big.Int).Add),
intarith(Int.Sub, (*big.Int).Sub), intarith(Int.Sub, (*big.Int).Sub),
intarith(Int.Mul, (*big.Int).Mul), intarith(Int.Mul, (*big.Int).Mul),
intarith(Int.Div, (*big.Int).Div), intarith(Int.Quo, (*big.Int).Quo),
intarithraw(Int.AddRaw, (*big.Int).Add), intarithraw(Int.AddRaw, (*big.Int).Add),
intarithraw(Int.SubRaw, (*big.Int).Sub), intarithraw(Int.SubRaw, (*big.Int).Sub),
intarithraw(Int.MulRaw, (*big.Int).Mul), intarithraw(Int.MulRaw, (*big.Int).Mul),
intarithraw(Int.DivRaw, (*big.Int).Div), intarithraw(Int.QuoRaw, (*big.Int).Quo),
} }
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {

View File

@ -46,7 +46,7 @@ var PowerReduction = NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewIn
// TokensToTendermintPower - convert input tokens to potential tendermint power // TokensToTendermintPower - convert input tokens to potential tendermint power
func TokensToTendermintPower(tokens Int) int64 { func TokensToTendermintPower(tokens Int) int64 {
return (tokens.Div(PowerReduction)).Int64() return (tokens.Quo(PowerReduction)).Int64()
} }
// TokensFromTendermintPower - convert input power to tokens // TokensFromTendermintPower - convert input power to tokens

View File

@ -91,11 +91,11 @@ func (u Uint) Mul(u2 Uint) (res Uint) {
// Mul multiplies two Uints // Mul multiplies two Uints
func (u Uint) MulUint64(u2 uint64) (res Uint) { return u.Mul(NewUint(u2)) } func (u Uint) MulUint64(u2 uint64) (res Uint) { return u.Mul(NewUint(u2)) }
// Div divides Uint with Uint // Quo divides Uint with Uint
func (u Uint) Div(u2 Uint) (res Uint) { return NewUintFromBigInt(div(u.i, u2.i)) } func (u Uint) Quo(u2 Uint) (res Uint) { return NewUintFromBigInt(div(u.i, u2.i)) }
// Div divides Uint with uint64 // Quo divides Uint with uint64
func (u Uint) DivUint64(u2 uint64) Uint { return u.Div(NewUint(u2)) } func (u Uint) QuoUint64(u2 uint64) Uint { return u.Quo(NewUint(u2)) }
// Return the minimum of the Uints // Return the minimum of the Uints
func MinUint(u1, u2 Uint) Uint { return NewUintFromBigInt(min(u1.i, u2.i)) } func MinUint(u1, u2 Uint) Uint { return NewUintFromBigInt(min(u1.i, u2.i)) }

View File

@ -35,8 +35,8 @@ func TestUintPanics(t *testing.T) {
require.True(t, u1.SubUint64(0).Equal(ZeroUint())) require.True(t, u1.SubUint64(0).Equal(ZeroUint()))
require.True(t, u2.Add(OneUint()).Sub(OneUint()).Equal(OneUint())) // i2 == 1 require.True(t, u2.Add(OneUint()).Sub(OneUint()).Equal(OneUint())) // i2 == 1
require.True(t, u2.Add(OneUint()).Mul(NewUint(5)).Equal(NewUint(10))) // i2 == 10 require.True(t, u2.Add(OneUint()).Mul(NewUint(5)).Equal(NewUint(10))) // i2 == 10
require.True(t, NewUint(7).Div(NewUint(2)).Equal(NewUint(3))) require.True(t, NewUint(7).Quo(NewUint(2)).Equal(NewUint(3)))
require.True(t, NewUint(0).Div(NewUint(2)).Equal(ZeroUint())) require.True(t, NewUint(0).Quo(NewUint(2)).Equal(ZeroUint()))
require.True(t, NewUint(5).MulUint64(4).Equal(NewUint(20))) require.True(t, NewUint(5).MulUint64(4).Equal(NewUint(20)))
require.True(t, NewUint(5).MulUint64(0).Equal(ZeroUint())) require.True(t, NewUint(5).MulUint64(0).Equal(ZeroUint()))
@ -45,10 +45,10 @@ func TestUintPanics(t *testing.T) {
// divs by zero // divs by zero
require.Panics(t, func() { OneUint().Mul(ZeroUint().SubUint64(uint64(1))) }) require.Panics(t, func() { OneUint().Mul(ZeroUint().SubUint64(uint64(1))) })
require.Panics(t, func() { OneUint().DivUint64(0) }) require.Panics(t, func() { OneUint().QuoUint64(0) })
require.Panics(t, func() { OneUint().Div(ZeroUint()) }) require.Panics(t, func() { OneUint().Quo(ZeroUint()) })
require.Panics(t, func() { ZeroUint().DivUint64(0) }) require.Panics(t, func() { ZeroUint().QuoUint64(0) })
require.Panics(t, func() { OneUint().Div(ZeroUint().Sub(OneUint())) }) require.Panics(t, func() { OneUint().Quo(ZeroUint().Sub(OneUint())) })
require.Panics(t, func() { uintmax.Add(OneUint()) }) require.Panics(t, func() { uintmax.Add(OneUint()) })
require.Panics(t, func() { uintmin.Sub(OneUint()) }) require.Panics(t, func() { uintmin.Sub(OneUint()) })
@ -108,10 +108,10 @@ func TestArithUint(t *testing.T) {
}{ }{
{u1.Add(u2), n1 + n2}, {u1.Add(u2), n1 + n2},
{u1.Mul(u2), n1 * n2}, {u1.Mul(u2), n1 * n2},
{u1.Div(u2), n1 / n2}, {u1.Quo(u2), n1 / n2},
{u1.AddUint64(n2), n1 + n2}, {u1.AddUint64(n2), n1 + n2},
{u1.MulUint64(n2), n1 * n2}, {u1.MulUint64(n2), n1 * n2},
{u1.DivUint64(n2), n1 / n2}, {u1.QuoUint64(n2), n1 / n2},
{MinUint(u1, u2), minuint(n1, n2)}, {MinUint(u1, u2), minuint(n1, n2)},
{MaxUint(u1, u2), maxuint(n1, n2)}, {MaxUint(u1, u2), maxuint(n1, n2)},
} }
@ -168,11 +168,11 @@ func TestImmutabilityAllUint(t *testing.T) {
func(i *Uint) { _ = i.Add(NewUint(rand.Uint64())) }, func(i *Uint) { _ = i.Add(NewUint(rand.Uint64())) },
func(i *Uint) { _ = i.Sub(NewUint(rand.Uint64() % i.Uint64())) }, func(i *Uint) { _ = i.Sub(NewUint(rand.Uint64() % i.Uint64())) },
func(i *Uint) { _ = i.Mul(randuint()) }, func(i *Uint) { _ = i.Mul(randuint()) },
func(i *Uint) { _ = i.Div(randuint()) }, func(i *Uint) { _ = i.Quo(randuint()) },
func(i *Uint) { _ = i.AddUint64(rand.Uint64()) }, func(i *Uint) { _ = i.AddUint64(rand.Uint64()) },
func(i *Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) }, func(i *Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) },
func(i *Uint) { _ = i.MulUint64(rand.Uint64()) }, func(i *Uint) { _ = i.MulUint64(rand.Uint64()) },
func(i *Uint) { _ = i.DivUint64(rand.Uint64()) }, func(i *Uint) { _ = i.QuoUint64(rand.Uint64()) },
func(i *Uint) { _ = i.IsZero() }, func(i *Uint) { _ = i.IsZero() },
func(i *Uint) { _ = i.Equal(randuint()) }, func(i *Uint) { _ = i.Equal(randuint()) },
func(i *Uint) { _ = i.GT(randuint()) }, func(i *Uint) { _ = i.GT(randuint()) },

View File

@ -233,7 +233,7 @@ func (bva BaseVestingAccount) spendableCoins(vestingCoins sdk.Coins) sdk.Coins {
spendableCoin := sdk.NewCoin(coin.Denom, min) spendableCoin := sdk.NewCoin(coin.Denom, min)
if !spendableCoin.IsZero() { if !spendableCoin.IsZero() {
spendableCoins = spendableCoins.Plus(sdk.Coins{spendableCoin}) spendableCoins = spendableCoins.Add(sdk.Coins{spendableCoin})
} }
} }
@ -270,15 +270,15 @@ func (bva *BaseVestingAccount) trackDelegation(vestingCoins, amount sdk.Coins) {
if !x.IsZero() { if !x.IsZero() {
xCoin := sdk.NewCoin(coin.Denom, x) xCoin := sdk.NewCoin(coin.Denom, x)
bva.DelegatedVesting = bva.DelegatedVesting.Plus(sdk.Coins{xCoin}) bva.DelegatedVesting = bva.DelegatedVesting.Add(sdk.Coins{xCoin})
} }
if !y.IsZero() { if !y.IsZero() {
yCoin := sdk.NewCoin(coin.Denom, y) yCoin := sdk.NewCoin(coin.Denom, y)
bva.DelegatedFree = bva.DelegatedFree.Plus(sdk.Coins{yCoin}) bva.DelegatedFree = bva.DelegatedFree.Add(sdk.Coins{yCoin})
} }
bva.Coins = bva.Coins.Minus(sdk.Coins{coin}) bva.Coins = bva.Coins.Sub(sdk.Coins{coin})
} }
} }
@ -304,15 +304,15 @@ func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins) {
if !x.IsZero() { if !x.IsZero() {
xCoin := sdk.NewCoin(coin.Denom, x) xCoin := sdk.NewCoin(coin.Denom, x)
bva.DelegatedFree = bva.DelegatedFree.Minus(sdk.Coins{xCoin}) bva.DelegatedFree = bva.DelegatedFree.Sub(sdk.Coins{xCoin})
} }
if !y.IsZero() { if !y.IsZero() {
yCoin := sdk.NewCoin(coin.Denom, y) yCoin := sdk.NewCoin(coin.Denom, y)
bva.DelegatedVesting = bva.DelegatedVesting.Minus(sdk.Coins{yCoin}) bva.DelegatedVesting = bva.DelegatedVesting.Sub(sdk.Coins{yCoin})
} }
bva.Coins = bva.Coins.Plus(sdk.Coins{coin}) bva.Coins = bva.Coins.Add(sdk.Coins{coin})
} }
} }
@ -417,7 +417,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin
// GetVestingCoins returns the total number of vesting coins. If no coins are // GetVestingCoins returns the total number of vesting coins. If no coins are
// vesting, nil is returned. // vesting, nil is returned.
func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins { func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
return cva.OriginalVesting.Minus(cva.GetVestedCoins(blockTime)) return cva.OriginalVesting.Sub(cva.GetVestedCoins(blockTime))
} }
// SpendableCoins returns the total number of spendable coins per denom for a // SpendableCoins returns the total number of spendable coins per denom for a
@ -480,7 +480,7 @@ func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins {
// GetVestingCoins returns the total number of vesting coins for a delayed // GetVestingCoins returns the total number of vesting coins for a delayed
// vesting account. // vesting account.
func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins { func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
return dva.OriginalVesting.Minus(dva.GetVestedCoins(blockTime)) return dva.OriginalVesting.Sub(dva.GetVestedCoins(blockTime))
} }
// SpendableCoins returns the total number of spendable coins for a delayed // SpendableCoins returns the total number of spendable coins for a delayed

View File

@ -181,14 +181,14 @@ func TestSpendableCoinsContVestingAcc(t *testing.T) {
// receive some coins // receive some coins
recvAmt := sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)} recvAmt := sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}
cva.SetCoins(cva.GetCoins().Plus(recvAmt)) cva.SetCoins(cva.GetCoins().Add(recvAmt))
// require that all vested coins (50%) are spendable plus any received // require that all vested coins (50%) are spendable plus any received
spendableCoins = cva.SpendableCoins(now.Add(12 * time.Hour)) spendableCoins = cva.SpendableCoins(now.Add(12 * time.Hour))
require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 100)}, spendableCoins) require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 100)}, spendableCoins)
// spend all spendable coins // spend all spendable coins
cva.SetCoins(cva.GetCoins().Minus(spendableCoins)) cva.SetCoins(cva.GetCoins().Sub(spendableCoins))
// require that no more coins are spendable // require that no more coins are spendable
spendableCoins = cva.SpendableCoins(now.Add(12 * time.Hour)) spendableCoins = cva.SpendableCoins(now.Add(12 * time.Hour))
@ -362,7 +362,7 @@ func TestSpendableCoinsDelVestingAcc(t *testing.T) {
// receive some coins // receive some coins
recvAmt := sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)} recvAmt := sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}
dva.SetCoins(dva.GetCoins().Plus(recvAmt)) dva.SetCoins(dva.GetCoins().Add(recvAmt))
// require that only received coins are spendable since the account is still // require that only received coins are spendable since the account is still
// vesting // vesting
@ -370,7 +370,7 @@ func TestSpendableCoinsDelVestingAcc(t *testing.T) {
require.Equal(t, recvAmt, spendableCoins) require.Equal(t, recvAmt, spendableCoins)
// spend all spendable coins // spend all spendable coins
dva.SetCoins(dva.GetCoins().Minus(spendableCoins)) dva.SetCoins(dva.GetCoins().Sub(spendableCoins))
// require that no more coins are spendable // require that no more coins are spendable
spendableCoins = dva.SpendableCoins(now.Add(12 * time.Hour)) spendableCoins = dva.SpendableCoins(now.Add(12 * time.Hour))

View File

@ -304,7 +304,7 @@ func DeductFees(blockTime time.Time, acc Account, fee StdFee) (Account, sdk.Resu
} }
// get the resulting coins deducting the fees // get the resulting coins deducting the fees
newCoins, ok := coins.SafeMinus(feeAmount) newCoins, ok := coins.SafeSub(feeAmount)
if ok { if ok {
return nil, sdk.ErrInsufficientFunds( return nil, sdk.ErrInsufficientFunds(
fmt.Sprintf("insufficient funds to pay for fees; %s < %s", coins, feeAmount), fmt.Sprintf("insufficient funds to pay for fees; %s < %s", coins, feeAmount),
@ -314,7 +314,7 @@ func DeductFees(blockTime time.Time, acc Account, fee StdFee) (Account, sdk.Resu
// Validate the account has enough "spendable" coins as this will cover cases // Validate the account has enough "spendable" coins as this will cover cases
// such as vesting accounts. // such as vesting accounts.
spendableCoins := acc.SpendableCoins(blockTime) spendableCoins := acc.SpendableCoins(blockTime)
if _, hasNeg := spendableCoins.SafeMinus(feeAmount); hasNeg { if _, hasNeg := spendableCoins.SafeSub(feeAmount); hasNeg {
return nil, sdk.ErrInsufficientFunds( return nil, sdk.ErrInsufficientFunds(
fmt.Sprintf("insufficient funds to pay for fees; %s < %s", spendableCoins, feeAmount), fmt.Sprintf("insufficient funds to pay for fees; %s < %s", spendableCoins, feeAmount),
).Result() ).Result()

View File

@ -49,7 +49,7 @@ func (fck FeeCollectionKeeper) setCollectedFees(ctx sdk.Context, coins sdk.Coins
// AddCollectedFees - add to the fee pool // AddCollectedFees - add to the fee pool
func (fck FeeCollectionKeeper) AddCollectedFees(ctx sdk.Context, coins sdk.Coins) sdk.Coins { func (fck FeeCollectionKeeper) AddCollectedFees(ctx sdk.Context, coins sdk.Coins) sdk.Coins {
newCoins := fck.GetCollectedFees(ctx).Plus(coins) newCoins := fck.GetCollectedFees(ctx).Add(coins)
fck.setCollectedFees(ctx, newCoins) fck.setCollectedFees(ctx, newCoins)
return newCoins return newCoins

View File

@ -40,13 +40,13 @@ func SimulateDeductFee(m auth.AccountKeeper, f auth.FeeCollectionKeeper) simulat
// balance. // balance.
fees := sdk.Coins{sdk.NewCoin(randCoin.Denom, amt)} fees := sdk.Coins{sdk.NewCoin(randCoin.Denom, amt)}
spendableCoins := stored.SpendableCoins(ctx.BlockHeader().Time) spendableCoins := stored.SpendableCoins(ctx.BlockHeader().Time)
if _, hasNeg := spendableCoins.SafeMinus(fees); hasNeg { if _, hasNeg := spendableCoins.SafeSub(fees); hasNeg {
event(fmt.Sprintf("auth/SimulateDeductFee/false")) event(fmt.Sprintf("auth/SimulateDeductFee/false"))
return action, nil, nil return action, nil, nil
} }
// get the new account balance // get the new account balance
newCoins, hasNeg := initCoins.SafeMinus(fees) newCoins, hasNeg := initCoins.SafeSub(fees)
if hasNeg { if hasNeg {
event(fmt.Sprintf("auth/SimulateDeductFee/false")) event(fmt.Sprintf("auth/SimulateDeductFee/false"))
return action, nil, nil return action, nil, nil

View File

@ -228,14 +228,14 @@ func subtractCoins(ctx sdk.Context, ak auth.AccountKeeper, addr sdk.AccAddress,
// For non-vesting accounts, spendable coins will simply be the original coins. // For non-vesting accounts, spendable coins will simply be the original coins.
// So the check here is sufficient instead of subtracting from oldCoins. // So the check here is sufficient instead of subtracting from oldCoins.
_, hasNeg := spendableCoins.SafeMinus(amt) _, hasNeg := spendableCoins.SafeSub(amt)
if hasNeg { if hasNeg {
return amt, nil, sdk.ErrInsufficientCoins( return amt, nil, sdk.ErrInsufficientCoins(
fmt.Sprintf("insufficient account funds; %s < %s", spendableCoins, amt), fmt.Sprintf("insufficient account funds; %s < %s", spendableCoins, amt),
) )
} }
newCoins := oldCoins.Minus(amt) // should not panic as spendable coins was already checked newCoins := oldCoins.Sub(amt) // should not panic as spendable coins was already checked
err := setCoins(ctx, ak, addr, newCoins) err := setCoins(ctx, ak, addr, newCoins)
tags := sdk.NewTags(TagKeySender, addr.String()) tags := sdk.NewTags(TagKeySender, addr.String())
@ -245,7 +245,7 @@ func subtractCoins(ctx sdk.Context, ak auth.AccountKeeper, addr sdk.AccAddress,
// AddCoins adds amt to the coins at the addr. // AddCoins adds amt to the coins at the addr.
func addCoins(ctx sdk.Context, am auth.AccountKeeper, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) { func addCoins(ctx sdk.Context, am auth.AccountKeeper, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) {
oldCoins := getCoins(ctx, am, addr) oldCoins := getCoins(ctx, am, addr)
newCoins := oldCoins.Plus(amt) newCoins := oldCoins.Add(amt)
if newCoins.IsAnyNegative() { if newCoins.IsAnyNegative() {
return amt, nil, sdk.ErrInsufficientCoins( return amt, nil, sdk.ErrInsufficientCoins(
@ -321,7 +321,7 @@ func delegateCoins(
oldCoins := acc.GetCoins() oldCoins := acc.GetCoins()
_, hasNeg := oldCoins.SafeMinus(amt) _, hasNeg := oldCoins.SafeSub(amt)
if hasNeg { if hasNeg {
return nil, sdk.ErrInsufficientCoins( return nil, sdk.ErrInsufficientCoins(
fmt.Sprintf("insufficient account funds; %s < %s", oldCoins, amt), fmt.Sprintf("insufficient account funds; %s < %s", oldCoins, amt),
@ -368,7 +368,7 @@ func trackDelegation(acc auth.Account, blockTime time.Time, amount sdk.Coins) er
return nil return nil
} }
return acc.SetCoins(acc.GetCoins().Minus(amount)) return acc.SetCoins(acc.GetCoins().Sub(amount))
} }
func trackUndelegation(acc auth.Account, amount sdk.Coins) error { func trackUndelegation(acc auth.Account, amount sdk.Coins) error {
@ -378,5 +378,5 @@ func trackUndelegation(acc auth.Account, amount sdk.Coins) error {
return nil return nil
} }
return acc.SetCoins(acc.GetCoins().Plus(amount)) return acc.SetCoins(acc.GetCoins().Add(amount))
} }

View File

@ -230,7 +230,7 @@ func TestVestingAccountSend(t *testing.T) {
require.Error(t, err) require.Error(t, err)
// receive some coins // receive some coins
vacc.SetCoins(origCoins.Plus(sendCoins)) vacc.SetCoins(origCoins.Add(sendCoins))
input.ak.SetAccount(ctx, vacc) input.ak.SetAccount(ctx, vacc)
// require that all vested coins are spendable plus any received // require that all vested coins are spendable plus any received
@ -268,7 +268,7 @@ func TestVestingAccountReceive(t *testing.T) {
// require the coins are spendable // require the coins are spendable
vacc = input.ak.GetAccount(ctx, addr1).(*auth.ContinuousVestingAccount) vacc = input.ak.GetAccount(ctx, addr1).(*auth.ContinuousVestingAccount)
require.Equal(t, origCoins.Plus(sendCoins), vacc.GetCoins()) require.Equal(t, origCoins.Add(sendCoins), vacc.GetCoins())
require.Equal(t, vacc.SpendableCoins(now), sendCoins) require.Equal(t, vacc.SpendableCoins(now), sendCoins)
// require coins are spendable plus any that have vested // require coins are spendable plus any that have vested

View File

@ -163,14 +163,14 @@ func ValidateInputsOutputs(inputs []Input, outputs []Output) sdk.Error {
if err := in.ValidateBasic(); err != nil { if err := in.ValidateBasic(); err != nil {
return err.TraceSDK("") return err.TraceSDK("")
} }
totalIn = totalIn.Plus(in.Coins) totalIn = totalIn.Add(in.Coins)
} }
for _, out := range outputs { for _, out := range outputs {
if err := out.ValidateBasic(); err != nil { if err := out.ValidateBasic(); err != nil {
return err.TraceSDK("") return err.TraceSDK("")
} }
totalOut = totalOut.Plus(out.Coins) totalOut = totalOut.Add(out.Coins)
} }
// make sure inputs and outputs match // make sure inputs and outputs match

View File

@ -32,7 +32,7 @@ func TotalCoinsInvariant(ak auth.AccountKeeper, totalSupplyFn func() sdk.Coins)
chkAccount := func(acc auth.Account) bool { chkAccount := func(acc auth.Account) bool {
coins := acc.GetCoins() coins := acc.GetCoins()
totalCoins = totalCoins.Plus(coins) totalCoins = totalCoins.Add(coins)
return false return false
} }

View File

@ -122,11 +122,11 @@ func sendAndVerifyMsgSend(app *baseapp.BaseApp, mapper auth.AccountKeeper, msg b
fromAcc = mapper.GetAccount(ctx, msg.FromAddress) fromAcc = mapper.GetAccount(ctx, msg.FromAddress)
toAcc = mapper.GetAccount(ctx, msg.ToAddress) toAcc = mapper.GetAccount(ctx, msg.ToAddress)
if !initialFromAddrCoins.Minus(msg.Amount).IsEqual(fromAcc.GetCoins()) { if !initialFromAddrCoins.Sub(msg.Amount).IsEqual(fromAcc.GetCoins()) {
return fmt.Errorf("fromAddress %s had an incorrect amount of coins", fromAcc.GetAddress()) return fmt.Errorf("fromAddress %s had an incorrect amount of coins", fromAcc.GetAddress())
} }
if !initialToAddrCoins.Plus(msg.Amount).IsEqual(toAcc.GetCoins()) { if !initialToAddrCoins.Add(msg.Amount).IsEqual(toAcc.GetCoins()) {
return fmt.Errorf("toAddress %s had an incorrect amount of coins", toAcc.GetAddress()) return fmt.Errorf("toAddress %s had an incorrect amount of coins", toAcc.GetAddress())
} }
@ -249,13 +249,13 @@ func sendAndVerifyMsgMultiSend(app *baseapp.BaseApp, mapper auth.AccountKeeper,
for i := 0; i < len(msg.Inputs); i++ { for i := 0; i < len(msg.Inputs); i++ {
terminalInputCoins := mapper.GetAccount(ctx, msg.Inputs[i].Address).GetCoins() terminalInputCoins := mapper.GetAccount(ctx, msg.Inputs[i].Address).GetCoins()
if !initialInputAddrCoins[i].Minus(msg.Inputs[i].Coins).IsEqual(terminalInputCoins) { if !initialInputAddrCoins[i].Sub(msg.Inputs[i].Coins).IsEqual(terminalInputCoins) {
return fmt.Errorf("input #%d had an incorrect amount of coins", i) return fmt.Errorf("input #%d had an incorrect amount of coins", i)
} }
} }
for i := 0; i < len(msg.Outputs); i++ { for i := 0; i < len(msg.Outputs); i++ {
terminalOutputCoins := mapper.GetAccount(ctx, msg.Outputs[i].Address).GetCoins() terminalOutputCoins := mapper.GetAccount(ctx, msg.Outputs[i].Address).GetCoins()
if !terminalOutputCoins.IsEqual(initialOutputAddrCoins[i].Plus(msg.Outputs[i].Coins)) { if !terminalOutputCoins.IsEqual(initialOutputAddrCoins[i].Add(msg.Outputs[i].Coins)) {
return fmt.Errorf("output #%d had an incorrect amount of coins", i) return fmt.Errorf("output #%d had an incorrect amount of coins", i)
} }
} }

View File

@ -20,7 +20,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower in
// temporary workaround to keep CanWithdrawInvariant happy // temporary workaround to keep CanWithdrawInvariant happy
// general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634
if totalPower == 0 { if totalPower == 0 {
feePool.CommunityPool = feePool.CommunityPool.Plus(feesCollected) feePool.CommunityPool = feePool.CommunityPool.Add(feesCollected)
k.SetFeePool(ctx, feePool) k.SetFeePool(ctx, feePool)
return return
} }
@ -37,7 +37,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower in
// pay proposer // pay proposer
proposerValidator := k.stakingKeeper.ValidatorByConsAddr(ctx, proposer) proposerValidator := k.stakingKeeper.ValidatorByConsAddr(ctx, proposer)
k.AllocateTokensToValidator(ctx, proposerValidator, proposerReward) k.AllocateTokensToValidator(ctx, proposerValidator, proposerReward)
remaining := feesCollected.Minus(proposerReward) remaining := feesCollected.Sub(proposerReward)
// calculate fraction allocated to validators // calculate fraction allocated to validators
communityTax := k.GetCommunityTax(ctx) communityTax := k.GetCommunityTax(ctx)
@ -53,16 +53,16 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower in
powerFraction := sdk.NewDec(vote.Validator.Power).Quo(sdk.NewDec(totalPower)) powerFraction := sdk.NewDec(vote.Validator.Power).Quo(sdk.NewDec(totalPower))
reward := feesCollected.MulDec(voteMultiplier).MulDec(powerFraction) reward := feesCollected.MulDec(voteMultiplier).MulDec(powerFraction)
k.AllocateTokensToValidator(ctx, validator, reward) k.AllocateTokensToValidator(ctx, validator, reward)
remaining = remaining.Minus(reward) remaining = remaining.Sub(reward)
} }
// allocate community funding // allocate community funding
feePool.CommunityPool = feePool.CommunityPool.Plus(remaining) feePool.CommunityPool = feePool.CommunityPool.Add(remaining)
k.SetFeePool(ctx, feePool) k.SetFeePool(ctx, feePool)
// update outstanding rewards // update outstanding rewards
outstanding := k.GetOutstandingRewards(ctx) outstanding := k.GetOutstandingRewards(ctx)
outstanding = outstanding.Plus(feesCollected.Minus(remaining)) outstanding = outstanding.Add(feesCollected.Sub(remaining))
k.SetOutstandingRewards(ctx, outstanding) k.SetOutstandingRewards(ctx, outstanding)
} }
@ -71,15 +71,15 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower in
func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val sdk.Validator, tokens sdk.DecCoins) { func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val sdk.Validator, tokens sdk.DecCoins) {
// split tokens between validator and delegators according to commission // split tokens between validator and delegators according to commission
commission := tokens.MulDec(val.GetCommission()) commission := tokens.MulDec(val.GetCommission())
shared := tokens.Minus(commission) shared := tokens.Sub(commission)
// update current commission // update current commission
currentCommission := k.GetValidatorAccumulatedCommission(ctx, val.GetOperator()) currentCommission := k.GetValidatorAccumulatedCommission(ctx, val.GetOperator())
currentCommission = currentCommission.Plus(commission) currentCommission = currentCommission.Add(commission)
k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), currentCommission) k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), currentCommission)
// update current rewards // update current rewards
currentRewards := k.GetValidatorCurrentRewards(ctx, val.GetOperator()) currentRewards := k.GetValidatorCurrentRewards(ctx, val.GetOperator())
currentRewards.Rewards = currentRewards.Rewards.Plus(shared) currentRewards.Rewards = currentRewards.Rewards.Add(shared)
k.SetValidatorCurrentRewards(ctx, val.GetOperator(), currentRewards) k.SetValidatorCurrentRewards(ctx, val.GetOperator(), currentRewards)
} }

View File

@ -40,7 +40,7 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val sdk.Valid
// return staking * (ending - starting) // return staking * (ending - starting)
starting := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), startingPeriod) starting := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), startingPeriod)
ending := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), endingPeriod) ending := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), endingPeriod)
difference := ending.CumulativeRewardRatio.Minus(starting.CumulativeRewardRatio) difference := ending.CumulativeRewardRatio.Sub(starting.CumulativeRewardRatio)
if difference.IsAnyNegative() { if difference.IsAnyNegative() {
panic("negative rewards should not be possible") panic("negative rewards should not be possible")
} }
@ -66,7 +66,7 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d
k.IterateValidatorSlashEventsBetween(ctx, del.GetValidatorAddr(), startingHeight, endingHeight, k.IterateValidatorSlashEventsBetween(ctx, del.GetValidatorAddr(), startingHeight, endingHeight,
func(height uint64, event types.ValidatorSlashEvent) (stop bool) { func(height uint64, event types.ValidatorSlashEvent) (stop bool) {
endingPeriod := event.ValidatorPeriod endingPeriod := event.ValidatorPeriod
rewards = rewards.Plus(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)) rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake))
// note: necessary to truncate so we don't allow withdrawing more rewards than owed // note: necessary to truncate so we don't allow withdrawing more rewards than owed
stake = stake.MulTruncate(sdk.OneDec().Sub(event.Fraction)) stake = stake.MulTruncate(sdk.OneDec().Sub(event.Fraction))
startingPeriod = endingPeriod startingPeriod = endingPeriod
@ -76,7 +76,7 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d
} }
// calculate rewards for final period // calculate rewards for final period
rewards = rewards.Plus(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)) rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake))
return return
} }
@ -101,9 +101,9 @@ func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val sdk.Validator, de
coins, remainder := rewards.TruncateDecimal() coins, remainder := rewards.TruncateDecimal()
outstanding := k.GetOutstandingRewards(ctx) outstanding := k.GetOutstandingRewards(ctx)
k.SetOutstandingRewards(ctx, outstanding.Minus(rewards)) k.SetOutstandingRewards(ctx, outstanding.Sub(rewards))
feePool := k.GetFeePool(ctx) feePool := k.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Plus(remainder) feePool.CommunityPool = feePool.CommunityPool.Add(remainder)
k.SetFeePool(ctx, feePool) k.SetFeePool(ctx, feePool)
// add coins to user account // add coins to user account

View File

@ -118,10 +118,10 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
rewards = k.calculateDelegationRewards(ctx, val, del, endingPeriod) rewards = k.calculateDelegationRewards(ctx, val, del, endingPeriod)
// rewards should be half the tokens // rewards should be half the tokens
require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, initial.DivRaw(2).ToDec()}}, rewards) require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, initial.QuoRaw(2).ToDec()}}, rewards)
// commission should be the other half // commission should be the other half
require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, initial.DivRaw(2).ToDec()}}, require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, initial.QuoRaw(2).ToDec()}},
k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) k.GetValidatorAccumulatedCommission(ctx, valOpAddr1))
} }
@ -307,7 +307,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
require.Equal(t, uint64(2), k.GetValidatorHistoricalReferenceCount(ctx)) require.Equal(t, uint64(2), k.GetValidatorHistoricalReferenceCount(ctx))
// assert correct balance // assert correct balance
exp := balanceTokens.Sub(valTokens).Add(initial.DivRaw(2)) exp := balanceTokens.Sub(valTokens).Add(initial.QuoRaw(2))
require.Equal(t, require.Equal(t,
sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, exp)}, sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, exp)},
ak.GetAccount(ctx, sdk.AccAddress(valOpAddr1)).GetCoins(), ak.GetAccount(ctx, sdk.AccAddress(valOpAddr1)).GetCoins(),
@ -540,7 +540,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
// commission should be zero // commission should be zero
require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero()) require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero())
totalRewards = k.GetOutstandingRewards(ctx).Plus(tokens) totalRewards = k.GetOutstandingRewards(ctx).Add(tokens)
k.SetOutstandingRewards(ctx, totalRewards) k.SetOutstandingRewards(ctx, totalRewards)
// allocate some more rewards // allocate some more rewards
@ -567,7 +567,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
// commission should be half initial // commission should be half initial
require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) require.Equal(t, sdk.DecCoins{{sdk.DefaultBondDenom, sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1))
totalRewards = k.GetOutstandingRewards(ctx).Plus(tokens) totalRewards = k.GetOutstandingRewards(ctx).Add(tokens)
k.SetOutstandingRewards(ctx, totalRewards) k.SetOutstandingRewards(ctx, totalRewards)
// allocate some more rewards // allocate some more rewards

View File

@ -29,12 +29,12 @@ func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr
// remainder to community pool // remainder to community pool
feePool := h.k.GetFeePool(ctx) feePool := h.k.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Plus(remainder) feePool.CommunityPool = feePool.CommunityPool.Add(remainder)
h.k.SetFeePool(ctx, feePool) h.k.SetFeePool(ctx, feePool)
// update outstanding // update outstanding
outstanding := h.k.GetOutstandingRewards(ctx) outstanding := h.k.GetOutstandingRewards(ctx)
h.k.SetOutstandingRewards(ctx, outstanding.Minus(commission)) h.k.SetOutstandingRewards(ctx, outstanding.Sub(commission))
// add to validator account // add to validator account
accAddr := sdk.AccAddress(valAddr) accAddr := sdk.AccAddress(valAddr)

View File

@ -85,7 +85,7 @@ func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddr
// update outstanding // update outstanding
outstanding := k.GetOutstandingRewards(ctx) outstanding := k.GetOutstandingRewards(ctx)
k.SetOutstandingRewards(ctx, outstanding.Minus(sdk.NewDecCoins(coins))) k.SetOutstandingRewards(ctx, outstanding.Sub(sdk.NewDecCoins(coins)))
accAddr := sdk.AccAddress(valAddr) accAddr := sdk.AccAddress(valAddr)
withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, accAddr) withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, accAddr)

View File

@ -229,7 +229,7 @@ func queryDelegatorTotalRewards(ctx sdk.Context, _ []string, req abci.RequestQue
endingPeriod := k.incrementValidatorPeriod(ctx, val) endingPeriod := k.incrementValidatorPeriod(ctx, val)
rewards := k.calculateDelegationRewards(ctx, val, del, endingPeriod) rewards := k.calculateDelegationRewards(ctx, val, del, endingPeriod)
totalRewards = totalRewards.Plus(rewards) totalRewards = totalRewards.Add(rewards)
return false return false
}, },
) )

View File

@ -31,8 +31,8 @@ func (k Keeper) incrementValidatorPeriod(ctx sdk.Context, val sdk.Validator) uin
// ergo we instead add to the community pool // ergo we instead add to the community pool
feePool := k.GetFeePool(ctx) feePool := k.GetFeePool(ctx)
outstanding := k.GetOutstandingRewards(ctx) outstanding := k.GetOutstandingRewards(ctx)
feePool.CommunityPool = feePool.CommunityPool.Plus(rewards.Rewards) feePool.CommunityPool = feePool.CommunityPool.Add(rewards.Rewards)
outstanding = outstanding.Minus(rewards.Rewards) outstanding = outstanding.Sub(rewards.Rewards)
k.SetFeePool(ctx, feePool) k.SetFeePool(ctx, feePool)
k.SetOutstandingRewards(ctx, outstanding) k.SetOutstandingRewards(ctx, outstanding)
@ -49,7 +49,7 @@ func (k Keeper) incrementValidatorPeriod(ctx sdk.Context, val sdk.Validator) uin
k.decrementReferenceCount(ctx, val.GetOperator(), rewards.Period-1) k.decrementReferenceCount(ctx, val.GetOperator(), rewards.Period-1)
// set new historical rewards with reference count of 1 // set new historical rewards with reference count of 1
k.SetValidatorHistoricalRewards(ctx, val.GetOperator(), rewards.Period, types.NewValidatorHistoricalRewards(historical.Plus(current), 1)) k.SetValidatorHistoricalRewards(ctx, val.GetOperator(), rewards.Period, types.NewValidatorHistoricalRewards(historical.Add(current), 1))
// set current rewards, incrementing period by 1 // set current rewards, incrementing period by 1
k.SetValidatorCurrentRewards(ctx, val.GetOperator(), types.NewValidatorCurrentRewards(sdk.DecCoins{}, rewards.Period+1)) k.SetValidatorCurrentRewards(ctx, val.GetOperator(), types.NewValidatorCurrentRewards(sdk.DecCoins{}, rewards.Period+1))

View File

@ -387,7 +387,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
} }
// Update proposal // Update proposal
proposal.SetTotalDeposit(proposal.GetTotalDeposit().Plus(depositAmount)) proposal.SetTotalDeposit(proposal.GetTotalDeposit().Add(depositAmount))
keeper.SetProposal(ctx, proposal) keeper.SetProposal(ctx, proposal)
// Check if deposit has provided sufficient total funds to transition the proposal into the voting period // Check if deposit has provided sufficient total funds to transition the proposal into the voting period
@ -403,7 +403,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
newDeposit := Deposit{depositorAddr, proposalID, depositAmount} newDeposit := Deposit{depositorAddr, proposalID, depositAmount}
keeper.setDeposit(ctx, proposalID, depositorAddr, newDeposit) keeper.setDeposit(ctx, proposalID, depositorAddr, newDeposit)
} else { } else {
currDeposit.Amount = currDeposit.Amount.Plus(depositAmount) currDeposit.Amount = currDeposit.Amount.Add(depositAmount)
keeper.setDeposit(ctx, proposalID, depositorAddr, currDeposit) keeper.setDeposit(ctx, proposalID, depositorAddr, currDeposit)
} }

View File

@ -93,7 +93,7 @@ func TestDeposits(t *testing.T) {
require.Equal(t, fourSteak, deposit.Amount) require.Equal(t, fourSteak, deposit.Amount)
require.Equal(t, addrs[0], deposit.Depositor) require.Equal(t, addrs[0], deposit.Depositor)
require.Equal(t, fourSteak, keeper.GetProposal(ctx, proposalID).GetTotalDeposit()) require.Equal(t, fourSteak, keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
require.Equal(t, addr0Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[0])) require.Equal(t, addr0Initial.Sub(fourSteak), keeper.ck.GetCoins(ctx, addrs[0]))
// Check a second deposit from same address // Check a second deposit from same address
err, votingStarted = keeper.AddDeposit(ctx, proposalID, addrs[0], fiveSteak) err, votingStarted = keeper.AddDeposit(ctx, proposalID, addrs[0], fiveSteak)
@ -101,10 +101,10 @@ func TestDeposits(t *testing.T) {
require.False(t, votingStarted) require.False(t, votingStarted)
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0]) deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0])
require.True(t, found) require.True(t, found)
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount) require.Equal(t, fourSteak.Add(fiveSteak), deposit.Amount)
require.Equal(t, addrs[0], deposit.Depositor) require.Equal(t, addrs[0], deposit.Depositor)
require.Equal(t, fourSteak.Plus(fiveSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit()) require.Equal(t, fourSteak.Add(fiveSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
require.Equal(t, addr0Initial.Minus(fourSteak).Minus(fiveSteak), keeper.ck.GetCoins(ctx, addrs[0])) require.Equal(t, addr0Initial.Sub(fourSteak).Sub(fiveSteak), keeper.ck.GetCoins(ctx, addrs[0]))
// Check third deposit from a new address // Check third deposit from a new address
err, votingStarted = keeper.AddDeposit(ctx, proposalID, addrs[1], fourSteak) err, votingStarted = keeper.AddDeposit(ctx, proposalID, addrs[1], fourSteak)
@ -114,8 +114,8 @@ func TestDeposits(t *testing.T) {
require.True(t, found) require.True(t, found)
require.Equal(t, addrs[1], deposit.Depositor) require.Equal(t, addrs[1], deposit.Depositor)
require.Equal(t, fourSteak, deposit.Amount) require.Equal(t, fourSteak, deposit.Amount)
require.Equal(t, fourSteak.Plus(fiveSteak).Plus(fourSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit()) require.Equal(t, fourSteak.Add(fiveSteak).Add(fourSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
require.Equal(t, addr1Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[1])) require.Equal(t, addr1Initial.Sub(fourSteak), keeper.ck.GetCoins(ctx, addrs[1]))
// Check that proposal moved to voting period // Check that proposal moved to voting period
require.True(t, keeper.GetProposal(ctx, proposalID).GetVotingStartTime().Equal(ctx.BlockHeader().Time)) require.True(t, keeper.GetProposal(ctx, proposalID).GetVotingStartTime().Equal(ctx.BlockHeader().Time))
@ -125,7 +125,7 @@ func TestDeposits(t *testing.T) {
require.True(t, depositsIterator.Valid()) require.True(t, depositsIterator.Valid())
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit) keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
require.Equal(t, addrs[0], deposit.Depositor) require.Equal(t, addrs[0], deposit.Depositor)
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount) require.Equal(t, fourSteak.Add(fiveSteak), deposit.Amount)
depositsIterator.Next() depositsIterator.Next()
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit) keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
require.Equal(t, addrs[1], deposit.Depositor) require.Equal(t, addrs[1], deposit.Depositor)

View File

@ -304,7 +304,7 @@ func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.AccAddress, denoms []s
} }
} }
app.TotalCoinsSupply = app.TotalCoinsSupply.Plus(coins) app.TotalCoinsSupply = app.TotalCoinsSupply.Add(coins)
baseAcc := auth.NewBaseAccountWithAddress(addrs[i]) baseAcc := auth.NewBaseAccountWithAddress(addrs[i])
(&baseAcc).SetCoins(coins) (&baseAcc).SetCoins(coins)

View File

@ -112,7 +112,7 @@ func TestSlashingMsgs(t *testing.T) {
sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commission, sdk.OneInt(), sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commission, sdk.OneInt(),
) )
mock.SignCheckDeliver(t, mapp.Cdc, mapp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1) mock.SignCheckDeliver(t, mapp.Cdc, mapp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{genCoin.Minus(bondCoin)}) mock.CheckBalance(t, mapp, addr1, sdk.Coins{genCoin.Sub(bondCoin)})
mapp.BeginBlock(abci.RequestBeginBlock{}) mapp.BeginBlock(abci.RequestBeginBlock{})
validator := checkValidator(t, mapp, stakingKeeper, addr1, true) validator := checkValidator(t, mapp, stakingKeeper, addr1, true)

View File

@ -123,7 +123,7 @@ func TestStakingMsgs(t *testing.T) {
) )
mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1) mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Minus(bondCoin)}) mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Sub(bondCoin)})
mApp.BeginBlock(abci.RequestBeginBlock{}) mApp.BeginBlock(abci.RequestBeginBlock{})
validator := checkValidator(t, mApp, keeper, sdk.ValAddress(addr1), true) validator := checkValidator(t, mApp, keeper, sdk.ValAddress(addr1), true)
@ -137,7 +137,7 @@ func TestStakingMsgs(t *testing.T) {
) )
mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{createValidatorMsgOnBehalfOf}, []uint64{0, 0}, []uint64{1, 0}, true, true, priv1, priv2) mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{createValidatorMsgOnBehalfOf}, []uint64{0, 0}, []uint64{1, 0}, true, true, priv1, priv2)
mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Minus(bondCoin).Minus(bondCoin)}) mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Sub(bondCoin).Sub(bondCoin)})
mApp.BeginBlock(abci.RequestBeginBlock{}) mApp.BeginBlock(abci.RequestBeginBlock{})
validator = checkValidator(t, mApp, keeper, sdk.ValAddress(addr2), true) validator = checkValidator(t, mApp, keeper, sdk.ValAddress(addr2), true)
@ -161,7 +161,7 @@ func TestStakingMsgs(t *testing.T) {
delegateMsg := NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin) delegateMsg := NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin)
mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{delegateMsg}, []uint64{0}, []uint64{1}, true, true, priv2) mock.SignCheckDeliver(t, mApp.Cdc, mApp.BaseApp, []sdk.Msg{delegateMsg}, []uint64{0}, []uint64{1}, true, true, priv2)
mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin.Minus(bondCoin)}) mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin.Sub(bondCoin)})
checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), true, bondTokens.ToDec()) checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), true, bondTokens.ToDec())
// begin unbonding // begin unbonding
@ -172,5 +172,5 @@ func TestStakingMsgs(t *testing.T) {
checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), false, sdk.Dec{}) checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), false, sdk.Dec{})
// balance should be the same because bonding not yet complete // balance should be the same because bonding not yet complete
mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin.Minus(bondCoin)}) mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin.Sub(bondCoin)})
} }

View File

@ -74,7 +74,7 @@ func TestValidatorByPowerIndex(t *testing.T) {
validator, found = keeper.GetValidator(ctx, validatorAddr) validator, found = keeper.GetValidator(ctx, validatorAddr)
require.True(t, found) require.True(t, found)
require.Equal(t, sdk.Unbonding, validator.Status) // ensure is unbonding require.Equal(t, sdk.Unbonding, validator.Status) // ensure is unbonding
require.Equal(t, initBond.DivRaw(2), validator.Tokens) // ensure tokens slashed require.Equal(t, initBond.QuoRaw(2), validator.Tokens) // ensure tokens slashed
keeper.Unjail(ctx, consAddr0) keeper.Unjail(ctx, consAddr0)
// the old power record should have been deleted as the power changed // the old power record should have been deleted as the power changed
@ -951,7 +951,7 @@ func TestMultipleRedelegationAtSameTime(t *testing.T) {
// begin a redelegate // begin a redelegate
selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator) selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator)
msgBeginRedelegate := NewMsgBeginRedelegate(selfDelAddr, msgBeginRedelegate := NewMsgBeginRedelegate(selfDelAddr,
valAddr, valAddr2, valTokens.DivRaw(2).ToDec()) valAddr, valAddr2, valTokens.QuoRaw(2).ToDec())
got = handleMsgBeginRedelegate(ctx, msgBeginRedelegate, keeper) got = handleMsgBeginRedelegate(ctx, msgBeginRedelegate, keeper)
require.True(t, got.IsOK(), "expected no error, %v", got) require.True(t, got.IsOK(), "expected no error, %v", got)
@ -1003,7 +1003,7 @@ func TestMultipleRedelegationAtUniqueTimes(t *testing.T) {
// begin a redelegate // begin a redelegate
selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator) selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator)
msgBeginRedelegate := NewMsgBeginRedelegate(selfDelAddr, msgBeginRedelegate := NewMsgBeginRedelegate(selfDelAddr,
valAddr, valAddr2, valTokens.DivRaw(2).ToDec()) valAddr, valAddr2, valTokens.QuoRaw(2).ToDec())
got = handleMsgBeginRedelegate(ctx, msgBeginRedelegate, keeper) got = handleMsgBeginRedelegate(ctx, msgBeginRedelegate, keeper)
require.True(t, got.IsOK(), "expected no error, %v", got) require.True(t, got.IsOK(), "expected no error, %v", got)
@ -1051,7 +1051,7 @@ func TestMultipleUnbondingDelegationAtSameTime(t *testing.T) {
// begin an unbonding delegation // begin an unbonding delegation
selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator) selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator)
msgUndelegate := NewMsgUndelegate(selfDelAddr, valAddr, valTokens.DivRaw(2).ToDec()) msgUndelegate := NewMsgUndelegate(selfDelAddr, valAddr, valTokens.QuoRaw(2).ToDec())
got = handleMsgUndelegate(ctx, msgUndelegate, keeper) got = handleMsgUndelegate(ctx, msgUndelegate, keeper)
require.True(t, got.IsOK(), "expected no error, %v", got) require.True(t, got.IsOK(), "expected no error, %v", got)
@ -1097,7 +1097,7 @@ func TestMultipleUnbondingDelegationAtUniqueTimes(t *testing.T) {
// begin an unbonding delegation // begin an unbonding delegation
selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator) selfDelAddr := sdk.AccAddress(valAddr) // (the validator is it's own delegator)
msgUndelegate := NewMsgUndelegate(selfDelAddr, valAddr, valTokens.DivRaw(2).ToDec()) msgUndelegate := NewMsgUndelegate(selfDelAddr, valAddr, valTokens.QuoRaw(2).ToDec())
got = handleMsgUndelegate(ctx, msgUndelegate, keeper) got = handleMsgUndelegate(ctx, msgUndelegate, keeper)
require.True(t, got.IsOK(), "expected no error, %v", got) require.True(t, got.IsOK(), "expected no error, %v", got)
@ -1239,7 +1239,7 @@ func TestBondUnbondRedelegateSlashTwice(t *testing.T) {
ubd, found := keeper.GetUnbondingDelegation(ctx, del, valA) ubd, found := keeper.GetUnbondingDelegation(ctx, del, valA)
require.True(t, found) require.True(t, found)
require.Len(t, ubd.Entries, 1) require.Len(t, ubd.Entries, 1)
require.Equal(t, ubdTokens.DivRaw(2), ubd.Entries[0].Balance) require.Equal(t, ubdTokens.QuoRaw(2), ubd.Entries[0].Balance)
// redelegation should have been slashed by half // redelegation should have been slashed by half
redelegation, found := keeper.GetRedelegation(ctx, del, valA, valB) redelegation, found := keeper.GetRedelegation(ctx, del, valA, valB)
@ -1249,12 +1249,12 @@ func TestBondUnbondRedelegateSlashTwice(t *testing.T) {
// destination delegation should have been slashed by half // destination delegation should have been slashed by half
delegation, found = keeper.GetDelegation(ctx, del, valB) delegation, found = keeper.GetDelegation(ctx, del, valB)
require.True(t, found) require.True(t, found)
require.Equal(t, rdTokens.DivRaw(2).ToDec(), delegation.Shares) require.Equal(t, rdTokens.QuoRaw(2).ToDec(), delegation.Shares)
// validator power should have been reduced by half // validator power should have been reduced by half
validator, found := keeper.GetValidator(ctx, valA) validator, found := keeper.GetValidator(ctx, valA)
require.True(t, found) require.True(t, found)
require.Equal(t, valTokens.DivRaw(2), validator.GetBondedTokens()) require.Equal(t, valTokens.QuoRaw(2), validator.GetBondedTokens())
// slash the validator for an infraction committed after the unbonding and redelegation begin // slash the validator for an infraction committed after the unbonding and redelegation begin
ctx = ctx.WithBlockHeight(3) ctx = ctx.WithBlockHeight(3)
@ -1264,7 +1264,7 @@ func TestBondUnbondRedelegateSlashTwice(t *testing.T) {
ubd, found = keeper.GetUnbondingDelegation(ctx, del, valA) ubd, found = keeper.GetUnbondingDelegation(ctx, del, valA)
require.True(t, found) require.True(t, found)
require.Len(t, ubd.Entries, 1) require.Len(t, ubd.Entries, 1)
require.Equal(t, ubdTokens.DivRaw(2), ubd.Entries[0].Balance) require.Equal(t, ubdTokens.QuoRaw(2), ubd.Entries[0].Balance)
// redelegation should be unchanged // redelegation should be unchanged
redelegation, found = keeper.GetRedelegation(ctx, del, valA, valB) redelegation, found = keeper.GetRedelegation(ctx, del, valA, valB)
@ -1274,7 +1274,7 @@ func TestBondUnbondRedelegateSlashTwice(t *testing.T) {
// destination delegation should be unchanged // destination delegation should be unchanged
delegation, found = keeper.GetDelegation(ctx, del, valB) delegation, found = keeper.GetDelegation(ctx, del, valB)
require.True(t, found) require.True(t, found)
require.Equal(t, rdTokens.DivRaw(2).ToDec(), delegation.Shares) require.Equal(t, rdTokens.QuoRaw(2).ToDec(), delegation.Shares)
// end blocker // end blocker
EndBlocker(ctx, keeper) EndBlocker(ctx, keeper)