Skip to content

Commit

Permalink
Add new EurekaMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Jan 22, 2025
1 parent 48c8c17 commit 800c506
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions types/eureka.go
Original file line number Diff line number Diff line change
@@ -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"`
}
15 changes: 15 additions & 0 deletions types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 800c506

Please # to comment.