Skip to content

Commit

Permalink
feat: accomplish relay feature between Axon and Ckb
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Jul 17, 2023
1 parent 060be2f commit d1057ee
Show file tree
Hide file tree
Showing 34 changed files with 1,007 additions and 658 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/relayer-types/src/clients/ics07_axon/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
client_state::ClientState as Ics02ClientState, client_state::UpgradeOptions,
client_type::ClientType, error::Error as Ics02Error,
},
ics24_host::identifier::{ChainId, ClientId},
ics24_host::identifier::ChainId,
},
prelude::*,
Height,
Expand All @@ -20,7 +20,6 @@ pub const AXON_CLIENT_STATE_TYPE_URL: &str = "/axon.client.v1.state";
pub struct AxonClientState {
pub chain_id: ChainId,
pub latest_height: Height,
pub default_client_id: ClientId,
}

impl Ics02ClientState for AxonClientState {
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer-types/src/clients/ics07_ckb/client_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
core::{
ics02_client::{client_state::UpgradeOptions, client_type::ClientType},
ics24_host::identifier::{ChainId, ClientId},
ics24_host::identifier::ChainId,
},
prelude::*,
Height,
Expand All @@ -21,7 +21,6 @@ pub const CKB_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.ckb.v1.ClientStat
pub struct CkbClientState {
pub chain_id: ChainId,
pub latest_height: Height,
pub default_client_id: ClientId,
}

impl Ics02ClientState for CkbClientState {
Expand Down
17 changes: 15 additions & 2 deletions crates/relayer-types/src/core/ics02_client/client_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;
use crate::{core::ics24_host::identifier::ClientId, prelude::*};
use core::fmt::{Display, Error as FmtError, Formatter};
use serde_derive::{Deserialize, Serialize};
use strum::IntoEnumIterator;

use super::error::Error;

Expand All @@ -26,7 +27,7 @@ pub enum ClientType {
Ckb4Ibc = 5,

#[cfg(any(test, feature = "mocks"))]
Mock = 9999,
Mock = 255,
}

impl ClientType {
Expand Down Expand Up @@ -71,6 +72,18 @@ impl TryFrom<u64> for ClientType {
}
}

impl From<ClientId> for ClientType {
fn from(client_id: ClientId) -> Self {
let mut client_type = ClientType::Mock;
for value in ClientType::iter() {
if client_id.as_str().starts_with(value.as_str()) {
client_type = value;
}
}
client_type
}
}

impl Display for ClientType {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "ClientType({})", self.as_str())
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ckb-jsonrpc-types = "0.106.0"
jsonrpc-core = "18.0"
strum = { version = "0.24.1", features = ["derive"] }

ckb-ics-axon = {git = "https://github.com/synapseweb3/ckb-ics.git", rev = "e57a669"}
ckb-ics-axon = {git = "https://github.com/synapseweb3/ckb-ics.git", rev = "fe67bd3"}
cstr_core = "0.2.6"
rlp = "0.5.2"

Expand Down
Loading

0 comments on commit d1057ee

Please sign in to comment.