register.gno
0.81 Kb · 29 lines
1package cometbls
2
3import (
4 "gno.land/p/onbloc/ibc/union/lightclient"
5 cometblsp "gno.land/p/onbloc/ibc/union/lightclient/cometbls"
6 "gno.land/p/onbloc/ibc/union/types"
7 "gno.land/r/onbloc/ibc/union/core"
8)
9
10const ClientType = types.ClientType(cometblsp.ClientType)
11
12// RegisterClient registers the cometbls light client implementation with core.
13func RegisterClient(cur realm) {
14 core.RegisterClient(cross(cur), ClientType, newClientImpl)
15}
16
17func newClientImpl(clientStateBytes, consensusStateBytes []byte) (lightclient.Interface, error) {
18 clientState, err := cometblsp.DecodeClientState(clientStateBytes)
19 if err != nil {
20 return nil, err
21 }
22
23 consensusState, err := cometblsp.DecodeConsensusState(consensusStateBytes)
24 if err != nil {
25 return nil, err
26 }
27
28 return cometblsp.NewCometblsLightClient(clientState, consensusState)
29}