types

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 20 Imported by: 61

Documentation

Overview

nolint

nolint

Index

Constants

View Source
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"
)
View Source
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
)
View Source
const (
	QueryToken     = "token"
	QueryTokens    = "tokens"
	QueryFees      = "fees"
	QueryParams    = "params"
	QueryTotalBurn = "total_burn"
)
View Source
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
)
View Source
const (
	ReservedPeg  = "peg"
	ReservedIBC  = "ibc"
	ReservedTIBC = "tibc"
	ReservedLpt  = "lpt"
	ReservedHTLT = "htlt"
)

Variables

View Source
var (
	ErrInvalidName          = errorsmod.Register(ModuleName, 2, "invalid token name")
	ErrInvalidMinUnit       = errorsmod.Register(ModuleName, 3, "invalid token min unit")
	ErrInvalidSymbol        = errorsmod.Register(ModuleName, 4, "invalid standard denom")
	ErrInvalidInitSupply    = errorsmod.Register(ModuleName, 5, "invalid token initial supply")
	ErrInvalidMaxSupply     = errorsmod.Register(ModuleName, 6, "invalid token maximum supply")
	ErrInvalidScale         = errorsmod.Register(ModuleName, 7, "invalid token scale")
	ErrSymbolAlreadyExists  = errorsmod.Register(ModuleName, 8, "symbol already exists")
	ErrMinUnitAlreadyExists = errorsmod.Register(ModuleName, 9, "min unit already exists")
	ErrTokenNotExists       = errorsmod.Register(ModuleName, 10, "token does not exist")
	ErrInvalidToAddress     = errorsmod.Register(ModuleName, 11, "the new owner must not be same as the original owner")
	ErrInvalidOwner         = errorsmod.Register(ModuleName, 12, "invalid token owner")
	ErrNotMintable          = errorsmod.Register(ModuleName, 13, "token is not mintable")
	ErrNotFoundTokenAmt     = errorsmod.Register(ModuleName, 14, "burned token amount not found")
	ErrInvalidAmount        = errorsmod.Register(ModuleName, 15, "invalid amount")
	ErrInvalidBaseFee       = errorsmod.Register(ModuleName, 16, "invalid base fee")
	ErrInvalidSwap          = errorsmod.Register(ModuleName, 17, "unregistered swapable fee token")
	ErrInsufficientFee      = errorsmod.Register(ModuleName, 18, "the amount of tokens after swap is less than 1")
	ErrJSONMarshal          = errorsmod.Register(ModuleName, 19, "failed to marshal JSON bytes")
	ErrVMExecution          = errorsmod.Register(ModuleName, 20, "evm transaction execution failed")
	ErrABIPack              = errorsmod.Register(ModuleName, 21, "contract ABI pack failed")
	ErrERC20AlreadyExists   = errorsmod.Register(ModuleName, 22, "erc20 contract already exists")
	ErrERC20NotDeployed     = errorsmod.Register(ModuleName, 23, "erc20 contract not deployed")
	ErrUnsupportedKey       = errorsmod.Register(ModuleName, 24, "evm not supported public key")
	ErrInvalidContract      = errorsmod.Register(ModuleName, 25, "invalid contract")
	ErrERC20Disabled        = errorsmod.Register(ModuleName, 26, "erc20 swap is disabled")
	ErrBeaconNotSet         = errorsmod.Register(ModuleName, 27, "beacon contract not set")
)

token module sentinel errors

View Source
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}
	// PrefixBurnTokenAmt defines a prefix for the amount of token burnt
	PrefixBurnTokenAmt = []byte{0x04}
	// PrefixParamsKey defines the key for the Params store
	PrefixParamsKey = []byte{0x05}
	// PrefixTokenForContract defines the erc20 contract prefix for the token
	PrefixTokenForContract = []byte{0x06}
)

Functions

func KeyBurnTokenAmt added in v1.2.0

func KeyBurnTokenAmt(minUint string) []byte

KeyBurnTokenAmt returns the key of the specified min unit.

func KeyContract added in v1.9.0

func KeyContract(contract string) []byte

KeyContract returns the key of the token with the specified contract

func KeyMinUint

func KeyMinUint(minUnit string) []byte

KeyMinUint returns the key of the token with the specified min unit

func KeySymbol

func KeySymbol(symbol string) []byte

KeySymbol returns the key of the token with the specified symbol

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

func LossLessSwap(input sdk.Int, ratio sdk.Dec, inputScale, outputScale uint32) (sdk.Int, sdk.Int)

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

func ValidateAmount(amount uint64) error

ValidateAmount checks if the given denom begins with `TokenKeywords`

func ValidateCoin added in v1.7.3

func ValidateCoin(coin sdk.Coin) error

ValidateCoin checks if the given coin

func ValidateInitialSupply added in v1.2.1

func ValidateInitialSupply(initialSupply uint64) error

ValidateInitialSupply verifies whether the initial supply is legal

func ValidateKeywords added in v1.2.1

func ValidateKeywords(denom string) error

ValidateKeywords checks if the given denom begins with `TokenKeywords`

func ValidateMinUnit added in v1.2.1

func ValidateMinUnit(minUnit string) error

ValidateMinUnit checks if the given min unit is valid

func ValidateName added in v1.2.1

func ValidateName(name string) error

ValidateName verifies whether the given name is legal

func ValidateScale added in v1.2.1

func ValidateScale(scale uint32) error

ValidateScale verifies whether the given scale is legal

func ValidateSymbol added in v1.2.1

func ValidateSymbol(symbol string) error

ValidateSymbol checks if the given symbol is valid

Types

type AccountKeeper

type AccountKeeper interface {
	GetModuleAddress(moduleName string) sdk.AccAddress
	GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
	GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI
	GetModuleAccount(ctx sdk.Context, moduleName 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)
	GetBlockedAddresses() map[string]bool
}

BankKeeper defines the expected bank keeper (noalias)

type Bool

type Bool string
const (
	False Bool = "false"
	True  Bool = "true"
	Nil   Bool = ""
)

func ParseBool

func ParseBool(v string) (Bool, error)

func (Bool) Marshal

func (b Bool) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (Bool) String

func (b Bool) String() string

func (Bool) ToBool

func (b Bool) ToBool() bool

func (*Bool) Unmarshal

func (b *Bool) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON from using string

type EVMKeeper added in v1.9.0

type EVMKeeper interface {
	ChainID() *big.Int
	SupportedKey(pubKey cryptotypes.PubKey) bool
	EstimateGas(ctx context.Context, req *types.EthCallRequest) (uint64, error)
	ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*types.Result, error)
}

EVMKeeper defines the expected keeper of the evm module

type Hook added in v1.9.0

type Hook interface {
	PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
}

Hook defines the hook interface

type ICS20Keeper added in v1.9.0

type ICS20Keeper interface {
	HasTrace(ctx sdk.Context, denom string) bool
}

ICS20Keeper defines the expected keeper of ICS20

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'

Directories

Path Synopsis
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
Package v1beta1 is a reverse proxy.
Package v1beta1 is a reverse proxy.

Jump to

Keyboard shortcuts

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