Documentation ¶
Overview ¶
Package token implements the token-related parts of the staking API.
Index ¶
Constants ¶
const ( // ModuleName is a unique module name for the staking/token module. ModuleName = "staking/token" // TokenSymbolMaxLength is the maximum length of the token symbol. TokenSymbolMaxLength = 8 // TokenSymbolRegexp is the regular expression defining valid token symbol characters. TokenSymbolRegexp = "^[A-Z]+$" // nolint: gosec // Not that kind of token :). // TokenValueExponentMaxValue is the maximum value of token's value base-10 exponent. TokenValueExponentMaxValue = 20 )
Variables ¶
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.
var TokenValueAllowedSigns = []string{"+", "-"}
TokenValueAllowedSigns specifies allowed token's value signs.
Functions ¶
func ConvertToTokenAmount ¶
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 ¶
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.