Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Sep 22, 2023
1 parent 9ae1384 commit 2007e7a
Show file tree
Hide file tree
Showing 36 changed files with 164 additions and 164 deletions.
26 changes: 13 additions & 13 deletions contracts/crypto-verify/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand All @@ -296,7 +296,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: false });
}
Expand Down Expand Up @@ -339,7 +339,7 @@ mod tests {
signer_address: signer_address.into(),
};
let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand All @@ -360,7 +360,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();
assert_eq!(res, VerifyResponse { verifies: false });
}

Expand All @@ -380,7 +380,7 @@ mod tests {
signer_address: signer_address.into(),
};
let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();
assert_eq!(res, VerifyResponse { verifies: false });

// Broken signature
Expand Down Expand Up @@ -447,7 +447,7 @@ mod tests {
v,
};
let raw = query(deps.as_ref(), mock_env(), msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();
assert_eq!(res, VerifyResponse { verifies: true });
}

Expand Down Expand Up @@ -475,7 +475,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand Down Expand Up @@ -508,7 +508,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand Down Expand Up @@ -542,7 +542,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand Down Expand Up @@ -573,7 +573,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: false });
}
Expand Down Expand Up @@ -626,7 +626,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: true });
}
Expand All @@ -648,7 +648,7 @@ mod tests {
};

let raw = query(deps.as_ref(), mock_env(), verify_msg).unwrap();
let res: VerifyResponse = from_json(&raw).unwrap();
let res: VerifyResponse = from_json(raw).unwrap();

assert_eq!(res, VerifyResponse { verifies: false });
}
Expand Down Expand Up @@ -683,7 +683,7 @@ mod tests {
let query_msg = QueryMsg::ListVerificationSchemes {};

let raw = query(deps.as_ref(), mock_env(), query_msg).unwrap();
let res: ListVerificationsResponse = from_json(&raw).unwrap();
let res: ListVerificationsResponse = from_json(raw).unwrap();

assert_eq!(
res,
Expand Down
4 changes: 2 additions & 2 deletions contracts/cyberpunk/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ mod tests {
);

let symbols: Vec<DenomMetadata> =
from_json(&query(deps.as_ref(), mock_env(), QueryMsg::Denoms {}).unwrap()).unwrap();
from_json(query(deps.as_ref(), mock_env(), QueryMsg::Denoms {}).unwrap()).unwrap();

assert_eq!(symbols.len(), 98);

let denom: DenomMetadata = from_json(
&query(
query(
deps.as_ref(),
mock_env(),
QueryMsg::Denom {
Expand Down
4 changes: 2 additions & 2 deletions contracts/cyberpunk/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ fn test_env() {
)
.unwrap();

let received_env: Env = from_json(&res.data.unwrap()).unwrap();
let received_env: Env = from_json(res.data.unwrap()).unwrap();

assert_eq!(received_env, env);

let env = mock_env();
let received_env: Env =
from_json(&query(&mut deps, env.clone(), QueryMsg::MirrorEnv {}).unwrap()).unwrap();
from_json(query(&mut deps, env.clone(), QueryMsg::MirrorEnv {}).unwrap()).unwrap();

assert_eq!(received_env, env);
}
8 changes: 4 additions & 4 deletions contracts/floaty/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn execute(
.storage
.get(CONFIG_KEY)
.ok_or_else(|| StdError::not_found("State"))?;
let state: State = from_json(&data)?;
let state: State = from_json(data)?;

if info.sender == state.verifier {
let to_addr = state.beneficiary;
Expand Down Expand Up @@ -77,7 +77,7 @@ fn query_verifier(deps: Deps) -> StdResult<VerifierResponse> {
.storage
.get(CONFIG_KEY)
.ok_or_else(|| StdError::not_found("State"))?;
let state: State = from_json(&data)?;
let state: State = from_json(data)?;
Ok(VerifierResponse {
verifier: state.verifier.into(),
})
Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {

// it worked, let's check the state
let data = deps.storage.get(CONFIG_KEY).expect("no data stored");
let state: State = from_json(&data).unwrap();
let state: State = from_json(data).unwrap();
assert_eq!(state, expected_state);
}

Expand Down Expand Up @@ -246,7 +246,7 @@ mod tests {

// state should not change
let data = deps.storage.get(CONFIG_KEY).expect("no data stored");
let state: State = from_json(&data).unwrap();
let state: State = from_json(data).unwrap();
assert_eq!(
state,
State {
Expand Down
10 changes: 5 additions & 5 deletions contracts/hackatom/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Ha
.storage
.get(CONFIG_KEY)
.ok_or_else(|| StdError::not_found("State"))?;
let mut config: State = from_json(&data)?;
let mut config: State = from_json(data)?;
config.verifier = deps.api.addr_validate(&msg.verifier)?;
deps.storage.set(CONFIG_KEY, &to_json_vec(&config)?);

Expand Down Expand Up @@ -85,7 +85,7 @@ fn do_release(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Response, Ha
.storage
.get(CONFIG_KEY)
.ok_or_else(|| StdError::not_found("State"))?;
let state: State = from_json(&data)?;
let state: State = from_json(data)?;

if info.sender == state.verifier {
let to_addr = state.beneficiary;
Expand Down Expand Up @@ -262,7 +262,7 @@ fn query_verifier(deps: Deps) -> StdResult<VerifierResponse> {
.storage
.get(CONFIG_KEY)
.ok_or_else(|| StdError::not_found("State"))?;
let state: State = from_json(&data)?;
let state: State = from_json(data)?;
Ok(VerifierResponse {
verifier: state.verifier.into(),
})
Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {

// it worked, let's check the state
let data = deps.storage.get(CONFIG_KEY).expect("no data stored");
let state: State = from_json(&data).unwrap();
let state: State = from_json(data).unwrap();
assert_eq!(state, expected_state);
}

Expand Down Expand Up @@ -514,7 +514,7 @@ mod tests {

// state should not change
let data = deps.storage.get(CONFIG_KEY).expect("no data stored");
let state: State = from_json(&data).unwrap();
let state: State = from_json(data).unwrap();
assert_eq!(
state,
State {
Expand Down
4 changes: 2 additions & 2 deletions contracts/hackatom/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ fn querier_callbacks_work() {
// querying with balance gets the balance
let query_msg = QueryMsg::OtherBalance { address: rich_addr };
let query_response = query(&mut deps, mock_env(), query_msg).unwrap();
let bal: AllBalanceResponse = from_json(&query_response).unwrap();
let bal: AllBalanceResponse = from_json(query_response).unwrap();
assert_eq!(bal.amount, rich_balance);

// querying other accounts gets none
let query_msg = QueryMsg::OtherBalance {
address: String::from("someone else"),
};
let query_response = query(&mut deps, mock_env(), query_msg).unwrap();
let bal: AllBalanceResponse = from_json(&query_response).unwrap();
let bal: AllBalanceResponse = from_json(query_response).unwrap();
assert_eq!(bal.amount, vec![]);
}

Expand Down
12 changes: 6 additions & 6 deletions contracts/ibc-reflect-send/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ pub fn ibc_packet_ack(
// which local channel was this packet send from
let caller = msg.original_packet.src.channel_id;
// we need to parse the ack based on our request
let packet: PacketMsg = from_json(&msg.original_packet.data)?;
let packet: PacketMsg = from_json(msg.original_packet.data)?;
match packet {
PacketMsg::Dispatch { .. } => {
let res: AcknowledgementMsg<DispatchResponse> = from_json(&msg.acknowledgement.data)?;
let res: AcknowledgementMsg<DispatchResponse> = from_json(msg.acknowledgement.data)?;
acknowledge_dispatch(deps, caller, res)
}
PacketMsg::WhoAmI {} => {
let res: AcknowledgementMsg<WhoAmIResponse> = from_json(&msg.acknowledgement.data)?;
let res: AcknowledgementMsg<WhoAmIResponse> = from_json(msg.acknowledgement.data)?;
acknowledge_who_am_i(deps, caller, res)
}
PacketMsg::Balances {} => {
let res: AcknowledgementMsg<BalancesResponse> = from_json(&msg.acknowledgement.data)?;
let res: AcknowledgementMsg<BalancesResponse> = from_json(msg.acknowledgement.data)?;
acknowledge_balances(deps, env, caller, res)
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ mod tests {
channel_id: channel_id.into(),
};
let r = query(deps.as_ref(), mock_env(), q).unwrap();
let acct: AccountResponse = from_json(&r).unwrap();
let acct: AccountResponse = from_json(r).unwrap();
assert!(acct.remote_addr.is_none());
assert!(acct.remote_balance.is_empty());
assert_eq!(0, acct.last_update_time.nanos());
Expand All @@ -319,7 +319,7 @@ mod tests {
channel_id: channel_id.into(),
};
let r = query(deps.as_ref(), mock_env(), q).unwrap();
let acct: AccountResponse = from_json(&r).unwrap();
let acct: AccountResponse = from_json(r).unwrap();
assert_eq!(acct.remote_addr.unwrap(), remote_addr);
assert!(acct.remote_balance.is_empty());
assert_eq!(0, acct.last_update_time.nanos());
Expand Down
6 changes: 3 additions & 3 deletions contracts/ibc-reflect-send/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct AccountData {
pub fn may_load_account(storage: &dyn Storage, id: &str) -> StdResult<Option<AccountData>> {
storage
.get(&namespace_with_key(&[PREFIX_ACCOUNTS], id.as_bytes()))
.map(|v| from_json(&v))
.map(from_json)
.transpose()
}

Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn range_accounts(
.map(|(key, val)| {
Ok((
String::from_utf8(key[PREFIX_ACCOUNTS.len() + 2..].to_vec())?,
from_json(&val)?,
from_json(val)?,
))
})
}
Expand All @@ -72,7 +72,7 @@ pub fn load_config(storage: &dyn Storage) -> StdResult<Config> {
storage
.get(&to_length_prefixed(KEY_CONFIG))
.ok_or_else(|| StdError::not_found("config"))
.and_then(|v| from_json(&v))
.and_then(from_json)
}

pub fn save_config(storage: &mut dyn Storage, item: &Config) -> StdResult<()> {
Expand Down
18 changes: 9 additions & 9 deletions contracts/ibc-reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub fn ibc_packet_receive(
let packet = msg.packet;
// which local channel did this packet come on
let caller = packet.dest.channel_id;
let msg: PacketMsg = from_json(&packet.data)?;
let msg: PacketMsg = from_json(packet.data)?;
match msg {
PacketMsg::Dispatch { msgs } => receive_dispatch(deps, caller, msgs),
PacketMsg::WhoAmI {} => receive_who_am_i(deps, caller),
Expand Down Expand Up @@ -482,7 +482,7 @@ mod tests {

// no accounts set yet
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();
let res: ListAccountsResponse = from_json(&raw).unwrap();
let res: ListAccountsResponse = from_json(raw).unwrap();
assert_eq!(0, res.accounts.len());

// fake a reply and ensure this works
Expand All @@ -497,7 +497,7 @@ mod tests {

// ensure this is now registered
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();
let res: ListAccountsResponse = from_json(&raw).unwrap();
let res: ListAccountsResponse = from_json(raw).unwrap();
assert_eq!(1, res.accounts.len());
assert_eq!(
&res.accounts[0],
Expand All @@ -516,7 +516,7 @@ mod tests {
},
)
.unwrap();
let res: AccountResponse = from_json(&raw).unwrap();
let res: AccountResponse = from_json(raw).unwrap();
assert_eq!(res.account.unwrap(), REFLECT_ADDR);
}

Expand Down Expand Up @@ -546,7 +546,7 @@ mod tests {
res.events[0]
);
// acknowledgement is an error
let ack: AcknowledgementMsg<DispatchResponse> = from_json(&res.acknowledgement).unwrap();
let ack: AcknowledgementMsg<DispatchResponse> = from_json(res.acknowledgement).unwrap();
assert_eq!(
ack.unwrap_err(),
"invalid packet: account channel-123 not found"
Expand All @@ -560,7 +560,7 @@ mod tests {
let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap();

// assert app-level success
let ack: AcknowledgementMsg<()> = from_json(&res.acknowledgement).unwrap();
let ack: AcknowledgementMsg<()> = from_json(res.acknowledgement).unwrap();
ack.unwrap();

// and we dispatch the BankMsg via submessage
Expand Down Expand Up @@ -597,7 +597,7 @@ mod tests {
// we didn't dispatch anything
assert_eq!(0, res.messages.len());
// acknowledgement is an error
let ack: AcknowledgementMsg<DispatchResponse> = from_json(&res.acknowledgement).unwrap();
let ack: AcknowledgementMsg<DispatchResponse> = from_json(res.acknowledgement).unwrap();
assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`, `panic`, `return_err`, `return_msgs`");
}

Expand All @@ -616,7 +616,7 @@ mod tests {

// channel should be listed and have balance
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();
let res: ListAccountsResponse = from_json(&raw).unwrap();
let res: ListAccountsResponse = from_json(raw).unwrap();
assert_eq!(1, res.accounts.len());
let balance = deps.as_ref().querier.query_all_balances(account).unwrap();
assert_eq!(funds, balance);
Expand Down Expand Up @@ -652,7 +652,7 @@ mod tests {

// and removes the account lookup
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();
let res: ListAccountsResponse = from_json(&raw).unwrap();
let res: ListAccountsResponse = from_json(raw).unwrap();
assert_eq!(0, res.accounts.len());
}
}
Loading

0 comments on commit 2007e7a

Please sign in to comment.