Skip to content

Commit 122a570

Browse files
committed
mv Tendermint ClientStateConfig under ics07
1 parent 87196d3 commit 122a570

File tree

3 files changed

+42
-47
lines changed

3 files changed

+42
-47
lines changed

crates/ibc/src/clients/ics07_tendermint/client_state.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,8 @@ pub mod test_util {
11291129
use tendermint::block::Header;
11301130

11311131
use crate::clients::ics07_tendermint::client_state::{AllowUpdate, ClientState};
1132-
use crate::clients::ics07_tendermint::error::Error;
1132+
use crate::clients::ics07_tendermint::error::{Error as ClientError, Error};
1133+
use crate::clients::ics07_tendermint::trust_threshold::TrustThreshold;
11331134
use crate::core::ics02_client::height::Height;
11341135
use crate::core::ics23_commitment::specs::ProofSpecs;
11351136
use crate::core::ics24_host::identifier::ChainId;
@@ -1180,4 +1181,42 @@ pub mod test_util {
11801181
allow_update_after_misbehaviour: false,
11811182
}
11821183
}
1184+
1185+
#[derive(typed_builder::TypedBuilder, Debug)]
1186+
pub struct ClientStateConfig {
1187+
pub chain_id: ChainId,
1188+
#[builder(default)]
1189+
pub trust_level: TrustThreshold,
1190+
#[builder(default = Duration::from_secs(64000))]
1191+
pub trusting_period: Duration,
1192+
#[builder(default = Duration::from_secs(128000))]
1193+
pub unbonding_period: Duration,
1194+
#[builder(default = Duration::from_millis(3000))]
1195+
max_clock_drift: Duration,
1196+
pub latest_height: Height,
1197+
#[builder(default)]
1198+
pub proof_specs: ProofSpecs,
1199+
#[builder(default)]
1200+
pub upgrade_path: Vec<String>,
1201+
#[builder(default = AllowUpdate { after_expiry: false, after_misbehaviour: false })]
1202+
allow_update: AllowUpdate,
1203+
}
1204+
1205+
impl TryFrom<ClientStateConfig> for ClientState {
1206+
type Error = ClientError;
1207+
1208+
fn try_from(config: ClientStateConfig) -> Result<Self, Self::Error> {
1209+
ClientState::new(
1210+
config.chain_id,
1211+
config.trust_level,
1212+
config.trusting_period,
1213+
config.unbonding_period,
1214+
config.max_clock_drift,
1215+
config.latest_height,
1216+
config.proof_specs,
1217+
config.upgrade_path,
1218+
config.allow_update,
1219+
)
1220+
}
1221+
}
11831222
}

crates/ibc/src/mock/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use tendermint_testgen::Validator as TestgenValidator;
1717
use tracing::debug;
1818
use typed_builder::TypedBuilder;
1919

20-
use self::clients::TmClientStateConfig;
2120
use super::client_state::{MOCK_CLIENT_STATE_TYPE_URL, MOCK_CLIENT_TYPE};
2221
use super::consensus_state::MOCK_CONSENSUS_STATE_TYPE_URL;
22+
use crate::clients::ics07_tendermint::client_state::test_util::ClientStateConfig as TmClientStateConfig;
2323
use crate::clients::ics07_tendermint::client_state::{
2424
ClientState as TmClientState, TENDERMINT_CLIENT_STATE_TYPE_URL,
2525
};

crates/ibc/src/mock/context/clients.rs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,19 @@
11
//! Client context implementations for `MockContext`
22
3-
use core::time::Duration;
4-
53
use super::{AnyClientState, AnyConsensusState, MockClientRecord, MockContext};
6-
use crate::clients::ics07_tendermint::client_state::{AllowUpdate, ClientState as TmClientState};
7-
use crate::clients::ics07_tendermint::error::Error as TmClientError;
8-
use crate::clients::ics07_tendermint::trust_threshold::TrustThreshold;
94
use crate::clients::ics07_tendermint::{
105
CommonContext as TmCommonContext, ValidationContext as TmValidationContext,
116
};
127
use crate::core::ics02_client::error::ClientError;
138
use crate::core::ics02_client::{ClientExecutionContext, ClientValidationContext};
14-
use crate::core::ics23_commitment::specs::ProofSpecs;
15-
use crate::core::ics24_host::identifier::{ChainId, ClientId};
9+
use crate::core::ics24_host::identifier::ClientId;
1610
use crate::core::ics24_host::path::{ClientConsensusStatePath, ClientStatePath};
1711
use crate::core::timestamp::Timestamp;
1812
use crate::core::{ContextError, ValidationContext};
1913
use crate::mock::client_state::MockClientContext;
2014
use crate::prelude::*;
2115
use crate::Height;
2216

23-
#[derive(typed_builder::TypedBuilder, Debug)]
24-
pub struct TmClientStateConfig {
25-
pub chain_id: ChainId,
26-
#[builder(default)]
27-
pub trust_level: TrustThreshold,
28-
#[builder(default = Duration::from_secs(64000))]
29-
pub trusting_period: Duration,
30-
#[builder(default = Duration::from_secs(128000))]
31-
pub unbonding_period: Duration,
32-
#[builder(default = Duration::from_millis(3000))]
33-
max_clock_drift: Duration,
34-
pub latest_height: Height,
35-
#[builder(default)]
36-
pub proof_specs: ProofSpecs,
37-
#[builder(default)]
38-
pub upgrade_path: Vec<String>,
39-
#[builder(default = AllowUpdate { after_expiry: false, after_misbehaviour: false })]
40-
allow_update: AllowUpdate,
41-
}
42-
43-
impl TryFrom<TmClientStateConfig> for TmClientState {
44-
type Error = TmClientError;
45-
46-
fn try_from(config: TmClientStateConfig) -> Result<Self, Self::Error> {
47-
TmClientState::new(
48-
config.chain_id,
49-
config.trust_level,
50-
config.trusting_period,
51-
config.unbonding_period,
52-
config.max_clock_drift,
53-
config.latest_height,
54-
config.proof_specs,
55-
config.upgrade_path,
56-
config.allow_update,
57-
)
58-
}
59-
}
60-
6117
impl MockClientContext for MockContext {
6218
type ConversionError = &'static str;
6319
type AnyConsensusState = AnyConsensusState;

0 commit comments

Comments
 (0)