types

package
v0.0.0-...-96f998e Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 7

Documentation

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"
)
View Source
const (
	// DefaultGasCap is the default gas cap for eth_call
	DefaultGasCap uint64 = 25000000
)

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 (
	NewParamSetPair = paramtypes.NewParamSetPair
	NewKeyTable     = paramtypes.NewKeyTable
)
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

func KeyBurnTokenAmt(minUint string) []byte

KeyBurnTokenAmt returns the key of the specified min unit.

func KeyContract

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

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

func ValidateAmount(amount uint64) error

ValidateAmount checks if the given denom begins with `TokenKeywords`

func ValidateCoin

func ValidateCoin(coin sdk.Coin) error

ValidateCoin checks if the given coin

func ValidateInitialSupply

func ValidateInitialSupply(initialSupply uint64) error

ValidateInitialSupply verifies whether the initial supply is legal

func ValidateKeywords

func ValidateKeywords(denom string) error

ValidateKeywords checks if the given denom begins with `TokenKeywords`

func ValidateMinUnit

func ValidateMinUnit(minUnit string) error

ValidateMinUnit checks if the given min unit is valid

func ValidateName

func ValidateName(name string) error

ValidateName verifies whether the given name is legal

func ValidateScale

func ValidateScale(scale uint32) error

ValidateScale verifies whether the given scale is legal

func ValidateSymbol

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(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
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 CompiledContract

type CompiledContract struct {
	ABI abi.ABI
	Bin HexString
}

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

func (s HexString) MarshalJSON() ([]byte, error)

MarshalJSON serializes ByteArray to hex

func (*HexString) UnmarshalJSON

func (s *HexString) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes 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

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

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 NewNoOpTracer

func NewNoOpTracer() *NoOpTracer

NewNoOpTracer creates a no-op vm.Tracer

func (NoOpTracer) CaptureEnd

func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error)

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

func (r *Result) Failed() bool

Failed returns if the contract execution failed in vm errors

func (*Result) Return

func (r *Result) Return() []byte

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.

func (*Result) Revert

func (r *Result) Revert() []byte

Revert returns the concrete revert reason if the execution is aborted by `REVERT` opcode. Note the reason can be nil if no data supplied with revert opcode.

type Subspace

type Subspace interface {
	GetParamSet(ctx sdk.Context, ps ParamSet)
}

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.

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