Skip to content

Commit

Permalink
fix Failure types for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Aug 17, 2023
1 parent 96e756a commit 1891649
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions packages/neutron-sdk/src/bindings/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Packet>,
/// **ack** is an acknowledgement data
pub ack: Acknowledgement,
pub ack: Option<Acknowledgement>,
}

#[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<Height>,

/// **timeout_timestamp** of a packet
pub timeout_timestamp: Option<u64>,
}

#[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),
}

Expand Down

0 comments on commit 1891649

Please sign in to comment.