Documentation
¶
Index ¶
- Constants
- Variables
- func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error
- func ErrExistingAsset(codespace sdk.CodespaceType) sdk.Error
- func ErrExpired(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidAsset(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidOracle(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateAddress(address string) (sdk.AccAddress, error)
- func ValidateGenesis(data GenesisState) error
- type Asset
- type Assets
- type CurrentPrice
- type GenesisState
- type MsgAddAsset
- type MsgAddOracle
- type MsgPostPrice
- type MsgSetAsset
- type MsgSetOracles
- type Oracle
- type Oracles
- type ParamSubspace
- type Params
- type PendingPriceAsset
- type PostedPrice
- type QueryAssetsResp
- type QueryRawPricesResp
- type SortDecs
Constants ¶
const ( // DefaultCodespace codespace for the module DefaultCodespace sdk.CodespaceType = ModuleName // CodeEmptyInput error code for empty input errors CodeEmptyInput sdk.CodeType = 1 // CodeExpired error code for expired prices CodeExpired sdk.CodeType = 2 // CodeInvalidPrice error code for all input prices expired CodeInvalidPrice sdk.CodeType = 3 // CodeInvalidAsset error code for invalid asset CodeInvalidAsset sdk.CodeType = 4 // CodeInvalidOracle error code for invalid oracle CodeInvalidOracle sdk.CodeType = 5 )
const ( // ModuleKey is the name of the module ModuleName = "oracle" // StoreKey is the store key string for gov StoreKey = ModuleName // RouterKey is the message route for gov RouterKey = ModuleName // QuerierRoute is the querier route for gov QuerierRoute = ModuleName // Parameter store default namestore DefaultParamspace = ModuleName // Store prefix for the raw oracle of an asset RawPriceFeedPrefix = StoreKey + ":raw:" // Store prefix for the current price of an asset CurrentPricePrefix = StoreKey + ":currentprice:" // Store Prefix for the assets in the oracle system AssetPrefix = StoreKey + ":assets" // OraclePrefix store prefix for the oracle accounts OraclePrefix = StoreKey + ":oracles" )
const ( // QueryCurrentPrice command for current price queries QueryCurrentPrice = "price" // QueryRawPrices command for raw price queries QueryRawPrices = "rawprices" // QueryAssets command for assets query QueryAssets = "assets" )
const (
PriceBytesLimit = 8
)
const (
// TypeMsgPostPrice type of PostPrice msg
TypeMsgPostPrice = "post_price"
)
Variables ¶
var ( // KeyAssets store key for assets KeyAssets = []byte("oracleassets") KeyNominees = []byte("oraclenominees") )
var ModuleCdc *codec.Codec
generic sealed codec to be used throughout module
Functions ¶
func ErrEmptyInput ¶
func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error
ErrEmptyInput Error constructor
func ErrExistingAsset ¶
func ErrExistingAsset(codespace sdk.CodespaceType) sdk.Error
ErrExistingAsset Error constructor for posted price messages for invalid assets
func ErrExpired ¶
func ErrExpired(codespace sdk.CodespaceType) sdk.Error
ErrExpired Error constructor for posted price messages with expired price
func ErrInvalidAsset ¶
func ErrInvalidAsset(codespace sdk.CodespaceType) sdk.Error
ErrInvalidAsset Error constructor for posted price messages for invalid assets
func ErrInvalidOracle ¶
func ErrInvalidOracle(codespace sdk.CodespaceType) sdk.Error
ErrInvalidOracle Error constructor for posted price messages for invalid oracles
func ErrNoValidPrice ¶
func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error
ErrNoValidPrice Error constructor for posted price messages with expired price
func ParamKeyTable ¶
ParamKeyTable Key declaration for parameters
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
func ValidateAddress ¶
func ValidateAddress(address string) (sdk.AccAddress, error)
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of genesis data returning an error for any failed validation criteria.
Types ¶
type Asset ¶
type Asset struct {
AssetCode string `json:"asset_code" yaml:"asset_code"`
BaseAsset string `json:"base_asset" yaml:"base_asset"`
QuoteAsset string `json:"quote_asset" yaml:"quote_asset"`
Oracles Oracles `json:"oracles" yaml:"oracles"`
Active bool `json:"active" yaml:"active"`
}
Asset struct that represents an asset in the oracle
func (Asset) ValidateBasic ¶
ValidateBasic does a simple validation check that doesn't require access to any other information.
type CurrentPrice ¶
type CurrentPrice struct {
AssetCode string `json:"asset_code" yaml:"asset_code"`
Price sdk.Int `json:"price" yaml:"price"`
}
CurrentPrice struct that contains the metadata of a current price for a particular asset in the oracle module.
type GenesisState ¶
type GenesisState struct {
Params Params `json:"asset_params" yaml:"asset_params"`
PostedPrices []PostedPrice `json:"posted_prices" yaml:"posted_prices"`
}
GenesisState - oracle state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState defines default GenesisState for oracle
func NewGenesisState ¶
func NewGenesisState(p Params, pp []PostedPrice) GenesisState
NewGenesisState creates a new genesis state for the oracle module
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
Equal checks whether two gov GenesisState structs are equivalent
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
IsEmpty returns true if a GenesisState is empty
type MsgAddAsset ¶
type MsgAddAsset struct {
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
Asset Asset `json:"asset" yaml:"asset"`
}
func NewMsgAddAsset ¶
func NewMsgAddAsset( nominee sdk.AccAddress, denom string, asset Asset, ) MsgAddAsset
func (MsgAddAsset) GetSignBytes ¶
func (msg MsgAddAsset) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgAddAsset) GetSigners ¶
func (msg MsgAddAsset) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgAddAsset) ValidateBasic ¶
func (msg MsgAddAsset) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgAddOracle ¶
type MsgAddOracle struct {
Oracle sdk.AccAddress `json:"oracle" yaml:"oracle"`
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
}
MsgAddOracle struct representing a new nominee based oracle
func NewMsgAddOracle ¶
func NewMsgAddOracle( nominee sdk.AccAddress, denom string, oracle sdk.AccAddress, ) MsgAddOracle
MsgAddOracle creates a new add oracle message
func (MsgAddOracle) GetSignBytes ¶
func (msg MsgAddOracle) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgAddOracle) GetSigners ¶
func (msg MsgAddOracle) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgAddOracle) ValidateBasic ¶
func (msg MsgAddOracle) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgPostPrice ¶
type MsgPostPrice struct {
From sdk.AccAddress `json:"from" yaml:"from"`
AssetCode string `json:"asset_code" yaml:"asset_code"`
Price sdk.Int `json:"price" yaml:"price"`
Expiry time.Time `json:"expiry" yaml:"expiry"`
}
MsgPostPrice struct representing a posted price message. Used by oracles to input prices to the oracle
func NewMsgPostPrice ¶
func NewMsgPostPrice( from sdk.AccAddress, assetCode string, price sdk.Int, expiry time.Time) MsgPostPrice
NewMsgPostPrice creates a new post price msg
func (MsgPostPrice) GetSignBytes ¶
func (msg MsgPostPrice) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgPostPrice) GetSigners ¶
func (msg MsgPostPrice) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgPostPrice) ValidateBasic ¶
func (msg MsgPostPrice) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgSetAsset ¶
type MsgSetAsset struct {
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
Asset Asset `json:"asset" yaml:"asset"`
}
MsgSetAsset struct representing a new nominee based oracle
func NewMsgSetAsset ¶
func NewMsgSetAsset( nominee sdk.AccAddress, denom string, asset Asset, ) MsgSetAsset
NewMsgSetAsset creates a new add oracle message
func (MsgSetAsset) GetSignBytes ¶
func (msg MsgSetAsset) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgSetAsset) GetSigners ¶
func (msg MsgSetAsset) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgSetAsset) ValidateBasic ¶
func (msg MsgSetAsset) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgSetOracles ¶
type MsgSetOracles struct {
Oracles Oracles `json:"oracles" yaml:"oracles"`
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
}
MsgSetOracle struct representing a new nominee based oracle
func NewMsgSetOracles ¶
func NewMsgSetOracles( nominee sdk.AccAddress, denom string, oracles Oracles, ) MsgSetOracles
MsgAddOracle creates a new add oracle message
func (MsgSetOracles) GetSignBytes ¶
func (msg MsgSetOracles) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgSetOracles) GetSigners ¶
func (msg MsgSetOracles) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgSetOracles) ValidateBasic ¶
func (msg MsgSetOracles) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type Oracle ¶
type Oracle struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
}
Oracle struct that documents which address an oracle is using
func NewOracle ¶
func NewOracle(address sdk.AccAddress) Oracle
type ParamSubspace ¶
type ParamSubspace interface {
Get(ctx sdk.Context, key []byte, ptr interface{})
Set(ctx sdk.Context, key []byte, param interface{})
}
ParamSubspace defines the expected Subspace interface for parameters
type Params ¶
type Params struct {
Assets []Asset `json:"assets" yaml:"assets"` // Array containing the assets supported by the oracle
Nominees []string `json:"nominees" yaml:"nominees"`
}
Params params for oracle. Can be altered via governance
func (Params) ParamSetPairs ¶
func (p Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of oracle module's parameters.
type PendingPriceAsset ¶
type PendingPriceAsset struct {
AssetCode string `json:"asset_code"`
}
PendingPriceAsset struct that contains the info about the asset which price is still to be determined
type PostedPrice ¶
type PostedPrice struct {
AssetCode string `json:"asset_code" yaml:"asset_code"`
OracleAddress sdk.AccAddress `json:"oracle_address" yaml:"oracle_address"`
Price sdk.Int `json:"price" yaml:"price"`
Expiry time.Time `json:"expiry" yaml:"expiry"`
}
PostedPrice struct represented a price for an asset posted by a specific oracle
type QueryRawPricesResp ¶
type QueryRawPricesResp []string
QueryRawPricesResp response to a rawprice query
func (QueryRawPricesResp) String ¶
func (n QueryRawPricesResp) String() string
implement fmt.Stringer