Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

types.gno

1.83 Kb · 64 lines
 1package lightclient
 2
 3import "gno.land/p/onbloc/ibc/union/types"
 4
 5// ClientImpl is the registered light client implementation for a client type.
 6// It mirrors Union's ClientRegistry value: Union stores a client contract
 7// address, while this Gno core stores a constructor function that instantiates
 8// the live light client for a submitted client state.
 9// Union references:
10// https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/core/src/contract.rs#L849-L865
11type ClientImpl func(clientStateBytes, consensusStateBytes []byte) (Interface, error)
12
13type Status string
14
15const (
16	Active Status = "Active"
17
18	Frozen Status = "Frozen"
19
20	Expired Status = "Expired"
21
22	Unknown Status = "Unknown"
23
24	Unauthorized Status = "Unauthorized"
25)
26
27func (s Status) ToType() types.Status {
28	switch s {
29	case Active:
30		return types.StatusActive
31	case Expired:
32		return types.StatusExpired
33	case Frozen:
34		return types.StatusFrozen
35	default:
36		return types.StatusUnknown
37	}
38}
39
40type Interface interface {
41	VerifyMembership(height uint64, key []byte, proof []byte, value []byte) error
42
43	VerifyNonMembership(height uint64, key []byte, proof []byte) error
44
45	GetTimestamp() types.Timestamp
46
47	// GetTimestampAtHeight returns the consensus timestamp recorded at a specific
48	// height. Packet timeout verification needs the counterparty timestamp at the
49	// proof height, not just the latest. Returns an error when no consensus state
50	// exists at the height.
51	GetTimestampAtHeight(height uint64) (types.Timestamp, error)
52
53	GetLatestHeight() uint64
54
55	GetCounterpartyChainID() string
56
57	Status() Status
58
59	VerifyHeader(caller address, header []byte, relayer address) (types.StateUpdate, error)
60
61	VerifyCreation(caller address, relayer address) (types.ClientCreationResult, error)
62
63	Misbehaviour(caller address, misbehaviour []byte, relayer address) ([]byte, error)
64}