Documentation ¶
Index ¶
- func NewMsgServer(k Keeper) types.MsgServer
- func NewQueryServer(k Keeper) types.QueryServer
- type Hooks
- func (h Hooks) AfterMarketCreated(ctx sdk.Context, market marketmaptypes.Market) error
- func (h Hooks) AfterMarketGenesis(ctx sdk.Context, markets map[string]marketmaptypes.Market) error
- func (h Hooks) AfterMarketRemoved(ctx sdk.Context, key string) error
- func (h Hooks) AfterMarketUpdated(ctx sdk.Context, market marketmaptypes.Market) error
- type Keeper
- func (k *Keeper) BeginBlocker(goCtx context.Context) error
- func (k *Keeper) CreateCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) error
- func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k *Keeper) GetAllCurrencyPairs(ctx sdk.Context) []slinkytypes.CurrencyPair
- func (k *Keeper) GetCurrencyPairFromID(ctx sdk.Context, id uint64) (slinkytypes.CurrencyPair, bool)
- func (k *Keeper) GetCurrencyPairMapping(ctx sdk.Context) (map[uint64]slinkytypes.CurrencyPair, error)
- func (k *Keeper) GetCurrencyPairMappingList(ctx sdk.Context) ([]types.CurrencyPairMapping, error)
- func (k *Keeper) GetDecimalsForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (decimals uint64, err error)
- func (k *Keeper) GetIDForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (uint64, bool)
- func (k *Keeper) GetNonceForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (uint64, error)
- func (k *Keeper) GetNumCurrencyPairs(ctx sdk.Context) (uint64, error)
- func (k *Keeper) GetNumRemovedCurrencyPairs(ctx sdk.Context) (uint64, error)
- func (k *Keeper) GetPriceForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (types.QuotePrice, error)
- func (k *Keeper) GetPriceWithNonceForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (types.QuotePriceWithNonce, error)
- func (k *Keeper) HasCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) bool
- func (k *Keeper) Hooks() Hooks
- func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState)
- func (k *Keeper) IterateCurrencyPairs(ctx sdk.Context, ...) error
- func (k *Keeper) NextCurrencyPairID(ctx sdk.Context) (uint64, error)
- func (k *Keeper) RemoveCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) error
- func (k *Keeper) SetPriceForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair, qp types.QuotePrice) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServer ¶
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 Hooks ¶ added in v1.2.0
type Hooks struct {
// contains filtered or unexported fields
}
Hooks is a wrapper struct around Keeper.
func (Hooks) AfterMarketCreated ¶ added in v1.2.0
AfterMarketCreated is the marketmap hook for x/oracle that is run after a market is created in the marketmap. After the market is created, a currency pair and its state are initialized in the oracle module.
func (Hooks) AfterMarketGenesis ¶ added in v1.2.0
AfterMarketGenesis verifies that all markets set in the x/marketmap genesis are registered in the x/oracle module.
func (Hooks) AfterMarketRemoved ¶ added in v1.2.0
AfterMarketRemoved is the marketmap hook for x/oracle that is run after a market is removed in the marketmap.
func (Hooks) AfterMarketUpdated ¶ added in v1.2.0
AfterMarketUpdated is the marketmap hook for x/oracle that is run after a market is updated in the marketmap.
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, mmKeeper types.MarketMapKeeper, authority sdk.AccAddress, ) Keeper
NewKeeper constructs a new keeper from a store-key + authority account address.
func (*Keeper) BeginBlocker ¶ added in v1.2.0
BeginBlocker is called at the beginning of every block. It resets the count of removed currency pairs.
func (*Keeper) CreateCurrencyPair ¶ added in v1.2.0
func (k *Keeper) CreateCurrencyPair(ctx sdk.Context, cp slinkytypes.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) []slinkytypes.CurrencyPair
GetAllCurrencyPairs returns all CurrencyPairs that have currently been stored to state.
func (*Keeper) GetCurrencyPairFromID ¶ added in v1.2.0
func (k *Keeper) GetCurrencyPairFromID(ctx sdk.Context, id uint64) (slinkytypes.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) GetCurrencyPairMapping ¶ added in v1.2.0
func (k *Keeper) GetCurrencyPairMapping(ctx sdk.Context) (map[uint64]slinkytypes.CurrencyPair, error)
GetCurrencyPairMapping returns a CurrencyPair mapping by ID that have currently been stored to state. NOTE: this map[] type should not be used by on-chain code.
func (*Keeper) GetCurrencyPairMappingList ¶ added in v1.2.0
GetCurrencyPairMappingList returns a CurrencyPair mapping by ID that have currently been stored to state as a list.
func (*Keeper) GetDecimalsForCurrencyPair ¶ added in v1.2.0
func (k *Keeper) GetDecimalsForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (decimals uint64, err error)
GetDecimalsForCurrencyPair gets the decimals used for the given currency pair. If the market map is not enabled with the x/oracle module, the legacy Decimals function is used.
func (*Keeper) GetIDForCurrencyPair ¶ added in v1.2.0
func (k *Keeper) GetIDForCurrencyPair(ctx sdk.Context, cp slinkytypes.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 slinkytypes.CurrencyPair) (uint64, error)
GetNonceForCurrencyPair returns the nonce for a given CurrencyPair. If one has not been stored, return an error.
func (*Keeper) GetNumCurrencyPairs ¶ added in v1.2.0
GetNumCurrencyPairs returns the number of currency pairs currently in state.
func (*Keeper) GetNumRemovedCurrencyPairs ¶ added in v1.2.0
GetNumRemovedCurrencyPairs gets the counter of removed currency pairs in the previous block.
func (*Keeper) GetPriceForCurrencyPair ¶
func (k *Keeper) GetPriceForCurrencyPair(ctx sdk.Context, cp slinkytypes.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 slinkytypes.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 ¶ added in v1.2.0
func (k *Keeper) HasCurrencyPair(ctx sdk.Context, cp slinkytypes.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 ¶ added in v1.2.0
func (k *Keeper) IterateCurrencyPairs(ctx sdk.Context, cb func(cp slinkytypes.CurrencyPair, cps types.CurrencyPairState)) error
IterateCurrencyPairs iterates over all CurrencyPairs in the store, and executes a callback for each CurrencyPair.
func (*Keeper) NextCurrencyPairID ¶ added in v1.2.0
NextCurrencyPairID returns the next ID to be assigned to a currency-pair.
func (*Keeper) RemoveCurrencyPair ¶
func (k *Keeper) RemoveCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) error
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 slinkytypes.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.