@@ -4,6 +4,7 @@ use std::cell::RefCell;
44use std:: collections:: HashMap ;
55
66use crate :: new_std:: { ExternMut , ExternRef } ;
7+ #[ cfg( test) ]
78use cosmwasm_std:: testing:: { mock_env, MockApi } ;
89use cosmwasm_std:: {
910 from_slice, Api , Attribute , BankMsg , BankQuery , Binary , BlockInfo , Coin , ContractInfo ,
@@ -12,6 +13,7 @@ use cosmwasm_std::{
1213} ;
1314use std:: ops:: { Deref , DerefMut } ;
1415
16+ // TODO: build a simple implementation
1517/// Bank is a minimal contract-like interface that implements a bank module
1618/// It is initialized outside of the trait
1719pub trait Bank < S : Storage > {
@@ -228,7 +230,7 @@ where
228230
229231 pub fn query ( & self , address : HumanAddr , querier : & Q , msg : Vec < u8 > ) -> Result < Binary , String > {
230232 self . with_storage ( querier, address, |handler, deps, env| {
231- handler. query ( deps. as_ref ( ) , env, msg)
233+ handler. query ( deps. into ( ) , env, msg)
232234 } )
233235 }
234236
@@ -241,7 +243,7 @@ where
241243 . storage
242244 . try_borrow ( )
243245 . map_err ( |e| format ! ( "Immutable borrowing failed - re-entrancy?: {}" , e) ) ?;
244- let data = storage. get ( & key) . unwrap_or ( vec ! [ ] ) ;
246+ let data = storage. get ( & key) . unwrap_or_default ( ) ;
245247 Ok ( data. into ( ) )
246248 }
247249
@@ -277,8 +279,7 @@ where
277279 api : & self . api ,
278280 querier,
279281 } ;
280- let res = action ( handler, deps, env) ;
281- res
282+ action ( handler, deps, env)
282283 }
283284}
284285
@@ -349,6 +350,7 @@ where
349350 }
350351}
351352
353+ #[ cfg( test) ]
352354impl < S : Storage + Default > Router < S , MockApi > {
353355 /// mock is a shortcut for tests, always returns A = MockApi
354356 pub fn mock < B : Bank < S > + ' static > ( bank : B ) -> Self {
0 commit comments