Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- Constants
- Variables
- func KeyBurnTokenAmt(minUint string) []byte
- func KeyMinUint(minUnit string) []byte
- func KeySymbol(symbol string) []byte
- func KeyTokens(owner sdk.AccAddress, symbol string) []byte
- func LossLessSwap(input sdk.Int, ratio sdk.Dec, inputScale, outputScale uint32) (sdk.Int, sdk.Int)
- func ValidateAmount(amount uint64) error
- func ValidateCoin(coin sdk.Coin) error
- func ValidateInitialSupply(initialSupply uint64) error
- func ValidateKeywords(denom string) error
- func ValidateMinUnit(minUnit string) error
- func ValidateName(name string) error
- func ValidateScale(scale uint32) error
- func ValidateSymbol(symbol string) error
- type AccountKeeper
- type BankKeeper
- type Bool
- type QueryTokenFeesParams
- type QueryTokenParams
- type QueryTokensParams
Constants ¶
const ( EventTypeIssueToken = "issue_token" EventTypeEditToken = "edit_token" EventTypeMintToken = "mint_token" EventTypeBurnToken = "burn_token" EventTypeTransferTokenOwner = "transfer_token_owner" EventTypeSwapFeeToken = "swap_fee_token" AttributeValueCategory = ModuleName AttributeKeyCreator = "creator" AttributeKeySymbol = "symbol" AttributeKeyAmount = "amount" AttributeKeyOwner = "owner" AttributeKeyDstOwner = "dst_owner" AttributeKeyRecipient = "recipient" AttributeKeySender = "sender" AttributeKeyFeePaid = "fee_paid" AttributeKeyFeeGot = "fee_got" )
const ( // ModuleName is the name of the token module ModuleName = "token" // StoreKey is the string store representation StoreKey string = ModuleName // QuerierRoute is the querier route for the token module QuerierRoute string = ModuleName // RouterKey is the msg router key for the token module RouterKey string = ModuleName // DefaultParamspace is the default name for parameter store DefaultParamspace = ModuleName )
const ( QueryToken = "token" QueryTokens = "tokens" QueryFees = "fees" QueryParams = "params" QueryTotalBurn = "total_burn" )
const ( // MaximumMaxSupply is the maximum limitation for the token max supply MaximumMaxSupply = math.MaxUint64 // MaximumInitSupply is maximum limitation for the token initial supply,100 billion MaximumInitSupply = uint64(100000000000) // MaximumScale is the maximum limitation for token decimals MaximumScale = uint32(18) // MinimumSymbolLen is the minimum limitation for the length of the token's symbol MinimumSymbolLen = 3 // MaximumSymbolLen is the maximum limitation for the length of the token's symbol MaximumSymbolLen = 64 // MaximumNameLen is the maximum limitation for the length of the token's name MaximumNameLen = 32 // MinimumMinUnitLen is the minimum limitation for the length of the token's min unit MinimumMinUnitLen = 3 // MaximumMinUnitLen is the maximum limitation for the length of the token's min unit MaximumMinUnitLen = 64 )
const ( ReservedPeg = "peg" ReservedIBC = "ibc" ReservedTIBC = "tibc" ReservedLpt = "lpt" ReservedHTLT = "htlt" )
Variables ¶
var ( ErrInvalidName = sdkerrors.Register(ModuleName, 2, "invalid token name") ErrInvalidMinUnit = sdkerrors.Register(ModuleName, 3, "invalid token min unit") ErrInvalidSymbol = sdkerrors.Register(ModuleName, 4, "invalid standard denom") ErrInvalidInitSupply = sdkerrors.Register(ModuleName, 5, "invalid token initial supply") ErrInvalidMaxSupply = sdkerrors.Register(ModuleName, 6, "invalid token maximum supply") ErrInvalidScale = sdkerrors.Register(ModuleName, 7, "invalid token scale") ErrSymbolAlreadyExists = sdkerrors.Register(ModuleName, 8, "symbol already exists") ErrMinUnitAlreadyExists = sdkerrors.Register(ModuleName, 9, "min unit already exists") ErrTokenNotExists = sdkerrors.Register(ModuleName, 10, "token does not exist") ErrInvalidToAddress = sdkerrors.Register(ModuleName, 11, "the new owner must not be same as the original owner") ErrInvalidOwner = sdkerrors.Register(ModuleName, 12, "invalid token owner") ErrNotMintable = sdkerrors.Register(ModuleName, 13, "token is not mintable") ErrNotFoundTokenAmt = sdkerrors.Register(ModuleName, 14, "burned token amount not found") ErrInvalidAmount = sdkerrors.Register(ModuleName, 15, "invalid amount") ErrInvalidBaseFee = sdkerrors.Register(ModuleName, 16, "invalid base fee") ErrInvalidSwap = sdkerrors.Register(ModuleName, 17, "unregistered swapable fee token") ErrInsufficientFee = sdkerrors.Register(ModuleName, 18, "the amount of tokens after swap is less than 1") )
token module sentinel errors
var ( // PrefixTokenForSymbol defines a symbol prefix for the token PrefixTokenForSymbol = []byte{0x01} // PrefixTokenForMinUint defines the min unit prefix for the token PrefixTokenForMinUint = []byte{0x02} // PrefixTokens defines a prefix for the tokens PrefixTokens = []byte{0x03} // PeffixBurnTokenAmt defines a prefix for the amount of token burnt PeffixBurnTokenAmt = []byte{0x04} )
Functions ¶
func KeyBurnTokenAmt ¶ added in v1.2.0
KeyBurnTokenAmt returns the key of the specified min unit.
func KeyMinUint ¶
KeyMinUint returns the key of the token with the specified min unit
func KeyTokens ¶
func KeyTokens(owner sdk.AccAddress, symbol string) []byte
KeyTokens returns the key of the specified owner and symbol. Intended for querying all tokens of an owner
func LossLessSwap ¶ added in v1.7.3
LossLessSwap calculates the output amount of a swap, ensuring no loss. input: input amount ratio: swap rate inputScale: the decimal scale of input amount outputScale: the decimal scale of output amount
func ValidateAmount ¶ added in v1.2.1
ValidateAmount checks if the given denom begins with `TokenKeywords`
func ValidateCoin ¶ added in v1.7.3
ValidateCoin checks if the given coin
func ValidateInitialSupply ¶ added in v1.2.1
ValidateInitialSupply verifies whether the initial supply is legal
func ValidateKeywords ¶ added in v1.2.1
ValidateKeywords checks if the given denom begins with `TokenKeywords`
func ValidateMinUnit ¶ added in v1.2.1
ValidateMinUnit checks if the given min unit is valid
func ValidateName ¶ added in v1.2.1
ValidateName verifies whether the given name is legal
func ValidateScale ¶ added in v1.2.1
ValidateScale verifies whether the given scale is legal
func ValidateSymbol ¶ added in v1.2.1
ValidateSymbol checks if the given symbol is valid
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI }
AccountKeeper defines the expected account keeper
type BankKeeper ¶
type BankKeeper interface { MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error GetSupply(ctx sdk.Context, denom string) sdk.Coin GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) }
BankKeeper defines the expected bank keeper (noalias)
type Bool ¶
type Bool string
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON from using string
type QueryTokenFeesParams ¶
type QueryTokenFeesParams struct {
Symbol string
}
QueryTokenFeesParams is the query parameters for 'custom/token/fees'
type QueryTokenParams ¶
type QueryTokenParams struct {
Denom string
}
QueryTokenParams is the query parameters for 'custom/token/token'
type QueryTokensParams ¶
type QueryTokensParams struct {
Owner sdk.AccAddress
}
QueryTokensParams is the query parameters for 'custom/token/tokens'