Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
add utils.MustParseAsset helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsaraf committed Dec 23, 2020
1 parent 5567779 commit e65e140
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion support/utils/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,16 @@ func CheckedFloatPtr(v *float64) string {
return fmt.Sprintf("%.10f", *v)
}

// ParseAsset returns a horizon asset a string
// MustParseAsset returns a horizon asset or panics
func MustParseAsset(code string, issuer string) *hProtocol.Asset {
a, e := ParseAsset(code, issuer)
if e != nil {
panic(e)
}
return a
}

// ParseAsset returns a horizon asset
func ParseAsset(code string, issuer string) (*hProtocol.Asset, error) {
if code != "XLM" && issuer == "" {
return nil, fmt.Errorf("error: issuer can only be empty if asset is XLM")
Expand Down

0 comments on commit e65e140

Please sign in to comment.