Search Apps Documentation Source Content File Folder Download Copy Actions Download

zz_timeout_example_filetest.gno

4.19 Kb · 118 lines
  1// PKGPATH: gno.land/r/aib/main
  2package main
  3
  4import (
  5	"time"
  6
  7	"gno.land/p/aib/ibc/types"
  8	"gno.land/p/aib/ics23"
  9	"gno.land/r/aib/ibc/core"
 10)
 11
 12func main(cur realm) {
 13	// Timeout the packet
 14	specs := ics23.IavlSpec()
 15	timeoutPacket := types.MsgTimeout{
 16		Packet: types.Packet{
 17			Sequence:          42,                        //XXX update
 18			SourceClient:      "clientID",                //XXX update
 19			DestinationClient: "counterPartyID",          // XXX update
 20			TimeoutTimestamp:  uint64(time.Now().Unix()), // XXX update: must be the same as the timestamp of the send packet
 21			Payloads: []types.Payload{{
 22				SourcePort:      "appID", // XXX update
 23				DestinationPort: "appID", //XXX update
 24				Encoding:        "application/x-protobuf",
 25				Value:           []byte{}, // XXX update
 26				Version:         "v1",     // XXX update: version of app (transfer uses v1)
 27			}},
 28		},
 29		// Write the proof that no RecvPacket have been received by the counterparty
 30		// chain.
 31		// NOTE proof generated by go run -C ./cmd/gen-proof . MERKLE_PREFIX CLIENT_ID acknowledgement
 32		ProofUnreceived: []ics23.CommitmentProof{
 33
 34			// iavl proof
 35			ics23.CommitmentProof_Nonexist{
 36				Nonexist: &ics23.NonExistenceProof{
 37					Key: []byte("\x70\x72\x65\x66\x69\x78\x32\x30\x37\x2d\x74\x65\x6e\x64\x65\x72\x6d\x69\x6e\x74\x2d\x34\x32\x03\x00\x00\x00\x00\x00\x00\x00\x01"),
 38					Left: &ics23.ExistenceProof{
 39						Key:   []byte("\x50"),
 40						Value: []byte("\x50"),
 41						Leaf: &ics23.LeafOp{
 42							Hash:         specs.LeafSpec.Hash,
 43							PrehashKey:   specs.LeafSpec.PrehashKey,
 44							PrehashValue: specs.LeafSpec.PrehashValue,
 45							Length:       specs.LeafSpec.Length,
 46							Prefix:       []byte("\x00\x02\x02"),
 47						},
 48						Path: []*ics23.InnerOp{
 49							{
 50								Hash:   specs.InnerSpec.Hash,
 51								Prefix: []byte("\x04\x06\x02\x20"),
 52								Suffix: []byte("\x20\x79\x8e\x2c\xaa\x96\xfd\xfb\xa3\x76\xdd\xeb\x47\x99\x99\x54\xd2\xf4\x7e\x65\x16\x22\x64\xb0\x53\x6a\xb5\xdf\xf7\xfc\x0a\x2e\x07"),
 53							},
 54							{
 55								Hash:   specs.InnerSpec.Hash,
 56								Prefix: []byte("\x06\x0a\x02\x20\x9a\xf3\x7d\xd5\x95\xa0\x19\x08\x03\xb5\xe0\x5a\xae\xf4\x2a\xe3\xfa\xd4\x99\xe4\xfb\xe3\x7f\x7c\xd3\x1c\xad\xff\x22\xa9\xee\x74\x20"),
 57								Suffix: []byte(""),
 58							},
 59						},
 60					},
 61					Right: &ics23.ExistenceProof{
 62						Key:   []byte("\x72"),
 63						Value: []byte("\x72"),
 64						Leaf: &ics23.LeafOp{
 65							Hash:         specs.LeafSpec.Hash,
 66							PrehashKey:   specs.LeafSpec.PrehashKey,
 67							PrehashValue: specs.LeafSpec.PrehashValue,
 68							Length:       specs.LeafSpec.Length,
 69							Prefix:       []byte("\x00\x02\x02"),
 70						},
 71						Path: []*ics23.InnerOp{
 72							{
 73								Hash:   specs.InnerSpec.Hash,
 74								Prefix: []byte("\x02\x04\x02\x20"),
 75								Suffix: []byte("\x20\xa3\x03\x93\x0c\xa8\x83\x16\x18\xac\x7e\x4d\xdd\x10\x54\x6c\xfc\x36\x6f\xb7\x30\xd6\x63\x0c\x03\x0a\x97\x22\x6b\xbe\xfc\x69\x35"),
 76							},
 77							{
 78								Hash:   specs.InnerSpec.Hash,
 79								Prefix: []byte("\x04\x06\x02\x20\x35\xf8\xea\x80\x53\x90\xe0\x84\x85\x4f\x39\x9b\x42\xcc\xde\xae\xa3\x3a\x1d\xed\xc1\x15\x63\x8a\xc4\x8d\x06\x00\x63\x7d\xba\x1f\x20"),
 80								Suffix: []byte(""),
 81							},
 82							{
 83								Hash:   specs.InnerSpec.Hash,
 84								Prefix: []byte("\x06\x0a\x02\x20\x9a\xf3\x7d\xd5\x95\xa0\x19\x08\x03\xb5\xe0\x5a\xae\xf4\x2a\xe3\xfa\xd4\x99\xe4\xfb\xe3\x7f\x7c\xd3\x1c\xad\xff\x22\xa9\xee\x74\x20"),
 85								Suffix: []byte(""),
 86							},
 87						},
 88					},
 89				},
 90			},
 91
 92			// rootmulti proof
 93			ics23.CommitmentProof_Exist{
 94				Exist: &ics23.ExistenceProof{
 95					Key:   []byte("\x69\x61\x76\x6c\x53\x74\x6f\x72\x65\x4b\x65\x79"),
 96					Value: []byte("\x38\x22\xf3\x2f\x21\x66\x53\x63\x29\x4f\x96\xed\xda\x15\xa7\x81\x1a\x67\x6c\x2b\xa9\xdd\xcc\xec\x46\x63\x64\xf1\x00\x69\x82\x7d"),
 97					Leaf: &ics23.LeafOp{
 98						Hash:         specs.LeafSpec.Hash,
 99						PrehashKey:   specs.LeafSpec.PrehashKey,
100						PrehashValue: specs.LeafSpec.PrehashValue,
101						Length:       specs.LeafSpec.Length,
102						Prefix:       []byte("\x00"),
103					},
104					Path: []*ics23.InnerOp{},
105				},
106			},
107		},
108
109		ProofHeight: types.NewHeight(1, 2000), // XXX update
110	}
111
112	res := core.Timeout(cross(cur), timeoutPacket)
113
114	println(res)
115}
116
117// Error:
118// invalid Payload #0: payload value cannot be empty