Documentation
¶
Index ¶
- Constants
- Variables
- func CoinTypeKey(coinName string) string
- func GetCoin(coinStr string) (denom, amount string, err error)
- func GetCoinName(coinStr string) (coinName string, err error)
- func RatEq(t *testing.T, exp, got Rat) (*testing.T, bool, string, Rat, Rat)
- func RatsEqual(r1s, r2s []Rat) bool
- type AnteHandler
- type CoinType
- func (ct CoinType) Convert(orgCoinStr string, denom string) (destCoinStr string, err error)
- func (ct CoinType) ConvertToMinCoin(coinStr string) (coin sdk.Coin, err error)
- func (ct CoinType) GetMainUnit() (unit Unit)
- func (ct CoinType) GetMinUnit() (unit Unit)
- func (ct CoinType) GetUnit(denom string) (u Unit, err error)
- func (ct CoinType) String() string
- type FeePreprocessHandler
- type FeeRefundHandler
- type Handler
- type Origin
- type Rat
- func MinRat(r1, r2 Rat) Rat
- func NewRat(Numerator int64, Denominator ...int64) Rat
- func NewRatFromBigInt(num *big.Int, denom ...*big.Int) Rat
- func NewRatFromDecimal(decimalStr string, prec int) (f Rat, err sdk.Error)
- func NewRatFromInt(num sdk.Int, denom ...sdk.Int) Rat
- func OneRat() Rat
- func ZeroRat() Rat
- func (r Rat) Add(r2 Rat) Rat
- func (r Rat) DecimalString(prec int) string
- func (r Rat) Denom() sdk.Int
- func (r Rat) Equal(r2 Rat) bool
- func (r Rat) EvaluateBig() *big.Int
- func (r Rat) FloatString() string
- func (r Rat) GT(r2 Rat) bool
- func (r Rat) GTE(r2 Rat) bool
- func (r Rat) IsZero() bool
- func (r Rat) LT(r2 Rat) bool
- func (r Rat) LTE(r2 Rat) bool
- func (r Rat) MarshalAmino() (string, error)
- func (r Rat) Mul(r2 Rat) Rat
- func (r Rat) Num() sdk.Int
- func (r Rat) Quo(r2 Rat) Rat
- func (r Rat) Round(precisionFactor int64) Rat
- func (r Rat) RoundInt() sdk.Int
- func (r Rat) RoundInt64() int64
- func (r Rat) String() string
- func (r Rat) Sub(r2 Rat) Rat
- func (r Rat) ToLeftPadded(totalDigits int8) string
- func (r *Rat) UnmarshalAmino(text string) (err error)
- type Unit
- type Units
Constants ¶
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 ¶
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 ¶
TODO currently only iris token is supported
func GetCoinName ¶
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 (CoinType) ConvertToMinCoin ¶
func (CoinType) GetMainUnit ¶
func (CoinType) GetMinUnit ¶
type FeeRefundHandler ¶
type Rat ¶
NOTE: never use new(Rat) or else we will panic unmarshalling into the nil embedded big.Rat
func NewRatFromBigInt ¶ added in v0.7.0
NewRatFromBigInt constructs Rat from big.Int
func NewRatFromDecimal ¶ added in v0.7.0
create a rational from decimal string or integer string precision is the number of values after the decimal point which should be read
func NewRatFromInt ¶ added in v0.7.0
NewRatFromInt constructs Rat from Int
func (Rat) EvaluateBig ¶ added in v0.7.0
evaluate the rational using bankers rounding
func (Rat) FloatString ¶ added in v0.7.0
func (Rat) MarshalAmino ¶ added in v0.7.0
Wraps r.MarshalText().
func (Rat) RoundInt64 ¶ added in v0.7.0
RoundInt64 rounds the rational using bankers rounding
func (Rat) ToLeftPadded ¶ added in v0.7.0
TODO panic if negative or if totalDigits < len(initStr)??? evaluate as an integer and return left padded string
func (*Rat) UnmarshalAmino ¶ added in v0.7.0
Requires a valid JSON string - strings quotes and calls UnmarshalText