api

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetPrice    uint64 = 99000
	SetPrice           = 187000
	RemovePrice        = 142000
	RangePrice         = 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 Create

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

func Execute

func Execute(
	cache Cache,
	checksum []byte,
	env []byte,
	info []byte,
	msg []byte,
	gasMeter *GasMeter,
	store KVStore,
	api *GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, uint64, 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 *GasMeter,
	store KVStore,
	api *GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, uint64, error)

func IBCChannelConnect

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

func IBCChannelOpen

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

func IBCPacketAck

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

func IBCPacketReceive

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

func IBCPacketTimeout

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

func Instantiate

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

func LibwasmvmVersion

func LibwasmvmVersion() (string, error)

func Migrate

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

func MockCanonicalAddress

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

func MockEnv

func MockEnv() types.Env

func MockEnvBin

func MockEnvBin(t *testing.T) []byte

func MockFailureCanonicalAddress

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

func MockFailureHumanAddress

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

func MockHumanAddress

func MockHumanAddress(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.T, sender types.HumanAddress) []byte

func MockInfoWithFunds

func MockInfoWithFunds(sender types.HumanAddress) types.MessageInfo

func Pin

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

func Query

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

func ReleaseCache

func ReleaseCache(cache Cache)

func Reply

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

func Sudo

func Sudo(
	cache Cache,
	checksum []byte,
	env []byte,
	msg []byte,
	gasMeter *GasMeter,
	store KVStore,
	api *GoAPI,
	querier *Querier,
	gasLimit uint64,
	printDebug bool,
) ([]byte, uint64, 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.Coins
}

func NewBankQuerier

func NewBankQuerier(balances map[string]types.Coins) 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, supportedFeatures string, cacheSize uint32, instanceMemoryLimit uint32) (Cache, error)

type CanonicalizeAddress

type CanonicalizeAddress func(string) ([]byte, uint64, 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 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 Gas

type Gas = uint64

type GasMeter

type GasMeter interface {
	GasConsumed() Gas
}

GasMeter is a copy of an interface declaration from cosmos-sdk https://github.com/cosmos/cosmos-sdk/blob/18890a225b46260a9adc587be6fa1cc2aff101cd/store/types/gas.go#L34

type GoAPI

type GoAPI struct {
	HumanAddress     HumanizeAddress
	CanonicalAddress CanonicalizeAddress
}

func NewMockAPI

func NewMockAPI() *GoAPI

func NewMockFailureAPI

func NewMockFailureAPI() *GoAPI

type HumanizeAddress

type HumanizeAddress func([]byte) (string, uint64, error)

type KVStore

type KVStore interface {
	Get(key []byte) []byte
	Set(key, value []byte)
	Delete(key []byte)

	// Iterator over a domain of keys in ascending order. End is exclusive.
	// Start must be less than end, or the Iterator is invalid.
	// Iterator must be closed by caller.
	// To iterate over entire domain, use store.Iterator(nil, nil)
	Iterator(start, end []byte) dbm.Iterator

	// Iterator over a domain of keys in descending order. End is exclusive.
	// Start must be less than end, or the Iterator is invalid.
	// Iterator must be closed by caller.
	ReverseIterator(start, end []byte) dbm.Iterator
}

KVStore copies a subset of types from cosmos-sdk We may wish to make this more generic sometime in the future, but not now https://github.com/cosmos/cosmos-sdk/blob/bef3689245bab591d7d169abd6bea52db97a70c7/store/types/store.go#L170

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) dbm.Iterator

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

func (Lookup) ReverseIterator

func (l Lookup) ReverseIterator(start, end []byte) dbm.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 {
	GasMeter
	ConsumeGas(amount Gas, descriptor string)
}

func NewMockGasMeter

func NewMockGasMeter(limit 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

func DefaultQuerier

func DefaultQuerier(contractAddr string, coins types.Coins) 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)

Jump to

Keyboard shortcuts

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