keeper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 112 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultGasCostHumanAddress is how much SDK gas we charge to convert to a human address format
	DefaultGasCostHumanAddress = 5
	// DefaultGasCostCanonicalAddress is how much SDK gas we charge to convert to a canonical address format
	DefaultGasCostCanonicalAddress = 4
	// DefaultGasCostValidateAddress is how much SDK gas we charge to validate an address
	DefaultGasCostValidateAddress = DefaultGasCostHumanAddress + DefaultGasCostCanonicalAddress

	// DefaultDeserializationCostPerByte The formula should be `len(data) * deserializationCostPerByte`
	DefaultDeserializationCostPerByte = 1
)
View Source
const DefaultGasCostBuildAddress = 10

DefaultGasCostBuildAddress is the SDK gas cost to build a contract address

View Source
const SnapshotFormat = 1

SnapshotFormat format 1 is just gzipped wasm byte code for each item payload. No protobuf envelope, no metadata.

Variables

View Source
var TestingStakeParams = stakingtypes.Params{
	UnbondingTime:     100,
	MaxValidators:     10,
	MaxEntries:        10,
	HistoricalEntries: 10,
	BondDenom:         "stake",
	MinCommissionRate: stakingtypes.DefaultMinCommissionRate,
}

Functions

func AcceptListGrpcQuerier

func AcceptListGrpcQuerier(acceptList AcceptedQueries, queryRouter GRPCQueryRouter, codec codec.Codec) func(ctx sdk.Context,
	request *wasmvmtypes.GrpcQuery) (proto.Message, error)

AcceptListGrpcQuerier supports a preconfigured set of gRPC queries only. All arguments must be non nil.

Warning: Chains need to test and maintain their accept list carefully. There were critical consensus breaking issues in the past with non-deterministic behavior in the SDK.

These queries can be set via WithQueryPlugins option in the wasm keeper constructor: WithQueryPlugins(&QueryPlugins{Grpc: AcceptListGrpcQuerier(acceptList, queryRouter, codec)})

func AcceptListStargateQuerier

func AcceptListStargateQuerier(acceptList AcceptedQueries, queryRouter GRPCQueryRouter, codec codec.Codec) func(ctx sdk.Context,
	request *wasmvmtypes.StargateQuery) ([]byte, error)

AcceptListStargateQuerier supports a preconfigured set of stargate queries only. All arguments must be non nil.

Warning: Chains need to test and maintain their accept list carefully. There were critical consensus breaking issues in the past with non-deterministic behavior in the SDK.

These queries can be set via WithQueryPlugins option in the wasm keeper constructor: WithQueryPlugins(&QueryPlugins{Stargate: AcceptListStargateQuerier(acceptList, queryRouter, codec)})

func BankQuerier

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

func BuildContractAddressClassic

func BuildContractAddressClassic(codeID, instanceID uint64) sdk.AccAddress

BuildContractAddressClassic builds an address for a contract.

func BuildContractAddressPredictable

func BuildContractAddressPredictable(checksum []byte, creator sdk.AccAddress,
	salt, initMsg types.RawContractMessage) sdk.AccAddress

BuildContractAddressPredictable generates a contract address for the wasm module with len = types.ContractAddrLen using the Cosmos SDK address.Module function. Internally a key is built containing: (len(checksum) | checksum | len(sender_address) | sender_address | len(salt) | salt| len(initMsg) | initMsg).

All method parameter values must be valid and not nil.

func BuiltInCapabilities

func BuiltInCapabilities() []string

BuiltInCapabilities returns all capabilities currently supported by this version of x/wasm. See also https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES-BUILT-IN.md.

Use this directly or together with your chain's custom capabilities (if any):

append(wasmkeeper.BuiltInCapabilities(), "token_factory")

func ContractFromPortID

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

func ConvertProtoToJSONMarshal

func ConvertProtoToJSONMarshal(cdc codec.Codec, protoResponse proto.Message, bz []byte) ([]byte, error)

ConvertProtoToJSONMarshal unmarshals the given bytes into a proto message and then marshals it to json. This is done so that clients calling stargate queries do not need to define their own proto unmarshalers, being able to use response directly by json marshaling, which is supported in cosmwasm.

func ConvertSDKDecCoinsToWasmDecCoins

func ConvertSDKDecCoinsToWasmDecCoins(src sdk.DecCoins) []wasmvmtypes.DecCoin

ConvertSDKDecCoinsToWasmDecCoins convert sdk to wasmvm type

func ConvertSDKDelegatorRewardsToWasmRewards

func ConvertSDKDelegatorRewardsToWasmRewards(rewards []distributiontypes.DelegationDelegatorReward) []wasmvmtypes.DelegatorReward

ConvertSDKDelegatorRewardsToWasmRewards convert sdk to wasmvm type

func ConvertSdkCoinToWasmCoin

func ConvertSdkCoinToWasmCoin(coin sdk.Coin) wasmvmtypes.Coin

ConvertSdkCoinToWasmCoin covert sdk type to wasmvm coin type

func ConvertSdkCoinsToWasmCoins

func ConvertSdkCoinsToWasmCoins(coins []sdk.Coin) wasmvmtypes.Array[wasmvmtypes.Coin]

ConvertSdkCoinsToWasmCoins covert sdk type to wasmvm coins type

func ConvertSdkDenomMetadataToWasmDenomMetadata

func ConvertSdkDenomMetadataToWasmDenomMetadata(metadata banktypes.Metadata) wasmvmtypes.DenomMetadata

func ConvertSdkDenomMetadatasToWasmDenomMetadatas

func ConvertSdkDenomMetadatasToWasmDenomMetadatas(metadata []banktypes.Metadata) []wasmvmtypes.DenomMetadata

func ConvertSdkDenomUnitsToWasmDenomUnits

func ConvertSdkDenomUnitsToWasmDenomUnits(denomUnits []*banktypes.DenomUnit) []wasmvmtypes.DenomUnit

func ConvertWasmCoinToSdkCoin

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

ConvertWasmCoinToSdkCoin converts a wasm vm type coin to sdk type coin

func ConvertWasmCoinsToSdkCoins

func ConvertWasmCoinsToSdkCoins(coins []wasmvmtypes.Coin) (sdk.Coins, 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 DeterministicAccountAddress

func DeterministicAccountAddress(_ testing.TB, v byte) sdk.AccAddress

DeterministicAccountAddress creates a test address with v repeated to valid address size

func DistributionQuerier

func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, request *wasmvmtypes.DistributionQuery) ([]byte,
	error)

func EncodeBankMsg

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

func EncodeDistributionMsg

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

func EncodeGovMsg

func EncodeGovMsg(sender sdk.AccAddress, msg *wasmvmtypes.GovMsg) ([]sdk.Msg, error)

func EncodeIBCMsg

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

func EncodeStakingMsg

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

func EncodeWasmMsg

func EncodeWasmMsg(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]sdk.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) ([]abci.ValidatorUpdate, error)

InitGenesis sets supply information for genesis.

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

func MakeTestCodec

func MakeTestCodec(t testing.TB) codec.Codec

func NewGovAuthorizationPolicy

func NewGovAuthorizationPolicy(actions ...types.AuthorizationPolicyAction) types.AuthorizationPolicy

NewGovAuthorizationPolicy public constructor

func NewLegacyWasmProposalHandler deprecated

func NewLegacyWasmProposalHandler(k decoratedKeeper, enabledProposalTypes []types.ProposalType) v1beta1.Handler

NewLegacyWasmProposalHandler creates a new governance Handler for wasm proposals

Deprecated: Do not use v1beta1 handlers anymore. Gov v1 is the way to go

func NewLegacyWasmProposalHandlerX deprecated

func NewLegacyWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []types.ProposalType) v1beta1.Handler

NewLegacyWasmProposalHandlerX creates a new governance Handler for wasm proposals

Deprecated: Do not use v1beta1 handlers anymore. Gov v1 is the way to go

func NewMsgServerImpl

func NewMsgServerImpl(k *Keeper) types.MsgServer

NewMsgServerImpl default constructor

func NoCustomMsg

func NoCustomMsg(_ sdk.AccAddress, _ json.RawMessage) ([]sdk.Msg, error)

func NoCustomQuerier

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

func PortIDForContract

func PortIDForContract(addr sdk.AccAddress) string

func RandomAccountAddress

func RandomAccountAddress(_ testing.TB) sdk.AccAddress

func RandomBech32AccountAddress

func RandomBech32AccountAddress(t testing.TB) string

func RejectGrpcQuerier

func RejectGrpcQuerier(ctx sdk.Context, request *wasmvmtypes.GrpcQuery) (proto.Message, error)

func RejectStargateQuerier

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

RejectStargateQuerier rejects all stargate queries

func StakingQuerier

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

func UInt64LengthPrefix

func UInt64LengthPrefix(bz []byte) []byte

UInt64LengthPrefix prepend big endian encoded byte length

func WasmQuerier

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

Types

type AcceptedQueries

type AcceptedQueries map[string]proto.Message

AcceptedQueries define accepted Stargate or gRPC queries as a map with path as key and response type as value. For example: acceptList["/cosmos.auth.v1beta1.Query/Account"]= &authtypes.QueryAccountResponse{}

type AccountPruner

type AccountPruner interface {
	// CleanupExistingAccount handles the cleanup process for balances and data of the given account. The persisted account
	// type is already reset to base account at this stage.
	// The method returns true when the account address can be reused. Unsupported account types are rejected by returning false
	CleanupExistingAccount(ctx sdk.Context, existingAccount sdk.AccountI) (handled bool, err error)
}

AccountPruner handles the balances and data cleanup for accounts that are pruned on contract instantiate. This is an extension point to attach custom logic

type AddressGenerator

type AddressGenerator func(ctx context.Context, codeID uint64, checksum []byte) sdk.AccAddress

AddressGenerator abstract address generator to be used for a single contract address

func PredictableAddressGenerator

func PredictableAddressGenerator(creator sdk.AccAddress, salt, msg []byte, fixMsg bool) AddressGenerator

PredictableAddressGenerator generates a predictable contract address

type AnyEncoder

type AnyEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.AnyMsg) ([]sdk.Msg, error)

func EncodeAnyMsg

func EncodeAnyMsg(unpacker codectypes.AnyUnpacker) AnyEncoder

type BankCoinTransferrer

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

BankCoinTransferrer replicates the cosmos-sdk behavior as in https://github.com/cosmos/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, 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) ([]sdk.Msg, error)

type BurnerExampleInitMsg

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

func (BurnerExampleInitMsg) GetBytes

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

type CoinTransferrer

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

type ContractConfirmStateAck

type ContractConfirmStateAck []byte

func (ContractConfirmStateAck) Acknowledgement

func (w ContractConfirmStateAck) Acknowledgement() []byte

func (ContractConfirmStateAck) Success

func (w ContractConfirmStateAck) Success() bool

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(s corestoretypes.KVStoreService) *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) ([]sdk.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(chainConfigs types.ChainAccessConfigs, actor sdk.AccAddress,
	contractConfig types.AccessConfig) bool

func (DefaultAuthorizationPolicy) CanInstantiateContract

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

func (DefaultAuthorizationPolicy) CanModifyCodeAccessConfig

func (p DefaultAuthorizationPolicy) CanModifyCodeAccessConfig(creator, actor sdk.AccAddress, isSubset bool) bool

func (DefaultAuthorizationPolicy) CanModifyContract

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

func (DefaultAuthorizationPolicy) SubMessageAuthorizationPolicy

SubMessageAuthorizationPolicy always returns the default policy

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) ([]sdk.Msg, error)

type ExampleContract

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

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 StoreExampleContractWasm

func StoreExampleContractWasm(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmCode []byte) 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.WasmEngine) ExampleContract

StoreRandomContract sets the mock WasmEngine in keeper and calls store

func StoreRandomContractWithAccessConfig

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

func StoreReflectContract

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

type ExampleContractInstance

type ExampleContractInstance struct {
	ExampleContract
	Contract sdk.AccAddress
}

func SeedNewContractInstance

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

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

type ExampleInstance

type ExampleInstance struct {
	ExampleContract
	Contract sdk.AccAddress
	Label    string
	Deposit  sdk.Coins
}

func InstantiateReflectExampleContract

func InstantiateReflectExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleInstance

InstantiateReflectExampleContract load and instantiate the "./testdata/reflect_2_0.wasm" contract

func InstantiateReflectExampleContractWithPortID

func InstantiateReflectExampleContractWithPortID(t testing.TB, ctx sdk.Context, keepers TestKeepers,
	portID string) ExampleInstance

InstantiateReflectExampleContractWithPortID load and instantiate the "./testdata/reflect_2_0.wasm" contract with defined port ID

type GRPCQueryRouter

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

type GasRegisterDecorator

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

GasRegisterDecorator ante decorator to store gas register in the context

func NewGasRegisterDecorator

func NewGasRegisterDecorator(gr types.GasRegister) *GasRegisterDecorator

NewGasRegisterDecorator constructor.

func (GasRegisterDecorator) AnteHandle

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

AnteHandle adds the gas register to the context.

type GovAuthorizationPolicy

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

func (GovAuthorizationPolicy) CanCreateCode

CanCreateCode implements AuthorizationPolicy.CanCreateCode to allow gov actions. Always returns true.

func (GovAuthorizationPolicy) CanInstantiateContract

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

func (GovAuthorizationPolicy) CanModifyCodeAccessConfig

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

func (GovAuthorizationPolicy) CanModifyContract

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

func (GovAuthorizationPolicy) SubMessageAuthorizationPolicy

func (p GovAuthorizationPolicy) SubMessageAuthorizationPolicy(action types.AuthorizationPolicyAction) types.AuthorizationPolicy

SubMessageAuthorizationPolicy returns new policy with fine-grained gov permission for given action only

type GrpcQuerier

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

func NewGrpcQuerier

func NewGrpcQuerier(cdc codec.Codec, storeService corestoretypes.KVStoreService, keeper types.ViewKeeper,
	queryGasLimit storetypes.Gas) *GrpcQuerier

NewGrpcQuerier constructor

func Querier

func Querier(k *Keeper) *GrpcQuerier

Querier creates a new grpc querier instance

func (GrpcQuerier) Code

func (GrpcQuerier) CodeInfo

func (GrpcQuerier) Codes

func (GrpcQuerier) ContractsByCode

ContractsByCode lists all smart contracts for a code id

func (GrpcQuerier) Params

Params returns params of the module.

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
	Label           string
	Deposit         sdk.Coins
}

func InstantiateHackatomExampleContract

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

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

type IBCEncoder

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

type IBCRawPacketHandler

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

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

func NewIBCRawPacketHandler

func NewIBCRawPacketHandler(ics4Wrapper types.ICS4Wrapper, wasmKeeper types.IBCContractKeeper,
	channelKeeper types.ChannelKeeper, capabilityKeeper types.CapabilityKeeper) IBCRawPacketHandler

NewIBCRawPacketHandler constructor

func (IBCRawPacketHandler) DispatchMsg

func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, contractIBCPortID string,
	msg wasmvmtypes.CosmosMsg) ([]sdk.Event, [][]byte, [][]*codectypes.Any, 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

func (IBCReflectExampleInstance) GetBytes

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

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 Wasm Engine with it's own data directory.

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeService corestoretypes.KVStoreService,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	stakingKeeper types.StakingKeeper,
	distrKeeper types.DistributionKeeper,
	ics4Wrapper types.ICS4Wrapper,
	channelKeeper types.ChannelKeeper,
	portKeeper types.PortKeeper,
	capabilityKeeper types.CapabilityKeeper,
	portSource types.ICS20TransferPortSource,
	router MessageRouter,
	_ GRPCQueryRouter,
	homeDir string,
	wasmConfig types.WasmConfig,
	availableCapabilities []string,
	authority 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 (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) ClassicAddressGenerator

func (k Keeper) ClassicAddressGenerator() AddressGenerator

ClassicAddressGenerator generates a contract address using codeID and instanceID sequence

func (Keeper) DeleteAsyncAckPacket

func (k Keeper) DeleteAsyncAckPacket(ctx context.Context, portID, channelID string, sequence uint64)

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/wasm module's authority.

func (Keeper) GetByteCode

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

func (Keeper) GetCodeInfo

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

func (Keeper) GetContractHistory

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

func (Keeper) GetContractInfo

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

func (Keeper) GetGasRegister

func (k Keeper) GetGasRegister() types.GasRegister

GetGasRegister returns the x/wasm module's gas register.

func (Keeper) GetParams

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

GetParams returns the total set of wasm parameters.

func (Keeper) HasContractInfo

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

func (Keeper) IBCDestinationCallback

func (k Keeper) IBCDestinationCallback(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCDestinationCallbackMsg,
) error

IBCDestinationCallback calls the contract to let it know that it received a packet of an IBC-callbacks-enabled message that was acknowledged.

func (Keeper) IBCSourceCallback

func (k Keeper) IBCSourceCallback(
	ctx sdk.Context,
	contractAddr sdk.AccAddress,
	msg wasmvmtypes.IBCSourceCallbackMsg,
) error

IBCSourceCallback calls the contract to let it know the packet triggered by its IBC-callbacks-enabled message either timed out or was acknowledged.

func (Keeper) InitializePinnedCodes

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

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

func (Keeper) IsPinnedCode

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

IsPinnedCode returns true when codeID is pinned in wasmvm cache

func (Keeper) IterateCodeInfos

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

func (Keeper) IterateContractInfo

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

func (Keeper) IterateContractState

func (k Keeper) IterateContractState(ctx context.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 context.Context, codeID uint64, cb func(address sdk.AccAddress) bool)

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

func (Keeper) IterateContractsByCreator

func (k Keeper) IterateContractsByCreator(ctx context.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool)

IterateContractsByCreator iterates over all contracts with given creator address in order of creation time asc.

func (Keeper) LoadAsyncAckPacket

func (k Keeper) LoadAsyncAckPacket(ctx context.Context, portID, channelID string, sequence uint64) (channeltypes.Packet,
	error)

func (Keeper) Logger

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

Logger returns a module-specific logger.

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/cosmos/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/cosmos/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/cosmos/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/cosmos/cosmos-sdk/issues/8334) that the counterparty channelID is empty on the initiating chain See https://github.com/cosmos/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/cosmos/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,
) (ibcexported.Acknowledgement, 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/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope

For more information see: https://github.com/cosmos/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 context.Context, sequenceKey []byte) (uint64, error)

PeekAutoIncrementID reads the current value without incrementing it.

func (Keeper) QueryGasLimit

func (k Keeper) QueryGasLimit() storetypes.Gas

QueryGasLimit returns the gas limit for smart queries.

func (Keeper) QueryRaw

func (k Keeper) QueryRaw(ctx context.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 context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)

QuerySmart queries the smart contract itself.

func (Keeper) SetParams

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

SetParams sets all wasm parameters.

func (Keeper) StoreAsyncAckPacket

func (k Keeper) StoreAsyncAckPacket(ctx context.Context, packet channeltypes.Packet) error

func (Keeper) Sudo

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

Sudo allows privileged 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)

Sub-messages returned from the sudo call to the contract are executed with the default authorization policy. This can be customized though by passing a new policy with the context. See types.WithSubMsgAuthzPolicy. The policy will be read in msgServer.selectAuthorizationPolicy and used for sub-message executions. This is an extension point for some very advanced scenarios only. Use with care!

type LimitSimulationGasDecorator

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

LimitSimulationGasDecorator ante decorator to limit gas in simulation calls

func NewLimitSimulationGasDecorator

func NewLimitSimulationGasDecorator(gasLimit *storetypes.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 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) ([]sdk.Msg, error)
	Custom       func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.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)
	Any     func(sender sdk.AccAddress, msg *wasmvmtypes.AnyMsg) ([]sdk.Msg, error)
	Wasm    func(sender sdk.AccAddress, msg *wasmvmtypes.WasmMsg) ([]sdk.Msg, error)
	Gov     func(sender sdk.AccAddress, msg *wasmvmtypes.GovMsg) ([]sdk.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) ([]sdk.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, [][]*codectypes.Any, 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, msgResponses [][]*codectypes.Any, err error)

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

func NewBurnCoinMessageHandler

func NewBurnCoinMessageHandler(burner types.Burner) MessageHandlerFunc

NewBurnCoinMessageHandler handles wasmvm.BurnMsg messages

func (MessageHandlerFunc) DispatchMsg

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

DispatchMsg delegates dispatching of provided message into the MessageHandlerFunc.

type MessageRouter

type MessageRouter interface {
	Handler(msg sdk.Msg) baseapp.MsgServiceHandler
}

MessageRouter ADR 031 request type routing

func TestHandler

func TestHandler(k types.ContractOpsKeeper) MessageRouter

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

type MessageRouterFunc

type MessageRouterFunc func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error)

func (MessageRouterFunc) Handler

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, msgResponses [][]*codectypes.Any, err error)
}

Messenger is an extension point for custom wasmd message handling

func NewDefaultMessageHandler

func NewDefaultMessageHandler(
	keeper *Keeper,
	router MessageRouter,
	ics4Wrapper types.ICS4Wrapper,
	channelKeeper types.ChannelKeeper,
	capabilityKeeper types.CapabilityKeeper,
	bankKeeper types.Burner,
	cdc codec.Codec,
	portSource types.ICS20TransferPortSource,
	customEncoders ...*MessageEncoders,
) Messenger

NewDefaultMessageHandler constructor

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper Keeper, legacySubspace exported.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx sdk.Context) error

Migrate2to3 migrates the x/wasm module state from the consensus version 2 to version 3.

func (Migrator) Migrate3to4

func (m Migrator) Migrate3to4(ctx sdk.Context) error

Migrate3to4 migrates the x/wasm module state from the consensus version 3 to version 4.

type MultipliedGasMeter

type MultipliedGasMeter struct {
	GasRegister types.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 storetypes.GasMeter, gr types.GasRegister) MultipliedGasMeter

func (MultipliedGasMeter) GasConsumed

func (m MultipliedGasMeter) GasConsumed() storetypes.Gas

type Option

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

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

func WitGovSubMsgAuthZPropagated

func WitGovSubMsgAuthZPropagated(entries ...types.AuthorizationPolicyAction) Option

WitGovSubMsgAuthZPropagated overwrites the default gov authorization policy for sub-messages

func WithAPICosts

func WithAPICosts(human, canonical uint64) Option

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

func WithAcceptedAccountTypesOnContractInstantiation

func WithAcceptedAccountTypesOnContractInstantiation(accts ...sdk.AccountI) Option

WithAcceptedAccountTypesOnContractInstantiation sets the accepted account types. Account types of this list won't be overwritten or cause a failure when they exist for an address on contract instantiation.

Values should be references and contain the `*authtypes.BaseAccount` as default bank account type.

func WithAccountPruner

func WithAccountPruner(x AccountPruner) Option

WithAccountPruner is an optional constructor parameter to set a custom type that handles balances and data cleanup for accounts pruned on contract instantiate

func WithCoinTransferrer

func WithCoinTransferrer(x CoinTransferrer) Option

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

func WithGasRegister

func WithGasRegister(x types.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 WithMaxCallDepth

func WithMaxCallDepth(m uint32) Option

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 and should not be combined with Option `WithQueryHandler` or `WithQueryHandlerDecorator`.

func WithVMCacheMetrics

func WithVMCacheMetrics(r prometheus.Registerer) Option

func WithWasmEngine

func WithWasmEngine(x types.WasmEngine) Option

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

func WithWasmEngineDecorator

func WithWasmEngineDecorator(d func(old types.WasmEngine) types.WasmEngine) Option

WithWasmEngineDecorator is an optional constructor parameter to decorate the default wasmVM engine.

type PartialGovAuthorizationPolicy

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

PartialGovAuthorizationPolicy decorates the given default policy to add fine-grained gov permissions to the defined action

func NewPartialGovAuthorizationPolicy

func NewPartialGovAuthorizationPolicy(defaultPolicy types.AuthorizationPolicy,
	entrypoint types.AuthorizationPolicyAction) PartialGovAuthorizationPolicy

NewPartialGovAuthorizationPolicy constructor

func (PartialGovAuthorizationPolicy) CanCreateCode

func (p PartialGovAuthorizationPolicy) CanCreateCode(chainConfigs types.ChainAccessConfigs, actor sdk.AccAddress,
	contractConfig types.AccessConfig) bool

func (PartialGovAuthorizationPolicy) CanInstantiateContract

func (p PartialGovAuthorizationPolicy) CanInstantiateContract(c types.AccessConfig, actor sdk.AccAddress) bool

func (PartialGovAuthorizationPolicy) CanModifyCodeAccessConfig

func (p PartialGovAuthorizationPolicy) CanModifyCodeAccessConfig(creator, actor sdk.AccAddress, isSubset bool) bool

func (PartialGovAuthorizationPolicy) CanModifyContract

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

func (PartialGovAuthorizationPolicy) SubMessageAuthorizationPolicy

SubMessageAuthorizationPolicy always returns self

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 types.AuthorizationPolicy) *PermissionedKeeper

func (PermissionedKeeper) ClearContractAdmin

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

func (PermissionedKeeper) Create

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

func (PermissionedKeeper) Execute

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

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)

Instantiate creates an instance of a WASM contract using the classic sequence based address generator

func (PermissionedKeeper) Instantiate2

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

Instantiate2 creates an instance of a WASM contract using the predictable address generator

func (PermissionedKeeper) Migrate

func (p PermissionedKeeper) Migrate(ctx sdk.Context, contractAddress, 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, caller sdk.AccAddress,
	newConfig 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

SetContractInfoExtension 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, caller, newAdmin sdk.AccAddress) error

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 types.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)
	Grpc         func(ctx sdk.Context, request *wasmvmtypes.GrpcQuery) (proto.Message, error)
	Wasm         func(ctx sdk.Context, request *wasmvmtypes.WasmQuery) ([]byte, error)
	Distribution func(ctx sdk.Context, request *wasmvmtypes.DistributionQuery) ([]byte, error)
}

func DefaultQueryPlugins

func DefaultQueryPlugins(
	bank types.BankViewKeeper,
	staking types.StakingKeeper,
	distKeeper types.DistributionKeeper,
	channelKeeper types.ChannelKeeper,
	wasm wasmQueryKeeper,
) QueryPlugins

func (QueryPlugins) HandleQuery

func (e QueryPlugins) HandleQuery(ctx sdk.Context, caller sdk.AccAddress, req 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(cdc codec.Codec, 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, msgResponses [][]*codectypes.Any, err error)

type StakingEncoder

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

type TestFaucet

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

func NewTestFaucet

func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.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) NewFundedRandomAccount

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

type TestKeepers

type TestKeepers struct {
	AccountKeeper    authkeeper.AccountKeeper
	StakingKeeper    *stakingkeeper.Keeper
	DistKeeper       distributionkeeper.Keeper
	BankKeeper       bankkeeper.Keeper
	GovKeeper        *govkeeper.Keeper
	ContractKeeper   types.ContractOpsKeeper
	WasmKeeper       *Keeper
	IBCKeeper        *ibckeeper.Keeper
	Router           MessageRouter
	EncodingConfig   moduletestutil.TestEncodingConfig
	Faucet           *TestFaucet
	MultiStore       storetypes.CommitMultiStore
	ScopedWasmKeeper capabilitykeeper.ScopedKeeper
	WasmStoreKey     *storetypes.KVStoreKey
}

func CreateDefaultTestInput

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

CreateDefaultTestInput common settings for CreateTestInput

func CreateTestInput

func CreateTestInput(t testing.TB, isCheckTx bool, availableCapabilities []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 TxContractsDecorator

type TxContractsDecorator struct{}

TxContractsDecorator implements an AnteHandler that keeps track of which contracts were already accessed during the current transaction. This allows discounting further calls to those contracts, as they are likely to be in the memory cache of the VM already.

func NewTxContractsDecorator

func NewTxContractsDecorator() *TxContractsDecorator

NewTxContractsDecorator constructor.

func (TxContractsDecorator) AnteHandle

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

AnteHandle initializes a new TxContracts object to the context.

type ValidatorSetSource

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

ValidatorSetSource is a subset of the staking keeper

type VestingCoinBurner

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

VestingCoinBurner default implementation for AccountPruner to burn the coins

func NewVestingCoinBurner

func NewVestingCoinBurner(bank types.BankKeeper) VestingCoinBurner

NewVestingCoinBurner constructor

func (VestingCoinBurner) CleanupExistingAccount

func (b VestingCoinBurner) CleanupExistingAccount(ctx sdk.Context, existingAcc sdk.AccountI) (handled bool, err error)

CleanupExistingAccount accepts only vesting account types to burns all their original vesting coin balances. Other account types will be rejected and returned as unhandled.

type WasmEncoder

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

type WasmSnapshotter

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

func NewWasmSnapshotter

func NewWasmSnapshotter(cms storetypes.MultiStore, wasm *Keeper) *WasmSnapshotter

func (*WasmSnapshotter) RestoreExtension

func (ws *WasmSnapshotter) RestoreExtension(height uint64, format uint32, payloadReader snapshot.ExtensionPayloadReader) error

func (*WasmSnapshotter) SnapshotExtension

func (ws *WasmSnapshotter) SnapshotExtension(height uint64, payloadWriter snapshot.ExtensionPayloadWriter) error

func (*WasmSnapshotter) SnapshotFormat

func (ws *WasmSnapshotter) SnapshotFormat() uint32

func (*WasmSnapshotter) SnapshotName

func (ws *WasmSnapshotter) SnapshotName() string

func (*WasmSnapshotter) SupportedFormats

func (ws *WasmSnapshotter) SupportedFormats() []uint32

type WasmVMMetricsCollector

type WasmVMMetricsCollector struct {
	CacheHitsDescr     *prometheus.Desc
	CacheMissesDescr   *prometheus.Desc
	CacheElementsDescr *prometheus.Desc
	CacheSizeDescr     *prometheus.Desc
	PinnedHitsDescr    *prometheus.Desc
	PinnedSizeDescr    *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