keeper

package
v0.0.0-...-69704c5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 104 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultGasCostHumanAddress is how moch SDK gas we charge to convert to a human address format
	DefaultGasCostHumanAddress = 5
	// DefaultGasCostCanonicalAddress is how moch SDK gas we charge to convert to a canonical address format
	DefaultGasCostCanonicalAddress = 4

	// DefaultDeserializationCostPerByte The formular should be `len(data) * deserializationCostPerByte`
	DefaultDeserializationCostPerByte = 1
)
View Source
const (
	// DefaultGasMultiplier is how many CosmWasm gas points = 1 Cosmos SDK gas point.
	//
	// CosmWasm gas strategy is documented in https://github.com/CosmWasm/cosmwasm/blob/v1.0.0-beta/docs/GAS.md.
	// Cosmos SDK reference costs can be found here: https://github.com/fanxchain/fanx/libs/cosmos-sdk/blob/v0.42.10/store/types/gas.go#L198-L209.
	//
	// The original multiplier of 100 up to CosmWasm 0.16 was based on
	//     "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)"
	// as well as manual Wasmer benchmarks from 2019. This was then multiplied by 150_000
	// in the 0.16 -> 1.0 upgrade (https://github.com/CosmWasm/cosmwasm/pull/1120).
	//
	// The multiplier deserves more reproducible benchmarking and a strategy that allows easy adjustments.
	// This is tracked in https://github.com/fanxchain/fanx/issues/566 and https://github.com/fanxchain/fanx/issues/631.
	// Gas adjustments are consensus breaking but may happen in any release marked as consensus breaking.
	// Do not make assumptions on how much gas an operation will consume in places that are hard to adjust,
	// such as hardcoding them in contracts.
	//
	// Please note that all gas prices returned to wasmvm should have this multiplied.
	// Benchmarks and numbers were discussed in: https://github.com/fanxchain/fanx/pull/634#issuecomment-938055852
	DefaultGasMultiplier uint64 = 140_000_000
	// DefaultInstanceCost is how much SDK gas we charge each time we load a WASM instance.
	// Creating a new instance is costly, and this helps put a recursion limit to contracts calling contracts.
	// Benchmarks and numbers were discussed in: https://github.com/fanxchain/fanx/pull/634#issuecomment-938056803
	DefaultInstanceCost uint64 = 60_000
	// DefaultCompileCost is how much SDK gas is charged *per byte* for compiling WASM code.
	// Benchmarks and numbers were discussed in: https://github.com/fanxchain/fanx/pull/634#issuecomment-938056803
	DefaultCompileCost uint64 = 3
	// DefaultEventAttributeDataCost is how much SDK gas is charged *per byte* for attribute data in events.
	// This is used with len(key) + len(value)
	DefaultEventAttributeDataCost uint64 = 1
	// DefaultContractMessageDataCost is how much SDK gas is charged *per byte* of the message that goes to the contract
	// This is used with len(msg). Note that the message is deserialized in the receiving contract and this is charged
	// with wasm gas already. The derserialization of results is also charged in wasmvm. I am unsure if we need to add
	// additional costs here.
	// Note: also used for error fields on reply, and data on reply. Maybe these should be pulled out to a different (non-zero) field
	DefaultContractMessageDataCost uint64 = 0
	// DefaultPerAttributeCost is how much SDK gas we charge per attribute count.
	DefaultPerAttributeCost uint64 = 10
	// DefaultPerCustomEventCost is how much SDK gas we charge per event count.
	DefaultPerCustomEventCost uint64 = 20
	// DefaultEventAttributeDataFreeTier number of bytes of total attribute data we do not charge.
	DefaultEventAttributeDataFreeTier = 100
)
View Source
const (
	QueryListContractByCode        = "list-contracts-by-code"
	QueryGetContract               = "contract-info"
	QueryGetContractState          = "contract-state"
	QueryGetCode                   = "code"
	QueryListCode                  = "list-code"
	QueryContractHistory           = "contract-history"
	QueryListContractBlockedMethod = "list-contract-blocked-method"
	QueryParams                    = "params"
)
View Source
const (
	QueryMethodContractStateSmart = "smart"
	QueryMethodContractStateAll   = "all"
	QueryMethodContractStateRaw   = "raw"
)
View Source
const SupportedFeatures = "iterator,staking,stargate"

Variables

View Source
var PubKeyCache = make(map[string]crypto.PubKey)
View Source
var TestingStakeParams = stakingtypes.Params{
	UnbondingTime:      100,
	MaxValidators:      10,
	Epoch:              10,
	MaxValsToAddShares: 1,
	MinDelegation:      sdk.OneDec(),
	MinSelfDelegation:  sdk.OneDec(),
	HistoricalEntries:  10,
}

Functions

func BankQuerier

func BankQuerier(bankKeeper types.BankViewKeeper) func(ctx sdk.Context, request *wasmvmtypes.BankQuery) ([]byte, error)

func BuildContractAddress

func BuildContractAddress(codeID, instanceID uint64) sdk.AccAddress

BuildContractAddress builds an sdk account address for a contract.

func ContractFromPortID

func ContractFromPortID(portID string) (sdk.AccAddress, error)

func ConvertSdkCoinToWasmCoin

func ConvertSdkCoinToWasmCoin(coin sdk.CoinAdapter) wasmvmtypes.Coin

ConvertSdkCoinToWasmCoin covert sdk type to wasmvm coin type

func ConvertSdkCoinsToWasmCoins

func ConvertSdkCoinsToWasmCoins(coins []sdk.CoinAdapter) wasmvmtypes.Coins

ConvertSdkCoinsToWasmCoins covert sdk type to wasmvm coins type

func ConvertWasmCoinToSdkCoin

func ConvertWasmCoinToSdkCoin(coin wasmvmtypes.Coin) (sdk.CoinAdapter, error)

ConvertWasmCoinToSdkCoin converts a wasm vm type coin to sdk type coin

func ConvertWasmCoinsToSdkCoins

func ConvertWasmCoinsToSdkCoins(coins []wasmvmtypes.Coin) (sdk.CoinAdapters, error)

ConvertWasmCoinsToSdkCoins converts the wasm vm type coins to sdk type coins

func ConvertWasmIBCTimeoutHeightToCosmosHeight

func ConvertWasmIBCTimeoutHeightToCosmosHeight(ibcTimeoutBlock *wasmvmtypes.IBCTimeoutBlock) ibcclienttypes.Height

ConvertWasmIBCTimeoutHeightToCosmosHeight converts a wasmvm type ibc timeout height to ibc module type height

func EncodeBankMsg

func EncodeBankMsg(sender sdk.AccAddress, msg *wasmvmtypes.BankMsg) ([]ibcadapter.Msg, error)

func EncodeIBCMsg

func EncodeIBCMsg(portSource types.ICS20TransferPortSource) func(ctx sdk.Context, sender sdk.AccAddress, contractIBCPortID string, msg *wasmvmtypes.IBCMsg) ([]ibcadapter.Msg, error)

func EncodeWasmMsg

func EncodeWasmMsg(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]ibcadapter.Msg, error)

func ExportGenesis

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

ExportGenesis returns a GenesisState for a given context and keeper.

func FuzzAbsoluteTxPosition

func FuzzAbsoluteTxPosition(m *types.AbsoluteTxPosition, c fuzz.Continue)

func FuzzAccessConfig

func FuzzAccessConfig(m *types.AccessConfig, c fuzz.Continue)

func FuzzAccessType

func FuzzAccessType(m *types.AccessType, c fuzz.Continue)

func FuzzAddr

func FuzzAddr(m *sdk.AccAddress, c fuzz.Continue)

func FuzzAddrString

func FuzzAddrString(m *string, c fuzz.Continue)

func FuzzContractCodeHistory

func FuzzContractCodeHistory(m *types.ContractCodeHistoryEntry, c fuzz.Continue)

func FuzzContractInfo

func FuzzContractInfo(m *types.ContractInfo, c fuzz.Continue)

func FuzzStateModel

func FuzzStateModel(m *types.Model, c fuzz.Continue)

func IBCQuerier

func IBCQuerier(wasm contractMetaDataSource, channelKeeper types.ChannelKeeper) func(ctx sdk.Context, caller sdk.AccAddress, request *wasmvmtypes.IBCQuery) ([]byte, error)

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState, msgHandler sdk.Handler) ([]abci.ValidatorUpdate, error)

InitGenesis sets supply information for genesis.

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

func LimitReader

func LimitReader(r io.Reader, n int64) io.Reader

LimitReader returns a Reader that reads from r but stops with types.ErrLimit after n bytes. The underlying implementation is a *io.LimitedReader.

func MakeTestCodec

func MakeTestCodec(t testing.TB) codec.CodecProxy

func NewGrpcQuerier

func NewGrpcQuerier(cdc codec.CodecProxy, storeKey sdk.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *grpcQuerier

NewGrpcQuerier constructor

func NewLegacyQuerier

func NewLegacyQuerier(keeper types.ViewKeeper, gasLimit sdk.Gas) sdk.Querier

NewLegacyQuerier creates a new querier

func NewMsgServerImpl

func NewMsgServerImpl(k types.ContractOpsKeeper) types.MsgServer

func NewWasmProposalHandler

func NewWasmProposalHandler(k decoratedKeeper, enabledProposalTypes []types.ProposalType) govtypes.Handler

NewWasmProposalHandler creates a new governance Handler for wasm proposals

func NewWasmProposalHandlerX

func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []types.ProposalType) govtypes.Handler

NewWasmProposalHandlerX creates a new governance Handler for wasm proposals

func NoCustomMsg

func NoCustomMsg(sender sdk.AccAddress, msg json.RawMessage) ([]ibcadapter.Msg, error)

func NoCustomQuerier

func NoCustomQuerier(sdk.Context, json.RawMessage) ([]byte, error)

func PortIDForContract

func PortIDForContract(addr sdk.AccAddress) string

func Querier

func Querier(k *Keeper) *grpcQuerier

Querier creates a new grpc querier instance

func RandomAccountAddress

func RandomAccountAddress(_ testing.TB) sdk.AccAddress

func RandomBech32AccountAddress

func RandomBech32AccountAddress(t testing.TB) string

func SetNeedParamsUpdate

func SetNeedParamsUpdate()

func SkipIfM1

func SkipIfM1(t *testing.T)

func StakingQuerier

func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKeeper) func(ctx sdk.Context, request *wasmvmtypes.StakingQuery) ([]byte, error)

func StargateQuerier

func StargateQuerier(queryRouter GRPCQueryRouter) func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error)

func StoreReflectContract

func StoreReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) uint64

func TestHandler

func TestHandler(k types.ContractOpsKeeper) sdk.Handler

TestHandler returns a wasm handler for tests (to avoid circular imports)

func WasmQuerier

func WasmQuerier(k wasmQueryKeeper) func(ctx sdk.Context, request *wasmvmtypes.WasmQuery) ([]byte, error)

Types

type AuthorizationPolicy

type AuthorizationPolicy interface {
	CanCreateCode(c types.AccessConfig, creator sdk.AccAddress) bool
	CanInstantiateContract(c types.AccessConfig, actor sdk.AccAddress) bool
	CanModifyContract(admin, actor sdk.AccAddress) bool
}

type BankCoinTransferrer

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

BankCoinTransferrer replicates the cosmos-sdk behaviour as in https://github.com/fanxchain/fanx/libs/cosmos-sdk/blob/v0.41.4/x/bank/keeper/msg_server.go#L26

func NewBankCoinTransferrer

func NewBankCoinTransferrer(keeper types.BankKeeper) BankCoinTransferrer

func (BankCoinTransferrer) TransferCoins

func (c BankCoinTransferrer) TransferCoins(parentCtx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amount sdk.Coins) error

TransferCoins transfers coins from source to destination account when coin send was enabled for them and the recipient is not in the blocked address list.

type BankEncoder

type BankEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.BankMsg) ([]ibcadapter.Msg, error)

type BurnerExampleInitMsg

type BurnerExampleInitMsg struct {
	Payout sdk.AccAddress `json:"payout"`
}

func (BurnerExampleInitMsg) GetBytes

func (m BurnerExampleInitMsg) GetBytes(t testing.TB) []byte

type Cache

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

func GetWasmParamsCache

func GetWasmParamsCache() *Cache

func NewCache

func NewCache() *Cache

func (*Cache) GetBlockedContractMethod

func (c *Cache) GetBlockedContractMethod(addr string) (contract *types.ContractMethods)

func (*Cache) GetParams

func (c *Cache) GetParams() types.Params

func (*Cache) IsNeedBlockedUpdate

func (c *Cache) IsNeedBlockedUpdate() bool

func (*Cache) IsNeedParamsUpdate

func (c *Cache) IsNeedParamsUpdate() bool

func (*Cache) SetNeedBlockedUpdate

func (c *Cache) SetNeedBlockedUpdate()

func (*Cache) SetNeedParamsUpdate

func (c *Cache) SetNeedParamsUpdate()

func (*Cache) UpdateBlockedContractMethod

func (c *Cache) UpdateBlockedContractMethod(cms []*types.ContractMethods)

func (*Cache) UpdateParams

func (c *Cache) UpdateParams(params types.Params)

type CoinTransferrer

type CoinTransferrer interface {
	// TransferCoins sends the coin amounts from the source to the destination with rules applied.
	TransferCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
}

type CountTXDecorator

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

CountTXDecorator ante handler to count the tx position in a block.

func NewCountTXDecorator

func NewCountTXDecorator(storeKey sdk.StoreKey) *CountTXDecorator

NewCountTXDecorator constructor

func (CountTXDecorator) AnteHandle

func (a CountTXDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle handler stores a tx counter with current height encoded in the store to let the app handle global rollback behavior instead of keeping state in the handler itself. The ante handler passes the counter value via sdk.Context upstream. See `types.TXCounter(ctx)` to read the value. Simulations don't get a tx counter value assigned.

type CustomEncoder

type CustomEncoder func(sender sdk.AccAddress, msg json.RawMessage) ([]ibcadapter.Msg, error)

type CustomQuerier

type CustomQuerier func(ctx sdk.Context, request json.RawMessage) ([]byte, error)

type DefaultAuthorizationPolicy

type DefaultAuthorizationPolicy struct{}

func (DefaultAuthorizationPolicy) CanCreateCode

func (p DefaultAuthorizationPolicy) CanCreateCode(config types.AccessConfig, actor sdk.AccAddress) bool

func (DefaultAuthorizationPolicy) CanInstantiateContract

func (p DefaultAuthorizationPolicy) CanInstantiateContract(config types.AccessConfig, actor sdk.AccAddress) bool

func (DefaultAuthorizationPolicy) CanModifyContract

func (p DefaultAuthorizationPolicy) CanModifyContract(admin, actor sdk.AccAddress) bool

type DefaultWasmVMContractResponseHandler

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

DefaultWasmVMContractResponseHandler default implementation that first dispatches submessage then normal messages. The Submessage execution may include an success/failure response handling by the contract that can overwrite the original

func NewDefaultWasmVMContractResponseHandler

func NewDefaultWasmVMContractResponseHandler(md msgDispatcher) *DefaultWasmVMContractResponseHandler

func (DefaultWasmVMContractResponseHandler) Handle

func (h DefaultWasmVMContractResponseHandler) Handle(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, messages []wasmvmtypes.SubMsg, origRspData []byte) ([]byte, error)

Handle processes the data returned by a contract invocation.

type DistributionEncoder

type DistributionEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.DistributionMsg) ([]ibcadapter.Msg, error)

type EncodingConfig

type EncodingConfig struct {
	InterfaceRegistry interfacetypes.InterfaceRegistry
	Marshaler         codec.CodecProxy
	TxConfig          client.TxConfig
	Amino             *codec.Codec
}

EncodingConfig specifies the concrete encoding types to use for a given app. This is provided for compatibility between protobuf and amino implementations.

func MakeEncodingConfig

func MakeEncodingConfig(_ testing.TB) EncodingConfig

type ExampleContract

type ExampleContract struct {
	InitialAmount sdk.Coins
	Creator       crypto.PrivKey
	CreatorAddr   sdk.AccAddress
	CodeID        uint64
}

func StoreBurnerExampleContract

func StoreBurnerExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract

func StoreExampleContract

func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract

func StoreHackatomExampleContract

func StoreHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract

func StoreIBCReflectContract

func StoreIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract

func StoreRandomContract

func StoreRandomContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContract

StoreRandomContract sets the mock wasmerEngine in keeper and calls store

func StoreRandomContractWithAccessConfig

func StoreRandomContractWithAccessConfig(
	t testing.TB, ctx sdk.Context,
	keepers TestKeepers,
	mock types.WasmerEngine,
	cfg *types.AccessConfig,
) ExampleContract

type ExampleContractInstance

type ExampleContractInstance struct {
	ExampleContract
	Contract sdk.AccAddress
}

func SeedNewContractInstance

func SeedNewContractInstance(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContractInstance

SeedNewContractInstance sets the mock wasmerEngine in keeper and calls store + instantiate to init the contract's metadata

type GRPCQueryRouter

type GRPCQueryRouter interface {
	Route(path string) baseapp.GRPCQueryHandler
}

type GasRegister

type GasRegister interface {
	// NewContractInstanceCosts costs to crate a new contract instance from code
	NewContractInstanceCosts(pinned bool, msgLen int) sdk.Gas
	// CompileCosts costs to persist and "compile" a new wasm contract
	CompileCosts(byteLength int) sdk.Gas
	// InstantiateContractCosts costs when interacting with a wasm contract
	InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas
	// ReplyCosts costs to to handle a message reply
	ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas
	// EventCosts costs to persist an event
	EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas
	// ToWasmVMGas converts from sdk gas to wasmvm gas
	ToWasmVMGas(source sdk.Gas) uint64
	// FromWasmVMGas converts from wasmvm gas to sdk gas
	FromWasmVMGas(source uint64) sdk.Gas
}

GasRegister abstract source for gas costs

type GovAuthorizationPolicy

type GovAuthorizationPolicy struct{}

func (GovAuthorizationPolicy) CanCreateCode

func (GovAuthorizationPolicy) CanInstantiateContract

func (p GovAuthorizationPolicy) CanInstantiateContract(types.AccessConfig, sdk.AccAddress) bool

func (GovAuthorizationPolicy) CanModifyContract

func (p GovAuthorizationPolicy) CanModifyContract(sdk.AccAddress, sdk.AccAddress) bool

type HackatomExampleInitMsg

type HackatomExampleInitMsg struct {
	Verifier    sdk.AccAddress `json:"verifier"`
	Beneficiary sdk.AccAddress `json:"beneficiary"`
}

func (HackatomExampleInitMsg) GetBytes

func (m HackatomExampleInitMsg) GetBytes(t testing.TB) []byte

type HackatomExampleInstance

type HackatomExampleInstance struct {
	ExampleContract
	Contract        sdk.AccAddress
	Verifier        crypto.PrivKey
	VerifierAddr    sdk.AccAddress
	Beneficiary     crypto.PrivKey
	BeneficiaryAddr sdk.AccAddress
}

func InstantiateHackatomExampleContract

func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance

InstantiateHackatomExampleContract load and instantiate the "./testdata/hackatom.wasm" contract

type HandlerOption

type HandlerOption struct {
	WasmConfig        *types.WasmConfig
	TXCounterStoreKey sdk.StoreKey
}

type IBCEncoder

type IBCEncoder func(ctx sdk.Context, sender sdk.AccAddress, contractIBCPortID string, msg *wasmvmtypes.IBCMsg) ([]ibcadapter.Msg, error)

type IBCRawPacketHandler

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

IBCRawPacketHandler handels IBC.SendPacket messages which are published to an IBC channel.

func (IBCRawPacketHandler) DispatchMsg

func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)

DispatchMsg publishes a raw IBC packet onto the channel.

type IBCReflectExampleInstance

type IBCReflectExampleInstance struct {
	Contract      sdk.AccAddress
	Admin         sdk.AccAddress
	CodeID        uint64
	ReflectCodeID uint64
}

func InstantiateIBCReflectContract

func InstantiateIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance

InstantiateIBCReflectContract load and instantiate the "./testdata/ibc_reflect.wasm" contract

type IBCReflectInitMsg

type IBCReflectInitMsg struct {
	ReflectCodeID uint64 `json:"reflect_code_id"`
}

func (IBCReflectInitMsg) GetBytes

func (m IBCReflectInitMsg) GetBytes(t testing.TB) []byte

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.CodecProxy,
	storeKey sdk.StoreKey,
	paramSpace paramtypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,

	channelKeeper types.ChannelKeeper,
	portKeeper types.PortKeeper,
	capabilityKeeper types.CapabilityKeeper,
	portSource types.ICS20TransferPortSource,
	router MessageRouter,
	queryRouter GRPCQueryRouter,
	homeDir string,
	wasmConfig types.WasmConfig,
	supportedFeatures string,
	opts ...Option,
) 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 NewSimulateKeeper

func NewSimulateKeeper(
	cdc *codec.CodecProxy,
	storeKey sdk.StoreKey,
	paramSpace types.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	channelKeeper types.ChannelKeeper,
	portKeeper types.PortKeeper,
	capabilityKeeper types.CapabilityKeeper,
	portSource types.ICS20TransferPortSource,
	router MessageRouter,
	queryRouter GRPCQueryRouter,
	homeDir string,
	wasmConfig types.WasmConfig,
	supportedFeatures string,
	opts ...Option,
) Keeper

func (Keeper) AuthenticateCapability

func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool

AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function

func (Keeper) ClaimCapability

func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error

ClaimCapability allows the transfer module to claim a capability that IBC module passes to it

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) GetContractHistory

func (k Keeper) GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) []types.ContractCodeHistoryEntry

func (Keeper) GetContractInfo

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

func (Keeper) GetContractMethodBlockedList

func (k Keeper) GetContractMethodBlockedList(ctx sdk.Context, contractAddr string) *types.ContractMethods

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

GetParams returns the total set of wasm parameters.

func (Keeper) GetStoreKey

func (k Keeper) GetStoreKey() sdk.StoreKey

func (Keeper) HasContractInfo

func (k Keeper) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool

func (Keeper) InitializePinnedCodes

func (k Keeper) InitializePinnedCodes(ctx sdk.Context) error

InitializePinnedCodes updates wasmvm to pin to cache all contracts marked as pinned

func (Keeper) IsContractMethodBlocked

func (k Keeper) IsContractMethodBlocked(ctx sdk.Context, contractAddr, method string) bool

func (Keeper) IsPinnedCode

func (k Keeper) IsPinnedCode(ctx sdk.Context, codeID uint64) bool

IsPinnedCode returns true when codeID is pinned in wasmvm cache

func (Keeper) IterateCodeInfos

func (k Keeper) IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo) bool)

func (Keeper) IterateContractInfo

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

func (Keeper) IterateContractState

func (k Keeper) IterateContractState(ctx sdk.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool)

IterateContractState iterates through all elements of the key value store for the given contract address and passes them to the provided callback function. The callback method can return true to abort early.

func (Keeper) IterateContractsByCode

func (k Keeper) IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(address sdk.AccAddress) bool)

IterateContractsByCode iterates over all contracts with given codeID ASC on code update time.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) OnAccountUpdated

func (k Keeper) OnAccountUpdated(acc exported.Account)

func (Keeper) OnAckPacket

func (k Keeper) OnAckPacket(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCPacketAckMsg,
) error

OnAckPacket calls the contract to handle the "acknowledgement" data which can contain success or failure of a packet acknowledgement written on the receiving chain for example. This is application level data and fully owned by the contract. The use of the standard acknowledgement envelope is recommended: https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope

On application errors the contract can revert an operation like returning tokens as in ibc-transfer.

For more information see: https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#packet-flow--handling

func (Keeper) OnCloseChannel

func (k Keeper) OnCloseChannel(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCChannelCloseMsg,
) error

OnCloseChannel calls the contract to let it know the IBC channel is closed. Calling modules MAY atomically execute appropriate application logic in conjunction with calling chanCloseConfirm.

Once closed, channels cannot be reopened and identifiers cannot be reused. Identifier reuse is prevented because we want to prevent potential replay of previously sent packets See https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#channel-lifecycle-management

func (Keeper) OnConnectChannel

func (k Keeper) OnConnectChannel(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCChannelConnectMsg,
) error

OnConnectChannel calls the contract to let it know the IBC channel was established. In the IBC protocol this is either the `Channel Open Ack` event on the initiating chain or `Channel Open Confirm` on the counterparty chain.

There is an open issue with the [cosmos-sdk](https://github.com/fanxchain/fanx/libs/cosmos-sdk/issues/8334) that the counterparty channelID is empty on the initiating chain See https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#channel-lifecycle-management

func (Keeper) OnOpenChannel

func (k Keeper) OnOpenChannel(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCChannelOpenMsg,
) (string, error)

OnOpenChannel calls the contract to participate in the IBC channel handshake step. In the IBC protocol this is either the `Channel Open Init` event on the initiating chain or `Channel Open Try` on the counterparty chain. Protocol version and channel ordering should be verified for example. See https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#channel-lifecycle-management

func (Keeper) OnRecvPacket

func (k Keeper) OnRecvPacket(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCPacketReceiveMsg,
) ([]byte, error)

OnRecvPacket calls the contract to process the incoming IBC packet. The contract fully owns the data processing and returns the acknowledgement data for the chain level. This allows custom applications and protocols on top of IBC. Although it is recommended to use the standard acknowledgement envelope defined in https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope

For more information see: https://github.com/fanxchain/fanx/libs/ics/tree/master/spec/ics-004-channel-and-packet-semantics#packet-flow--handling

func (Keeper) OnTimeoutPacket

func (k Keeper) OnTimeoutPacket(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCPacketTimeoutMsg,
) error

OnTimeoutPacket calls the contract to let it know the packet was never received on the destination chain within the timeout boundaries. The contract should handle this on the application level and undo the original operation

func (Keeper) PeekAutoIncrementID

func (k Keeper) PeekAutoIncrementID(ctx sdk.Context, lastIDKey []byte) uint64

PeekAutoIncrementID reads the current value without incrementing it.

func (Keeper) QueryGasLimit

func (k Keeper) QueryGasLimit() sdk.Gas

QueryGasLimit returns the gas limit for smart queries.

func (Keeper) QueryRaw

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

QueryRaw returns the contract's state for give key. Returns `nil` when key is `nil`.

func (Keeper) QuerySmart

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

QuerySmart queries the smart contract itself.

func (*Keeper) SetInnerTxKeeper

func (k *Keeper) SetInnerTxKeeper(innertxKeeper innertx.InnerTxKeeper)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, ps types.Params)

func (Keeper) Sudo

func (k Keeper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error)

Sudo allows priviledged access to a contract. This can never be called by an external tx, but only by another native Go module directly, or on-chain governance (if sudo proposals are enabled). Thus, the keeper doesn't place any access controls on it, that is the responsibility or the app developer (who passes the wasm.Keeper in app.go)

type LimitSimulationGasDecorator

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

LimitSimulationGasDecorator ante decorator to limit gas in simulation calls

func NewLimitSimulationGasDecorator

func NewLimitSimulationGasDecorator(gasLimit *sdk.Gas) *LimitSimulationGasDecorator

NewLimitSimulationGasDecorator constructor accepts nil value to fallback to block gas limit.

func (LimitSimulationGasDecorator) AnteHandle

func (d LimitSimulationGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle that limits the maximum gas available in simulations only. A custom max value can be configured and will be applied when set. The value should not exceed the max block gas limit. Different values on nodes are not consensus breaking as they affect only simulations but may have effect on client user experience.

When no custom value is set then the max block gas is used as default limit.

type LimitedReader

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

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

type MessageDispatcher

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

MessageDispatcher coordinates message sending and submessage reply/ state commits

func NewMessageDispatcher

func NewMessageDispatcher(messenger Messenger, keeper replyer) *MessageDispatcher

NewMessageDispatcher constructor

func (MessageDispatcher) DispatchMessages

func (d MessageDispatcher) DispatchMessages(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, msgs []wasmvmtypes.CosmosMsg) error

DispatchMessages sends all messages.

func (MessageDispatcher) DispatchSubmessages

func (d MessageDispatcher) DispatchSubmessages(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, msgs []wasmvmtypes.SubMsg) ([]byte, error)

DispatchSubmessages builds a sandbox to execute these messages and returns the execution result to the contract that dispatched them, both on success as well as failure

type MessageEncoders

type MessageEncoders struct {
	Bank   func(sender sdk.AccAddress, msg *wasmvmtypes.BankMsg) ([]ibcadapter.Msg, error)
	Custom func(sender sdk.AccAddress, msg json.RawMessage) ([]ibcadapter.Msg, error)
	//Distribution func(sender sdk.AccAddress, msg *wasmvmtypes.DistributionMsg) ([]sdk.Msg, error)
	//IBC          func(ctx sdk.Context, sender sdk.AccAddress, contractIBCPortID string, msg *wasmvmtypes.IBCMsg) ([]sdk.Msg, error)
	//Staking      func(sender sdk.AccAddress, msg *wasmvmtypes.StakingMsg) ([]sdk.Msg, error)
	Stargate func(sender sdk.AccAddress, msg *wasmvmtypes.StargateMsg) ([]ibcadapter.Msg, error)
	Wasm     func(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]ibcadapter.Msg, error)
}

func DefaultEncoders

func DefaultEncoders(unpacker codectypes.AnyUnpacker, portSource types.ICS20TransferPortSource) MessageEncoders

func (MessageEncoders) Encode

func (e MessageEncoders) Encode(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) ([]ibcadapter.Msg, error)

func (MessageEncoders) Merge

type MessageHandlerChain

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

MessageHandlerChain defines a chain of handlers that are called one by one until it can be handled.

func NewMessageHandlerChain

func NewMessageHandlerChain(first Messenger, others ...Messenger) *MessageHandlerChain

func (MessageHandlerChain) DispatchMsg

func (m MessageHandlerChain) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) ([]sdk.Event, [][]byte, error)

DispatchMsg dispatch message and calls chained handlers one after another in order to find the right one to process given message. If a handler cannot process given message (returns ErrUnknownMsg), its result is ignored and the next handler is executed.

type MessageHandlerFunc

type MessageHandlerFunc func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)

MessageHandlerFunc is a helper to construct a function based message handler.

func (MessageHandlerFunc) DispatchMsg

func (m MessageHandlerFunc) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)

DispatchMsg delegates dispatching of provided message into the MessageHandlerFunc.

type MessageRouter

type MessageRouter interface {
	Handler(methodName string) baseapp.MsgServiceHandler
}

MessageRouter ADR 031 request type routing

type Messenger

type Messenger interface {
	// DispatchMsg encodes the wasmVM message and dispatches it.
	DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)
}

Messenger is an extension point for custom wasmd message handling

func NewDefaultMessageHandler

func NewDefaultMessageHandler(
	router MessageRouter,
	channelKeeper types.ChannelKeeper,
	capabilityKeeper types.CapabilityKeeper,

	unpacker codectypes.AnyUnpacker,
	portSource types.ICS20TransferPortSource,
	customEncoders ...*MessageEncoders,
) Messenger

type MultipliedGasMeter

type MultipliedGasMeter struct {
	GasRegister GasRegister
	// contains filtered or unexported fields
}

MultipliedGasMeter wraps the GasMeter from context and multiplies all reads by out defined multiplier

func NewMultipliedGasMeter

func NewMultipliedGasMeter(originalMeter sdk.GasMeter, gr GasRegister) MultipliedGasMeter

func (MultipliedGasMeter) GasConsumed

func (m MultipliedGasMeter) GasConsumed() sdk.Gas

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an extension point to instantiate keeper with non default values

func WithAPICosts

func WithAPICosts(human, canonical uint64) Option

WithAPICosts sets custom api costs. Amounts are in cosmwasm gas Not SDK gas.

func WithCoinTransferrer

func WithCoinTransferrer(x CoinTransferrer) Option

WithCoinTransferrer is an optional constructor parameter to set a custom coin transferrer

func WithGasRegister

func WithGasRegister(x GasRegister) Option

WithGasRegister set a new gas register to implement custom gas costs. When the "gas multiplier" for wasmvm gas conversion is modified inside the new register, make sure to also use `WithApiCosts` option for non default values

func WithMaxQueryStackSize

func WithMaxQueryStackSize(m uint32) Option

WithMaxQueryStackSize overwrites the default limit for maximum query stacks

func WithMessageEncoders

func WithMessageEncoders(x *MessageEncoders) Option

WithMessageEncoders is an optional constructor parameter to pass custom message encoder to the default wasm message handler. This option expects the `DefaultMessageHandler` set and should not be combined with Option `WithMessageHandler` or `WithMessageHandlerDecorator`.

func WithMessageHandler

func WithMessageHandler(x Messenger) Option

WithMessageHandler is an optional constructor parameter to set a custom handler for wasmVM messages. This option should not be combined with Option `WithMessageEncoders` or `WithMessageHandlerDecorator`

func WithMessageHandlerDecorator

func WithMessageHandlerDecorator(d func(old Messenger) Messenger) Option

WithMessageHandlerDecorator is an optional constructor parameter to decorate the wasm handler for wasmVM messages. This option should not be combined with Option `WithMessageEncoders` or `WithMessageHandler`

func WithQueryHandler

func WithQueryHandler(x WasmVMQueryHandler) Option

WithQueryHandler is an optional constructor parameter to set custom query handler for wasmVM requests. This option should not be combined with Option `WithQueryPlugins` or `WithQueryHandlerDecorator`

func WithQueryHandlerDecorator

func WithQueryHandlerDecorator(d func(old WasmVMQueryHandler) WasmVMQueryHandler) Option

WithQueryHandlerDecorator is an optional constructor parameter to decorate the default wasm query handler for wasmVM requests. This option should not be combined with Option `WithQueryPlugins` or `WithQueryHandler`

func WithQueryPlugins

func WithQueryPlugins(x *QueryPlugins) Option

WithQueryPlugins is an optional constructor parameter to pass custom query plugins for wasmVM requests. This option expects the default `QueryHandler` set an should not be combined with Option `WithQueryHandler` or `WithQueryHandlerDecorator`.

func WithVMCacheMetrics

func WithVMCacheMetrics(r prometheus.Registerer) Option

func WithWasmEngine

func WithWasmEngine(x types.WasmerEngine) Option

WithWasmEngine is an optional constructor parameter to replace the default wasmVM engine with the given one.

type PermissionedKeeper

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

func NewDefaultPermissionKeeper

func NewDefaultPermissionKeeper(nested decoratedKeeper) *PermissionedKeeper

func NewGovPermissionKeeper

func NewGovPermissionKeeper(nested decoratedKeeper) *PermissionedKeeper

func NewPermissionedKeeper

func NewPermissionedKeeper(nested decoratedKeeper, authZPolicy AuthorizationPolicy) *PermissionedKeeper

func (PermissionedKeeper) ClearContractAdmin

func (p PermissionedKeeper) ClearContractAdmin(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress) error

func (PermissionedKeeper) Create

func (p PermissionedKeeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig) (codeID uint64, err error)

func (PermissionedKeeper) Execute

func (p PermissionedKeeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error)

func (PermissionedKeeper) GetParams

func (p PermissionedKeeper) GetParams(ctx sdk.Context) types.Params

func (PermissionedKeeper) Instantiate

func (p PermissionedKeeper) Instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins) (sdk.AccAddress, []byte, error)

func (PermissionedKeeper) Migrate

func (p PermissionedKeeper) Migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, newCodeID uint64, msg []byte) ([]byte, error)

func (PermissionedKeeper) PinCode

func (p PermissionedKeeper) PinCode(ctx sdk.Context, codeID uint64) error

func (PermissionedKeeper) SetAccessConfig

func (p PermissionedKeeper) SetAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error

SetAccessConfig updates the access config of a code id.

func (PermissionedKeeper) SetContractInfoExtension

func (p PermissionedKeeper) SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error

SetExtraContractAttributes updates the extra attributes that can be stored with the contract info

func (PermissionedKeeper) Sudo

func (p PermissionedKeeper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error)

func (PermissionedKeeper) UnpinCode

func (p PermissionedKeeper) UnpinCode(ctx sdk.Context, codeID uint64) error

func (PermissionedKeeper) UpdateContractAdmin

func (p PermissionedKeeper) UpdateContractAdmin(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, newAdmin sdk.AccAddress) error

func (PermissionedKeeper) UpdateContractMethodBlockedList

func (p PermissionedKeeper) UpdateContractMethodBlockedList(ctx sdk.Context, blockedMethods *types.ContractMethods, isDelete bool) error

func (PermissionedKeeper) UpdateUploadAccessConfig

func (p PermissionedKeeper) UpdateUploadAccessConfig(ctx sdk.Context, config types.AccessConfig)

type QueryHandler

type QueryHandler struct {
	Ctx     sdk.Context
	Plugins WasmVMQueryHandler
	Caller  sdk.AccAddress
	// contains filtered or unexported fields
}

func NewQueryHandler

func NewQueryHandler(ctx sdk.Context, vmQueryHandler WasmVMQueryHandler, caller sdk.AccAddress, gasRegister GasRegister) QueryHandler

func (QueryHandler) GasConsumed

func (q QueryHandler) GasConsumed() uint64

func (QueryHandler) Query

func (q QueryHandler) Query(request wasmvmtypes.QueryRequest, gasLimit uint64) ([]byte, error)

type QueryPlugins

type QueryPlugins struct {
	Bank   func(ctx sdk.Context, request *wasmvmtypes.BankQuery) ([]byte, error)
	Custom CustomQuerier
	//IBC      func(ctx sdk.Context, caller sdk.AccAddress, request *wasmvmtypes.IBCQuery) ([]byte, error)
	//Staking  func(ctx sdk.Context, request *wasmvmtypes.StakingQuery) ([]byte, error)
	Stargate func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error)
	Wasm     func(ctx sdk.Context, request *wasmvmtypes.WasmQuery) ([]byte, error)
}

func DefaultQueryPlugins

func DefaultQueryPlugins(
	bank types.BankViewKeeper,

	channelKeeper types.ChannelKeeper,
	queryRouter GRPCQueryRouter,
	wasm wasmQueryKeeper,
) QueryPlugins

func (QueryPlugins) HandleQuery

func (e QueryPlugins) HandleQuery(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error)

HandleQuery executes the requested query

func (QueryPlugins) Merge

type SDKMessageHandler

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

SDKMessageHandler can handles messages that can be encoded into sdk.Message types and routed.

func NewSDKMessageHandler

func NewSDKMessageHandler(router MessageRouter, encoders msgEncoder) SDKMessageHandler

func (SDKMessageHandler) DispatchMsg

func (h SDKMessageHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)

type StakingEncoder

type StakingEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.StakingMsg) ([]ibcadapter.Msg, error)

type StargateEncoder

type StargateEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.StargateMsg) ([]ibcadapter.Msg, error)

func EncodeStargateMsg

func EncodeStargateMsg(unpacker codectypes.AnyUnpacker) StargateEncoder

type TestFaucet

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

func NewTestFaucet

func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bank.Keeper, supplyKeeper supply.Keeper, minterModuleName string, initialAmount ...sdk.Coin) *TestFaucet

func (*TestFaucet) Fund

func (f *TestFaucet) Fund(parentCtx sdk.Context, receiver sdk.AccAddress, amounts ...sdk.Coin)

func (*TestFaucet) Mint

func (f *TestFaucet) Mint(parentCtx sdk.Context, addr sdk.AccAddress, amounts ...sdk.Coin)

func (*TestFaucet) NewFundedAccount

func (f *TestFaucet) NewFundedAccount(ctx sdk.Context, amounts ...sdk.Coin) sdk.AccAddress

type TestKeepers

type TestKeepers struct {
	AccountKeeper authkeeper.AccountKeeper

	StakingKeeper  stakingkeeper.Keeper
	DistKeeper     distributionkeeper.Keeper
	BankKeeper     bank.Keeper
	GovKeeper      govkeeper.Keeper
	ContractKeeper types.ContractOpsKeeper
	WasmKeeper     *Keeper
	IBCKeeper      *ibckeeper.Keeper
	Router         *baseapp.Router
	EncodingConfig EncodingConfig
	Faucet         *TestFaucet
	MultiStore     sdk.CommitMultiStore
	// contains filtered or unexported fields
}

func CreateDefaultTestInput

func CreateDefaultTestInput(t testing.TB) (sdk.Context, TestKeepers)

CreateDefaultTestInput common settings for CreateTestInput

func CreateTestInput

func CreateTestInput(t testing.TB, isCheckTx bool, supportedFeatures string, opts ...Option) (sdk.Context, TestKeepers)

CreateTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default)

type ValidatorSetSource

type ValidatorSetSource interface {
	ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate, err error)
}

ValidatorSetSource is a subset of the staking keeper

type WasmEncoder

type WasmEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]ibcadapter.Msg, error)

type WasmGasRegister

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

WasmGasRegister implements GasRegister interface

func NewDefaultWasmGasRegister

func NewDefaultWasmGasRegister() WasmGasRegister

NewDefaultWasmGasRegister creates instance with default values

func NewWasmGasRegister

func NewWasmGasRegister(c WasmGasRegisterConfig) WasmGasRegister

NewWasmGasRegister constructor

func (WasmGasRegister) CompileCosts

func (g WasmGasRegister) CompileCosts(byteLength int) storetypes.Gas

CompileCosts costs to persist and "compile" a new wasm contract

func (WasmGasRegister) EventCosts

func (g WasmGasRegister) EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas

EventCosts costs to persist an event

func (WasmGasRegister) FromWasmVMGas

func (g WasmGasRegister) FromWasmVMGas(source uint64) sdk.Gas

FromWasmVMGas converts to SDK gas unit

func (WasmGasRegister) InstantiateContractCosts

func (g WasmGasRegister) InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas

InstantiateContractCosts costs when interacting with a wasm contract

func (WasmGasRegister) NewContractInstanceCosts

func (g WasmGasRegister) NewContractInstanceCosts(pinned bool, msgLen int) storetypes.Gas

NewContractInstanceCosts costs to crate a new contract instance from code

func (WasmGasRegister) ReplyCosts

func (g WasmGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas

ReplyCosts costs to to handle a message reply

func (WasmGasRegister) ToWasmVMGas

func (g WasmGasRegister) ToWasmVMGas(source storetypes.Gas) uint64

ToWasmVMGas convert to wasmVM contract runtime gas unit

type WasmGasRegisterConfig

type WasmGasRegisterConfig struct {
	// InstanceCost costs when interacting with a wasm contract
	InstanceCost sdk.Gas
	// CompileCosts costs to persist and "compile" a new wasm contract
	CompileCost sdk.Gas
	// GasMultiplier is how many cosmwasm gas points = 1 sdk gas point
	// SDK reference costs can be found here: https://github.com/fanxchain/fanx/libs/cosmos-sdk/blob/02c6c9fafd58da88550ab4d7d494724a477c8a68/store/types/gas.go#L153-L164
	GasMultiplier sdk.Gas
	// EventPerAttributeCost is how much SDK gas is charged *per byte* for attribute data in events.
	// This is used with len(key) + len(value)
	EventPerAttributeCost sdk.Gas
	// EventAttributeDataCost is how much SDK gas is charged *per byte* for attribute data in events.
	// This is used with len(key) + len(value)
	EventAttributeDataCost sdk.Gas
	// EventAttributeDataFreeTier number of bytes of total attribute data that is free of charge
	EventAttributeDataFreeTier uint64
	// ContractMessageDataCost SDK gas charged *per byte* of the message that goes to the contract
	// This is used with len(msg)
	ContractMessageDataCost sdk.Gas
	// CustomEventCost cost per custom event
	CustomEventCost uint64
}

WasmGasRegisterConfig config type

func DefaultGasRegisterConfig

func DefaultGasRegisterConfig() WasmGasRegisterConfig

DefaultGasRegisterConfig default values

type WasmVMMetricsCollector

type WasmVMMetricsCollector struct {
	CacheHitsDescr     *prometheus.Desc
	CacheMissesDescr   *prometheus.Desc
	CacheElementsDescr *prometheus.Desc
	CacheSizeDescr     *prometheus.Desc
	// contains filtered or unexported fields
}

WasmVMMetricsCollector custom metrics collector to be used with Prometheus

func NewWasmVMMetricsCollector

func NewWasmVMMetricsCollector(s metricSource) *WasmVMMetricsCollector

NewWasmVMMetricsCollector constructor

func (*WasmVMMetricsCollector) Collect

func (p *WasmVMMetricsCollector) Collect(c chan<- prometheus.Metric)

Collect is called by the Prometheus registry when collecting metrics.

func (*WasmVMMetricsCollector) Describe

func (p *WasmVMMetricsCollector) Describe(descs chan<- *prometheus.Desc)

Describe sends the super-set of all possible descriptors of metrics

func (*WasmVMMetricsCollector) Register

Register registers all metrics

type WasmVMQueryHandler

type WasmVMQueryHandler interface {
	// HandleQuery executes the requested query
	HandleQuery(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error)
}

WasmVMQueryHandler is an extension point for custom query handler implementations

type WasmVMQueryHandlerFn

type WasmVMQueryHandlerFn func(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error)

WasmVMQueryHandlerFn is a helper to construct a function based query handler.

func (WasmVMQueryHandlerFn) HandleQuery

func (w WasmVMQueryHandlerFn) HandleQuery(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error)

HandleQuery delegates call into wrapped WasmVMQueryHandlerFn

type WasmVMResponseHandler

type WasmVMResponseHandler interface {
	// Handle processes the data returned by a contract invocation.
	Handle(
		ctx sdk.Context,
		contractAddr sdk.AccAddress,
		ibcPort string,
		messages []wasmvmtypes.SubMsg,
		origRspData []byte,
	) ([]byte, error)
}

WasmVMResponseHandler is an extension point to handles the response data returned by a contract call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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