token

package
v0.0.0-...-2c3f891 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName        = types.ModuleName
	RouterKey         = types.RouterKey
	StoreKey          = types.StoreKey
	QueryTokens       = types.QueryTokens
	QueryToken        = types.QueryToken
	QuerySymbols      = types.QuerySymbols
	QueryParameters   = types.QueryParameters
	DefaultParamspace = types.DefaultParamspace
	DefaultCodespace  = types.DefaultCodespace
)

Variables

View Source
var (
	ModuleCdc                        = types.ModuleCdc
	RegisterCodec                    = types.RegisterCodec
	DefaultParams                    = types.DefaultParams
	KeyTokenCacheSize                = types.KeyTokenCacheSize
	DisableTokenProposalHandler      = client.DisableTokenProposalHandler
	TokenParamsChangeProposalHandler = client.TokenParamsChangeProposalHandler
	NewTokenParamsChangeProposal     = types.NewTokenParamsChangeProposal
	NewDisableTokenProposal          = types.NewDisableTokenProposal
)
View Source
var (
	EthToken  = "eth"
	BtcToken  = "btc"
	UsdtToken = "usdt"
)
View Source
var TestTokenData = []sdk.TokenInfo{
	{
		Symbol:        sdk.Symbol(sdk.NativeToken),
		Issuer:        "",
		IsSendEnabled: true,
		Decimals:      8,
		TotalSupply:   sdk.NewIntWithDecimal(21, 15),
	},
	{
		Symbol:        sdk.Symbol(BtcToken),
		Issuer:        "",
		IsSendEnabled: true,
		Decimals:      8,
		TotalSupply:   sdk.NewIntWithDecimal(21, 15),
	},
	{
		Symbol:        sdk.Symbol(EthToken),
		Issuer:        "",
		IsSendEnabled: true,
		Decimals:      18,
		TotalSupply:   sdk.NewInt(0),
	},
	{
		Symbol:        sdk.Symbol(UsdtToken),
		Issuer:        "0xFF760fcB0fa4Ba68d9DD2e28fc7A3c593b5d2106",
		IsSendEnabled: true,
		Decimals:      18,
		TotalSupply:   sdk.NewIntWithDecimal(1, 28),
	},
}
View Source
var TokenStoreKeyPrefix = []byte{0x01}

TokenStoreKeyPrefix define prefix for storing tokeninfk

Functions

func InitGenesis

func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) []abci.ValidatorUpdate

InitGenesis ...

func NewHandler

func NewHandler(keeper Keeper) sdk.Handler

NewHandler create a token message handler

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier create a token's query handler

func NewTokenProposalHandler

func NewTokenProposalHandler(k Keeper) govtypes.Handler

NewTokenProposalHandler create handler for token's proposal

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis ...

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements an application module for the token module.

func NewAppModule

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

BeginBlock returns the begin blocker for the distribution module.

func (AppModule) EndBlock

EndBlock returns the end blocker for the distribution module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the distribution module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the token module. It returns no validator updates.

func (AppModule) Name

func (AppModule) Name() string

Name returns the distribution module's name.

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler returns an sdk.Handler for the token module.

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler returns the distribution module sdk.Querier.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the distribution module's querier route name.

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)

RegisterInvariants registers the distribution module invariants.

func (AppModule) Route

func (AppModule) Route() string

Route returns the message routing key for the token module.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the token module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the token module.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command

GetQueryCmd returns the root query command for the token module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command

GetTxCmd returns the root tx command for the token module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the distribution module's name.

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the distribution module's types for the given codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes registers the REST routes for the token module.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the token module.

type GenesisState

type GenesisState struct {
	GenesisTokenInfos []sdk.TokenInfoWithoutSupply `json:"genesis_token_info"`
	Params            Params                       `json:"params"`
}

GenesisState ...

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState ...

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState

ExportGenesis ...

func NewGenesisState

func NewGenesisState(tokenInfos []sdk.TokenInfoWithoutSupply, params Params) GenesisState

NewGenesisState ...

func (*GenesisState) AddTokenInfoWithoutSupplyIntoGenesis

func (g *GenesisState) AddTokenInfoWithoutSupplyIntoGenesis(new sdk.TokenInfoWithoutSupply) error

AddTokenInfoWithoutSupplyIntoGenesis add a token into genesis

func (GenesisState) Equal

func (g GenesisState) Equal(g2 GenesisState) bool

Equal check whether 2 genesisstate equal

func (GenesisState) IsEmpty

func (g GenesisState) IsEmpty() bool

IsEmpty checks whether genesis state is empty

func (GenesisState) String

func (g GenesisState) String() string

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper ...

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, dk types.DistrKeeper, sk types.SupplyKeeper, paramSubSpace params.Subspace) Keeper

NewKeeper create token's Keeper

func (*Keeper) DeleteTokenInfo

func (k *Keeper) DeleteTokenInfo(ctx sdk.Context, symbol string)

DeleteTokenInfo delete TokenInfo and total supply

func (*Keeper) DeleteTokenInfoWithoutSupply

func (k *Keeper) DeleteTokenInfoWithoutSupply(ctx sdk.Context, symbol string)

DeleteTokenInfoWithoutSupply delete TokenInfoWithoutSupply

func (*Keeper) DisableSend

func (k *Keeper) DisableSend(ctx sdk.Context, symbol sdk.Symbol)

DisableSend ...

func (*Keeper) EnableSend

func (k *Keeper) EnableSend(ctx sdk.Context, symbol sdk.Symbol)

EnableSend ...

func (*Keeper) GetAllTokenInfo

func (k *Keeper) GetAllTokenInfo(ctx sdk.Context) []sdk.TokenInfo

GetAllTokenInfo get all tokeninfo, whose totalsupply is stored in supply module

func (*Keeper) GetAllTokenInfoWithoutSupply

func (k *Keeper) GetAllTokenInfoWithoutSupply(ctx sdk.Context) []sdk.TokenInfoWithoutSupply

GetAllTokenInfoWithoutSupply get all token's TokenInfoWithoutSupply

func (*Keeper) GetDecimals

func (k *Keeper) GetDecimals(ctx sdk.Context, symbol sdk.Symbol) uint64

GetDecimals ...

func (*Keeper) GetIssuer

func (k *Keeper) GetIssuer(ctx sdk.Context, symbol sdk.Symbol) string

GetIssuer ...

func (*Keeper) GetParams

func (k *Keeper) GetParams(ctx sdk.Context) (params Params)

GetParams gets the token module's parameters.

func (*Keeper) GetSymbolIterator

func (k *Keeper) GetSymbolIterator(ctx sdk.Context) sdk.Iterator

GetSymbolIterator ...

func (*Keeper) GetSymbols

func (k *Keeper) GetSymbols(ctx sdk.Context) []string

GetSymbols ...

func (*Keeper) GetTokenInfo

func (k *Keeper) GetTokenInfo(ctx sdk.Context, symbol sdk.Symbol) *sdk.TokenInfo

GetTokenInfo get a specified tokeninfo, whose totalsupply is stored in supply module

func (*Keeper) GetTokenInfoWithoutSupply

func (k *Keeper) GetTokenInfoWithoutSupply(ctx sdk.Context, symbol sdk.Symbol) *sdk.TokenInfoWithoutSupply

GetTokenInfoWithoutSupply gets a specified token's GetTokenInfoWithoutSupply

func (*Keeper) GetTotalSupply

func (k *Keeper) GetTotalSupply(ctx sdk.Context, symbol sdk.Symbol) sdk.Int

GetTotalSupply ...

func (*Keeper) IsSendEnabled

func (k *Keeper) IsSendEnabled(ctx sdk.Context, symbol sdk.Symbol) bool

IsSendEnabled ...

func (*Keeper) IsTokenSupported

func (k *Keeper) IsTokenSupported(ctx sdk.Context, symbol sdk.Symbol) bool

IsTokenSupported ...

func (*Keeper) SetParams

func (k *Keeper) SetParams(ctx sdk.Context, params Params)

SetParams sets the token module's parameters.

func (*Keeper) SetTokenInfo

func (k *Keeper) SetTokenInfo(ctx sdk.Context, tokenInfo *sdk.TokenInfo)

__For Test only__ The following methods will update total supply unconditionlly, shoul only be used in test SetTokenInfo set TokenInfo and total supply

func (*Keeper) SetTokenInfoWithoutSupply

func (k *Keeper) SetTokenInfoWithoutSupply(ctx sdk.Context, tokenInfo *sdk.TokenInfoWithoutSupply)

SetTokenInfoWithoutSupply sets TokenInfoWithoutSupply

type Params

type Params = types.Params

type QueryTokenInfo

type QueryTokenInfo = types.QueryTokenInfo

type TokenKeeper

type TokenKeeper interface {
	SetTokenInfoWithoutSupply(ctx sdk.Context, tokenInfo *sdk.TokenInfoWithoutSupply)
	DeleteTokenInfoWithoutSupply(ctx sdk.Context, symbol string)

	GetTokenInfo(ctx sdk.Context, symbol sdk.Symbol) *sdk.TokenInfo
	GetIssuer(ctx sdk.Context, symbol sdk.Symbol) string
	GetDecimals(ctx sdk.Context, symbol sdk.Symbol) uint64
	GetTotalSupply(ctx sdk.Context, symbol sdk.Symbol) sdk.Int

	IsSendEnabled(ctx sdk.Context, symbol sdk.Symbol) bool
	EnableSend(ctx sdk.Context, symbol sdk.Symbol)
	DisableSend(ctx sdk.Context, symbol sdk.Symbol)
}

TokenKeeper defines the token module interface

Directories

Path Synopsis
cli
* ******************************************************************* * @项目名称: types * @文件名称: querier.go * @Date: 2019/06/05 * @Author: Keep * @Copyright(C): 2019 BlueHelix Inc.
* ******************************************************************* * @项目名称: types * @文件名称: querier.go * @Date: 2019/06/05 * @Author: Keep * @Copyright(C): 2019 BlueHelix Inc.

Jump to

Keyboard shortcuts

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