Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored and completed Path; added query to Chain trait; refactored query code into TendermintChain #174

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions modules/src/error.rs

This file was deleted.

1 change: 0 additions & 1 deletion modules/src/ics02_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pub mod error;
pub mod events;
pub mod header;
pub mod msgs;
pub mod query;
pub mod state;
106 changes: 0 additions & 106 deletions modules/src/ics02_client/query.rs

This file was deleted.

10 changes: 0 additions & 10 deletions modules/src/ics23_commitment/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde_derive::{Deserialize, Serialize};

use crate::path::Path;
use std::fmt;
use tendermint::merkle::proof::Proof;

Expand All @@ -10,15 +9,6 @@ pub struct CommitmentRoot;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CommitmentPath;

impl CommitmentPath {
pub fn from_path<P>(_p: P) -> Self
where
P: Path,
{
CommitmentPath {}
}
}

pub type CommitmentProof = Proof;
/*
impl CommitmentProof {
Expand Down
2 changes: 2 additions & 0 deletions modules/src/ics24_host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

pub mod error;
pub mod identifier;
mod path;
pub use path::{Path, IBC_QUERY_PATH};
pub mod validate;
86 changes: 86 additions & 0 deletions modules/src/ics24_host/path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/// Path-space as listed in ICS-024
/// https://github.com/cosmos/ics/tree/master/spec/ics-024-host-requirements#path-space
/// Some of these are implemented in other ICSs, but ICS-024 has a nice summary table.
use crate::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
use std::fmt::{Display, Formatter, Result};

/// IBC Query Path is hard-coded
pub const IBC_QUERY_PATH: &str = "store/ibc/key";

/// The Path enum abstracts out the different sub-paths
pub enum Path {
greg-szabo marked this conversation as resolved.
Show resolved Hide resolved
ClientType(ClientId),
ClientState(ClientId),
ConsensusState(ClientId, u64),
ClientConnections(ClientId),
Connections(ConnectionId),
Ports(PortId),
ChannelEnds(PortId, ChannelId),
SeqSends(PortId, ChannelId),
SeqRecvs(PortId, ChannelId),
SeqAcks(PortId, ChannelId),
Commitments(PortId, ChannelId, u64),
Acks(PortId, ChannelId, u64),
}

impl Path {
/// Indication if the path is provable.
pub fn is_provable(&self) -> bool {
match &self {
Path::ClientState(_) => false,
Path::ClientConnections(_) => false,
Path::Ports(_) => false,
_ => true,
}
}

/// into_bytes implementation
pub fn into_bytes(self) -> Vec<u8> {
self.to_string().into_bytes()
}
}

/// The Display trait adds the `.to_string()` method to the Path struct
/// This is where the different path strings are constructed
impl Display for Path {
greg-szabo marked this conversation as resolved.
Show resolved Hide resolved
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match &self {
Path::ClientType(id) => write!(f, "clients/{}/clientType", id),
Path::ClientState(id) => write!(f, "clients/{}/clientState", id),
Path::ConsensusState(id, height) => {
write!(f, "clients/{}/consensusState/{}", id, height)
}
Path::ClientConnections(id) => write!(f, "clients/{}/connections", id),
Path::Connections(id) => write!(f, "connections/{}", id),
Path::Ports(id) => write!(f, "ports/{}", id),
Path::ChannelEnds(port_id, channel_id) => {
write!(f, "channelEnds/ports/{}/channels/{}", port_id, channel_id)
}
Path::SeqSends(port_id, channel_id) => write!(
f,
"seqSends/ports/{}/channels/{}/nextSequenceSend",
port_id, channel_id
),
Path::SeqRecvs(port_id, channel_id) => write!(
f,
"seqRecvs/ports/{}/channels/{}/nextSequenceRecv",
port_id, channel_id
),
Path::SeqAcks(port_id, channel_id) => write!(
f,
"seqAcks/ports/{}/channels/{}/nextSequenceAck",
port_id, channel_id
),
Path::Commitments(port_id, channel_id, seq) => write!(
f,
"commitments/ports/{}/channels/{}/packets/{}",
port_id, channel_id, seq
),
Path::Acks(port_id, channel_id, seq) => write!(
f,
"acks/ports/{}/channels/{}/acknowledgements/{}",
port_id, channel_id, seq
),
}
}
}
2 changes: 0 additions & 2 deletions modules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//! - ICS 23: Vector Commitment Scheme
//! - ICS 24: Host Requirements

pub mod error;
pub mod events;
pub mod ics02_client;
pub mod ics03_connection;
Expand All @@ -29,7 +28,6 @@ pub mod ics20_fungible_token_transfer;
pub mod ics23_commitment;
pub mod ics24_host;
pub mod keys;
pub mod path;
pub mod proofs;
pub mod try_from_raw;
pub mod tx_msg;
Expand Down
109 changes: 0 additions & 109 deletions modules/src/path.rs

This file was deleted.

Loading