Skip to content

Commit 800c506

Browse files
committed
Add new EurekaMsg
1 parent 48c8c17 commit 800c506

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

types/eureka.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package types
2+
3+
// EurekaPayload defines a single packet sent in the EurekaSendPacketMsg
4+
//
5+
// Payload value should be encoded in a format defined by the channel version,
6+
// and the module on the other side should know how to parse this.
7+
type EurekaPayload struct {
8+
// The port id on the chain where the packet is sent to (external chain).
9+
DestinationPort string `json:"destination_port"`
10+
// Version of the receiving contract.
11+
Version string `json:"version"`
12+
// Encoding used to serialize the Value.
13+
Encoding string `json:"encoding"`
14+
// Encoded payload data
15+
Value []byte `json:"value"`
16+
}

types/msg.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type CosmosMsg struct {
6060
Staking *StakingMsg `json:"staking,omitempty"`
6161
Any *AnyMsg `json:"any,omitempty"`
6262
Wasm *WasmMsg `json:"wasm,omitempty"`
63+
Eureka *EurekaMsg `json:"eureka,omitempty"`
6364
}
6465

6566
func (m *CosmosMsg) UnmarshalJSON(data []byte) error {
@@ -74,6 +75,7 @@ func (m *CosmosMsg) UnmarshalJSON(data []byte) error {
7475
Any *AnyMsg `json:"any,omitempty"`
7576
Wasm *WasmMsg `json:"wasm,omitempty"`
7677
Stargate *AnyMsg `json:"stargate,omitempty"`
78+
Eureka *EurekaMsg `json:"eureka,omitempty"`
7779
}
7880
var tmp InternalCosmosMsg
7981
err := json.Unmarshal(data, &tmp)
@@ -97,6 +99,7 @@ func (m *CosmosMsg) UnmarshalJSON(data []byte) error {
9799
Staking: tmp.Staking,
98100
Any: tmp.Any,
99101
Wasm: tmp.Wasm,
102+
Eureka: tmp.Eureka,
100103
}
101104
return nil
102105
}
@@ -350,6 +353,18 @@ type WasmMsg struct {
350353
ClearAdmin *ClearAdminMsg `json:"clear_admin,omitempty"`
351354
}
352355

356+
// These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts
357+
type EurekaMsg struct {
358+
SendPacket *EurekaSendPacketMsg `json:"execute,omitempty"`
359+
}
360+
361+
// Sends an IBC packet with given payloads over the existing channel.
362+
type EurekaSendPacketMsg struct {
363+
ChannelID string `json:"channel_id"`
364+
Data []EurekaPayload `json:"data"`
365+
Timestamp uint64 `json:"timestamp,string,omitempty"`
366+
}
367+
353368
// ExecuteMsg is used to call another defined contract on this chain.
354369
// The calling contract requires the callee to be defined beforehand,
355370
// and the address should have been defined in initialization.

0 commit comments

Comments
 (0)