types

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = ModuleName

	CodeEmptyInput        sdk.CodeType = 1
	CodeExpired           sdk.CodeType = 2
	CodeInvalidPrice      sdk.CodeType = 3
	CodeInvalidAsset      sdk.CodeType = 4
	CodeInvalidOracle     sdk.CodeType = 5
	CodeInvalidReceivedAt sdk.CodeType = 6
)
View Source
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"
)
View Source
const (
	// QueryCurrentPrice command for current price queries
	QueryCurrentPrice = "price"
	// QueryRawPrices command for raw price queries
	QueryRawPrices = "rawprices"
	// QueryAssets command for assets query
	QueryAssets = "assets"
)
View Source
const (
	PriceBytesLimit = 8
)
View Source
const (
	// TypeMsgPostPrice type of PostPrice msg
	TypeMsgPostPrice = "post_price"
)

Variables

View Source
var (
	// KeyAssets store key for assets
	KeyAssets    = []byte("oracleassets")
	KeyNominees  = []byte("oraclenominees")
	KeyPostPrice = []byte("oraclepostprice")
)
View Source
var ModuleCdc *codec.Codec

generic sealed codec to be used throughout module

Functions

func ErrEmptyInput

func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error

Not used

func ErrExistingAsset

func ErrExistingAsset(codespace sdk.CodespaceType) sdk.Error

Asset already exists

func ErrExpired

func ErrExpired(codespace sdk.CodespaceType) sdk.Error

New PostPrice is expired

func ErrInvalidAsset

func ErrInvalidAsset(codespace sdk.CodespaceType) sdk.Error

Asset not found

func ErrInvalidOracle

func ErrInvalidOracle(codespace sdk.CodespaceType) sdk.Error

Oracle not found

func ErrInvalidReceivedAt

func ErrInvalidReceivedAt(codespace sdk.CodespaceType, comment string) sdk.Error

New PostPrice ReceivedAt field is invalid

func ErrNoValidPrice

func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error

Not used

func GetRawPricesKey

func GetRawPricesKey(assetCode string, blockHeight int64) []byte

Get a key to store PostedPrices for specific assetCode and blockHeight

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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" example:"dfi"`
	Oracles   Oracles `json:"oracles" yaml:"oracles"` // List of registered RawPrice sources
	Active    bool    `json:"active" yaml:"active"`   // Not used ATM
}

Asset struct that represents an asset in the oracle

func NewAsset

func NewAsset(
	assetCode string,
	oracles Oracles,
	active bool,
) Asset

NewAsset creates a new asset

func (Asset) String

func (a Asset) String() string

implement fmt.Stringer

func (Asset) ValidateBasic

func (a Asset) ValidateBasic() sdk.Error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type Assets

type Assets []Asset

Assets array type for oracle

func (Assets) String

func (as Assets) String() string

String implements fmt.Stringer

type CurrentPrice

type CurrentPrice struct {
	AssetCode  string    `json:"asset_code" yaml:"asset_code" example:"dfi"` // Denom
	Price      sdk.Int   `json:"price" yaml:"price" swaggertype:"string" example:"1000"`
	ReceivedAt time.Time `json:"received_at" yaml:"received_at" format:"RFC 3339" example:"2020-03-27T13:45:15.293426Z"` // Timestamp Price createdAt
}

CurrentPrice struct that contains the metadata of a current price for a particular asset in the oracle module.

func (CurrentPrice) String

func (cp CurrentPrice) String() string

implement fmt.Stringer

type GenesisState

type GenesisState struct {
	Params Params `json:"asset_params" yaml:"asset_params"`
}

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) 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) Route

func (msg MsgAddAsset) Route() string

Route Implements Msg.

func (MsgAddAsset) Type

func (msg MsgAddAsset) Type() string

Type 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) Route

func (msg MsgAddOracle) Route() string

Route Implements Msg.

func (MsgAddOracle) Type

func (msg MsgAddOracle) Type() string

Type 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"`
	ReceivedAt time.Time      `json:"received_at" yaml:"received_at"`
}

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,
	receivedAt 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) Route

func (msg MsgPostPrice) Route() string

Route Implements Msg.

func (MsgPostPrice) Type

func (msg MsgPostPrice) Type() string

Type 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) Route

func (msg MsgSetAsset) Route() string

Route Implements Msg.

func (MsgSetAsset) Type

func (msg MsgSetAsset) Type() string

Type 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) Route

func (msg MsgSetOracles) Route() string

Route Implements Msg.

func (MsgSetOracles) Type

func (msg MsgSetOracles) Type() string

Type 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

func (Oracle) String

func (o Oracle) String() string

String implements fmt.Stringer

type Oracles

type Oracles []Oracle

Oracles array type for oracle

func ParseOracles

func ParseOracles(addresses string) (Oracles, error)

func (Oracles) String

func (os Oracles) String() string

String implements fmt.Stringer

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    Assets          `json:"assets" yaml:"assets"` //  Array containing the assets supported by the oracle
	Nominees  []string        `json:"nominees" yaml:"nominees"`
	PostPrice PostPriceParams `json:"post_price" yaml:"post_price"`
}

Params params for oracle. Can be altered via governance

func DefaultParams

func DefaultParams() Params

DefaultParams default params for oracle

func NewParams

func NewParams(assets []Asset, nominees []string, postPrice PostPriceParams) Params

NewParams creates a new AssetParams object

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.

func (Params) String

func (p Params) String() string

String implements fmt.stringer

func (Params) Validate

func (p Params) Validate() error

Validate ensure that params have valid values

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

func (PendingPriceAsset) String

func (a PendingPriceAsset) String() string

implement fmt.Stringer

type PostPriceParams

type PostPriceParams struct {
	// allowed timestamp difference between current block time and oracle's receivedAt (0 - disabled) [sec]
	ReceivedAtDiffInS uint32 `json:"received_at_diff_in_s" yaml:"received_at_diff_in_s"`
}

Posting rawPrices from oracles configuration params

func (PostPriceParams) String

func (p PostPriceParams) String() string

type PostedPrice

type PostedPrice struct {
	AssetCode     string         `json:"asset_code" yaml:"asset_code" example:"dfi"`                                                                        // Denom
	OracleAddress sdk.AccAddress `json:"oracle_address" yaml:"oracle_address" swaggertype:"string" example:"wallet13jyjuz3kkdvqw8u4qfkwd94emdl3vx394kn07h"` // Price source
	Price         sdk.Int        `json:"price" yaml:"price" swaggertype:"string" example:"1000"`
	ReceivedAt    time.Time      `json:"received_at" yaml:"received_at" format:"RFC 3339" example:"2020-03-27T13:45:15.293426Z"` // Timestamp Price createdAt
}

PostedPrice struct represented a price for an asset posted by a specific oracle

func (PostedPrice) String

func (pp PostedPrice) String() string

implement fmt.Stringer

type QueryAssetsResp

type QueryAssetsResp []string

QueryAssetsResp response to a assets query

func (QueryAssetsResp) String

func (n QueryAssetsResp) String() string

implement fmt.Stringer

type QueryRawPricesResp

type QueryRawPricesResp []PostedPrice

QueryRawPricesResp response to a rawprice query

func (QueryRawPricesResp) String

func (n QueryRawPricesResp) String() string

implement fmt.Stringer

type SortDecs

type SortDecs []sdk.Dec

SortDecs provides the interface needed to sort sdk.Dec slices

func (SortDecs) Len

func (a SortDecs) Len() int

func (SortDecs) Less

func (a SortDecs) Less(i, j int) bool

func (SortDecs) Swap

func (a SortDecs) Swap(i, j int)

Jump to

Keyboard shortcuts

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