-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
52 lines (43 loc) · 1.31 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mercury
import (
"context"
"math/big"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
)
type ObsResult[T any] struct {
Val T
Err error
}
type OnchainConfig struct {
// applies to all values: price, bid and ask
Min *big.Int
Max *big.Int
}
type OnchainConfigCodec interface {
Encode(OnchainConfig) ([]byte, error)
Decode([]byte) (OnchainConfig, error)
}
type ServerFetcher interface {
// FetchInitialMaxFinalizedBlockNumber should fetch the initial max finalized block number
FetchInitialMaxFinalizedBlockNumber(context.Context) (*int64, error)
LatestPrice(ctx context.Context, feedID [32]byte) (*big.Int, error)
LatestTimestamp(context.Context) (int64, error)
}
type Transmitter interface {
ServerFetcher
// NOTE: Mercury doesn't actually transmit on-chain, so there is no
// "contract" involved with the transmitter.
// - Transmit should be implemented and send to Mercury server
// - LatestConfigDigestAndEpoch is a stub method, does not need to do anything
// - FromAccount() should return CSA public key
ocrtypes.ContractTransmitter
}
type ChainReader interface {
// LatestHeads returns an ordered list of the latest specified number of heads
LatestHeads(context.Context, int) ([]Head, error)
}
type Head struct {
Number uint64
Hash []byte
Timestamp uint64
}