Documentation ¶
Index ¶
- Constants
- Variables
- func BankQuerier(bank bank.ViewKeeper) func(ctx sdk.Context, request *wasmTypes.BankQuery) ([]byte, error)
- func EncodeBankMsg(sender sdk.AccAddress, msg *wasmTypes.BankMsg) ([]sdk.Msg, error)
- func EncodeStakingMsg(sender sdk.AccAddress, msg *wasmTypes.StakingMsg) ([]sdk.Msg, error)
- func EncodeWasmMsg(sender sdk.AccAddress, msg *wasmTypes.WasmMsg) ([]sdk.Msg, error)
- func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState
- func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState)
- func MakeTestCodec() *codec.Codec
- func NewQuerier(keeper Keeper) sdk.Querier
- func NoCustomMsg(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error)
- func NoCustomQuerier(ctx sdk.Context, request json.RawMessage) ([]byte, error)
- func StakingQuerier(keeper staking.Keeper) func(ctx sdk.Context, request *wasmTypes.StakingQuery) ([]byte, error)
- func TestHandler(k Keeper) sdk.Handler
- func WasmQuerier(wasm Keeper) func(ctx sdk.Context, request *wasmTypes.WasmQuery) ([]byte, error)
- type BankEncoder
- type ContractInfoWithAddress
- type CustomEncoder
- type CustomQuerier
- type GetCodeResponse
- type Keeper
- func (k Keeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, source string, ...) (codeID uint64, err error)
- func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, ...) (sdk.Result, error)
- func (k Keeper) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error)
- func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo
- func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo
- func (k Keeper) GetContractState(ctx sdk.Context, contractAddress sdk.AccAddress) sdk.Iterator
- func (k Keeper) GetNextCodeID(ctx sdk.Context) uint64
- func (k Keeper) Instantiate(ctx sdk.Context, codeID uint64, creator sdk.AccAddress, initMsg []byte, ...) (sdk.AccAddress, error)
- func (k Keeper) ListContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool)
- func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []types.Model
- func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)
- type ListCodeResponse
- type MessageEncoders
- type MessageHandler
- type QueryHandler
- type QueryPlugins
- type StakingEncoder
- type TestKeepers
- type WasmEncoder
Constants ¶
const ( QueryListContractByCode = "list-contracts-by-code" QueryGetContract = "contract-info" QueryGetContractState = "contract-state" QueryGetCode = "code" QueryListCode = "list-code" )
const ( QueryMethodContractStateSmart = "smart" QueryMethodContractStateAll = "all" QueryMethodContractStateRaw = "raw" )
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)
const MaxGas = 900_000_000
MaxGas for a contract is 900 million (enforced in rust)
Variables ¶
var TestingStakeParams = staking.Params{
UnbondingTime: 100,
MaxValidators: 10,
MaxEntries: 10,
HistoricalEntries: 10,
BondDenom: "stake",
}
Functions ¶
func BankQuerier ¶
func EncodeBankMsg ¶
func EncodeStakingMsg ¶
func EncodeStakingMsg(sender sdk.AccAddress, msg *wasmTypes.StakingMsg) ([]sdk.Msg, error)
func EncodeWasmMsg ¶
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 NoCustomMsg ¶
func NoCustomMsg(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error)
func NoCustomQuerier ¶
func StakingQuerier ¶
func TestHandler ¶
TestHandler returns a wasm handler for tests (to avoid circular imports)
Types ¶
type BankEncoder ¶
type ContractInfoWithAddress ¶
type ContractInfoWithAddress struct { // embedded here, so all json items remain top level *types.ContractInfo Address sdk.AccAddress `json:"address"` }
ContractInfoWithAddress adds the address (key) to the ContractInfo representation
type CustomEncoder ¶
type CustomEncoder func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error)
type CustomQuerier ¶
type GetCodeResponse ¶
type GetCodeResponse struct { ListCodeResponse // Data is the entire wasm bytecode Data []byte `json:"data" yaml:"data"` }
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper will have a reference to Wasmer with it's own data directory.
func NewKeeper ¶
func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, stakingKeeper staking.Keeper, router sdk.Router, homeDir string, wasmConfig types.WasmConfig, supportedFeatures string, customEncoders *MessageEncoders, customPlugins *QueryPlugins) Keeper
NewKeeper creates a new contract Keeper instance If customEncoders is non-nil, we can use this to override some of the message handler, especially custom
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 (Keeper) GetCodeInfo ¶
func (Keeper) GetContractInfo ¶
func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo
func (Keeper) GetContractState ¶
func (Keeper) Instantiate ¶
func (k Keeper) Instantiate(ctx sdk.Context, codeID uint64, creator sdk.AccAddress, initMsg []byte, label string, 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 ¶
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 MessageEncoders ¶
type MessageEncoders struct { Bank BankEncoder Custom CustomEncoder Staking StakingEncoder Wasm WasmEncoder }
func DefaultEncoders ¶
func DefaultEncoders() MessageEncoders
func (MessageEncoders) Encode ¶
func (e MessageEncoders) Encode(contractAddr sdk.AccAddress, msg wasmTypes.CosmosMsg) ([]sdk.Msg, error)
func (MessageEncoders) Merge ¶
func (e MessageEncoders) Merge(o *MessageEncoders) MessageEncoders
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
func NewMessageHandler ¶
func NewMessageHandler(router sdk.Router, customEncoders *MessageEncoders) MessageHandler
func (MessageHandler) Dispatch ¶
func (h MessageHandler) Dispatch(ctx sdk.Context, contractAddr sdk.AccAddress, msg wasmTypes.CosmosMsg) error
type QueryHandler ¶
type QueryHandler struct { Ctx sdk.Context Plugins QueryPlugins }
func (QueryHandler) Query ¶
func (q QueryHandler) Query(request wasmTypes.QueryRequest) ([]byte, error)
type QueryPlugins ¶
type QueryPlugins struct { Bank func(ctx sdk.Context, request *wasmTypes.BankQuery) ([]byte, error) Custom CustomQuerier Staking func(ctx sdk.Context, request *wasmTypes.StakingQuery) ([]byte, error) Wasm func(ctx sdk.Context, request *wasmTypes.WasmQuery) ([]byte, error) }
func DefaultQueryPlugins ¶
func DefaultQueryPlugins(bank bank.ViewKeeper, staking staking.Keeper, wasm Keeper) QueryPlugins
func (QueryPlugins) Merge ¶
func (e QueryPlugins) Merge(o *QueryPlugins) QueryPlugins
type StakingEncoder ¶
type StakingEncoder func(sender sdk.AccAddress, msg *wasmTypes.StakingMsg) ([]sdk.Msg, error)
type TestKeepers ¶
type TestKeepers struct { AccountKeeper auth.AccountKeeper StakingKeeper staking.Keeper WasmKeeper Keeper DistKeeper distribution.Keeper SupplyKeeper supply.Keeper }
func CreateTestInput ¶
func CreateTestInput(t *testing.T, isCheckTx bool, tempDir string, supportedFeatures string, encoders *MessageEncoders, queriers *QueryPlugins) (sdk.Context, TestKeepers)
encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default)