Documentation ¶
Index ¶
- Constants
- Variables
- func AbiStoreKey(addr crypto.Address) []byte
- func AddressMetaStoreKey(addr crypto.Address) []byte
- func BlockHashStoreKey(height int64) []byte
- func CodeStoreKey(addr crypto.Address) []byte
- func ErrCodedError(error errors.CodedError) *sdkerrors.Error
- func MetaHashStoreKey(metahash acmstate.MetadataHash) []byte
- func ParamKeyTable() subspace.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func StorageStoreKey(addr crypto.Address, key binary.Word256) []byte
- func ValidateGenesis(bz json.RawMessage) error
- type AccountKeeper
- type BankKeeper
- type CVMAccount
- type CVMCode
- type CVMCodeType
- type CertKeeper
- type Contract
- type ContractMeta
- type DistributionKeeper
- type GenesisState
- type Metadata
- type MsgCall
- type MsgDeploy
- type Params
- type QueryResAbi
- type QueryResAddrMeta
- type QueryResCode
- type QueryResMeta
- type QueryResStorage
- type QueryResView
- type Storage
Constants ¶
const ( EventTypeCVMEvent = "cvm-event" EventTypeCall = "call" EventTypeDeploy = "deploy" EventTypeInternalCall = "internal-call" AttributeKeyNewContractAddress = "new-contract-address" AttributeKeyRecipient = "recipient" AttributeKeyValue = "value" )
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 )
const ( QueryCode = "code" QueryStorage = "storage" QueryAbi = "abi" QueryAddrMeta = "address-meta" QueryMeta = "meta" QueryView = "view" QueryAccount = "account" )
querier keys
const BurrowErrorCodeStart = 200
BurrowErrorCodeStart is the default sdk code type.
const (
DefaultGasRate uint64 = 1
)
Default parameter values
Variables ¶
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} )
var ModuleCdc *codec.Codec
ModuleCdc defines the cvm codec.
var (
ParamStoreKeyGasRate = []byte("GasRate")
)
Parameter keys
Functions ¶
func AbiStoreKey ¶
AbiStoreKey returns the kv-store key for the contract's code ABI key.
func AddressMetaStoreKey ¶
AddressMetaStoreKey returns the kv-store key for the address-metahash key.
func BlockHashStoreKey ¶
BlockHashStoreKey returns the kv-store key for the chain's block hashes.
func CodeStoreKey ¶
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 RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
func StorageStoreKey ¶
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 ContractMeta ¶
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 ¶
GetSignBytes encodes the message for signing.
func (MsgCall) GetSigners ¶
func (m MsgCall) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required.
func (MsgCall) ValidateBasic ¶
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 ¶
GetSignBytes encodes the message for signing.
func (MsgDeploy) GetSigners ¶
func (m MsgDeploy) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required.
func (MsgDeploy) ValidateBasic ¶
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 (*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.
type QueryResAbi ¶
type QueryResAbi struct {
Abi []byte `json:"abi"`
}
QueryResAbi is the query result payload for a contract code ABI query.
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 ¶
QueryResCode is the query result payload for a contract code query.
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.