api

package
v0.12.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 16 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 Create

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

func GetCode

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

func Handle

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

func Instantiate

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

func Migrate

func Migrate(
	cache Cache,
	code_id []byte,
	env []byte,
	info []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 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 Query

func Query(
	cache Cache,
	code_id []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 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)

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) (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
	// IteratorStackID is used to lookup the proper stack frame for iterators associated with this DB (iterator.go)
	IteratorStackID 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