keeper

package
v0.5.11-oracle Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 76 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PubKeys = []crypto.PubKey{
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
	}

	Addrs = []sdk.AccAddress{
		sdk.AccAddress(PubKeys[0].Address()),
		sdk.AccAddress(PubKeys[1].Address()),
		sdk.AccAddress(PubKeys[2].Address()),
	}

	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(PubKeys[0].Address()),
		sdk.ValAddress(PubKeys[1].Address()),
		sdk.ValAddress(PubKeys[2].Address()),
	}

	InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
	InitCoins  = sdk.NewCoins(sdk.NewCoin(core.MicroLunaDenom, InitTokens))
)

Test Account

ModuleBasics nolint

Functions

func FundAccount

func FundAccount(input TestInput, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address. This should be used for testing purposes only!

func LimitReader

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

LimitReader returns LimitedReader

func MakeEncodingConfig

func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig

MakeEncodingConfig nolint

func MakeTestCodec

func MakeTestCodec(t *testing.T) codec.Codec

MakeTestCodec nolint

func NewLegacyQuerier

func NewLegacyQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewLegacyQuerier creates a new querier

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the wasm MsgServer interface for the provided Keeper.

func NewQuerier

func NewQuerier(keeper Keeper) types.QueryServer

NewQuerier returns an implementation of the market QueryServer interface for the provided Keeper.

Types

type ContractInfoQueryParams

type ContractInfoQueryParams struct {
	ContractAddress string `json:"contract_address"`
}

ContractInfoQueryParams query request params for contract info

type ContractInfoQueryResponse

type ContractInfoQueryResponse struct {
	Address string `json:"address"`
	Creator string `json:"creator"`
	Admin   string `json:"admin,omitempty"`
	CodeID  uint64 `json:"code_id"`
}

ContractInfoQueryResponse - exchange rates query response for wasm module

type CosmosQuery

type CosmosQuery struct {
	ContractInfo *ContractInfoQueryParams `json:"contract_info,omitempty"`
}

CosmosQuery custom query interface for oracle querier

type HackatomExampleInitMsg

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

HackatomExampleInitMsg nolint

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.BinaryCodec,
	storeKey sdk.StoreKey,
	paramspace paramstypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	treasuryKeeper types.TreasuryKeeper,
	serviceRouter types.MsgServiceRouter,
	queryRouter types.GRPCQueryRouter,
	supportedFeatures string,
	homePath string,
	wasmConfig *config.Config) Keeper

NewKeeper creates a new contract Keeper instance

func (Keeper) CompileCode

func (k Keeper) CompileCode(ctx sdk.Context, wasmCode []byte) (codeHash []byte, err error)

CompileCode uncompress the wasm code bytes and store the code to local file system

func (Keeper) ExecuteContract

func (k Keeper) ExecuteContract(
	ctx sdk.Context,
	contractAddress sdk.AccAddress,
	sender sdk.AccAddress,
	execMsg []byte,
	coins sdk.Coins) ([]byte, error)

ExecuteContract executes the contract instance

func (Keeper) GetByteCode

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

GetByteCode returns ByteCode of the given CodeHash

func (Keeper) GetCodeInfo

func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) (codeInfo types.CodeInfo, err error)

GetCodeInfo returns CodeInfo for the given codeID

func (Keeper) GetContractInfo

func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) (contractInfo types.ContractInfo, err error)

GetContractInfo returns contract info of the given address

func (Keeper) GetContractStoreIterator

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

GetContractStoreIterator returns iterator for a contract store

func (Keeper) GetLastCodeID

func (k Keeper) GetLastCodeID(ctx sdk.Context) (uint64, error)

GetLastCodeID return last code ID

func (Keeper) GetLastInstanceID

func (k Keeper) GetLastInstanceID(ctx sdk.Context) (uint64, error)

GetLastInstanceID return last instance ID

func (Keeper) GetParams

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

GetParams returns the total set of oracle parameters.

func (Keeper) InstantiateContract

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

InstantiateContract creates an instance of a WASM contract

func (Keeper) IterateContractInfo

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

IterateContractInfo iterates all contract infos

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MaxContractGas

func (k Keeper) MaxContractGas(ctx sdk.Context) (res uint64)

MaxContractGas defines allowed maximum gas usage per each contract execution

func (Keeper) MaxContractMsgSize

func (k Keeper) MaxContractMsgSize(ctx sdk.Context) (res uint64)

MaxContractMsgSize defines maximum bytes size of a contract

func (Keeper) MaxContractSize

func (k Keeper) MaxContractSize(ctx sdk.Context) (res uint64)

MaxContractSize defines maximum bytes size of a contract

func (Keeper) MigrateCode

func (k Keeper) MigrateCode(ctx sdk.Context, codeID uint64, creator sdk.AccAddress, wasmCode []byte) error

MigrateCode uploads and compiles a WASM contract bytecode for the existing code id. After columbus-5 update, all contract code will be removed from the store due to in-compatibility between CosmWasm@v0.10.x and CosmWasm@v0.16.x The migration can be executed by once after columbus-5 update. TODO - remove after columbus-5 update

func (Keeper) MigrateContract

func (k Keeper) MigrateContract(
	ctx sdk.Context,
	contractAddress sdk.AccAddress,
	sender sdk.AccAddress,
	newCodeID uint64,
	migrateMsg []byte) ([]byte, error)

MigrateContract allows to upgrade a contract to a new code with data migration.

func (*Keeper) RegisterMsgParsers

func (k *Keeper) RegisterMsgParsers(
	parsers map[string]types.WasmMsgParserInterface,
	stargateWasmMsgParser types.StargateWasmMsgParserInterface,
)

RegisterMsgParsers register module msg parsers

func (*Keeper) RegisterQueriers

func (k *Keeper) RegisterQueriers(
	queriers map[string]types.WasmQuerierInterface,
	stargateWasmQuerier types.StargateWasmQuerierInterface,
)

RegisterQueriers register module queriers

func (Keeper) SetCodeInfo

func (k Keeper) SetCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo)

SetCodeInfo stores CodeInfo for the given codeID

func (Keeper) SetContractInfo

func (k Keeper) SetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress, codeInfo types.ContractInfo)

SetContractInfo stores ContractInfo for the given contractAddress

func (Keeper) SetContractStore

func (k Keeper) SetContractStore(ctx sdk.Context, contractAddress sdk.AccAddress, models []types.Model)

SetContractStore records all the Models on the contract store

func (Keeper) SetLastCodeID

func (k Keeper) SetLastCodeID(ctx sdk.Context, id uint64)

SetLastCodeID set last code id

func (Keeper) SetLastInstanceID

func (k Keeper) SetLastInstanceID(ctx sdk.Context, id uint64)

SetLastInstanceID set last instance id

func (Keeper) SetParams

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

SetParams sets the total set of oracle parameters.

func (Keeper) StoreCode

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

StoreCode uploads and compiles a WASM contract bytecode, returning a short identifier for the stored code

type LimitedReader

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

LimitedReader is a Reader that reads from r but stops with types.ErrExceedMaxContractSize after n bytes.

func (*LimitedReader) Read

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

type StargateWasmMsgParser

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

StargateWasmMsgParser - wasm msg parser for stargate msgs

func NewStargateWasmMsgParser

func NewStargateWasmMsgParser(unpacker codectypes.AnyUnpacker) StargateWasmMsgParser

NewStargateWasmMsgParser returns stargate wasm msg parser

func (StargateWasmMsgParser) Parse

func (parser StargateWasmMsgParser) Parse(wasmMsg wasmvmtypes.CosmosMsg) (sdk.Msg, error)

Parse implements wasm stargate msg parser

type StargateWasmQuerier

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

StargateWasmQuerier - wasm query interface for wasm contract

func NewStargateWasmQuerier

func NewStargateWasmQuerier(keeper Keeper) StargateWasmQuerier

NewStargateWasmQuerier returns stargate wasm querier

func (StargateWasmQuerier) Query

func (querier StargateWasmQuerier) Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error)

Query - implement query function

type TestInput

type TestInput struct {
	Ctx                sdk.Context
	Cdc                *codec.LegacyAmino
	AccKeeper          authkeeper.AccountKeeper
	BankKeeper         bankkeeper.Keeper
	StakingKeeper      stakingkeeper.Keeper
	DistributionKeeper distrkeeper.Keeper
	OracleKeeper       oraclekeeper.Keeper
	MarketKeeper       marketkeeper.Keeper
	TreasuryKeeper     treasurykeeper.Keeper
	WasmKeeper         Keeper
}

TestInput nolint

func CreateTestInput

func CreateTestInput(t *testing.T) TestInput

CreateTestInput nolint

type WasmMsgParser

type WasmMsgParser struct{}

WasmMsgParser - wasm msg parser for wasm msgs

func NewWasmMsgParser

func NewWasmMsgParser() WasmMsgParser

NewWasmMsgParser returns wasm msg parser

func (WasmMsgParser) Parse

func (WasmMsgParser) Parse(contractAddr sdk.AccAddress, wasmMsg wasmvmtypes.CosmosMsg) (sdk.Msg, error)

Parse implements wasm staking msg parser

func (WasmMsgParser) ParseCustom

func (parser WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) (sdk.Msg, error)

ParseCustom implements custom parser

type WasmQuerier

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

WasmQuerier - wasm query interface for wasm contract

func NewWasmQuerier

func NewWasmQuerier(keeper Keeper) WasmQuerier

NewWasmQuerier returns wasm querier

func (WasmQuerier) Query

func (querier WasmQuerier) Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error)

Query - implement query function

func (WasmQuerier) QueryCustom

func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error)

QueryCustom implements custom query interface

Jump to

Keyboard shortcuts

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