types

package
v0.0.2-0...-13a971e Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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
)
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 (
	// TypeMsgPostPrice type of PostPrice msg
	TypeMsgPostPrice = "post_price"
)

Variables

View Source
var (
	// KeyAssets store key for assets
	KeyAssets   = []byte("oracleassets")
	KeyNominees = []byte("oraclenominees")
)
View Source
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

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"`
	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 NewAsset

func NewAsset(
	assetCode, baseAsset, quoteAsset 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"`
	Price     sdk.Dec `json:"price" yaml:"price"`
}

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"`
	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"`
}

MsgAddAsset struct representing a new nominee based oracle

func NewMsgAddAsset

func NewMsgAddAsset(
	nominee sdk.AccAddress,
	denom string,
	asset Asset,
) MsgAddAsset

NewMsgAddAsset creates a new add oracle message

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.Dec        `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.Dec,
	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) 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   []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 DefaultParams

func DefaultParams() Params

DefaultParams default params for oracle

func NewParams

func NewParams(assets []Asset, nominees []string) 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 PostedPrice

type PostedPrice struct {
	AssetCode     string         `json:"asset_code" yaml:"asset_code"`
	OracleAddress sdk.AccAddress `json:"oracle_address" yaml:"oracle_address"`
	Price         sdk.Dec        `json:"price" yaml:"price"`
	Expiry        time.Time      `json:"expiry" yaml:"expiry"`
}

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 []string

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