From 18916490588058f40c97b5db25ee9ae8c2fa4a43 Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 17 Aug 2023 16:26:23 +0400 Subject: [PATCH] fix Failure types for serialization --- packages/neutron-sdk/src/bindings/types.rs | 47 ++++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/packages/neutron-sdk/src/bindings/types.rs b/packages/neutron-sdk/src/bindings/types.rs index 9b70b503..ac432f00 100644 --- a/packages/neutron-sdk/src/bindings/types.rs +++ b/packages/neutron-sdk/src/bindings/types.rs @@ -98,43 +98,64 @@ pub struct StorageValue { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] +/// Acknowledgement Failure of sudo handler; can be resubmitted. pub struct Failure { - /// **channel_id** is an id for channel failure - pub channel_id: String, - // **address** of the failed contract + /// **address** of the failed contract pub address: String, - // **id** of the failure under specific address + /// **id** of the failure under specific address pub id: u64, - /// **sequence_id** is channel sequence id - pub sequence_id: u64, // TODO: is renaming ok?; TODO: remove this since we have sequence_id in packet? /// **ack_type** is an acknowledgement type ('ack' or 'timeout') pub ack_type: String, /// **packet** is an IBC Packet that was sent - pub packet: Packet, + pub packet: Option, /// **ack** is an acknowledgement data - pub ack: Acknowledgement, + pub ack: Option, } #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] /// IBC packet pub struct Packet { + /// **sequence** number of packet in ordered channel pub sequence: u64, + + /// **source_port** of packet packet pub source_port: String, + + /// **source_channel** of a packet pub source_channel: String, + + /// **destination_port** of a packet pub destination_port: String, + + /// **destination_channel** of a packet pub destination_channel: String, + + /// **data** of a packet pub data: Binary, - pub timeout_height: Height, - pub timeout_timestamp: u64, + + /// **timeout_height** of a packet + pub timeout_height: Option, + + /// **timeout_timestamp** of a packet + pub timeout_timestamp: Option, } #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] -/// IBC packet -/// TODO: do we need our own structure in order for it to pass through neutron -pub enum Acknowledgement { +/// IBC message Acknowledgement +pub struct Acknowledgement { + #[serde(rename(serialize = "response", deserialize = "Response"))] + pub response: AcknowledgementResponse, +} + +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +/// IBC message acknowledgement response +pub enum AcknowledgementResponse { + /// Error response Error(String), + /// Successful response with result as encoded binary Result(Binary), }