Search Apps Documentation Source Content File Folder Download Copy Actions Download

zz_create_client_example_filetest.gno

1.36 Kb · 47 lines
 1// PKGPATH: gno.land/r/aib/main
 2package main
 3
 4import (
 5	"crypto/sha256"
 6	"time"
 7
 8	"gno.land/p/aib/ibc/lightclient/tendermint"
 9	"gno.land/p/aib/ibc/types"
10	"gno.land/p/aib/ics23"
11	"gno.land/r/aib/ibc/core"
12)
13
14func main(cur realm) {
15	core.SetAdmin(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
16	core.AddRelayer(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
17	// CreateClient
18	var (
19		chainID      = "chain-id-2"  // XXX update
20		latestHeight = types.Height{ // XXX update
21			RevisionNumber: 2,
22			RevisionHeight: 100,
23		}
24		clientState = tendermint.ClientState{
25			ChainID:         chainID,
26			TrustLevel:      tendermint.Fraction{2, 3},
27			UnbondingPeriod: time.Hour * 3, // XXX update
28			TrustingPeriod:  time.Hour,     // XXX update
29			MaxClockDrift:   time.Hour,     // XXX update
30			LatestHeight:    latestHeight,
31			ProofSpecs:      ics23.GetSDKProofSpecs(),
32		}
33		apphash        = sha256.Sum256([]byte("apphash"))    // XXX update
34		valhash        = sha256.Sum256([]byte("validators")) // XXX update
35		timestamp      = time.Now()                          // XXX update
36		consensusState = tendermint.ConsensusState{
37			Timestamp:          timestamp,
38			Root:               tendermint.MerkleRoot{Hash: apphash[:]},
39			NextValidatorsHash: valhash[:],
40		}
41	)
42	id := core.CreateClient(cross(cur), clientState, consensusState)
43	println(id)
44}
45
46// Output:
47// 07-tendermint-1