types

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MiniTokenSymbolMaxLen          = 8
	MiniTokenSymbolMinLen          = 3
	MiniTokenSymbolNewMinLen       = 2
	MiniTokenSymbolSuffixLen       = 4 // probably enough. if it collides (unlikely) the issuer can just use another tx.
	MiniTokenSymbolTxHashSuffixLen = 3 // probably enough. if it collides (unlikely) the issuer can just use another tx.
	MiniTokenSymbolMSuffix         = "M"

	MiniTokenMinExecutionAmount int64 = 1e8       // 1 with 8 decimal digits
	MiniTokenSupplyUpperBound   int64 = 1000000e8 // 1m with 8 decimal digits
	TinyTokenSupplyUpperBound   int64 = 10000e8   // 10k with 8 decimal digits
	MaxTokenURILength                 = 2048

	TinyRangeType SupplyRangeType = 1
	MiniRangeType SupplyRangeType = 2
)
View Source
const (
	TokenSymbolMaxLen          = 8
	TokenSymbolMinLen          = 3
	TokenSymbolNewMinLen       = 2
	TokenSymbolTxHashSuffixLen = 3 // probably enough. if it collides (unlikely) the issuer can just use another tx.
	TokenSymbolDotBSuffix      = ".B"

	TokenDecimals       int8  = 8
	TokenMaxTotalSupply int64 = 9000000000000000000 // 90 billions with 8 decimal digits

	NativeTokenSymbol             = "AXC" // number of zeros = TokenSymbolTxHashSuffixLen
	NativeTokenSymbolDotBSuffixed = "AXC" + TokenSymbolDotBSuffix
	NativeTokenTotalSupply        = 2e16
)

Variables

View Source
var SupplyRange = struct {
	TINY SupplyRangeType
	MINI SupplyRangeType
}{TinyRangeType, MiniRangeType}

Functions

func GetAccountDecoder

func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder

Get the AccountDecoder function for the custom AppAccount

func IsMiniTokenSymbol

func IsMiniTokenSymbol(symbol string) bool

check if it's mini token by last letter without validation

func IsValidMiniTokenSymbol

func IsValidMiniTokenSymbol(symbol string) bool

Validate and check if it's mini token

func ProtoAppAccount

func ProtoAppAccount() sdk.Account

Prototype function for AppAccount

func RegisterWire

func RegisterWire(cdc *wire.Codec)

func ValidateIssueMiniSymbol

func ValidateIssueMiniSymbol(symbol string) error

This function is used by both client and server side, and the client needs to use MiniTokenSymbolNewMinLen for the validation. If the UpgradeMgr.GetHeight == 0, that indicates the function is invoked by client side, and we should use MiniTokenSymbolNewMinLen

func ValidateIssueSymbol

func ValidateIssueSymbol(symbol string) error

This function is used by both client and server side, and the client needs to use TokenSymbolNewMinLen for the validation. If the UpgradeMgr.GetHeight == 0, that indicates the function is invoked by client side, and we should use TokenSymbolNewMinLen

func ValidateMiniTokenSymbol

func ValidateMiniTokenSymbol(symbol string) error

func ValidateTokenSymbol

func ValidateTokenSymbol(symbol string) error

func ValidateTokenSymbols

func ValidateTokenSymbols(coins sdk.Coins) error

Types

type AbciQueryHandler

type AbciQueryHandler func(app ChainApp, req abci.RequestQuery, path []string) (res *abci.ResponseQuery)

AbciQueryHandler represents an abci query handler, registered by a plugin's InitPlugin.

type AppAccount

type AppAccount struct {
	auth.BaseAccount `json:"base"`
	Name             string    `json:"name"`
	FrozenCoins      sdk.Coins `json:"frozen"`
	LockedCoins      sdk.Coins `json:"locked"`
	Flags            uint64    `json:"flags"`
}

func (*AppAccount) Clone

func (acc *AppAccount) Clone() sdk.Account

func (*AppAccount) GetFlags

func (acc *AppAccount) GetFlags() uint64

func (AppAccount) GetFrozenCoins

func (acc AppAccount) GetFrozenCoins() sdk.Coins

func (AppAccount) GetLockedCoins

func (acc AppAccount) GetLockedCoins() sdk.Coins

func (AppAccount) GetName

func (acc AppAccount) GetName() string

nolint

func (*AppAccount) SetFlags

func (acc *AppAccount) SetFlags(flags uint64)

func (*AppAccount) SetFrozenCoins

func (acc *AppAccount) SetFrozenCoins(frozen sdk.Coins)

func (*AppAccount) SetLockedCoins

func (acc *AppAccount) SetLockedCoins(frozen sdk.Coins)

func (*AppAccount) SetName

func (acc *AppAccount) SetName(name string)

type ChainApp

type ChainApp interface {
	GetCodec() *wire.Codec
	GetRouter() baseapp.Router
	GetContextForCheckState() sdk.Context
	Query(req abci.RequestQuery) (res abci.ResponseQuery)
	RegisterQueryHandler(prefix string, handler AbciQueryHandler)
	ExportAppStateAndValidators() (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)
	EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
}

ChainApp represents the main ABCI application

type IToken

type IToken interface {
	GetName() string
	GetSymbol() string
	GetOrigSymbol() string
	GetTotalSupply() utils.Fixed8
	SetTotalSupply(totalSupply utils.Fixed8)
	SetContractAddress(addr string)
	GetContractAddress() string
	SetContractDecimals(decimal int8)
	GetContractDecimals() int8

	SetOwner(addr sdk.AccAddress)
	GetOwner() sdk.AccAddress
	IsMintable() bool
	IsOwner(addr sdk.AccAddress) bool
	String() string
}

type MiniToken

type MiniToken struct {
	Name             string          `json:"name"`
	Symbol           string          `json:"symbol"`
	OrigSymbol       string          `json:"original_symbol"`
	TotalSupply      utils.Fixed8    `json:"total_supply"`
	Owner            sdk.AccAddress  `json:"owner"`
	Mintable         bool            `json:"mintable"`
	TokenType        SupplyRangeType `json:"token_type"`
	TokenURI         string          `json:"token_uri"`
	ContractAddress  string          `json:"contract_address,omitempty"`
	ContractDecimals int8            `json:"contract_decimals,omitempty"`
}

func NewMiniToken

func NewMiniToken(name, origSymbol, symbol string, supplyRangeType SupplyRangeType, totalSupply int64, owner sdk.AccAddress, mintable bool, tokenURI string) *MiniToken

func (*MiniToken) GetContractAddress

func (token *MiniToken) GetContractAddress() string

func (MiniToken) GetContractDecimals

func (token MiniToken) GetContractDecimals() int8

func (MiniToken) GetName

func (token MiniToken) GetName() string

func (MiniToken) GetOrigSymbol

func (token MiniToken) GetOrigSymbol() string

func (MiniToken) GetOwner

func (token MiniToken) GetOwner() sdk.AccAddress

func (MiniToken) GetSymbol

func (token MiniToken) GetSymbol() string

func (MiniToken) GetTotalSupply

func (token MiniToken) GetTotalSupply() utils.Fixed8

func (MiniToken) IsMintable

func (token MiniToken) IsMintable() bool

func (*MiniToken) IsOwner

func (token *MiniToken) IsOwner(addr sdk.AccAddress) bool

func (*MiniToken) SetContractAddress

func (token *MiniToken) SetContractAddress(addr string)

func (*MiniToken) SetContractDecimals

func (token *MiniToken) SetContractDecimals(decimal int8)

func (*MiniToken) SetOwner

func (token *MiniToken) SetOwner(addr sdk.AccAddress)

func (*MiniToken) SetTotalSupply

func (token *MiniToken) SetTotalSupply(totalSupply utils.Fixed8)

func (MiniToken) String

func (token MiniToken) String() string

type NamedAccount

type NamedAccount interface {
	sdk.Account
	GetName() string
	SetName(string)

	GetFrozenCoins() sdk.Coins
	SetFrozenCoins(sdk.Coins)

	//TODO: this should merge into Coin
	GetLockedCoins() sdk.Coins
	SetLockedCoins(sdk.Coins)

	GetFlags() uint64
	SetFlags(uint64)
}

TODO: maybe need to move GetFrozenCoins to the base interface

type SupplyRangeType

type SupplyRangeType int8

func (SupplyRangeType) String

func (t SupplyRangeType) String() string

func (SupplyRangeType) UpperBound

func (t SupplyRangeType) UpperBound() int64

type Token

type Token struct {
	Name             string         `json:"name"`
	Symbol           string         `json:"symbol"`
	OrigSymbol       string         `json:"original_symbol"`
	TotalSupply      utils.Fixed8   `json:"total_supply"`
	Owner            sdk.AccAddress `json:"owner"`
	Mintable         bool           `json:"mintable"`
	ContractAddress  string         `json:"contract_address,omitempty"`
	ContractDecimals int8           `json:"contract_decimals,omitempty"`
}

func NewToken

func NewToken(name, symbol string, totalSupply int64, owner sdk.AccAddress, mintable bool) (*Token, error)

func (*Token) GetContractAddress

func (token *Token) GetContractAddress() string

func (Token) GetContractDecimals

func (token Token) GetContractDecimals() int8

func (Token) GetName

func (token Token) GetName() string

func (Token) GetOrigSymbol

func (token Token) GetOrigSymbol() string

func (Token) GetOwner

func (token Token) GetOwner() sdk.AccAddress

func (Token) GetSymbol

func (token Token) GetSymbol() string

func (Token) GetTotalSupply

func (token Token) GetTotalSupply() utils.Fixed8

func (Token) IsMintable

func (token Token) IsMintable() bool

func (*Token) IsOwner

func (token *Token) IsOwner(addr sdk.AccAddress) bool

func (*Token) SetContractAddress

func (token *Token) SetContractAddress(addr string)

func (*Token) SetContractDecimals

func (token *Token) SetContractDecimals(decimal int8)

func (*Token) SetOwner

func (token *Token) SetOwner(addr sdk.AccAddress)

func (*Token) SetTotalSupply

func (token *Token) SetTotalSupply(totalSupply utils.Fixed8)

func (Token) String

func (token Token) String() string

Jump to

Keyboard shortcuts

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