types

package
v0.5.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//1 iris = 10^3 iris-milli
	Milli = "milli"

	//1 iris = 10^6 iris-micro
	Micro = "micro"

	//1 iris = 10^9 iris-nano
	Nano = "nano"

	//1 iris = 10^12 iris-pico
	Pico = "pico"

	//1 iris = 10^15 iris-femto
	Femto = "femto"

	//1 iris = 10^18 iris-atto
	Atto = "atto"

	Native     Origin = 0x01
	External   Origin = 0x02
	UserIssued Origin = 0x03
)

Variables

View Source
var (
	MainUnit = func(coinName string) Unit {
		return NewUnit(coinName, 0)
	}

	MilliUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Milli)
		return NewUnit(denom, 3)
	}

	MicroUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Micro)
		return NewUnit(denom, 6)
	}

	NanoUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Nano)
		return NewUnit(denom, 9)
	}

	PicoUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Pico)
		return NewUnit(denom, 12)
	}

	FemtoUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Femto)
		return NewUnit(denom, 15)
	}

	AttoUnit = func(coinName string) Unit {
		denom := fmt.Sprintf("%s-%s", coinName, Atto)
		return NewUnit(denom, 18)
	}
)

Functions

func CoinTypeKey

func CoinTypeKey(coinName string) string

func GetCoin

func GetCoin(coinStr string) (denom, amount string, err error)

func GetCoinName

func GetCoinName(coinStr string) (coinName string, err error)

Types

type AnteHandler

type AnteHandler func(ctx sdk.Context, tx sdk.Tx) (newCtx sdk.Context, result sdk.Result, abort bool)

AnteHandler authenticates transactions, before their internal messages are handled. If newCtx.IsZero(), ctx is used instead.

type CoinType

type CoinType struct {
	Name    string `json:"name"`
	MinUnit Unit   `json:"min_unit"`
	Units   Units  `json:"units"`
	Origin  Origin `json:"origin"`
	Desc    string `json:"desc"`
}

func NewDefaultCoinType

func NewDefaultCoinType(name string) CoinType

func (CoinType) Convert

func (ct CoinType) Convert(orgCoinStr string, denom string) (destCoinStr string, err error)

func (CoinType) ConvertToMinCoin

func (ct CoinType) ConvertToMinCoin(coinStr string) (coin sdk.Coin, err error)

func (CoinType) GetMainUnit

func (ct CoinType) GetMainUnit() (unit Unit)

func (CoinType) GetMinUnit

func (ct CoinType) GetMinUnit() (unit Unit)

func (CoinType) GetUnit

func (ct CoinType) GetUnit(denom string) (u Unit, err error)

func (CoinType) String

func (ct CoinType) String() string

type FeePreprocessHandler

type FeePreprocessHandler func(ctx sdk.Context, tx sdk.Tx) error

type FeeRefundHandler

type FeeRefundHandler func(ctx sdk.Context, tx sdk.Tx, result sdk.Result) (sdk.Coin, error)

type Handler

type Handler func(ctx sdk.Context, msg sdk.Msg) sdk.Result

Handler defines the core of the state transition function of an application.

type Origin

type Origin = byte

func ToOrigin

func ToOrigin(origin string) (og Origin, err error)

type Rat

type Rat struct {
	sdk.Rat
}

NOTE: never use new(Rat) or else we will panic unmarshalling into the nil embedded big.Rat

func NewRat

func NewRat(rat sdk.Rat) Rat

func (Rat) DecimalString

func (r Rat) DecimalString(prec int) string

type Unit

type Unit struct {
	Denom   string `json:"denom"`
	Decimal int    `json:"decimal"`
}

func NewUnit

func NewUnit(denom string, decimal int) Unit

func (Unit) GetPrecision

func (u Unit) GetPrecision() sdk.Int

type Units

type Units = []Unit

func GetDefaultUnits

func GetDefaultUnits(coin string) Units

Jump to

Keyboard shortcuts

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