// PKGPATH: gno.land/r/aib/main package main import ( "chain" "encoding/hex" "testing" "time" tmtesting "gno.land/p/aib/ibc/lightclient/tendermint/testing" "gno.land/p/aib/ibc/types" "gno.land/p/aib/ics23" "gno.land/r/aib/ibc/apps/transfer" "gno.land/r/aib/ibc/core" ) // OnAcknowledgementPacket: invalid AppAcknowledgements func main(cur realm) { var ( chainID = "chain-id-2" trustedHeight = types.NewHeight(2, 2) clientState = tmtesting.NewClientState(chainID, trustedHeight) apphash, _ = hex.DecodeString("e0e3b9fff6b7dae2afc0e430b6765483deeb42489187280bf0e8779515a779bb") trustedValset = tmtesting.GenValset() consensusState = tmtesting.GenConsensusState(time.Now(), apphash[:], trustedValset.Hash()) counterpartyID = "07-tendermint-42" ) clientID := core.CreateClient(cross(cur), clientState, consensusState) core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, counterpartyID) // Transfer the 100ugnot we want to ack testing.SetRealm(testing.NewUserRealm("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")) testing.SetOriginSend(chain.NewCoins(chain.NewCoin("ugnot", 100))) println("----------- assert render total_escrow/ugnot before Transfer") println(transfer.Render("total_escrow/ugnot")) sendPacket, sequence := transfer.Transfer(cross(cur), clientID, "atone1user", "ugnot", 100, uint64(time.Now().Add(time.Hour).Unix()), "") println("----------- assert render total_escrow/ugnot after Transfer") println(transfer.Render("total_escrow/ugnot")) // Acknowledge the packet specs := ics23.IavlSpec() // Generate the proof of acknowledgement written during the RecvPacket of the // counterparty client. // NOTE proof generated by ./cmd/gen-proof 'prefix2' '07-tendermint-42' 'acknowledgement' 'not json' proofAcked := []ics23.CommitmentProof{ // iavl proof ics23.CommitmentProof_Exist{ Exist: &ics23.ExistenceProof{ 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"), Value: []byte("\x6a\x1b\x58\x87\x05\x25\xf5\x0a\x67\xe0\xf0\x59\x58\x70\x50\x5a\x1e\x82\x07\xac\xfb\xfe\x5f\xe7\xf6\x40\x45\x13\xa3\x57\xd3\xc3"), Leaf: &ics23.LeafOp{ Hash: specs.LeafSpec.Hash, PrehashKey: specs.LeafSpec.PrehashKey, PrehashValue: specs.LeafSpec.PrehashValue, Length: specs.LeafSpec.Length, Prefix: []byte("\x00\x02\x02"), }, Path: []*ics23.InnerOp{ { Hash: specs.InnerSpec.Hash, Prefix: []byte("\x02\x04\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"), Suffix: []byte(""), }, { Hash: specs.InnerSpec.Hash, Prefix: []byte("\x04\x08\x02\x20"), 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"), }, { Hash: specs.InnerSpec.Hash, Prefix: []byte("\x06\x0c\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"), Suffix: []byte(""), }, }, }, }, // rootmulti proof ics23.CommitmentProof_Exist{ Exist: &ics23.ExistenceProof{ Key: []byte("\x69\x61\x76\x6c\x53\x74\x6f\x72\x65\x4b\x65\x79"), Value: []byte("\x87\x64\x71\x03\x02\xf7\x2c\xad\x01\x9e\x20\x71\xeb\xf2\x56\xc4\xeb\xe6\xe6\x9e\xba\xb5\xb2\x9e\xe1\xaf\x39\x51\xca\x17\x01\xd7"), Leaf: &ics23.LeafOp{ Hash: specs.LeafSpec.Hash, PrehashKey: specs.LeafSpec.PrehashKey, PrehashValue: specs.LeafSpec.PrehashValue, Length: specs.LeafSpec.Length, Prefix: []byte("\x00"), }, Path: []*ics23.InnerOp{}, }, }, } ackPacket := types.MsgAcknowledgement{ Packet: types.Packet{ Sequence: sequence, SourceClient: clientID, DestinationClient: counterpartyID, TimeoutTimestamp: sendPacket.TimeoutTimestamp, Payloads: sendPacket.Payloads, }, Acknowledgement: types.Acknowledgement{ AppAcknowledgements: [][]byte{[]byte(`not json`)}, }, ProofAcked: proofAcked, ProofHeight: trustedHeight, } core.Acknowledgement(cross(cur), ackPacket) } // Error: // acknowledgement packet failed for payload #0 app "transfer": cannot unmarshal ICS-20 transfer packet acknowledgement: invalid token