common

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 9 Imported by: 5

README

pipeline status coverage report

Common

Common types of assets for a blockchain.

Testing
make test 
make test-watch
Linting
make lint

Documentation

Index

Constants

View Source
const (
	BNBChain = Chain("BNB")
	ETHChain = Chain("ETH")
	BTCChain = Chain("BTC")
)
View Source
const (
	BNBTicker     = Ticker("BNB")
	RuneTicker    = Ticker("RUNE")
	RuneA1FTicker = Ticker("RUNE-A1F")
	RuneB1ATicker = Ticker("RUNE-B1A")
)
View Source
const One = 100000000

One is useful type so we don't need to type 8 zero all the time

Variables

This section is empty.

Functions

func AmountToUint

func AmountToUint(amount Amount) sdk.Uint

func FloatToUint

func FloatToUint(input float64) sdk.Uint

func FloatToUintAndMultipleOne

func FloatToUintAndMultipleOne(input float64) sdk.Uint

func IntToInt64 added in v1.0.1

func IntToInt64(input sdk.Int) int64

func IntToUint64 added in v1.0.1

func IntToUint64(input sdk.Int) uint64

func IsBNB

func IsBNB(ticker Ticker) bool

func IsBNBChain added in v1.0.1

func IsBNBChain(c Chain) bool

func IsRune

func IsRune(ticker Ticker) bool

func UintToFloat64

func UintToFloat64(input sdk.Uint) float64

UintToFloat64

func UintToUint64 added in v1.0.1

func UintToUint64(input sdk.Uint) uint64

UintToUint64

Types

type Address added in v1.0.1

type Address string
var NoAddress Address = Address("")

func NewAddress added in v1.0.1

func NewAddress(address string) (Address, error)

NewAddress create a new Address Sample: bnb1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6

func (Address) Equals added in v1.0.1

func (addr Address) Equals(addr2 Address) bool

func (Address) IsChain added in v1.0.1

func (addr Address) IsChain(chain Chain) bool

func (Address) IsEmpty added in v1.0.1

func (addr Address) IsEmpty() bool

func (Address) String added in v1.0.1

func (addr Address) String() string

type Amount

type Amount string
var ZeroAmount Amount = Amount("0")

func NewAmount

func NewAmount(amount string) (Amount, error)

func NewAmountFromFloat

func NewAmountFromFloat(f float64) Amount

func UintToAmount

func UintToAmount(input sdk.Uint) Amount

func (Amount) Equals

func (a Amount) Equals(a2 Amount) bool

func (Amount) Float64

func (a Amount) Float64() float64

func (Amount) GreaterThen

func (a Amount) GreaterThen(f float64) bool

func (Amount) IsEmpty

func (a Amount) IsEmpty() bool

func (Amount) IsNegative

func (a Amount) IsNegative() bool

func (Amount) IsZero

func (a Amount) IsZero() bool

func (Amount) LessThen

func (a Amount) LessThen(f float64) bool

func (Amount) Minus

func (a Amount) Minus(a2 Amount) Amount

func (Amount) Plus

func (a Amount) Plus(a2 Amount) Amount

func (Amount) String

func (a Amount) String() string

type Chain added in v1.0.1

type Chain string

func NewChain added in v1.0.1

func NewChain(chain string) (Chain, error)

func (Chain) Equals added in v1.0.1

func (c Chain) Equals(c2 Chain) bool

func (Chain) IsEmpty added in v1.0.1

func (c Chain) IsEmpty() bool

func (Chain) String added in v1.0.1

func (c Chain) String() string

type Coin

type Coin struct {
	Chain  Chain    `json:"chain"`
	Denom  Ticker   `json:"denom"`
	Amount sdk.Uint `json:"amount"`
}

func NewCoin

func NewCoin(chain Chain, denom Ticker, amount sdk.Uint) Coin

NewCoin return a new instance of Coin

func (Coin) Valid added in v1.0.1

func (c Coin) Valid() error

type Coins

type Coins []Coin

type Duration

type Duration struct {
	time.Duration
}

Duration embedded time.Duration so we could use string to represent duration in json file for example ,1s ,1h , 5m etc

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON marshal the duration to json string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON convert the json value back to time.Duration

type Ticker

type Ticker string

func NewTicker

func NewTicker(ticker string) (Ticker, error)

func (Ticker) Equals

func (t Ticker) Equals(t2 Ticker) bool

func (Ticker) IsEmpty

func (t Ticker) IsEmpty() bool

func (Ticker) String

func (t Ticker) String() string

type Tickers

type Tickers []Ticker

type TxID

type TxID string

func NewTxID

func NewTxID(hash string) (TxID, error)

func (TxID) Equals

func (tx TxID) Equals(tx2 TxID) bool

func (TxID) IsEmpty

func (tx TxID) IsEmpty() bool

func (TxID) String

func (tx TxID) String() string

type TxIDs

type TxIDs []TxID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL