Documentation ¶
Index ¶
- Constants
- Variables
- func KeyBurnTokenAmt(minUint string) []byte
- func KeyContract(contract string) []byte
- func KeyMinUint(minUnit string) []byte
- func KeySymbol(symbol string) []byte
- func KeyTokens(owner sdk.AccAddress, symbol string) []byte
- func LossLessSwap(input sdkmath.Int, ratio sdkmath.LegacyDec, inputScale, outputScale uint32) (sdkmath.Int, sdkmath.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 CompiledContract
- type EVMKeeper
- type EthCallRequest
- type HexString
- type Hook
- type ICS20Keeper
- type KeyTable
- type NoOpTracer
- func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error)
- func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from, to common.Address, input []byte, gas uint64, ...)
- func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error)
- func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, ...)
- func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, ...)
- func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, ...)
- func (dt NoOpTracer) CaptureTxEnd(restGas uint64)
- func (dt NoOpTracer) CaptureTxStart(gasLimit uint64)
- type ParamSet
- type ParamSetPairs
- type QueryTokenFeesParams
- type QueryTokenParams
- type QueryTokensParams
- type Result
- type Subspace
- type TransactionArgs
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" )
const ( // DefaultGasCap is the default gas cap for eth_call DefaultGasCap uint64 = 25000000 )
Variables ¶
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
var ( NewParamSetPair = paramtypes.NewParamSetPair NewKeyTable = paramtypes.NewKeyTable )
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 ¶
KeyBurnTokenAmt returns the key of the specified min unit.
func KeyContract ¶
KeyContract returns the key of the token with the specified contract
func KeyMinUint ¶
KeyMinUint returns the key of the token with the specified min unit
func KeySymbol ¶
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 ¶
func LossLessSwap(input sdkmath.Int, ratio sdkmath.LegacyDec, inputScale, outputScale uint32) (sdkmath.Int, sdkmath.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 ¶
ValidateAmount checks if the given denom begins with `TokenKeywords`
func ValidateInitialSupply ¶
ValidateInitialSupply verifies whether the initial supply is legal
func ValidateKeywords ¶
ValidateKeywords checks if the given denom begins with `TokenKeywords`
func ValidateMinUnit ¶
ValidateMinUnit checks if the given min unit is valid
func ValidateName ¶
ValidateName verifies whether the given name is legal
func ValidateScale ¶
ValidateScale verifies whether the given scale is legal
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress GetSequence(context.Context, sdk.AccAddress) (uint64, error) GetAccount(context.Context, sdk.AccAddress) sdk.AccountI GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI }
AccountKeeper defines the expected account keeper
type BankKeeper ¶
type BankKeeper interface { MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error GetSupply(ctx context.Context, denom string) sdk.Coin GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin SendCoinsFromModuleToAccount( ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, ) error SendCoinsFromAccountToModule( ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins, ) error SendCoinsFromModuleToModule( ctx context.Context, senderModule, recipientModule string, amt sdk.Coins, ) error SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins SetDenomMetaData(ctx context.Context, denomMetaData banktypes.Metadata) GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool) GetBlockedAddresses() map[string]bool }
BankKeeper defines the expected bank keeper (noalias)
type Bool ¶
type Bool string
func (Bool) Marshal ¶
Marshal needed for protobuf compatibility
func (*Bool) Unmarshal ¶
Unmarshal needed for protobuf compatibility
type CompiledContract ¶
CompiledContract contains compiled bytecode and abi
type EVMKeeper ¶
type EVMKeeper interface { ChainID() *big.Int SupportedKey(pubKey cryptotypes.PubKey) bool EstimateGas(ctx context.Context, req *EthCallRequest) (uint64, error) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*Result, error) }
EVMKeeper defines the expected keeper of the evm module
type EthCallRequest ¶
type EthCallRequest struct { // args uses the same json format as the json rpc api. Args []byte `json:"args,omitempty"` // gas_cap defines the default gas cap to be used GasCap uint64 `json:"gas_cap,omitempty"` // proposer_address of the requested block in hex format ProposerAddress sdk.ConsAddress `json:"proposer_address,omitempty"` // chain_id is the eip155 chain id parsed from the requested block header ChainID int64 `json:"chain_id,omitempty"` }
EthCallRequest represents the arguments to the eth_call RPC
type HexString ¶
type HexString []byte
HexString is a byte array that serializes to hex
func (HexString) MarshalJSON ¶
MarshalJSON serializes ByteArray to hex
type Hook ¶
type Hook interface {
PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
}
Hook defines the hook interface
type ICS20Keeper ¶
ICS20Keeper defines the expected keeper of ICS20
type KeyTable ¶
type KeyTable = paramtypes.KeyTable
type NoOpTracer ¶
type NoOpTracer struct{}
NoOpTracer is an empty implementation of vm.Tracer interface
func (NoOpTracer) CaptureEnd ¶
CaptureEnd implements vm.Tracer interface
func (NoOpTracer) CaptureEnter ¶
func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from, to common.Address, input []byte, gas uint64, value *big.Int)
CaptureEnter implements vm.Tracer interface
func (NoOpTracer) CaptureExit ¶
func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error)
CaptureExit implements vm.Tracer interface
func (NoOpTracer) CaptureFault ¶
func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)
CaptureFault implements vm.Tracer interface
func (NoOpTracer) CaptureStart ¶
func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)
CaptureStart implements vm.Tracer interface
func (NoOpTracer) CaptureState ¶
func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error)
CaptureState implements vm.Tracer interface
func (NoOpTracer) CaptureTxEnd ¶
func (dt NoOpTracer) CaptureTxEnd(restGas uint64)
CaptureTxEnd implements vm.Tracer interface
func (NoOpTracer) CaptureTxStart ¶
func (dt NoOpTracer) CaptureTxStart(gasLimit uint64)
CaptureTxStart implements vm.Tracer interface
type ParamSet ¶
type ParamSet = paramtypes.ParamSet
type ParamSetPairs ¶
type ParamSetPairs = paramtypes.ParamSetPairs
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'
type Result ¶
type Result struct { // hash of the ethereum transaction in hex format. This hash differs from the // Tendermint sha256 hash of the transaction bytes. See // https://github.com/tendermint/tendermint/issues/6539 for reference Hash string // logs contains the transaction hash and the proto-compatible ethereum // logs. Logs []*ethtypes.Log // ret is the returned data from evm function (result or data supplied with revert // opcode) Ret []byte // vm_error is the error returned by vm execution VMError string // gas_used specifies how much gas was consumed by the transaction GasUsed uint64 }
Result represents the result of a contract execution
func (*Result) Failed ¶
Failed returns if the contract execution failed in vm errors
func (*Result) Return ¶
Return is a helper function to help caller distinguish between revert reason and function return. Return returns the data after execution if no error occurs.
type Subspace ¶
Subspace defines an interface that implements the legacy x/params Subspace type.
NOTE: This is used solely for migration of x/params managed parameters.
type TransactionArgs ¶
type TransactionArgs struct { From *common.Address `json:"from"` To *common.Address `json:"to"` Gas *hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` Value *hexutil.Big `json:"value"` Nonce *hexutil.Uint64 `json:"nonce"` // We accept "data" and "input" for backwards-compatibility reasons. // "input" is the newer name and should be preferred by clients. Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` // Introduced by AccessListTxType transaction. AccessList *ethtypes.AccessList `json:"accessList,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` }
TransactionArgs represents the arguments to construct a new transaction or a message call using JSON-RPC.