Skip to content

Commit d60328b

Browse files
committed
Clean up lint errors
1 parent b68be2c commit d60328b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/cw0/src/handlers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::cell::RefCell;
44
use std::collections::HashMap;
55

66
use crate::new_std::{ExternMut, ExternRef};
7+
#[cfg(test)]
78
use cosmwasm_std::testing::{mock_env, MockApi};
89
use cosmwasm_std::{
910
from_slice, Api, Attribute, BankMsg, BankQuery, Binary, BlockInfo, Coin, ContractInfo,
@@ -12,6 +13,7 @@ use cosmwasm_std::{
1213
};
1314
use 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
1719
pub 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)]
352354
impl<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 {

packages/cw0/src/new_std.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ pub struct ExternRef<'a, S: Storage, A: Api, Q: Querier> {
1414
pub querier: &'a Q,
1515
}
1616

17-
impl<'a, S: Storage, A: Api, Q: Querier> ExternMut<'a, S, A, Q> {
18-
pub fn as_ref(self) -> ExternRef<'a, S, A, Q> {
17+
impl<'a, S: Storage, A: Api, Q: Querier> From<ExternMut<'a, S, A, Q>> for ExternRef<'a, S, A, Q> {
18+
fn from(other: ExternMut<'a, S, A, Q>) -> Self {
1919
ExternRef {
20-
storage: self.storage,
21-
api: self.api,
22-
querier: self.querier,
20+
storage: other.storage,
21+
api: other.api,
22+
querier: other.querier,
2323
}
2424
}
2525
}

0 commit comments

Comments
 (0)