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(ctx context.Context) error
- func (k *Keeper) CreateCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) error
- func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k *Keeper) GetAllCurrencyPairs(ctx context.Context) []connecttypes.CurrencyPair
- func (k *Keeper) GetCurrencyPairFromID(ctx context.Context, id uint64) (connecttypes.CurrencyPair, bool)
- func (k *Keeper) GetCurrencyPairMapping(ctx context.Context) (map[uint64]connecttypes.CurrencyPair, error)
- func (k *Keeper) GetCurrencyPairMappingList(ctx context.Context) ([]types.CurrencyPairMapping, error)
- func (k *Keeper) GetDecimalsForCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) (decimals uint64, err error)
- func (k *Keeper) GetIDForCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) (uint64, bool)
- func (k *Keeper) GetNonceForCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) (uint64, error)
- func (k *Keeper) GetNumCurrencyPairs(ctx context.Context) (uint64, error)
- func (k *Keeper) GetNumRemovedCurrencyPairs(ctx context.Context) (uint64, error)
- func (k *Keeper) GetPriceForCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) (types.QuotePrice, error)
- func (k *Keeper) GetPriceWithNonceForCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) (types.QuotePriceWithNonce, error)
- func (k *Keeper) HasCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) bool
- func (k *Keeper) Hooks() Hooks
- func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState)
- func (k *Keeper) IterateCurrencyPairs(ctx context.Context, ...) error
- func (k *Keeper) NextCurrencyPairID(ctx context.Context) (uint64, error)
- func (k *Keeper) RemoveCurrencyPair(ctx context.Context, cp connecttypes.CurrencyPair) error
- func (k *Keeper) SetPriceForCurrencyPair(ctx context.Context, cp connecttypes.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 ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks is a wrapper struct around Keeper.
func (Hooks) AfterMarketCreated ¶
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 ¶
AfterMarketGenesis verifies that all markets set in the x/marketmap genesis are registered in the x/oracle module.
func (Hooks) AfterMarketRemoved ¶
AfterMarketRemoved is the marketmap hook for x/oracle that is run after a market is removed in the marketmap.
func (Hooks) AfterMarketUpdated ¶
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 ¶
BeginBlocker is called at the beginning of every block. It resets the count of removed currency pairs.
func (*Keeper) CreateCurrencyPair ¶
func (k *Keeper) CreateCurrencyPair(ctx context.Context, cp connecttypes.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 context.Context) []connecttypes.CurrencyPair
GetAllCurrencyPairs returns all CurrencyPairs that have currently been stored to state.
func (*Keeper) GetCurrencyPairFromID ¶
func (k *Keeper) GetCurrencyPairFromID(ctx context.Context, id uint64) (connecttypes.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 ¶
func (k *Keeper) GetCurrencyPairMapping(ctx context.Context) (map[uint64]connecttypes.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 ¶
func (k *Keeper) GetCurrencyPairMappingList(ctx context.Context) ([]types.CurrencyPairMapping, error)
GetCurrencyPairMappingList returns a CurrencyPair mapping by ID that have currently been stored to state as a list.
func (*Keeper) GetDecimalsForCurrencyPair ¶
func (k *Keeper) GetDecimalsForCurrencyPair(ctx context.Context, cp connecttypes.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 ¶
func (k *Keeper) GetIDForCurrencyPair(ctx context.Context, cp connecttypes.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 context.Context, cp connecttypes.CurrencyPair) (uint64, error)
GetNonceForCurrencyPair returns the nonce for a given CurrencyPair. If one has not been stored, return an error.
func (*Keeper) GetNumCurrencyPairs ¶
GetNumCurrencyPairs returns the number of currency pairs currently in state.
func (*Keeper) GetNumRemovedCurrencyPairs ¶
GetNumRemovedCurrencyPairs gets the counter of removed currency pairs in the previous block.
func (*Keeper) GetPriceForCurrencyPair ¶
func (k *Keeper) GetPriceForCurrencyPair(ctx context.Context, cp connecttypes.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 context.Context, cp connecttypes.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 context.Context, cp connecttypes.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 context.Context, cb func(cp connecttypes.CurrencyPair, cps types.CurrencyPairState)) error
IterateCurrencyPairs iterates over all CurrencyPairs in the store, and executes a callback for each CurrencyPair.
func (*Keeper) NextCurrencyPairID ¶
NextCurrencyPairID returns the next ID to be assigned to a currency-pair.
func (*Keeper) RemoveCurrencyPair ¶
func (k *Keeper) RemoveCurrencyPair(ctx context.Context, cp connecttypes.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 context.Context, cp connecttypes.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.