keeper

package
v0.1.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServer

func NewMsgServer(k Keeper) types.MsgServer

NewMsgServer returns the default implementation of the x/oracle message service

func NewQueryServer

func NewQueryServer(k Keeper) types.QueryServer

NewQueryServer returns an implementation of the x/oracle QueryServer

Types

type Keeper

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

Keeper is the base keeper for the x/oracle module

func NewKeeper

func NewKeeper(
	ss store.KVStoreService,
	cdc codec.BinaryCodec,
	authority sdk.AccAddress,
) Keeper

NewKeeper constructs a new keeper from a store-key + authority account address

func (Keeper) CreateCurrencyPair

func (k Keeper) CreateCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) error

CreateCurrencyPair creates a CurrencyPair in state, and sets its ID to the next available ID. If the CurrencyPair already exists, return an error. the nonce for the CurrencyPair is set to 0.

func (Keeper) ExportGenesis

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

ExportGenesis, retrieve all CurrencyPairs + QuotePrices set for the module, and return them as a genesis state. This module panics on any errors encountered in execution.

func (Keeper) GetAllCurrencyPairs

func (k Keeper) GetAllCurrencyPairs(ctx sdk.Context) []types.CurrencyPair

GetAllCurrencyPairs returns all CurrencyPairs that have currently been stored to state.

func (Keeper) GetCurrencyPairFromID

func (k Keeper) GetCurrencyPairFromID(ctx sdk.Context, id uint64) (types.CurrencyPair, bool)

GetCurrencyPairFromID returns the CurrencyPair for a given ID. If the ID does not exist, return an error and an empty CurrencyPair. Otherwise, return the currency pair and no error.

func (Keeper) GetIDForCurrencyPair

func (k Keeper) GetIDForCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) (uint64, bool)

GetIDForCurrencyPair returns the ID for a given CurrencyPair. If the CurrencyPair does not exist, return 0, false, if it does, return true and the ID.

func (Keeper) GetNonceForCurrencyPair

func (k Keeper) GetNonceForCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) (uint64, error)

GetNonceForCurrency Pair returns the nonce for a given CurrencyPair. If one has not been stored, return an error.

func (Keeper) GetPriceForCurrencyPair

func (k Keeper) GetPriceForCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) (types.QuotePrice, error)

GetPriceForCurrencyPair retrieves the QuotePrice for a given CurrencyPair. if a QuotePrice does not exist for the given CurrencyPair, this function errors and returns an empty QuotePrice

func (Keeper) GetPriceWithNonceForCurrencyPair

func (k Keeper) GetPriceWithNonceForCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) (types.QuotePriceWithNonce, error)

GetPriceWithNonceForCurrencyPair returns a QuotePriceWithNonce for a given CurrencyPair. The nonce for the QuotePrice represents the number of times that a given QuotePrice has been updated. Notice: prefer GetPriceWithNonceForCurrencyPair over GetPriceForCurrencyPair.

func (Keeper) HasCurrencyPair

func (k Keeper) HasCurrencyPair(ctx sdk.Context, cp types.CurrencyPair) bool

HasCurrencyPair returns true if a given CurrencyPair is stored in state, false otherwise.

func (Keeper) InitGenesis

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

InitGenesis initializes the set of CurrencyPairs + their genesis prices (if any) for the x/oracle module. this function panics on any errors, i.e if the genesis state is invalid, or any state-modifications fail.

func (Keeper) IterateCurrencyPairs

func (k Keeper) IterateCurrencyPairs(ctx sdk.Context, cb func(cp types.CurrencyPair, cps types.CurrencyPairState)) error

IterateCurrencyPairs iterates over all CurrencyPairs in the store, and executes a callback for each CurrencyPair.

func (Keeper) NextCurrencyPairID

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

NextCurrencyPairID returns the next ID to be assigned to a currency-pair

func (Keeper) RemoveCurrencyPair

func (k Keeper) RemoveCurrencyPair(ctx sdk.Context, cp types.CurrencyPair)

RemoveCurrencyPair removes a given CurrencyPair from state, i.e removes its nonce + QuotePrice from the module's store.

func (Keeper) SetPriceForCurrencyPair

func (k Keeper) SetPriceForCurrencyPair(ctx sdk.Context, cp types.CurrencyPair, qp types.QuotePrice) error

SetPriceForCurrencyPair sets the given QuotePrice for a given CurrencyPair, and updates the CurrencyPair's nonce. Note, no validation is performed on either the CurrencyPair or the QuotePrice (it is expected the caller performs this validation). If the CurrencyPair does not exist, create the currency-pair and set its nonce to 0.

Jump to

Keyboard shortcuts

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