Skip to content

Commit

Permalink
Quickfix: make fields in event subscription accessible publicly (info…
Browse files Browse the repository at this point in the history
…rmalsystems#312)

* quickfix: pub all fields

* add debug output for informalsystems#311
  • Loading branch information
liamsi committed Jun 9, 2020
1 parent 71d7e23 commit eda96b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 2 additions & 0 deletions tendermint/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
mod client;
pub mod endpoint;
pub mod error;
// TODO(ismail): document fields or re-use the abci types
#[allow(missing_docs)]
pub mod event_listener;
mod id;
mod method;
Expand Down
40 changes: 21 additions & 19 deletions tendermint/src/rpc/event_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ impl EventListener {
dbg!(&msg.to_string());
return Ok(None);
}

dbg!("received neither event nor generic string message:");
dbg!(&msg.to_string());
Err(RPCError::new(
Code::Other(-1),
Some("received neither event nor generic string message".to_string()),
Expand Down Expand Up @@ -151,61 +152,62 @@ pub type WrappedResultEvent = Wrapper<ResultEvent>;
/// TX value
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EventDataTx {
/// The actual TxResult
#[serde(rename = "TxResult")]
tx_result: TxResult,
pub tx_result: TxResult,
}

/// Tx Result
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TxResult {
height: String,
index: i64,
tx: String,
result: TxResultResult,
pub height: String,
pub index: i64,
pub tx: String,
pub result: TxResultResult,
}

/// TX Results Results
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TxResultResult {
log: String,
gas_wanted: String,
gas_used: String,
events: Vec<TmEvent>,
pub log: String,
pub gas_wanted: String,
pub gas_used: String,
pub events: Vec<TmEvent>,
}
impl response::Response for TxResultResult {}

/// Tendermint ABCI Events
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TmEvent {
#[serde(rename = "type")]
event_type: String,
attributes: Vec<Attribute>,
pub event_type: String,
pub attributes: Vec<Attribute>,
}
/// Event Attributes
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Attribute {
key: String,
value: String,
pub key: String,
pub value: String,
}

///Block Value
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EventDataNewBlock {
block: Option<Block>,
pub block: Option<Block>,

// TODO(ismail): these should be the same as abci::responses::BeginBlock
// and abci::responses::EndBlock
result_begin_block: Option<ResultBeginBlock>,
result_end_block: Option<ResultEndBlock>,
pub result_begin_block: Option<ResultBeginBlock>,
pub result_end_block: Option<ResultEndBlock>,
}

/// Begin Block Events
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ResultBeginBlock {
events: Option<Vec<TmEvent>>,
pub events: Option<Vec<TmEvent>>,
}
///End Block Events
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ResultEndBlock {
validator_updates: Option<Vec<Option<serde_json::Value>>>,
pub validator_updates: Option<Vec<Option<serde_json::Value>>>,
}

0 comments on commit eda96b4

Please sign in to comment.