types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeCVMEvent              = "cvm-event"
	EventTypeCall                  = "call"
	EventTypeDeploy                = "deploy"
	EventTypeInternalCall          = "internal-call"
	AttributeKeyNewContractAddress = "new-contract-address"
	AttributeKeyRecipient          = "recipient"
	AttributeKeyValue              = "value"
)
View Source
const (
	// ModuleName is the name of the staking module.
	ModuleName = "cvm"

	// StoreKey is the string store representation.
	StoreKey = ModuleName

	// QuerierRoute is the querier route for the staking module.
	QuerierRoute = ModuleName

	// RouterKey is the msg router key for the staking module.
	RouterKey = ModuleName

	// DefaultParamspace is the default name for parameter store.
	DefaultParamspace = ModuleName
)
View Source
const (
	QueryCode     = "code"
	QueryStorage  = "storage"
	QueryAbi      = "abi"
	QueryAddrMeta = "address-meta"
	QueryMeta     = "meta"
	QueryView     = "view"
	QueryAccount  = "account"
)

querier keys

View Source
const BurrowErrorCodeStart = 200

BurrowErrorCodeStart is the default sdk code type.

View Source
const (
	DefaultGasRate uint64 = 1
)

Default parameter values

Variables

View Source
var (
	// StorageStoreKeyPrefix is the prefix of CVM storage kv-store keys.
	StorageStoreKeyPrefix = []byte{0x00}

	// BlockHashStoreKeyPrefix is the prefix of block hash kv-store keys.
	BlockHashStoreKeyPrefix = []byte{0x01}

	// CodeStoreKeyPrefix is the prefix of code kv-store keys.
	CodeStoreKeyPrefix = []byte{0x02}

	// AbiStoreKeyPrefix is the prefix of code ABI kv-store keys.
	AbiStoreKeyPrefix = []byte{0x03}

	// MetaHashStoreKeyPrefix is the prefix of contract metadata hash kv-store keys.
	MetaHashStoreKeyPrefix = []byte{0x04}

	// AddressMetaHashStoreKeyPrefix is the prefix of contract metadata hash kv-store keys.
	AddressMetaHashStoreKeyPrefix = []byte{0x5}
)
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the cvm codec.

View Source
var (
	ParamStoreKeyGasRate = []byte("GasRate")
)

Parameter keys

Functions

func AbiStoreKey

func AbiStoreKey(addr crypto.Address) []byte

AbiStoreKey returns the kv-store key for the contract's code ABI key.

func AddressMetaStoreKey

func AddressMetaStoreKey(addr crypto.Address) []byte

AddressMetaStoreKey returns the kv-store key for the address-metahash key.

func BlockHashStoreKey

func BlockHashStoreKey(height int64) []byte

BlockHashStoreKey returns the kv-store key for the chain's block hashes.

func CodeStoreKey

func CodeStoreKey(addr crypto.Address) []byte

CodeStoreKey returns the kv-store key for the contract's storage key.

func ErrCodedError

func ErrCodedError(error errors.CodedError) *sdkerrors.Error

ErrCodedError wraps execution CodedError into sdk Error.

func MetaHashStoreKey

func MetaHashStoreKey(metahash acmstate.MetadataHash) []byte

metaHashStoreKey returns the kv-store key for the metahash key.

func ParamKeyTable

func ParamKeyTable() subspace.KeyTable

ParamKeyTable for auth module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

func StorageStoreKey

func StorageStoreKey(addr crypto.Address, key binary.Word256) []byte

StorageStoreKey returns the kv-store key for the contract's storage key.

func ValidateGenesis

func ValidateGenesis(bz json.RawMessage) error

ValidateGenesis validates cvm genesis data.

Types

type AccountKeeper

type AccountKeeper interface {
	IterateAccounts(ctx sdk.Context, process func(exported.Account) (stop bool))
	GetAccount(sdk.Context, sdk.AccAddress) exported.Account
	SetAccount(sdk.Context, exported.Account)
	NewAccount(sdk.Context, exported.Account) exported.Account
	NewAccountWithAddress(sdk.Context, sdk.AccAddress) exported.Account
}

AccountKeeper defines the expected account keeper (noalias)

type BankKeeper

type BankKeeper interface {
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
	DelegateCoins(ctx sdk.Context, fromAdd, toAddr sdk.AccAddress, amt sdk.Coins) error
	UndelegateCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error

	SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, error)
	AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, error)
}

BankKeeper defines the expected bank keeper (noalias)

type CVMAccount

type CVMAccount struct {
	*authtypes.BaseAccount

	Code acm.Bytecode `json:"code" yaml:"code"`
	Abi  string       `json:"abi" yaml:"abi"`
}

CVMAccount implements the BaseAccount interface. It contains all CVM contract related info.

func NewCVMAccount

func NewCVMAccount(baseAcc *authtypes.BaseAccount, code acm.Bytecode, abi string) *CVMAccount

NewCVMAccount creates a new CVM account

func (CVMAccount) MarshalJSON

func (ca CVMAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a CVMAccount.

func (CVMAccount) MarshalYAML

func (ca CVMAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a CVMAccount.

func (CVMAccount) String

func (ca CVMAccount) String() string

func (*CVMAccount) UnmarshalJSON

func (ca *CVMAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a CVMAccount.

type CVMCode

type CVMCode struct {
	CodeType CVMCodeType
	Code     acm.Bytecode
}

CVMCode defines the data structure of code in CVM.

func NewCVMCode

func NewCVMCode(codeType CVMCodeType, code []byte) CVMCode

NewCVMCode returns a new CVM code instance.

type CVMCodeType

type CVMCodeType byte

CVMCodeType is the type for code in CVM.

const (
	CVMCodeTypeEVMCode CVMCodeType = iota
	CVMCodeTypeEWASMCode
)

CVM code types

type CertKeeper

type CertKeeper interface {
	IsCertified(ctx sdk.Context, contentType string, content string, certType string) bool
	IsContentCertified(ctx sdk.Context, content string) bool
	IsCertifier(ctx sdk.Context, addr sdk.AccAddress) bool
	SetValidator(ctx sdk.Context, key crypto.PubKey, certifier sdk.AccAddress)
}

CertKeeper defines the expected cert keeper (noalias)

type Contract

type Contract struct {
	Address crypto.Address `json:"address"`
	Code    CVMCode        `json:"code"`
	Storage []Storage      `json:"storage"`
	Abi     []byte         `json:"abi"`
	Meta    []ContractMeta `json:"meta"`
}

type ContractMeta

type ContractMeta struct {
	CodeHash     []byte
	MetadataHash []byte
}

type DistributionKeeper

type DistributionKeeper interface {
	FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}

DistributionKeeper defines the expected distribution keeper (noalias)

type GenesisState

type GenesisState struct {
	// GasRate defines the gas exchange rate between Cosmos gas and CVM gas.
	// CVM gas equals to Cosmos Gas * gasRate.
	GasRate   uint64     `json:"gasrate"`
	Contracts []Contract `json:"contracts"`
	Metadata  []Metadata `json:"metadata"`
}

GenesisState is a cvm genesis state.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object.

func NewGenesisState

func NewGenesisState(rate uint64) GenesisState

NewGenesisState creates a new GenesisState object.

type Metadata

type Metadata struct {
	Hash     acmstate.MetadataHash `json:"hash"`
	Metadata string                `json:"metadata"`
}

type MsgCall

type MsgCall struct {
	// Caller is the sender of the CVM-message.
	Caller sdk.AccAddress

	// Callee is the recipient of the CVM-message.
	Callee sdk.AccAddress

	// Value is the amount of CTK transferred with the call.
	Value uint64

	// Data is the binary call data.
	Data acm.Bytecode
}

MsgCall is the CVM call message.

func NewMsgCall

func NewMsgCall(caller, callee sdk.AccAddress, value uint64, data []byte) MsgCall

NewMsgCall returns a new CVM call message.

func (MsgCall) GetSignBytes

func (m MsgCall) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgCall) GetSigners

func (m MsgCall) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgCall) Route

func (m MsgCall) Route() string

Route returns the module name.

func (MsgCall) Type

func (m MsgCall) Type() string

Type returns the action name.

func (MsgCall) ValidateBasic

func (m MsgCall) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgDeploy

type MsgDeploy struct {
	// Caller is the sender of the CVM-message.
	Caller sdk.AccAddress

	// Value is the amount of CTK transferred with the call.
	Value uint64

	// Code is the contract byte code.
	Code acm.Bytecode

	// Abi is the Solidity ABI bytes for the contract code.
	Abi string

	// Meta is the metadata for the contract.
	Meta []*payload.ContractMeta

	// IsEWASM is true if the code is EWASM code.
	IsEWASM bool

	// IsRuntime is true if the code is runtime code.
	IsRuntime bool
}

MsgDeploy is the CVM deploy message.

func NewMsgDeploy

func NewMsgDeploy(caller sdk.AccAddress, value uint64, code acm.Bytecode, abi string, meta []*payload.ContractMeta, isEWASM, isRuntime bool) MsgDeploy

NewMsgDeploy returns a new CVM deploy message.

func (MsgDeploy) GetSignBytes

func (m MsgDeploy) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgDeploy) GetSigners

func (m MsgDeploy) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgDeploy) Route

func (m MsgDeploy) Route() string

Route returns the module name.

func (MsgDeploy) Type

func (m MsgDeploy) Type() string

Type returns the action name.

func (MsgDeploy) ValidateBasic

func (m MsgDeploy) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type Params

type Params struct {
	GasRate uint64 `json:"gas_rate"`
}

Params defines the parameters for the cvm module.

func NewParams

func NewParams(gasRate uint64) Params

NewParams creates a new Params object.

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() subspace.ParamSetPairs

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of cvm module's parameters.

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

type QueryResAbi

type QueryResAbi struct {
	Abi []byte `json:"abi"`
}

QueryResAbi is the query result payload for a contract code ABI query.

func (QueryResAbi) String

func (q QueryResAbi) String() string

String implements fmt.Stringer.

type QueryResAddrMeta

type QueryResAddrMeta struct {
	Metahash string `json:"metahash"`
}

QueryResAddrMeta is the query result payload for a contract code ABI query.

func (QueryResAddrMeta) String

func (q QueryResAddrMeta) String() string

String implements fmt.Stringer.

type QueryResCode

type QueryResCode struct {
	Code acm.Bytecode `json:"code"`
}

QueryResCode is the query result payload for a contract code query.

func (QueryResCode) String

func (q QueryResCode) String() string

String implements fmt.Stringer.

type QueryResMeta

type QueryResMeta struct {
	Meta string `json:"meta"`
}

QueryResMeta is the query result payload for a contract code ABI query.

type QueryResStorage

type QueryResStorage struct {
	Value []byte `json:"value"`
}

QueryResStorage is the query result payload for a storage query.

func (QueryResStorage) String

func (q QueryResStorage) String() string

String implements fmt.Stringer.

type QueryResView

type QueryResView struct {
	Ret []byte `json:"ret"`
}

QueryResView is the query result payload for a storage query.

type Storage

type Storage struct {
	Key   binary.Word256 `json:"key"`
	Value []byte         `json:"value"`
}

Jump to

Keyboard shortcuts

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