token

package
v0.2101.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package token implements the token-related parts of the staking API.

Index

Constants

View Source
const (
	// ModuleName is a unique module name for the staking/token module.
	ModuleName = "staking/token"

	// Maximum length of the token symbol.
	TokenSymbolMaxLength = 8
	// Regular expression defining valid token symbol characters.
	TokenSymbolRegexp = "^[A-Z]+$" // nolint: gosec // Not that kind of token :).
	// Maximum value of token's value base-10 exponent.
	TokenValueExponentMaxValue = 20
)

Variables

View Source
var ErrInvalidTokenValueExponent = errors.New(ModuleName, 1, "staking/token: invalid token's value exponent")

ErrInvalidTokenValueExponent is the error returned when an invalid token's value base-10 exponent is specified.

View Source
var TokenValueAllowedSigns = []string{"+", "-"}

TokenValueAllowedSigns specifies allowed token's value signs.

Functions

func ConvertToTokenAmount

func ConvertToTokenAmount(amount quantity.Quantity, tokenValueExponent uint8) (string, error)

ConvertToTokenAmount returns the given amount in base units to the corresponding token amount accourding to the given token's value base-10 exponent.

func PrettyPrintAmount

func PrettyPrintAmount(ctx context.Context, amount interface{}, w io.Writer)

PrettyPrintAmount writes a pretty-printed representation of the given amount to the given writer.

If the context carries appropriate values for the token's ticker symbol and token's value base-10 exponent, then the amount is printed in tokens instead of base units. If the context carries appropriate value for the token's value sign, then the amount is prefixed with the sign.

Types

This section is empty.

Jump to

Keyboard shortcuts

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