types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the contract module
	ModuleName = "wasm"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// TStoreKey is the string transient store representation
	TStoreKey = "transient_" + ModuleName

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

	// RouterKey is the msg router key for the staking module
	RouterKey = ModuleName
)
View Source
const (
	MaxWasmSize   = 500 * 1024
	BuildTagRegex = "^cosmwasm-opt:"
)

Variables

View Source
var (
	DefaultCodespace = ModuleName

	// ErrCreateFailed error for wasm code that has already been uploaded or failed
	ErrCreateFailed = sdkErrors.Register(DefaultCodespace, 1, "create wasm contract failed")

	// ErrAccountExists error for a contract account that already exists
	ErrAccountExists = sdkErrors.Register(DefaultCodespace, 2, "contract account already exists")

	// ErrInstantiateFailed error for rust instantiate contract failure
	ErrInstantiateFailed = sdkErrors.Register(DefaultCodespace, 3, "instantiate wasm contract failed")

	// ErrExecuteFailed error for rust execution contract failure
	ErrExecuteFailed = sdkErrors.Register(DefaultCodespace, 4, "execute wasm contract failed")

	// ErrGasLimit error for out of gas
	ErrGasLimit = sdkErrors.Register(DefaultCodespace, 5, "insufficient gas")

	// ErrInvalidGenesis error for invalid genesis file syntax
	ErrInvalidGenesis = sdkErrors.Register(DefaultCodespace, 6, "invalid genesis")

	// ErrNotFound error for an entry not found in the store
	ErrNotFound = sdkErrors.Register(DefaultCodespace, 7, "not found")

	// ErrQueryFailed error for rust smart query contract failure
	ErrQueryFailed = sdkErrors.Register(DefaultCodespace, 8, "query wasm contract failed")
)

Codes for wasm contract errors

View Source
var (
	KeyLastCodeID     = []byte("lastCodeId")
	KeyLastInstanceID = []byte("lastContractId")

	CodeKeyPrefix       = []byte{0x01}
	ContractKeyPrefix   = []byte{0x02}
	ContractStorePrefix = []byte{0x03}
)

nolint

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func CosmosResult

func CosmosResult(wasmResult wasmTypes.Result) sdk.Result

CosmosResult converts from a Wasm Result type

func GetCodeKey

func GetCodeKey(contractID uint64) []byte

GetCodeKey constructs the key for retreiving the ID for the WASM code

func GetContractAddressKey

func GetContractAddressKey(addr sdk.AccAddress) []byte

GetContractAddressKey returns the key for the WASM contract instance

func GetContractStorePrefixKey

func GetContractStorePrefixKey(addr sdk.AccAddress) []byte

GetContractStorePrefixKey returns the store prefix for the WASM contract instance

func NewParams

func NewParams(ctx sdk.Context, creator sdk.AccAddress, deposit sdk.Coins, contractAcct auth.Account) wasmTypes.Params

NewParams initializes params for a contract instance

func NewWasmCoins

func NewWasmCoins(cosmosCoins sdk.Coins) (wasmCoins []wasmTypes.Coin)

NewWasmCoins translates between Cosmos SDK coins and Wasm coins

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the account types and interface

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis performs basic validation of supply genesis data returning an error for any failed validation criteria.

Types

type Code

type Code struct {
	CodeInfo   CodeInfo `json:"code_info"`
	CodesBytes []byte   `json:"code_bytes"`
}

Code struct encompasses CodeInfo and CodeBytes

type CodeInfo

type CodeInfo struct {
	CodeHash []byte         `json:"code_hash"`
	Creator  sdk.AccAddress `json:"creator"`
	Source   string         `json:"source"`
	Builder  string         `json:"builder"`
}

CodeInfo is data for the uploaded contract WASM code

func NewCodeInfo

func NewCodeInfo(codeHash []byte, creator sdk.AccAddress, source string, builder string) CodeInfo

NewCodeInfo fills a new Contract struct

type Contract

type Contract struct {
	ContractAddress sdk.AccAddress `json:"contract_address"`
	ContractInfo    ContractInfo   `json:"contract_info"`
	ContractState   []Model        `json:"contract_state"`
}

Contract struct encompasses ContractAddress, ContractInfo, and ContractState

type ContractInfo

type ContractInfo struct {
	CodeID  uint64          `json:"code_id"`
	Creator sdk.AccAddress  `json:"creator"`
	InitMsg json.RawMessage `json:"init_msg"`
}

ContractInfo stores a WASM contract instance

func NewContractInfo

func NewContractInfo(codeID uint64, creator sdk.AccAddress, initMsg []byte) ContractInfo

NewContractInfo creates a new instance of a given WASM contract info

type GenesisState

type GenesisState struct {
	Codes     []Code     `json:"codes"`
	Contracts []Contract `json:"contracts"`
}

GenesisState is the struct representation of the export genesis

type Model

type Model struct {
	// hex-encode key to read it better (this is often ascii)
	Key tmBytes.HexBytes `json:"key"`
	// base64-encode raw value
	Value []byte `json:"val"`
}

Model is a struct that holds a KV pair

type MsgExecuteContract

type MsgExecuteContract struct {
	Sender    sdk.AccAddress  `json:"sender" yaml:"sender"`
	Contract  sdk.AccAddress  `json:"contract" yaml:"contract"`
	Msg       json.RawMessage `json:"msg" yaml:"msg"`
	SentFunds sdk.Coins       `json:"sent_funds" yaml:"sent_funds"`
}

func (MsgExecuteContract) GetSignBytes

func (msg MsgExecuteContract) GetSignBytes() []byte

func (MsgExecuteContract) GetSigners

func (msg MsgExecuteContract) GetSigners() []sdk.AccAddress

func (MsgExecuteContract) Route

func (msg MsgExecuteContract) Route() string

func (MsgExecuteContract) Type

func (msg MsgExecuteContract) Type() string

func (MsgExecuteContract) ValidateBasic

func (msg MsgExecuteContract) ValidateBasic() error

type MsgInstantiateContract

type MsgInstantiateContract struct {
	Sender    sdk.AccAddress  `json:"sender" yaml:"sender"`
	Code      uint64          `json:"code_id" yaml:"code_id"`
	InitMsg   json.RawMessage `json:"init_msg" yaml:"init_msg"`
	InitFunds sdk.Coins       `json:"init_funds" yaml:"init_funds"`
}

func (MsgInstantiateContract) GetSignBytes

func (msg MsgInstantiateContract) GetSignBytes() []byte

func (MsgInstantiateContract) GetSigners

func (msg MsgInstantiateContract) GetSigners() []sdk.AccAddress

func (MsgInstantiateContract) Route

func (msg MsgInstantiateContract) Route() string

func (MsgInstantiateContract) Type

func (msg MsgInstantiateContract) Type() string

func (MsgInstantiateContract) ValidateBasic

func (msg MsgInstantiateContract) ValidateBasic() error

type MsgStoreCode

type MsgStoreCode struct {
	Sender sdk.AccAddress `json:"sender" yaml:"sender"`
	// WASMByteCode can be raw or gzip compressed
	WASMByteCode []byte `json:"wasm_byte_code" yaml:"wasm_byte_code"`
	// Source is a valid URI reference to the contract's source code, optional
	Source string `json:"source" yaml:"source"`
	// Builder is a docker tag, optional
	Builder string `json:"builder" yaml:"builder"`
}

func (MsgStoreCode) GetSignBytes

func (msg MsgStoreCode) GetSignBytes() []byte

func (MsgStoreCode) GetSigners

func (msg MsgStoreCode) GetSigners() []sdk.AccAddress

func (MsgStoreCode) Route

func (msg MsgStoreCode) Route() string

func (MsgStoreCode) Type

func (msg MsgStoreCode) Type() string

func (MsgStoreCode) ValidateBasic

func (msg MsgStoreCode) ValidateBasic() error

type WasmConfig

type WasmConfig struct {
	SmartQueryGasLimit uint64 `mapstructure:"query_gas_limit"`
	CacheSize          uint64 `mapstructure:"lru_size"`
}

WasmConfig is the extra config required for wasm

func DefaultWasmConfig

func DefaultWasmConfig() WasmConfig

DefaultWasmConfig returns the default settings for WasmConfig

Jump to

Keyboard shortcuts

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