1
- use std:: marker:: PhantomData ;
2
-
3
1
use common:: icon:: icon:: lightclient:: v1:: ClientState ;
4
2
use common:: icon:: icon:: lightclient:: v1:: ConsensusState ;
5
3
@@ -13,9 +11,8 @@ use cosmwasm_std::Storage;
13
11
use cw_storage_plus:: { Item , Map } ;
14
12
use debug_print:: debug_eprintln;
15
13
16
- use prost:: Message ;
17
14
use crate :: query_handler:: QueryHandler ;
18
-
15
+ use prost :: Message ;
19
16
20
17
use crate :: traits:: Config ;
21
18
use crate :: traits:: IContext ;
@@ -32,7 +29,6 @@ pub struct CwContext<'a> {
32
29
pub storage : & ' a mut dyn Storage ,
33
30
pub api : & ' a dyn Api ,
34
31
pub env : Env ,
35
-
36
32
}
37
33
38
34
impl < ' a > CwContext < ' a > {
@@ -46,18 +42,15 @@ impl<'a> CwContext<'a> {
46
42
}
47
43
48
44
impl < ' a > IContext for CwContext < ' a > {
49
-
50
-
51
-
52
- fn get_client_state ( & self , client_id : & str ) -> Result < ClientState , ContractError > {
45
+ fn get_client_state ( & self , client_id : & str ) -> Result < ClientState , ContractError > {
53
46
QueryHandler :: get_client_state ( self . storage , client_id)
54
47
}
55
48
56
49
fn insert_client_state (
57
50
& mut self ,
58
51
client_id : & str ,
59
52
state : ClientState ,
60
- ) -> Result < ( ) , ContractError > {
53
+ ) -> Result < ( ) , ContractError > {
61
54
let data = state. encode_to_vec ( ) ;
62
55
CLIENT_STATES
63
56
. save ( self . storage , client_id. to_string ( ) , & data)
@@ -84,7 +77,7 @@ impl<'a> IContext for CwContext<'a> {
84
77
. map_err ( |_e| ContractError :: FailedToSaveClientState )
85
78
}
86
79
87
- fn get_timestamp_at_height ( & self , client_id : & str , height : u64 ) -> Result < u64 , ContractError > {
80
+ fn get_timestamp_at_height ( & self , client_id : & str , height : u64 ) -> Result < u64 , ContractError > {
88
81
QueryHandler :: get_timestamp_at_height ( self . storage , client_id, height)
89
82
}
90
83
@@ -106,11 +99,11 @@ impl<'a> IContext for CwContext<'a> {
106
99
. map ( |addr| addr. to_vec ( ) )
107
100
}
108
101
109
- fn get_config ( & self ) -> Result < Config , ContractError > {
102
+ fn get_config ( & self ) -> Result < Config , ContractError > {
110
103
QueryHandler :: get_config ( self . storage )
111
104
}
112
105
113
- fn insert_config ( & mut self , config : & Config ) -> Result < ( ) , ContractError > {
106
+ fn insert_config ( & mut self , config : & Config ) -> Result < ( ) , ContractError > {
114
107
CONFIG
115
108
. save ( self . storage , config)
116
109
. map_err ( |_e| ContractError :: FailedToSaveConfig )
@@ -162,23 +155,23 @@ impl<'a> IContext for CwContext<'a> {
162
155
QueryHandler :: get_processed_blocknumber_at_height ( self . storage , client_id, height)
163
156
}
164
157
165
- fn ensure_ibc_host ( & self , caller : cosmwasm_std:: Addr ) -> Result < ( ) , ContractError > {
158
+ fn ensure_ibc_host ( & self , caller : cosmwasm_std:: Addr ) -> Result < ( ) , ContractError > {
166
159
let config = self . get_config ( ) ?;
167
160
if caller != config. ibc_host {
168
161
return Err ( ContractError :: Unauthorized { } ) ;
169
162
}
170
163
Ok ( ( ) )
171
164
}
172
- fn ensure_owner ( & self , caller : cosmwasm_std:: Addr ) -> Result < ( ) , ContractError > {
165
+ fn ensure_owner ( & self , caller : cosmwasm_std:: Addr ) -> Result < ( ) , ContractError > {
173
166
let config = self . get_config ( ) ?;
174
167
debug_eprintln ! ( "owner {:?} caller {}" , config. owner, caller. to_string( ) ) ;
175
168
if caller != config. owner {
176
169
return Err ( ContractError :: Unauthorized { } ) ;
177
170
}
178
171
Ok ( ( ) )
179
172
}
180
- fn api ( & self ) -> & dyn Api {
181
- return self . api
173
+ fn api ( & self ) -> & dyn Api {
174
+ self . api
182
175
}
183
176
}
184
177
0 commit comments