From 800c506e6d58cc7ec4b7a1030309fd305f97e63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Wed, 22 Jan 2025 18:11:08 +0100 Subject: [PATCH] Add new EurekaMsg --- types/eureka.go | 16 ++++++++++++++++ types/msg.go | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 types/eureka.go diff --git a/types/eureka.go b/types/eureka.go new file mode 100644 index 000000000..befbeee99 --- /dev/null +++ b/types/eureka.go @@ -0,0 +1,16 @@ +package types + +// EurekaPayload defines a single packet sent in the EurekaSendPacketMsg +// +// Payload value should be encoded in a format defined by the channel version, +// and the module on the other side should know how to parse this. +type EurekaPayload struct { + // The port id on the chain where the packet is sent to (external chain). + DestinationPort string `json:"destination_port"` + // Version of the receiving contract. + Version string `json:"version"` + // Encoding used to serialize the Value. + Encoding string `json:"encoding"` + // Encoded payload data + Value []byte `json:"value"` +} diff --git a/types/msg.go b/types/msg.go index 60a6e8751..d26d92062 100644 --- a/types/msg.go +++ b/types/msg.go @@ -60,6 +60,7 @@ type CosmosMsg struct { Staking *StakingMsg `json:"staking,omitempty"` Any *AnyMsg `json:"any,omitempty"` Wasm *WasmMsg `json:"wasm,omitempty"` + Eureka *EurekaMsg `json:"eureka,omitempty"` } func (m *CosmosMsg) UnmarshalJSON(data []byte) error { @@ -74,6 +75,7 @@ func (m *CosmosMsg) UnmarshalJSON(data []byte) error { Any *AnyMsg `json:"any,omitempty"` Wasm *WasmMsg `json:"wasm,omitempty"` Stargate *AnyMsg `json:"stargate,omitempty"` + Eureka *EurekaMsg `json:"eureka,omitempty"` } var tmp InternalCosmosMsg err := json.Unmarshal(data, &tmp) @@ -97,6 +99,7 @@ func (m *CosmosMsg) UnmarshalJSON(data []byte) error { Staking: tmp.Staking, Any: tmp.Any, Wasm: tmp.Wasm, + Eureka: tmp.Eureka, } return nil } @@ -350,6 +353,18 @@ type WasmMsg struct { ClearAdmin *ClearAdminMsg `json:"clear_admin,omitempty"` } +// These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts +type EurekaMsg struct { + SendPacket *EurekaSendPacketMsg `json:"execute,omitempty"` +} + +// Sends an IBC packet with given payloads over the existing channel. +type EurekaSendPacketMsg struct { + ChannelID string `json:"channel_id"` + Data []EurekaPayload `json:"data"` + Timestamp uint64 `json:"timestamp,string,omitempty"` +} + // ExecuteMsg is used to call another defined contract on this chain. // The calling contract requires the callee to be defined beforehand, // and the address should have been defined in initialization.