Skip to content

Commit

Permalink
add Failures binding query
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Aug 14, 2023
1 parent bb21885 commit 43de8e7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
25 changes: 25 additions & 0 deletions packages/neutron-sdk/schema/neutron_query.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,31 @@
}
},
"additionalProperties": false
},
{
"description": "Contractmanager query. Returns the failures for a particular contract address.",
"type": "object",
"required": [
"failures"
],
"properties": {
"failures": {
"type": "object",
"required": [
"address",
"pagination"
],
"properties": {
"address": {
"type": "string"
},
"pagination": {
"$ref": "#/definitions/PageRequest"
}
}
}
},
"additionalProperties": false
}
],
"definitions": {
Expand Down
15 changes: 14 additions & 1 deletion packages/neutron-sdk/src/bindings/query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::bindings::types::{InterchainQueryResult, RegisteredQuery};
use crate::bindings::types::{Failure, InterchainQueryResult, RegisteredQuery};
use cosmwasm_std::{Binary, CustomQuery};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -56,6 +56,12 @@ pub enum NeutronQuery {

/// TokenFactory query. Returns the admin of a denom, if the denom is a TokenFactory denom.
DenomAdmin { subdenom: String },

/// Contractmanager query. Returns the failures for a particular contract address.
Failures {
address: String,
pagination: PageRequest,
},
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down Expand Up @@ -108,4 +114,11 @@ pub struct QueryInterchainAccountAddressResponse {
pub interchain_account_address: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct QueryFailuresResponse {
/// **failures** is a list of failures of sudo handler calls
pub failures: Vec<Failure>,
}

impl CustomQuery for NeutronQuery {}
42 changes: 42 additions & 0 deletions packages/neutron-sdk/src/bindings/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,48 @@ pub struct StorageValue {
pub value: Binary,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Failure {
/// **channel_id** is an id for channel failure
pub channel_id: String,
// **address** of the failed contract
pub address: String,
// **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,
/// **ack** is an acknowledgement data
pub ack: Acknowledgement,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
/// IBC packet
pub struct Packet {
pub sequence: u64,
pub source_port: String,
pub source_channel: String,
pub destination_port: String,
pub destination_channel: String,
pub data: Binary,
pub timeout_height: Height,
pub timeout_timestamp: 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 {
Error(String),
Result(Binary),
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
/// Type for wrapping any protobuf message
Expand Down

0 comments on commit 43de8e7

Please sign in to comment.