chronicle

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MedianPricePrecision = 18

MedianPricePrecision is the precision of the price value in the Median contract as a number of decimal places after the decimal point.

View Source
const ScribePricePrecision = 18

ScribePricePrecision is the precision of the price value in the Scribe contract as a number of decimal places after the decimal point.

Variables

This section is empty.

Functions

func ConstructMedianPokeMessage

func ConstructMedianPokeMessage(wat string, val *bn.DecFloatPointNumber, age time.Time) []byte

ConstructMedianPokeMessage returns the message expected to be signed via ECDSA for calling Median.poke method.

The message structure is defined as: H(val ‖ age ‖ wat)

Where: - val: a price value - age: a time when the price was observed - wat: an asset name

func ConstructScribeOpPokeMessage

func ConstructScribeOpPokeMessage(wat string, pokeData PokeData, schnorrData SchnorrData, feedIDs FeedIDs) []byte

ConstructScribeOpPokeMessage returns the message expected to be signed via ECDSA for calling OpScribe.opPoke method.

The message structure is defined as: H(wat ‖ val ‖ age ‖ signature ‖ commitment ‖ signersBlob)

Where: - wat: an asset name - val: a price value - age: a time when the price was observed - signature: a Schnorr signature - commitment: a Schnorr commitment - feedIDs: a feed IDs that are participated in the signing

func ConstructScribePokeMessage

func ConstructScribePokeMessage(wat string, pokeData PokeData) []byte

ConstructScribePokeMessage returns the message expected to be signed via ECDSA for calling Scribe.poke method.

The message is defined as: H(wat ‖ val ‖ age)

Where: - wat: an asset name - val: a price value - age: a time when the price was observed

Types

type Chainlog

type Chainlog struct {
	// contains filtered or unexported fields
}

Chainlog allows interacting with the Chainlog contract.

func NewChainlog

func NewChainlog(client rpc.RPC, address types.Address) *Chainlog

NewChainlog creates a new Chainlog instance.

func (*Chainlog) Address

func (w *Chainlog) Address() types.Address

Address returns the address of the Chainlog contract.

func (*Chainlog) Client added in v0.23.0

func (w *Chainlog) Client() rpc.RPC

Client returns the RPC client used to interact with the Chainlog.

func (*Chainlog) TryGet

TryGet returns the address of the contract that implements the given wat.

type ConfigResult added in v0.23.0

type ConfigResult struct {
	Bar   int     `abi:"bar"`
	Bloom FeedIDs `abi:"bloom"`
}

type Deployment added in v0.23.0

type Deployment struct {
	Address types.Address
	ChainID uint64
	Feeds   []types.Address
	Wat     string
	Bar     int
}

type ECDSADataStruct

type ECDSADataStruct struct {
	V uint8    `abi:"v"`
	R *big.Int `abi:"r"`
	S *big.Int `abi:"s"`
}

ECDSADataStruct represents the ECDSAData struct in the IScribe interface.

type FeedIDs added in v0.23.0

type FeedIDs [256]bool

FeedIDs contains list of feed IDs. A feed ID is the first byte of the feed address.

func FeedIDsFromAddresses added in v0.23.0

func FeedIDsFromAddresses(addresses []types.Address) FeedIDs

FeedIDsFromAddresses returns a FeedIDs from a list of feed addresses.

func FeedIDsFromIDs added in v0.23.0

func FeedIDsFromIDs(ids []byte) FeedIDs

FeedIDsFromIDs returns a FeedIDs from a list of feed IDs.

func (*FeedIDs) Add added in v0.23.0

func (b *FeedIDs) Add(address ...types.Address)

Add adds the given address to the feed IDs.

func (FeedIDs) FeedIDs added in v0.23.0

func (b FeedIDs) FeedIDs() []byte

FeedIDs returns a feed IDs as a byte slice. Each byte in the slice represents a feed ID.

func (FeedIDs) Has added in v0.23.0

func (b FeedIDs) Has(address ...types.Address) bool

Has returns true if the given address is included in the feed IDs.

func (*FeedIDs) SetFeedIDs added in v0.23.0

func (b *FeedIDs) SetFeedIDs(ids []byte)

SetFeedIDs sets the feed IDs from a byte slice.

type FeedRegistry added in v0.23.0

type FeedRegistry struct {
	// contains filtered or unexported fields
}

FeedRegistry allows interacting with the FeedRegistry contract.

func NewFeedRegistry added in v0.23.0

func NewFeedRegistry(client rpc.RPC, address types.Address) *FeedRegistry

NewFeedRegistry creates a new FeedRegistry instance.

func (*FeedRegistry) Address added in v0.23.0

func (w *FeedRegistry) Address() types.Address

Address returns the address of the FeedRegistry contract.

func (*FeedRegistry) Client added in v0.23.0

func (w *FeedRegistry) Client() rpc.RPC

Client returns the RPC client used to interact with the FeedRegistry.

func (*FeedRegistry) FeedExists added in v0.23.0

func (w *FeedRegistry) FeedExists(feed types.Address) contract.TypedSelfCaller[bool]

FeedExists returns whether address `feed` is a feed.

func (*FeedRegistry) Feeds added in v0.23.0

Feeds returns all of Chronicle Protocol's feeds.

type Median

type Median struct {
	// contains filtered or unexported fields
}

Median allows interacting with the Median contract.

func NewMedian

func NewMedian(client rpc.RPC, address types.Address) *Median

NewMedian creates a new Median instance.

func (*Median) Address

func (m *Median) Address() types.Address

Address returns the address of the Median contract.

func (*Median) Age

Age returns the current median price age.

func (*Median) Bar

func (m *Median) Bar() contract.TypedSelfCaller[int]

Bar returns the median price bar.

func (*Median) Client

func (m *Median) Client() rpc.RPC

Client returns the RPC client used to interact with the Median.

func (*Median) Poke

Poke updates the median price value.

func (*Median) Val

Val returns the current median price value.

func (*Median) Wat

Wat returns the median price asset name.

type MedianVal

type MedianVal struct {
	Val *bn.DecFixedPointNumber
	Age time.Time
	V   uint8
	R   *big.Int
	S   *big.Int
}

type OpScribe

type OpScribe struct {
	Scribe
}

OpScribe allows interacting with the OpScribe contract.

func NewOpScribe

func NewOpScribe(client rpc.RPC, address types.Address) *OpScribe

NewOpScribe creates a new OpScribe instance.

func (*OpScribe) Address added in v0.23.0

func (s *OpScribe) Address() types.Address

Address returns the address of the OpScribe contract.

func (*OpScribe) Client added in v0.23.0

func (s *OpScribe) Client() rpc.RPC

Client returns the RPC client used to interact with the OpScribe.

func (*OpScribe) OpChallengePeriod

func (s *OpScribe) OpChallengePeriod() contract.TypedSelfCaller[time.Duration]

OpChallengePeriod returns the challenge period for the OpScribe contract.

func (*OpScribe) OpPoke

func (s *OpScribe) OpPoke(pokeData PokeData, schnorrData SchnorrData, ecdsaData types.Signature) contract.SelfTransactableCaller

OpPoke updates the optimistic poke data in the contract.

func (*OpScribe) Read

func (s *OpScribe) Read(ctx context.Context) (PokeData, error)

Read reads the PokeData from the contract using the current time as the reference time for determining if the latest optimistic poke is finalized.

func (*OpScribe) ReadAt

func (s *OpScribe) ReadAt(ctx context.Context, readTime time.Time) (PokeData, bool, error)

ReadAt reads the PokeData from the contract using the given readTime as the reference time for determining if the latest optimistic poke is finalized.

If the latest optimistic poke is finalized, the returned PokeData will be the latest optimistic poke. Otherwise, the returned PokeData will be the latest poke.

The returned boolean indicates if the latest optimistic poke is finalized.

func (*OpScribe) ReadNext

func (s *OpScribe) ReadNext(ctx context.Context) (PokeData, bool, error)

ReadNext reads the next poke data from the contract without checking if the latest optimistic poke is already finalized.

func (*OpScribe) ReadNextAt

func (s *OpScribe) ReadNextAt(ctx context.Context, readTime time.Time) (PokeData, bool, error)

ReadNextAt reads the next poke data from the contract without checking if the latest optimistic poke is already finalized.

The returned boolean indicates if the latest optimistic poke is finalized.

func (*OpScribe) ReadOpPokeData

func (s *OpScribe) ReadOpPokeData(ctx context.Context) (PokeData, error)

ReadOpPokeData reads the PokeData from the last optimistic poke.

func (*OpScribe) ReadPokeData

func (s *OpScribe) ReadPokeData(ctx context.Context) (PokeData, error)

ReadPokeData reads the PokeData from the last non-optimistic poke.

type PokeData

type PokeData struct {
	Val *bn.DecFixedPointNumber
	Age time.Time
}

type PokeDataStruct

type PokeDataStruct struct {
	Val *big.Int `abi:"val"`
	Age uint32   `abi:"age"`
}

PokeDataStruct represents the PokeData struct in the IScribe interface.

type Registry added in v0.23.0

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a wrapper around the FeedRegistry and WatRegistry contracts.

It provides a single interface for querying on-chain registries.

func NewRegistry added in v0.23.0

func NewRegistry(feedRegistry *FeedRegistry, watRegistry *WatRegistry) (*Registry, error)

func (*Registry) Deployments added in v0.23.0

func (r *Registry) Deployments(ctx context.Context) ([]Deployment, error)

Deployments returns a list of all deployed contracts from the WatRegistry.

type SchnorrData

type SchnorrData struct {
	Signature  *big.Int
	Commitment types.Address
	FeedIDs    FeedIDs
}

type SchnorrDataStruct

type SchnorrDataStruct struct {
	Signature  *big.Int      `abi:"signature"`
	Commitment types.Address `abi:"commitment"`
	FeedIDs    []byte        `abi:"feedIDs"`
}

SchnorrDataStruct represents the SchnorrData struct in the IScribe interface.

type Scribe

type Scribe struct {
	// contains filtered or unexported fields
}

Scribe allows interacting with the Scribe contract.

func NewScribe

func NewScribe(client rpc.RPC, address types.Address) *Scribe

NewScribe creates a new Scribe instance.

func (*Scribe) Address

func (s *Scribe) Address() types.Address

Address returns the address of the Scribe contract.

func (*Scribe) Bar

func (s *Scribe) Bar() contract.TypedSelfCaller[int]

Bar returns the bar value from the contract.

func (*Scribe) Client

func (s *Scribe) Client() rpc.RPC

Client returns the RPC client used to interact with the Scribe.

func (*Scribe) Feeds

Feeds returns Chronicle Protocol's feeds that are lifted in the contract.

func (*Scribe) Poke

func (s *Scribe) Poke(pokeData PokeData, schnorrData SchnorrData) contract.SelfTransactableCaller

Poke updates the poke data in the contract.

func (*Scribe) Read

func (s *Scribe) Read(ctx context.Context) (PokeData, error)

Read reads the poke data from the contract.

func (*Scribe) Wat

Wat returns the wat value from the contract.

type TryGetResult

type TryGetResult struct {
	Ok      bool          `abi:"ok"`
	Address types.Address `abi:"address"`
}

type WatRegistry

type WatRegistry struct {
	// contains filtered or unexported fields
}

WatRegistry allows interacting with the WatRegistry contract.

func NewWatRegistry

func NewWatRegistry(client rpc.RPC, address types.Address) *WatRegistry

NewWatRegistry creates a new WatRegistry instance.

func (*WatRegistry) Address

func (w *WatRegistry) Address() types.Address

Address returns the address of the WatRegistry contract.

func (*WatRegistry) Chains added in v0.23.0

func (w *WatRegistry) Chains(wat string) contract.TypedSelfCaller[[]uint64]

Chains returns wat `wat`'s list of chain ids its deployed to.

func (*WatRegistry) Client added in v0.23.0

func (w *WatRegistry) Client() rpc.RPC

Client returns the RPC client used to interact with the WatRegistry

func (*WatRegistry) Config added in v0.23.0

Config returns wat `wat`'s configuration.

func (*WatRegistry) Deployment added in v0.23.0

func (w *WatRegistry) Deployment(wat string, chainID uint64) contract.TypedSelfCaller[types.Address]

Deployment returns wat `wat`'s deployment address for chain `chainId`.

func (*WatRegistry) Exists added in v0.23.0

Exists returns whether wat `wat` exists in registry.

func (*WatRegistry) Wats added in v0.23.0

Wats returns all of Chronicle Protocol's wat identifiers.

Jump to

Keyboard shortcuts

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