openoracle

package
v0.0.0-...-b399be2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(oresp OracleResponse) ([]string, map[string]string, error)

Types

type OraclePrice

type OraclePrice struct {
	// The asset which is priced
	Asset string
	// The asset value, a string reprenting an unsigned integer.
	Price string
	// The timestamp at which this specific price was valid
	Timestamp uint64
}

An oracle price input

type OracleRequest

type OracleRequest struct {
	// The Timestamp at which this payload is valid
	Timestamp uint64 `json:"timestamp"`
	// The list of price to bundle
	Prices []OraclePrice `json:"oracle_prices"`
}

A request to build an open oracle payload

func (*OracleRequest) IntoOpenOracle

func (oreq *OracleRequest) IntoOpenOracle(privKey *ecdsa.PrivateKey) (*OracleResponse, error)

type OracleResponse

type OracleResponse struct {
	// the timestamp at which this payload was emitted
	Timestamp string `json:"timestamp"`
	// a list of ABI encoded message containing the price feeds
	Messages []string `json:"messages"`
	// the matching signatures for the list of messages contains the price feeds
	Signatures []string `json:"signatures"`
	// An option decoded map of asset -> price
	Prices map[string]string `json:"prices"`
}

The open oracle payload. every messages contain the prices and a timestamps abi encoded. A valid payload will contain a valid signature for every message bundles. or every entry in the Message array, an corresponding signature must be available at the same position in the Signatures array. e.g: - Message[0] -> Signatures[0] - Message[n] -> Signatures[n]

The ABI encode message, contains the following values: - "kind", of type string, here always `prices` - "timestamp", of type uint64, which is the time at which this specific price was emitted - "key", of type string, which here is always a asset name (e.g: BTC, ETH, VEGA) - "value", of type uint256, always as price.

Decoding the message can be found in the Verify function below.

func Unmarshal

func Unmarshal(payload []byte) (*OracleResponse, error)

func UnmarshalVerify

func UnmarshalVerify(payload []byte, address string) (*OracleResponse, error)

UnmarshalVerify will unmarshal a json raw payload into and OracleResponse if the unmarshal is successful then the content is verified

Jump to

Keyboard shortcuts

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