keeper

package
v10.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 30 Imported by: 17

Documentation

Index

Constants

View Source
const SnapshotFormat = 1

SnapshotFormat defines the default snapshot extension encoding format. SnapshotFormat 1 is gzipped wasm byte code for each item payload. No protobuf envelope, no metadata.

Variables

View Source
var (
	VMGasRegister = types.NewDefaultWasmGasRegister()
)

Functions

func AcceptListStargateQuerier

func AcceptListStargateQuerier(acceptedQueries []string, queryRouter types.QueryRouter) func(sdk.Context, *wasmvmtypes.StargateQuery) ([]byte, error)

AcceptListStargateQuerier allows all queries that are in the provided accept list. This function returns protobuf encoded responses in bytes.

func NewWasmSnapshotter

func NewWasmSnapshotter(cms storetypes.MultiStore, keeper *Keeper) snapshot.ExtensionSnapshotter

NewWasmSnapshotter creates and returns a new snapshot.ExtensionSnapshotter implementation for the 08-wasm module.

func RejectCustomQuerier

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

RejectCustomQuerier rejects all custom queries

Types

type CustomQuerier

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

type Keeper

type Keeper struct {
	// implements gRPC QueryServer interface
	types.QueryServer
	// contains filtered or unexported fields
}

Keeper defines the 08-wasm keeper

func NewKeeperWithConfig

func NewKeeperWithConfig(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	clientKeeper types.ClientKeeper,
	authority string,
	wasmConfig types.WasmConfig,
	queryRouter types.QueryRouter,
	opts ...Option,
) Keeper

NewKeeperWithConfig creates a new Keeper instance with the provided Wasm configuration. This constructor function is meant to be used when the chain does not use x/wasm and a Wasm VM needs to be instantiated using the provided parameters.

func NewKeeperWithVM

func NewKeeperWithVM(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	clientKeeper types.ClientKeeper,
	authority string,
	vm types.WasmEngine,
	queryRouter types.QueryRouter,
	opts ...Option,
) Keeper

NewKeeperWithVM creates a new Keeper instance with the provided Wasm VM. This constructor function is meant to be used when the chain uses x/wasm and the same Wasm VM instance should be shared with it.

func (Keeper) Checksums

Checksums implements the Query/Checksums gRPC method. It returns a list of hex encoded checksums stored.

func (Keeper) Code

Code implements the Query/Code gRPC method

func (Keeper) Codec

func (k Keeper) Codec() codec.BinaryCodec

Codec returns the 08-wasm module's codec.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState

ExportGenesis returns the 08-wasm module's exported genesis. This includes the code for all contracts previously stored.

func (Keeper) GetAllChecksums

func (k Keeper) GetAllChecksums(ctx sdk.Context) ([]types.Checksum, error)

GetAllChecksums is a helper to get all checksums from the store. It returns an empty slice if no checksums are found

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the 08-wasm module's authority.

func (Keeper) GetChecksums

func (k Keeper) GetChecksums() collections.KeySet[[]byte]

GetChecksums returns the stored checksums.

func (Keeper) GetVM

func (k Keeper) GetVM() types.WasmEngine

GetVM returns the keeper's vm engine.

func (Keeper) GetWasmClientState

func (k Keeper) GetWasmClientState(ctx sdk.Context, clientID string) (*types.ClientState, error)

GetWasmClientState returns the 08-wasm client state for the given client identifier.

func (Keeper) HasChecksum

func (k Keeper) HasChecksum(ctx sdk.Context, checksum types.Checksum) bool

HasChecksum returns true if the given checksum exists in the store and false otherwise.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) error

InitGenesis initializes the 08-wasm module's state from a provided genesis state.

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

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

Logger returns a module-specific logger.

func (Keeper) MigrateContract

MigrateContract defines a rpc handler method for MsgMigrateContract

func (Keeper) RemoveChecksum

func (k Keeper) RemoveChecksum(goCtx context.Context, msg *types.MsgRemoveChecksum) (*types.MsgRemoveChecksumResponse,
	error,
)

RemoveChecksum defines a rpc handler method for MsgRemoveChecksum

func (Keeper) StoreCode

func (k Keeper) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*types.MsgStoreCodeResponse, error)

StoreCode defines a rpc handler method for MsgStoreCode

func (Keeper) WasmInstantiate

func (k Keeper) WasmInstantiate(ctx sdk.Context, clientID string, clientStore storetypes.KVStore, cs *types.ClientState, payload types.InstantiateMessage) error

WasmInstantiate accepts a message to instantiate a wasm contract, JSON encodes it and calls instantiateContract.

func (Keeper) WasmMigrate

func (k Keeper) WasmMigrate(ctx sdk.Context, clientStore storetypes.KVStore, cs *types.ClientState, clientID string, payload []byte) error

WasmMigrate migrate calls the migrate entry point of the contract with the given payload and returns the result. WasmMigrate returns an error if: - the contract migration returns an error

func (Keeper) WasmQuery

func (k Keeper) WasmQuery(ctx sdk.Context, clientID string, clientStore storetypes.KVStore, cs *types.ClientState, payload types.QueryMsg) ([]byte, error)

WasmQuery queries the contract with the given payload and returns the result. WasmQuery returns an error if: - the contract query returns an error - the data bytes of the response cannot be unmarshal into the result type

func (Keeper) WasmSudo

func (k Keeper) WasmSudo(ctx sdk.Context, clientID string, clientStore storetypes.KVStore, cs *types.ClientState, payload types.SudoMsg) ([]byte, error)

WasmSudo calls the contract with the given payload and returns the result. WasmSudo returns an error if: - the contract call returns an error - the response of the contract call contains non-empty messages - the response of the contract call contains non-empty events - the response of the contract call contains non-empty attributes - the data bytes of the response cannot be unmarshaled into the result type

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

NewMigrator returns a new Migrator.

func (Migrator) MigrateChecksums

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

MigrateChecksums migrates the wasm store from using a single key to store a list of checksums to using a collections.KeySet to store the checksums.

It grabs the checksums stored previously under the old key and stores them in the global KeySet collection. It then deletes the old key and the checksums stored under it.

type Option

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

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

func WithQueryPlugins

func WithQueryPlugins(plugins *QueryPlugins) Option

WithQueryPlugins is an optional constructor parameter to pass custom query plugins for wasmVM requests. Missing fields will be filled with default queriers.

type QueryPlugins

type QueryPlugins struct {
	Custom   CustomQuerier
	Stargate StargateQuerier
}

QueryPlugins is a list of queriers that can be used to extend the default querier.

func NewDefaultQueryPlugins

func NewDefaultQueryPlugins(queryRouter types.QueryRouter) QueryPlugins

NewDefaultQueryPlugins returns the default set of query plugins

func (QueryPlugins) HandleQuery

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

HandleQuery implements the ibcwasm.QueryPluginsI interface.

func (QueryPlugins) Merge

Merge merges the query plugin with a provided one.

type StargateQuerier

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

type WasmSnapshotter

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

WasmSnapshotter implements the snapshot.ExtensionSnapshotter interface and is used to import and export state maintained within the wasmvm cache. NOTE: The following ExtensionSnapshotter has been adapted from CosmWasm's x/wasm: https://github.com/CosmWasm/wasmd/blob/v0.43.0/x/wasm/keeper/snapshotter.go

func (*WasmSnapshotter) RestoreExtension

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

RestoreExtension implements the snapshot.ExtensionSnapshotter interface. RestoreExtension is used to read data from an existing extension state snapshot into the 08-wasm module. The payload reader returns io.EOF when it has reached the end of the extension state snapshot.

func (*WasmSnapshotter) SnapshotExtension

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

SnapshotExtension implements the snapshot.ExntensionSnapshotter interface. SnapshotExtension is used to write data payloads into the underlying protobuf stream from the 08-wasm module.

func (*WasmSnapshotter) SnapshotFormat

func (*WasmSnapshotter) SnapshotFormat() uint32

SnapshotFormat implements the snapshot.ExtensionSnapshotter interface. This is the default format used for encoding payloads when taking a snapshot.

func (*WasmSnapshotter) SnapshotName

func (*WasmSnapshotter) SnapshotName() string

SnapshotName implements the snapshot.ExtensionSnapshotter interface. A unique name should be provided such that the implementation can be identified by the manager.

func (*WasmSnapshotter) SupportedFormats

func (*WasmSnapshotter) SupportedFormats() []uint32

SupportedFormats implements the snapshot.ExtensionSnapshotter interface. This defines a list of supported formats the snapshotter extension can restore from.

Jump to

Keyboard shortcuts

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