File tree Expand file tree Collapse file tree 1 file changed +3
-29
lines changed
Expand file tree Collapse file tree 1 file changed +3
-29
lines changed Original file line number Diff line number Diff line change @@ -30,38 +30,12 @@ func (b Balance) GetCoins() sdk.Coins {
3030
3131// Validate checks for address and coins correctness.
3232func (b Balance ) Validate () error {
33- _ , err := sdk .AccAddressFromBech32 (b .Address )
34- if err != nil {
33+ if _ , err := sdk .AccAddressFromBech32 (b .Address ); err != nil {
3534 return err
3635 }
3736
38- var prevDenom string
39- if ! b .Coins .Empty () {
40- prevDenom = b .Coins [0 ].Denom
41- }
42- seenDenoms := make (map [string ]bool )
43-
44- // NOTE: we perform a custom validation since the coins.Validate function
45- // errors on zero balance coins
46- for _ , coin := range b .Coins {
47- if seenDenoms [coin .Denom ] {
48- return fmt .Errorf ("duplicate denomination %s" , coin .Denom )
49- }
50-
51- if err := sdk .ValidateDenom (coin .Denom ); err != nil {
52- return err
53- }
54-
55- if coin .Denom < prevDenom {
56- return fmt .Errorf ("denomination %s is not sorted" , coin .Denom )
57- }
58-
59- if coin .IsNegative () {
60- return fmt .Errorf ("coin %s amount is cannot be negative" , coin .Denom )
61- }
62-
63- seenDenoms [coin .Denom ] = true
64- prevDenom = coin .Denom
37+ if err := b .Coins .Validate (); err != nil {
38+ return err
6539 }
6640
6741 return nil
You can’t perform that action at this time.
0 commit comments