Skip to content

Commit

Permalink
fix: clippy warnings
Browse files Browse the repository at this point in the history
Co-authored-by: Belsy Yuen <belsy@equilibrium.co>
Signed-off-by: Niklas Long <niklas@equilibrium.co>
  • Loading branch information
niklaslong and whalelephant committed Oct 1, 2020
1 parent 4593e9c commit 2b61c7c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
4 changes: 1 addition & 3 deletions crates/interledger-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ where
{
match NumOrStr::deserialize(deserializer)? {
NumOrStr::Num(n) => Ok(Some(n)),
NumOrStr::Str(s) => T::from_str(&s)
.map_err(de::Error::custom)
.and_then(|n| Ok(Some(n))),
NumOrStr::Str(s) => T::from_str(&s).map_err(de::Error::custom).map(Some),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/interledger-api/src/routes/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{number_or_string, AccountDetails, AccountSettings, NodeStore};
use bytes::Bytes;
use futures::{Future, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
use futures::{Future, FutureExt, StreamExt, TryFutureExt};
use interledger_btp::{connect_to_service_account, BtpAccount, BtpOutgoingService};
use interledger_ccp::{CcpRoutingAccount, Mode, RouteControlRequest, RoutingRelation};
use interledger_errors::*;
Expand Down
2 changes: 0 additions & 2 deletions crates/interledger-service-util/src/echo_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ where
}
};

let source_address = Address::try_from(source_address).unwrap();

// create a new prepare packet to echo the prepare
let execution_condition =
<[u8; 32]>::try_from(request.prepare.execution_condition()).unwrap();
Expand Down
8 changes: 1 addition & 7 deletions crates/interledger-spsp/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use super::{Error, SpspResponse};
use futures::TryFutureExt;
use interledger_packet::Address;
use interledger_rates::ExchangeRateStore;
use interledger_service::{Account, IncomingService};
use interledger_stream::{send_money, StreamDelivery};
use reqwest::Client;
use std::convert::TryFrom;
use tracing::{debug, error, trace};

/// Get an ILP Address and shared secret by the receiver of this payment for this connection
Expand Down Expand Up @@ -48,11 +46,7 @@ where
{
let spsp = query(receiver).await?;
let shared_secret = spsp.shared_secret;
let dest = spsp.destination_account;
let addr = Address::try_from(dest).map_err(move |err| {
error!("Error parsing address");
Error::InvalidSpspServerResponseError(err.to_string())
})?;
let addr = spsp.destination_account;
debug!("Sending SPSP payment to address: {}", addr);

let receipt = send_money(
Expand Down
22 changes: 7 additions & 15 deletions crates/interledger-stream/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,8 @@ mod receiving_money {
let data = stream_packet.into_encrypted(&shared_secret[..]);
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand All @@ -414,9 +413,8 @@ mod receiving_money {
let data = stream_packet.into_encrypted(&shared_secret[..]);
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand All @@ -443,9 +441,8 @@ mod receiving_money {
data.extend_from_slice(b"x");
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand Down Expand Up @@ -482,9 +479,8 @@ mod receiving_money {
let data = stream_packet.into_encrypted(&shared_secret[..]);
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand Down Expand Up @@ -534,7 +530,6 @@ mod stream_receiver_service {
use interledger_packet::PrepareBuilder;
use interledger_service::outgoing_service_fn;

use std::convert::TryFrom;
use std::str::FromStr;
use std::time::UNIX_EPOCH;

Expand All @@ -549,9 +544,8 @@ mod stream_receiver_service {
let data = stream_packet.into_encrypted(&shared_secret[..]);
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand Down Expand Up @@ -602,10 +596,9 @@ mod stream_receiver_service {
let execution_condition = generate_condition(&shared_secret[..], &data);

data.extend_from_slice(b"extra");
let dest = Address::try_from(destination_account).unwrap();

let prepare = PrepareBuilder {
destination: dest,
destination: destination_account,
amount: 100,
expires_at: UNIX_EPOCH,
data: &data[..],
Expand Down Expand Up @@ -663,8 +656,7 @@ mod stream_receiver_service {
let data = stream_packet.into_encrypted(&shared_secret[..]);
let execution_condition = generate_condition(&shared_secret[..], &data);

let dest = Address::try_from(destination_account).unwrap();
let dest = dest.with_suffix(b"extra").unwrap();
let dest = destination_account.with_suffix(b"extra").unwrap();

let prepare = PrepareBuilder {
destination: dest,
Expand Down

0 comments on commit 2b61c7c

Please sign in to comment.