types

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventType = "contract"

	AttributeKeyCodeHash   = "code_hash"
	AttributeKeyAddress    = "contract_address"
	AttributeKeyMethod     = "operation"
	AttributeValueUpload   = "upload_contract"
	AttributeValueInitiate = "init_contract"
	AttributeValueInvoke   = "invoke_contract"
	AttributeValueMigrate  = "migrate_contract"

	AttributeValueCategory = vmmodule.ModuleName
)
View Source
const (
	QueryContractInfo  = "queryContractInfo"
	QueryCodeInfo      = "queryCodeInfo"
	QueryContractState = "queryContractState"
	QueryContractList  = "queryContractList"
	QueryContractExist = "queryContractExist"

	SystemContract = "system_contract"

	ModePerm   os.FileMode = 0666
	SuffixName             = ".wasm"
	FolderName             = "wasm"

	InitFunctionName   = "init"
	HandleFunctionName = "handle"
	QueryFunctionName  = "query"
)
View Source
const (
	DefaultCodespace sdk.CodespaceType = "wasm"
)
View Source
const (
	InitMethodStr = "init(string)"
)

Variables

View Source
var (
	ErrInvalidParams       = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCheckParamsError), "invalid params")
	ErrInvalidEndPoint     = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidEndPoint), "invalid endpoint")
	ErrCdcUnMarshalFailed  = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCdcUnMarshalFailed), "cdc marshal failed")
	ErrQueryFailed         = sdkerrors.Register(string(DefaultCodespace), uint32(CodeQueryFailed), "query failed")
	ErrJsonUnmarshalFailed = sdkerrors.Register(string(DefaultCodespace), uint32(CodeJsonUnmarshalFailed), "json marshal failed")
	ErrCdcMarshalFailed    = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCdcMarshalFailed), "cdc marshal failed")
	ErrGetBlockBloomFailed = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetBlockBloomFailed), "get block bloom failed")
)
View Source
var (
	WasmerKey = []byte("wasmer")

	CodeKeyPrefix             = []byte{0x01}
	ContractKeyPrefix         = []byte{0x02}
	ContractStorePrefix       = []byte{0x03}
	AccountContractListPrefix = []byte{0x04}
)
View Source
var (
	EmptyAddress = sdk.HexToAddress("0x0000000000000000000000000000000000000000")
)
View Source
var WasmCodec *codec.Codec
View Source
var WasmIdent = []byte("\x00\x61\x73\x6D")

Functions

func ArgsToInput

func ArgsToInput(args utils.CallData) (res []byte, err error)

func CallData2Input

func CallData2Input(data utils.CallData) (utils.WasmInput, error)

func GetAccountContractListKey

func GetAccountContractListKey(accountAddr sdk.AccAddress) []byte

func GetCodeKey

func GetCodeKey(codeHash []byte) []byte

func GetContractAddressKey

func GetContractAddressKey(addr sdk.AccAddress) []byte

func GetContractStorePrefixKey

func GetContractStorePrefixKey(addr sdk.AccAddress) []byte

func GetWasmerKey

func GetWasmerKey() []byte

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

func ValidType

func ValidType(signature *utils.Signature) error

Types

type CodeInfo

type CodeInfo struct {
	CodeHash string         `json:"code_hash"`
	Creator  sdk.AccAddress `json:"creator"`
}

func NewCodeInfo

func NewCodeInfo(codeHash string, creator sdk.AccAddress) CodeInfo

type CodeInfoParams

type CodeInfoParams struct {
	Hash []byte `json:"hash"`
}

func NewQueryCodeInfoParams

func NewQueryCodeInfoParams(hashStr string) CodeInfoParams

type CodeType

type CodeType = sdk.CodeType
const (
	CodeCheckParamsError CodeType = 1750
	CodeInvalidEndPoint  CodeType = 1751
	//CodeInvalidMsgError     CodeType = 1751
	//CodeHandleMsgFailedError  CodeType = 1752
	//CodeSetSequenceFailedError CodeType = 1753
	//CodeInvalidAddress        CodeType  = 1754
	//CodeQueryCodeInfoFailed   CodeType = 1755
	CodeCdcUnMarshalFailed  CodeType = 1756
	CodeQueryFailed         CodeType = 1757
	CodeJsonUnmarshalFailed CodeType = 1758
	CodeCdcMarshalFailed    CodeType = 1759
	CodeGetBlockBloomFailed CodeType = 1760
)

type Contract

type Contract struct {
	Index   int               `json:"index"`
	Code    string            `json:"code"`
	Method  string            `json:"method"`
	Params  []json.RawMessage `json:"params"`
	Address string            `json:"address"`
}

type ContractExistParams

type ContractExistParams struct {
	WasmCodeHash []byte `json:"wasm_code_hash"`
}

func NewContractExistParams

func NewContractExistParams(hash []byte) ContractExistParams

type ContractInfo

type ContractInfo struct {
	CodeInfo CodeInfo        `json:"code_info"`
	Name     string          `json:"name"`
	Version  string          `json:"version"`
	Author   string          `json:"author"`
	Email    string          `json:"email"`
	Describe string          `json:"describe"`
	InitMsg  json.RawMessage `json:"init_msg"`
	Created  *CreatedAt      `json:"created"`
}

func NewContractInfo

func NewContractInfo(codeInfo CodeInfo, initMsg []byte, name, version, author, email, describe string, createdAt *CreatedAt) ContractInfo

type ContractInfoParams

type ContractInfoParams struct {
	ContractAddress sdk.AccAddress `json:"contract_address"`
}

func NewQueryContractInfoParams

func NewQueryContractInfoParams(contractAddress sdk.AccAddress) ContractInfoParams

type ContractListParams

type ContractListParams struct {
	AccountAddress sdk.AccAddress `json:"account_address"`
}

func NewContractListParams

func NewContractListParams(accountAddress sdk.AccAddress) ContractListParams

type ContractListResponse

type ContractListResponse struct {
	ContractAddressList []string `json:"contract_address_list"`
}

func NewContractListResponse

func NewContractListResponse(contractList []string) ContractListResponse

type ContractState

type ContractState struct {
	Result string `json:"result"`
}

type ContractStateParam

type ContractStateParam struct {
	ContractAddress sdk.AccAddress `json:"contract_address"`
	InvokerAddress  sdk.AccAddress `json:"invoker_address"`
	QueryMessage    utils.CallData `json:"query_message"`
}

func NewContractStateParam

func NewContractStateParam(addr, invokerAddr sdk.AccAddress, msg utils.CallData) ContractStateParam

type CreatedAt

type CreatedAt struct {
	BlockHeight int64  `json:"block_height"`
	TxIndex     uint64 `json:"tx_index"`
}

func NewCreatedAt

func NewCreatedAt(ctx sdk.Context) *CreatedAt

func (*CreatedAt) LessThan

func (a *CreatedAt) LessThan(b *CreatedAt) bool

type GenesisState

type GenesisState struct {
	Contracts []Contract `json:"contracts"`
	Invoker   string     `json:"invoker"` //invoker.
	Name      string     `json:"name"`
	Version   string     `json:"version"`
	Author    string     `json:"author"`
	Email     string     `json:"email"`
	Describe  string     `json:"describe"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

type MsgExecuteContract

type MsgExecuteContract struct {
	FromAddress sdk.AccAddress `json:"from_address"`
	Contract    sdk.AccAddress `json:"contract"`
	Args        utils.CallData `json:"args"`
}

func NewMsgExecuteContract

func NewMsgExecuteContract(from sdk.AccAddress, contractAddress sdk.AccAddress, msg utils.CallData) *MsgExecuteContract

func (*MsgExecuteContract) Bytes

func (msg *MsgExecuteContract) Bytes() []byte

func (*MsgExecuteContract) GetFromAddress

func (msg *MsgExecuteContract) GetFromAddress() sdk.AccAddress

func (*MsgExecuteContract) MsgType

func (msg *MsgExecuteContract) MsgType() string

func (*MsgExecuteContract) Route

func (msg *MsgExecuteContract) Route() string

func (*MsgExecuteContract) ValidateBasic

func (msg *MsgExecuteContract) ValidateBasic() error

TODO

type MsgInstantiateContract

type MsgInstantiateContract struct {
	FromAddress sdk.AccAddress `json:"from_address"`
	CodeHash    []byte         `json:"code"`
	Name        string         `json:"name,omitempty"`
	Version     string         `json:"version,omitempty"`
	Author      string         `json:"author,omitempty"`
	Email       string         `json:"email,omitempty"`
	Describe    string         `json:"describe,omitempty"`
	Args        utils.CallData `json:"args,omitempty"`
}

func NewMsgInstantiateContract

func NewMsgInstantiateContract(codeHash []byte, from sdk.AccAddress, name, version, author, email, describe string,
	initMsg utils.CallData) *MsgInstantiateContract

func (*MsgInstantiateContract) Bytes

func (msg *MsgInstantiateContract) Bytes() []byte

func (*MsgInstantiateContract) GetFromAddress

func (msg *MsgInstantiateContract) GetFromAddress() sdk.AccAddress

func (*MsgInstantiateContract) MsgType

func (msg *MsgInstantiateContract) MsgType() string

func (*MsgInstantiateContract) Route

func (msg *MsgInstantiateContract) Route() string

func (*MsgInstantiateContract) ValidateBasic

func (msg *MsgInstantiateContract) ValidateBasic() error

TODO

type MsgMigrateContract

type MsgMigrateContract struct {
	FromAddress sdk.AccAddress `json:"from_address"`
	CodeHash    []byte         `json:"code"`
	Contract    sdk.AccAddress `json:"contract"`
	Name        string         `json:"name,omitempty"`
	Version     string         `json:"version,omitempty"`
	Author      string         `json:"author,omitempty"`
	Email       string         `json:"email,omitempty"`
	Describe    string         `json:"describe,omitempty"`
	Args        utils.CallData `json:"args,omitempty"`
}

func NewMsgMigrateContract

func NewMsgMigrateContract(codeHash []byte, from sdk.AccAddress, name, version, author, email, describe string,
	contract sdk.AccAddress, initMsg utils.CallData) *MsgMigrateContract

func (*MsgMigrateContract) Bytes

func (msg *MsgMigrateContract) Bytes() []byte

func (*MsgMigrateContract) GetFromAddress

func (msg *MsgMigrateContract) GetFromAddress() sdk.AccAddress

func (*MsgMigrateContract) MsgType

func (msg *MsgMigrateContract) MsgType() string

func (*MsgMigrateContract) Route

func (msg *MsgMigrateContract) Route() string

func (*MsgMigrateContract) ValidateBasic

func (msg *MsgMigrateContract) ValidateBasic() error

type MsgUploadContract

type MsgUploadContract struct {
	FromAddress sdk.AccAddress `json:"from_address"`
	Code        []byte         `json:"code"`
}

func NewMsgUploadContract

func NewMsgUploadContract(code []byte, from sdk.AccAddress) *MsgUploadContract

func (*MsgUploadContract) Bytes

func (msg *MsgUploadContract) Bytes() []byte

func (*MsgUploadContract) GetFromAddress

func (msg *MsgUploadContract) GetFromAddress() sdk.AccAddress

func (*MsgUploadContract) MsgType

func (msg *MsgUploadContract) MsgType() string

func (*MsgUploadContract) Route

func (msg *MsgUploadContract) Route() string

func (*MsgUploadContract) ValidateBasic

func (msg *MsgUploadContract) ValidateBasic() error

TODO

type RustI128

type RustI128 number128

func NewRustI128

func NewRustI128(i *big.Int) *RustI128

func (*RustI128) Bytes

func (i128 *RustI128) Bytes() []byte

type RustU128

type RustU128 number128

func NewRustU128

func NewRustU128(i *big.Int) *RustU128

func (*RustU128) Bytes

func (u128 *RustU128) Bytes() []byte

type Sink

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

func NewSink

func NewSink(raw []byte) Sink

func (Sink) Bytes

func (sink Sink) Bytes() []byte

func (Sink) ReadBool

func (sink Sink) ReadBool() (bool, error)

func (Sink) ReadByte

func (sink Sink) ReadByte() (byte, error)

func (Sink) ReadBytes

func (sink Sink) ReadBytes() ([]byte, int, error)

func (Sink) ReadI32

func (sink Sink) ReadI32() (result int32, err error)

func (Sink) ReadI64

func (sink Sink) ReadI64() (result int64, err error)

func (Sink) ReadString

func (sink Sink) ReadString() (string, error)

func (Sink) ReadU32

func (sink Sink) ReadU32() (result uint32, err error)

func (Sink) ReadU64

func (sink Sink) ReadU64() (result uint64, err error)

func (Sink) ReadUSize

func (sink Sink) ReadUSize() (result uint32, err error)

func (Sink) WriteBool

func (sink Sink) WriteBool(b bool)

func (Sink) WriteBytes

func (sink Sink) WriteBytes(b []byte)

func (Sink) WriteI128

func (sink Sink) WriteI128(i128 *RustI128)

func (Sink) WriteI32

func (sink Sink) WriteI32(i int32)

func (Sink) WriteI64

func (sink Sink) WriteI64(i int64)

func (Sink) WriteString

func (sink Sink) WriteString(s string)

func (Sink) WriteU128

func (sink Sink) WriteU128(u128 *RustU128)

func (Sink) WriteU32

func (sink Sink) WriteU32(i uint32)

func (Sink) WriteU64

func (sink Sink) WriteU64(i uint64)

type WasmConfig

type WasmConfig struct{}

Jump to

Keyboard shortcuts

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