Skip to content

Commit dc39e8f

Browse files
committed
use multierr consistently
1 parent e9a2084 commit dc39e8f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package types
22

33
import (
4-
"fmt"
5-
64
"go.uber.org/multierr"
75

86
"cosmossdk.io/math"
97

108
sdk "github.com/cosmos/cosmos-sdk/types"
9+
10+
"github.com/quicksilver-zone/quicksilver/utils"
1111
)
1212

1313
func NewClaim(address, chainID string, module ClaimType, srcChainID string, amount math.Int) Claim {
@@ -16,20 +16,24 @@ func NewClaim(address, chainID string, module ClaimType, srcChainID string, amou
1616

1717
// ValidateBasic performs stateless validation of a Claim.
1818
func (c *Claim) ValidateBasic() error {
19-
var errs error
19+
errs := make(map[string]error)
2020

2121
_, err := sdk.AccAddressFromBech32(c.UserAddress)
2222
if err != nil {
23-
errs = multierr.Append(errs, fmt.Errorf("userAddress: %w", err))
23+
errs["userAddress"] = err
2424
}
2525

2626
if c.ChainId == "" {
27-
errs = multierr.Append(errs, fmt.Errorf("chainID: %w", ErrUndefinedAttribute))
27+
errs["chainID"] = ErrUndefinedAttribute
2828
}
2929

3030
if c.Amount.IsNil() || !c.Amount.IsPositive() {
31-
errs = multierr.Append(errs, fmt.Errorf("amount: %w", ErrNotPositive))
31+
errs["amount"] = ErrNotPositive
32+
}
33+
34+
if len(errs) > 0 {
35+
return multierr.Combine(utils.ErrorMapToSlice(errs)...)
3236
}
3337

34-
return errs
38+
return nil
3539
}

0 commit comments

Comments
 (0)