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

msgs.gno

4.14 Kb · 152 lines
  1package types
  2
  3// Packet-lifecycle datagrams, mirroring the ibc-union-spec `Datagram` variants
  4// that carry packets (recv / acknowledgement / timeout / intent / batch).
  5// Proof heights are plain block numbers (u64), matching the spec.
  6
  7// MsgPacketRecv delivers one or more packets to their destination, proven
  8// against the source chain's batch commitment.
  9type MsgPacketRecv struct {
 10	Packets     []Packet
 11	RelayerMsgs [][]byte
 12	Relayer     address
 13	Proof       []byte
 14	ProofHeight uint64
 15}
 16
 17func NewMsgPacketRecv(packets []Packet, relayerMsgs [][]byte, proof []byte, proofHeight uint64) MsgPacketRecv {
 18	return MsgPacketRecv{
 19		Packets:     packets,
 20		RelayerMsgs: relayerMsgs,
 21		Proof:       proof,
 22		ProofHeight: proofHeight,
 23	}
 24}
 25
 26// MsgPacketAcknowledgement settles sent packets against the acknowledgements
 27// committed on the destination chain.
 28type MsgPacketAcknowledgement struct {
 29	Packets          []Packet
 30	Acknowledgements [][]byte
 31	Proof            []byte
 32	ProofHeight      uint64
 33	Relayer          address
 34}
 35
 36func NewMsgPacketAcknowledgement(packets []Packet, acknowledgements [][]byte, proof []byte, proofHeight uint64) MsgPacketAcknowledgement {
 37	return MsgPacketAcknowledgement{
 38		Packets:          packets,
 39		Acknowledgements: acknowledgements,
 40		Proof:            proof,
 41		ProofHeight:      proofHeight,
 42	}
 43}
 44
 45// MsgPacketTimeout proves, via non-membership, that a packet was never received
 46// on the destination chain before its timeout.
 47type MsgPacketTimeout struct {
 48	Packet      Packet
 49	Proof       []byte
 50	ProofHeight uint64
 51	Relayer     address
 52}
 53
 54func NewMsgPacketTimeout(packet Packet, proof []byte, proofHeight uint64) MsgPacketTimeout {
 55	return MsgPacketTimeout{
 56		Packet:      packet,
 57		Proof:       proof,
 58		ProofHeight: proofHeight,
 59	}
 60}
 61
 62// MsgCommitMembershipProof verifies and commits a membership proof for later
 63// counterparty proof-lens reads.
 64type MsgCommitMembershipProof struct {
 65	ClientId    ClientId
 66	ProofHeight uint64
 67	Proof       []byte
 68	Path        []byte
 69	Value       []byte
 70}
 71
 72func NewMsgCommitMembershipProof(clientId ClientId, proofHeight uint64, proof, path, value []byte) MsgCommitMembershipProof {
 73	return MsgCommitMembershipProof{
 74		ClientId:    clientId,
 75		ProofHeight: proofHeight,
 76		Proof:       proof,
 77		Path:        path,
 78		Value:       value,
 79	}
 80}
 81
 82// MsgCommitNonMembershipProof verifies and commits a non-membership proof for
 83// later counterparty proof-lens reads.
 84type MsgCommitNonMembershipProof struct {
 85	ClientId    ClientId
 86	ProofHeight uint64
 87	Proof       []byte
 88	Path        []byte
 89}
 90
 91func NewMsgCommitNonMembershipProof(clientId ClientId, proofHeight uint64, proof, path []byte) MsgCommitNonMembershipProof {
 92	return MsgCommitNonMembershipProof{
 93		ClientId:    clientId,
 94		ProofHeight: proofHeight,
 95		Proof:       proof,
 96		Path:        path,
 97	}
 98}
 99
100// MsgIntentPacketRecv lets a market maker fill packets ahead of proof, carrying
101// per-packet market-maker messages instead of a membership proof.
102type MsgIntentPacketRecv struct {
103	Packets             []Packet
104	MarketMakerMessages [][]byte
105	MarketMaker         address
106}
107
108func NewMsgIntentPacketRecv(packets []Packet, marketMakerMessages [][]byte) MsgIntentPacketRecv {
109	return MsgIntentPacketRecv{
110		Packets:             packets,
111		MarketMakerMessages: marketMakerMessages,
112	}
113}
114
115// MsgBatchSend commits a batch of already-sent packets so they can be proven
116// together.
117type MsgBatchSend struct {
118	Packets []Packet
119}
120
121func NewMsgBatchSend(packets []Packet) MsgBatchSend {
122	return MsgBatchSend{
123		Packets: packets,
124	}
125}
126
127// MsgBatchAcks commits a batch of acknowledgements for received packets.
128type MsgBatchAcks struct {
129	Packets []Packet
130	Acks    [][]byte
131}
132
133func NewMsgBatchAcks(packets []Packet, acks [][]byte) MsgBatchAcks {
134	return MsgBatchAcks{
135		Packets: packets,
136		Acks:    acks,
137	}
138}
139
140// MsgWriteAcknowledgement writes the acknowledgement for a previously received
141// packet (the async-ack settlement path).
142type MsgWriteAcknowledgement struct {
143	Packet          Packet
144	Acknowledgement []byte
145}
146
147func NewMsgWriteAcknowledgement(packet Packet, acknowledgement []byte) MsgWriteAcknowledgement {
148	return MsgWriteAcknowledgement{
149		Packet:          packet,
150		Acknowledgement: acknowledgement,
151	}
152}