api

package
v2.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetPrice    uint64 = 99000
	SetPrice    uint64 = 187000
	RemovePrice uint64 = 142000
	RangePrice  uint64 = 261000
)

Note: these gas prices are all in *wasmer gas* and (sdk gas * 100)

We making simple values and non-clear multiples so it is easy to see their impact in test output Also note we do not charge for each read on an iterator (out of simplicity and not needed for tests)

View Source
const (
	CostCanonical uint64 = 440
	CostHuman     uint64 = 550
)
View Source
const CanonicalLength = 32
View Source
const DEFAULT_QUERIER_GAS_LIMIT = 1_000_000
View Source
const MOCK_CONTRACT_ADDR = "contract"

Variables

This section is empty.

Functions

func AnalyzeCode

func AnalyzeCode(cache Cache, checksum []byte) (*types.AnalysisReport, error)

func DefaultQuerier

func DefaultQuerier(contractAddr string, coins types.Array[types.Coin]) types.Querier

func Execute

func Execute(
	cache Cache,
	checksum []byte,
	env []byte,
	info []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func GetCode

func GetCode(cache Cache, checksum []byte) ([]byte, error)

func GetMetrics

func GetMetrics(cache Cache) (*types.Metrics, error)

func IBCChannelClose

func IBCChannelClose(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func IBCChannelConnect

func IBCChannelConnect(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func IBCChannelOpen

func IBCChannelOpen(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func IBCPacketAck

func IBCPacketAck(
	cache Cache,
	checksum []byte,
	env []byte,
	ack []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func IBCPacketReceive

func IBCPacketReceive(
	cache Cache,
	checksum []byte,
	env []byte,
	packet []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func IBCPacketTimeout

func IBCPacketTimeout(
	cache Cache,
	checksum []byte,
	env []byte,
	packet []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func Instantiate

func Instantiate(
	cache Cache,
	checksum []byte,
	env []byte,
	info []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func LibwasmvmVersion

func LibwasmvmVersion() (string, error)

func Migrate

func Migrate(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func MockCanonicalizeAddress

func MockCanonicalizeAddress(human string) ([]byte, uint64, error)

func MockEnv

func MockEnv() types.Env

func MockEnvBin

func MockEnvBin(t testing.TB) []byte

func MockFailureCanonicalizeAddress

func MockFailureCanonicalizeAddress(human string) ([]byte, uint64, error)

func MockFailureHumanizeAddress

func MockFailureHumanizeAddress(canon []byte) (string, uint64, error)

func MockFailureValidateAddress

func MockFailureValidateAddress(human string) (uint64, error)

func MockHumanizeAddress

func MockHumanizeAddress(canon []byte) (string, uint64, error)

func MockIBCChannel

func MockIBCChannel(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannel

func MockIBCChannelCloseConfirm

func MockIBCChannelCloseConfirm(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelCloseMsg

func MockIBCChannelCloseInit

func MockIBCChannelCloseInit(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelCloseMsg

func MockIBCChannelConnectAck

func MockIBCChannelConnectAck(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelConnectMsg

func MockIBCChannelConnectConfirm

func MockIBCChannelConnectConfirm(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelConnectMsg

func MockIBCChannelOpenInit

func MockIBCChannelOpenInit(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelOpenMsg

func MockIBCChannelOpenTry

func MockIBCChannelOpenTry(channelID string, ordering types.IBCOrder, ibcVersion string) types.IBCChannelOpenMsg

func MockIBCPacket

func MockIBCPacket(myChannel string, data []byte) types.IBCPacket

func MockIBCPacketAck

func MockIBCPacketAck(myChannel string, data []byte, ack types.IBCAcknowledgement) types.IBCPacketAckMsg

func MockIBCPacketReceive

func MockIBCPacketReceive(myChannel string, data []byte) types.IBCPacketReceiveMsg

func MockIBCPacketTimeout

func MockIBCPacketTimeout(myChannel string, data []byte) types.IBCPacketTimeoutMsg

func MockInfo

func MockInfo(sender types.HumanAddress, funds []types.Coin) types.MessageInfo

func MockInfoBin

func MockInfoBin(t testing.TB, sender types.HumanAddress) []byte

func MockInfoWithFunds

func MockInfoWithFunds(sender types.HumanAddress) types.MessageInfo

func MockValidateAddress

func MockValidateAddress(input string) (gasCost uint64, _ error)

func NewMockAPI

func NewMockAPI() *types.GoAPI

func NewMockFailureAPI

func NewMockFailureAPI() *types.GoAPI

func Pin

func Pin(cache Cache, checksum []byte) error

func Query

func Query(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func ReleaseCache

func ReleaseCache(cache Cache)

func RemoveCode

func RemoveCode(cache Cache, checksum []byte) error

func Reply

func Reply(
	cache Cache,
	checksum []byte,
	env []byte,
	reply []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func StoreCode

func StoreCode(cache Cache, wasm []byte) ([]byte, error)

func StoreCodeUnchecked

func StoreCodeUnchecked(cache Cache, wasm []byte) ([]byte, error)

func Sudo

func Sudo(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *types.GasMeter,
	store types.KVStore,
	api *types.GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, types.GasReport, error)

func TestBankQuerierAllBalances

func TestBankQuerierAllBalances(t *testing.T)

func TestBankQuerierBalance

func TestBankQuerierBalance(t *testing.T)

func TestMockApi

func TestMockApi(t *testing.T)

func TestReflectCustomQuerier

func TestReflectCustomQuerier(t *testing.T)

func Unpin

func Unpin(cache Cache, checksum []byte) error

Types

type BankQuerier

type BankQuerier struct {
	Balances map[string]types.Array[types.Coin]
}

func NewBankQuerier

func NewBankQuerier(balances map[string]types.Array[types.Coin]) BankQuerier

func (BankQuerier) Query

func (q BankQuerier) Query(request *types.BankQuery) ([]byte, error)

type Cache

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

func InitCache

func InitCache(dataDir string, supportedCapabilities []string, cacheSize uint32, instanceMemoryLimit uint32) (Cache, error)

type CapitalizedQuery

type CapitalizedQuery struct {
	Text string `json:"text"`
}

type CustomQuerier

type CustomQuerier interface {
	Query(request json.RawMessage) ([]byte, error)
}

type CustomQuery

type CustomQuery struct {
	Ping        *struct{}         `json:"ping,omitempty"`
	Capitalized *CapitalizedQuery `json:"capitalized,omitempty"`
}

type CustomResponse

type CustomResponse struct {
	Msg string `json:"msg"`
}

CustomResponse is the response for all `CustomQuery`s

type DBState

type DBState struct {
	Store types.KVStore
	// CallID is used to lookup the proper frame for iterators associated with this contract call (iterator.go)
	CallID uint64
}

type ErrorGasOverflow

type ErrorGasOverflow struct {
	Descriptor string
}

ErrorGasOverflow defines an error thrown when an action results gas consumption unsigned integer overflow.

type ErrorOutOfGas

type ErrorOutOfGas struct {
	Descriptor string
}

ErrorOutOfGas defines an error thrown when an action results in out of gas.

type Lookup

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

func NewLookup

func NewLookup(meter MockGasMeter) *Lookup

func (Lookup) Delete

func (l Lookup) Delete(key []byte)

Delete wraps the underlying DB's Delete method panicing on error.

func (Lookup) Get

func (l Lookup) Get(key []byte) []byte

Get wraps the underlying DB's Get method panicing on error.

func (Lookup) Iterator

func (l Lookup) Iterator(start, end []byte) types.Iterator

Iterator wraps the underlying DB's Iterator method panicing on error.

func (Lookup) ReverseIterator

func (l Lookup) ReverseIterator(start, end []byte) types.Iterator

ReverseIterator wraps the underlying DB's ReverseIterator method panicing on error.

func (Lookup) Set

func (l Lookup) Set(key, value []byte)

Set wraps the underlying DB's Set method panicing on error.

func (*Lookup) SetGasMeter

func (l *Lookup) SetGasMeter(meter MockGasMeter)

func (*Lookup) WithGasMeter

func (l *Lookup) WithGasMeter(meter MockGasMeter) *Lookup

type MockGasMeter

type MockGasMeter interface {
	types.GasMeter
	ConsumeGas(amount types.Gas, descriptor string)
}

func NewMockGasMeter

func NewMockGasMeter(limit types.Gas) MockGasMeter

NewMockGasMeter returns a reference to a new mockGasMeter.

type MockQuerier

type MockQuerier struct {
	Bank   BankQuerier
	Custom CustomQuerier
	// contains filtered or unexported fields
}

func (MockQuerier) GasConsumed

func (q MockQuerier) GasConsumed() uint64

func (*MockQuerier) Query

func (q *MockQuerier) Query(request types.QueryRequest, _gasLimit uint64) ([]byte, error)

type NoCustom

type NoCustom struct{}

func (NoCustom) Query

func (q NoCustom) Query(request json.RawMessage) ([]byte, error)

type Querier

type Querier = types.Querier

type ReflectCustom

type ReflectCustom struct{}

ReflectCustom fulfills the requirements for testing `reflect` contract

func (ReflectCustom) Query

func (q ReflectCustom) Query(request json.RawMessage) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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