Skip to content

Commit

Permalink
add channel info types
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinzer0 committed Oct 10, 2024
1 parent 2d1828c commit c28aed1
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion packages/notification/src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cosmwasm_std::{Addr, Api, Binary, Env, StdError, StdResult};
use cosmwasm_std::{Addr, Api, Binary, Env, StdError, StdResult, Uint64};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::{encrypt_notification_data, get_seed, notification_id};
Expand Down Expand Up @@ -74,4 +75,63 @@ impl TxHashNotification {
pub fn data_plaintext(&self) -> String {
self.encrypted_data.to_base64()
}
}

// types for channel info response

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct ChannelInfoData {
/// same as query input
pub channel: String,
/// "counter", "txhash", "bloom"
pub mode: String,

/// txhash / bloom fields only
/// if txhash argument was given, this will be its computed Notification ID
pub answer_id: Option<Binary>,

/// bloom fields only
/// bloom filter parameters
pub parameters: Option<BloomParameters>,
/// bloom filter data
pub data: Option<Descriptor>,

/// counter fields only
/// current counter value
pub counter: Option<Uint64>,
/// the next Notification ID
pub next_id: Option<Binary>,

/// counter / txhash field only
/// optional CDDL schema definition string for the CBOR-encoded notification data
pub cddl: Option<String>,
}

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct BloomParameters {
pub m: u32,
pub k: u32,
pub h: String,
}

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct Descriptor {
pub r#type: String,
pub version: String,
pub packet_size: u32,
pub data: StructDescriptor,
}

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct StructDescriptor {
pub r#type: String,
pub label: String,
pub members: Vec<FlatDescriptor>,
}

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct FlatDescriptor {
pub r#type: String,
pub label: String,
pub description: Option<String>,
}

0 comments on commit c28aed1

Please sign in to comment.