prettyprint

package
v0.2102.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Index

Constants

View Source
const QuantityInvalidText = "(invalid)"

QuantityInvalidText is the textual representation of an invalid Quantity.

Variables

View Source
var (
	// ContextKeyGenesisHash is the key to retrieve the Genesis document's hash
	// value from a context.
	ContextKeyGenesisHash = contextKey("genesis/hash")
	// ContextKeyTokenSymbol is the key to retrieve the token's ticker symbol
	// value from a context.
	ContextKeyTokenSymbol = contextKey("staking/token-symbol")
	// ContextKeyTokenValueExponent is the key to retrieve the token's value
	// base-10 exponent from a context.
	ContextKeyTokenValueExponent = contextKey("staking/token-value-exponent")
	// ContextKeyTokenValueSign is the key to retrieve the token's value sign
	// from a context.
	ContextKeyTokenValueSign = contextKey("staking/token-value-sign")
	// ContextKeyCommissionScheduleIndex is the key to retrieve the rate (bound)
	// index in a commission schedule (amendment).
	ContextKeyCommissionScheduleIndex = contextKey("staking/commission-schedule-index")
)

Functions

func QuantityFrac

func QuantityFrac(numerator quantity.Quantity, denominatorExp uint8) string

QuantityFrac returns a pretty-printed representation of a quantity fraction for the given numerator and denominator's base-10 exponent.

Types

type PrettyPrinter

type PrettyPrinter interface {
	// PrettyPrint writes a pretty-printed representation of the type
	// to the given writer.
	PrettyPrint(ctx context.Context, prefix string, w io.Writer)

	// PrettyType returns a representation of the type that can be used for pretty printing.
	PrettyType() (interface{}, error)
}

PrettyPrinter is an interface for types that know how to pretty print themselves (e.g., to be displayed in a CLI).

type Quantity added in v0.2100.0

type Quantity struct {
	// contains filtered or unexported fields
}

Quantity is a quantity.Quantity wrapper for pretty-printing.

Operations over it never return an error, but just record that the Quantity has become invalid.

func NewFromQuanQuantity added in v0.2100.0

func NewFromQuanQuantity(q *quantity.Quantity) Quantity

New creates a new Quantity from a given quantity.Quantity object.

func NewQuantity added in v0.2100.0

func NewQuantity() (q Quantity)

New creates a new Quantity, initialized to zero.

func (*Quantity) Add added in v0.2100.0

func (q *Quantity) Add(n Quantity)

Add adds n to q if q is valid.

func (Quantity) IsValid added in v0.2100.0

func (q Quantity) IsValid() bool

IsValid returns true iff the q is valid.

func (*Quantity) Mul added in v0.2100.0

func (q *Quantity) Mul(n Quantity)

Mul multiplies n with q if q is valid.

func (*Quantity) Quo added in v0.2100.0

func (q *Quantity) Quo(n Quantity)

Quo divides q with n if q is valid.

func (Quantity) String added in v0.2100.0

func (q Quantity) String() string

String returns the string representation of q.

func (*Quantity) Sub added in v0.2100.0

func (q *Quantity) Sub(n Quantity)

Sub subtracts exactly n from q if q is valid.

func (Quantity) Unwrap added in v0.2100.0

func (q Quantity) Unwrap() *quantity.Quantity

Unwrap returns q's wrapped quantity.Quantity object.

Jump to

Keyboard shortcuts

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