Skip to content

Commit

Permalink
docs: fill in some documentation for Hbar
Browse files Browse the repository at this point in the history
  • Loading branch information
qtbeee authored and janaakhterov committed Jul 24, 2020
1 parent 450a19e commit ec451a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import (
"math"
)

// Hbar is a typesafe wrapper around values of HBAR providing foolproof conversions to other denominations.
type Hbar struct {
tinybar int64
}

// MaxHbar is the maximum amount the Hbar type can wrap.
var MaxHbar = Hbar{math.MaxInt64}

// MinHbar is the minimum amount the Hbar type can wrap.
var MinHbar = Hbar{math.MinInt64}

// ZeroHbar wraps a 0 value of Hbar.
var ZeroHbar = Hbar{0}

// HbarFrom creates a representation of Hbar in tinybar on the unit provided
Expand All @@ -25,10 +29,12 @@ func HbarFromTinybar(tinybar int64) Hbar {
return Hbar{tinybar}
}

// NewHbar constructs a new Hbar from a possibly fractional amount of hbar.
func NewHbar(hbar float64) Hbar {
return HbarFrom(hbar, HbarUnits.Hbar)
}

// AsTinybar returns the equivalent tinybar amount.
func (hbar Hbar) AsTinybar() int64 {
return hbar.tinybar
}
Expand Down

0 comments on commit ec451a1

Please sign in to comment.