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

client.gno

2.92 Kb · 68 lines
 1package core
 2
 3import (
 4	"gno.land/p/onbloc/ibc/union/lightclient"
 5	"gno.land/p/onbloc/ibc/union/types"
 6	"gno.land/r/onbloc/ibc/union/access"
 7)
 8
 9// HasClient reports whether a light client is registered for a client type.
10func HasClient(clientType types.ClientType) bool {
11	return mustGetImpl().HasClient(clientType)
12}
13
14// RegisterClient registers a light client implementation for a client type,
15// delegating to the installed impl.
16//
17// Union reference:
18// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L849-L865
19func RegisterClient(cur realm, clientType types.ClientType, clientImpl lightclient.ClientImpl) {
20	access.AssertCanCall(0, cur, SelectorRegisterClient)
21	mustGetImpl().RegisterClient(0, cur, clientType, clientImpl)
22}
23
24// CreateClient assigns a client id, stores the submitted state bytes, then lets
25// the light client verify creation against that freshly stored state.
26//
27// Union references:
28// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L867-L903
29// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L905-L972
30func CreateClient(cur realm, msg types.MsgCreateClient) {
31	access.AssertCanCall(0, cur, SelectorCreateClient)
32	mustGetImpl().CreateClient(0, cur, msg)
33}
34
35// UpdateClient verifies a client message against the light client object, which
36// updates its own state, and mirrors the resulting state bytes for queries and
37// counterparty proofs.
38//
39// Union reference:
40// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L975-L1046
41func UpdateClient(cur realm, msg types.MsgUpdateClient) {
42	access.AssertCanCall(0, cur, SelectorUpdateClient)
43	mustGetImpl().UpdateClient(0, cur, msg)
44}
45
46// ForceUpdateClient re-initializes a client from submitted state bytes,
47// bypassing header proof verification.
48//
49// It is restricted to the admin and recovers expired or otherwise unrecoverable
50// clients. The registered light client type for the existing client is reused.
51//
52// Union references:
53// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L146-L166
54// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L905-L972
55func ForceUpdateClient(cur realm, msg types.MsgForceUpdateClient) {
56	access.AssertCanCall(0, cur, SelectorForceUpdateClient)
57	mustGetImpl().ForceUpdateClient(0, cur, msg)
58}
59
60// Misbehaviour freezes a client after a valid misbehaviour proof, delegating to
61// the installed impl.
62//
63// Union reference:
64// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/core/src/contract.rs#L1048-L1093
65func Misbehaviour(cur realm, msg types.MsgMisbehaviour) {
66	access.AssertCanCall(0, cur, SelectorMisbehaviour)
67	mustGetImpl().Misbehaviour(0, cur, msg)
68}