Skip to content

Commit 0aaa93d

Browse files
committed
fix: fix deps issue
1 parent b44406d commit 0aaa93d

File tree

9 files changed

+414
-39
lines changed

9 files changed

+414
-39
lines changed

Cargo.lock

+149-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
use common::icon::icon::lightclient::v1::TrustLevel;
2+
use cw_storage_plus::{Item, Map};
3+
4+
use crate::traits::Config;
5+
type ClientId = String;
26

37
pub const CLIENT_STATE_HASH: &str = "client_state_hash";
48
pub const CONSENSUS_STATE_HASH: &str = "consensus_state_hash";
@@ -7,3 +11,10 @@ pub const TRUST_LEVEL: TrustLevel = TrustLevel {
711
numerator: 2,
812
denominator: 3,
913
};
14+
15+
pub const CLIENT_STATES: Map<String, Vec<u8>> = Map::new("CLIENT_STATES");
16+
pub const CONSENSUS_STATES: Map<(ClientId, u64), Vec<u8>> = Map::new("CONSENSUS_STATES");
17+
pub const PROCESSED_TIMES: Map<(ClientId, u64), u64> = Map::new("PROCESSED_TIMES");
18+
pub const PROCESSED_HEIGHTS: Map<(ClientId, u64), u64> = Map::new("PROCESSED_HEIGHTS");
19+
20+
pub const CONFIG: Item<Config> = Item::new("CONFIG");

contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs

+34-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::marker::PhantomData;
22

33
use crate::{
4-
state::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES},
4+
constants::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES},
55
traits::Config,
66
ContractError,
77
};
@@ -140,6 +140,35 @@ impl QueryHandler {
140140
deps: Deps,
141141
client_id: &str,
142142
height: u64,
143+
delay_time_period: u64,
144+
delay_block_period: u64,
145+
proof: &[MerkleNode],
146+
value: &[u8],
147+
path: &[u8],
148+
) -> Result<bool, ContractError> {
149+
let client_state = Self::get_client_state(deps.storage, client_id)?;
150+
let consensus_state: ConsensusState =
151+
Self::get_consensus_state(deps.storage, client_id, height)?;
152+
Self::verify_membership_inner(
153+
deps,
154+
client_id,
155+
client_state,
156+
consensus_state,
157+
height,
158+
delay_time_period,
159+
delay_block_period,
160+
proof,
161+
value,
162+
path,
163+
)
164+
}
165+
166+
pub fn verify_membership_inner(
167+
deps: Deps,
168+
client_id: &str,
169+
client_state: ClientState,
170+
consensus_state: ConsensusState,
171+
height: u64,
143172
_delay_time_period: u64,
144173
_delay_block_period: u64,
145174
proof: &[MerkleNode],
@@ -159,10 +188,8 @@ impl QueryHandler {
159188
let path = keccak256(path).to_vec();
160189
cw_println!(deps.api, "[LightClient]: client id is: {:?}", client_id);
161190

162-
let state = Self::get_client_state(deps.storage, client_id)?;
163-
164-
if state.frozen_height != 0 && height > state.frozen_height {
165-
return Err(ContractError::ClientStateFrozen(state.frozen_height));
191+
if client_state.frozen_height != 0 && height > client_state.frozen_height {
192+
return Err(ContractError::ClientStateFrozen(client_state.frozen_height));
166193
}
167194

168195
let mut value_hash = value.to_vec();
@@ -172,8 +199,7 @@ impl QueryHandler {
172199

173200
// let _ =
174201
// self.validate_delay_args(client_id, height, delay_time_period, delay_block_period)?;
175-
let consensus_state: ConsensusState =
176-
Self::get_consensus_state(deps.storage, client_id, height)?;
202+
177203
cw_println!(
178204
deps.api,
179205
"[LightClient]: Path Hash {:?}",
@@ -257,7 +283,7 @@ impl QueryHandler {
257283
mod tests {
258284
use cosmwasm_std::testing::MockStorage;
259285

260-
use crate::state::CONSENSUS_STATES;
286+
use crate::constants::CONSENSUS_STATES;
261287

262288
use super::QueryHandler;
263289

0 commit comments

Comments
 (0)