keeper

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: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryListContracts      = "list-contracts"
	QueryListContractByCode = "list-contracts-by-code"
	QueryGetContract        = "contract-info"
	QueryGetContractState   = "contract-state"
	QueryGetCode            = "code"
	QueryListCode           = "list-code"
)
View Source
const (
	QueryMethodContractStateSmart = "smart"
	QueryMethodContractStateAll   = "all"
	QueryMethodContractStateRaw   = "raw"
)
View Source
const GasMultiplier = 100

GasMultiplier is how many cosmwasm gas points = 1 sdk gas point SDK reference costs can be found here: https://github.com/cosmos/cosmos-sdk/blob/02c6c9fafd58da88550ab4d7d494724a477c8a68/store/types/gas.go#L153-L164 A write at ~3000 gas and ~200us = 10 gas per us (microsecond) cpu/io Rough timing have 88k gas at 90us, which is equal to 1k sdk gas... (one read)

View Source
const MaxGas = 900_000_000

MaxGas for a contract is 900 million (enforced in rust)

Variables

This section is empty.

Functions

func DecodeCosmosMsgContract

func DecodeCosmosMsgContract(encoded string) ([]byte, error)

func EncodeCosmosMsgContract

func EncodeCosmosMsgContract(raw string) string

func ExportGenesis

func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState

ExportGenesis returns a GenesisState for a given context and keeper.

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState)

InitGenesis sets supply information for genesis.

CONTRACT: all types of accounts must have been already initialized/created

func MakeTestCodec

func MakeTestCodec() *codec.Codec

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier creates a new querier

func ParseOpaqueMsg

func ParseOpaqueMsg(cdc *codec.Codec, msg *wasmTypes.OpaqueMsg) (sdk.Msg, error)

ParseOpaqueMsg parses msg.Data as a base64 string it then decodes to an sdk.Msg using amino json encoding.

func ToOpaqueMsg

func ToOpaqueMsg(cdc *codec.Codec, msg sdk.Msg) (*wasmTypes.OpaqueMsg, error)

ToOpaqueMsg encodes the msg using amino json encoding. Then it wraps it in base64 to make a string to include in OpaqueMsg

Types

type GetCodeResponse

type GetCodeResponse struct {
	Code []byte `json:"code" yaml:"code"`
}

type Keeper

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

Keeper will have a reference to Wasmer with it's own data directory.

func CreateTestInput

func CreateTestInput(t *testing.T, isCheckTx bool, tempDir string) (sdk.Context, auth.AccountKeeper, Keeper)

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper,
	router sdk.Router, homeDir string, wasmConfig types.WasmConfig) Keeper

NewKeeper creates a new contract Keeper instance

func (Keeper) Create

func (k Keeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, source string, builder string) (codeID uint64, err error)

Create uploads and compiles a WASM contract, returning a short identifier for the contract

func (Keeper) Execute

func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) (sdk.Result, error)

Execute executes the contract instance

func (Keeper) GetByteCode

func (k Keeper) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error)

func (Keeper) GetCodeInfo

func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo

func (Keeper) GetContractInfo

func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo

func (Keeper) GetContractState

func (k Keeper) GetContractState(ctx sdk.Context, contractAddress sdk.AccAddress) sdk.Iterator

func (Keeper) GetNextCodeID

func (k Keeper) GetNextCodeID(ctx sdk.Context) uint64

func (Keeper) Instantiate

func (k Keeper) Instantiate(ctx sdk.Context, codeID uint64, creator sdk.AccAddress, initMsg []byte, deposit sdk.Coins) (sdk.AccAddress, error)

Instantiate creates an instance of a WASM contract

func (Keeper) ListContractInfo

func (k Keeper) ListContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool)

func (Keeper) QueryRaw

func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []types.Model

QueryRaw returns the contract's state for give key. For a `nil` key a empty slice` result is returned.

func (Keeper) QuerySmart

func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)

QuerySmart queries the smart contract itself.

type ListCodeResponse

type ListCodeResponse struct {
	ID       uint64           `json:"id"`
	Creator  sdk.AccAddress   `json:"creator"`
	CodeHash tmbytes.HexBytes `json:"code_hash"`
	Source   string           `json:"source"`
	Builder  string           `json:"builder"`
}

Jump to

Keyboard shortcuts

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