coin

package
v4.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewDecFromFloat

func MustNewDecFromFloat(f float64) sdk.Dec

func New added in v4.2.0

func New(denom string, amount int64) sdk.Coin

New creates a mkCoin with a given base denom and amount

func NewDecFromFloat

func NewDecFromFloat(f float64) (sdk.Dec, error)

func Normalize added in v4.2.0

func Normalize(cs sdk.Coins) sdk.Coins

Normalize transform nil coins to empty list

func Zero added in v4.2.0

func Zero(denom string) sdk.Coin

Zero returns new coin with zero amount

func ZeroDec added in v4.2.0

func ZeroDec(denom string) sdk.DecCoin

Zero returns new coin with zero amount

Types

type DecBld

type DecBld struct {
	D sdk.DecCoin
}

TODO: add unit tests for `util/coin/math.go` DecBld is a Builder pattern for dec coin

func NewDecBld

func NewDecBld(d sdk.DecCoin) *DecBld

NewDecBld is a constructor for DecBld type

func (*DecBld) Scale

func (d *DecBld) Scale(f int64) *DecBld

Scale scales dec coin by given factor

func (*DecBld) ScaleStr

func (d *DecBld) ScaleStr(f string) *DecBld

Scale scales dec coin by given factor provided as string. Panics if f is not a correct decimal number.

func (*DecBld) ToCoin

func (d *DecBld) ToCoin() sdk.Coin

ToCoin converts DecCoin to sdk.Coin rounding up

func (*DecBld) ToCoins

func (d *DecBld) ToCoins() sdk.Coins

ToCoins converts DecCoin to sdk.Coins rounding up

func (*DecBld) ToDecCoins

func (d *DecBld) ToDecCoins() sdk.DecCoins

ToCoin converts DecCoin to sdk.DecCoins

Jump to

Keyboard shortcuts

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