From 36b124d1d5c080d9b28f319260c3205bc2a50975 Mon Sep 17 00:00:00 2001 From: "Demi M. Obenour" Date: Thu, 28 May 2020 12:34:08 -0400 Subject: [PATCH 1/2] Reformat --- src/frame/balances.rs | 21 +++++++++++++++++---- src/signer.rs | 26 +++++++++++++++++++++----- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/frame/balances.rs b/src/frame/balances.rs index cbbca1fbce..02e41d9342 100644 --- a/src/frame/balances.rs +++ b/src/frame/balances.rs @@ -16,11 +16,21 @@ //! Implements support for the pallet_balances module. -use crate::frame::system::{System, SystemEventsDecoder}; -use codec::{Decode, Encode}; +use crate::frame::system::{ + System, + SystemEventsDecoder, +}; +use codec::{ + Decode, + Encode, +}; use core::marker::PhantomData; use frame_support::Parameter; -use sp_runtime::traits::{AtLeast32Bit, MaybeSerialize, Member}; +use sp_runtime::traits::{ + AtLeast32Bit, + MaybeSerialize, + Member, +}; use std::fmt::Debug; /// The subset of the `pallet_balances::Trait` that a client must implement. @@ -100,7 +110,10 @@ pub struct TransferEvent { mod tests { use super::*; use crate::{ - system::{AccountStore, AccountStoreExt}, + system::{ + AccountStore, + AccountStoreExt, + }, tests::test_client, }; use sp_keyring::AccountKeyring; diff --git a/src/signer.rs b/src/signer.rs index 0ab07b2e1d..68657f04e1 100644 --- a/src/signer.rs +++ b/src/signer.rs @@ -17,18 +17,34 @@ //! A library to **sub**mit e**xt**rinsics to a //! [substrate](https://github.com/paritytech/substrate) node via RPC. -use crate::{extra::SignedExtra, frame::system::System, Encoded}; +use crate::{ + extra::SignedExtra, + frame::system::System, + Encoded, +}; use codec::Encode; use sp_core::Pair; use sp_runtime::{ - generic::{SignedPayload, UncheckedExtrinsic}, - traits::{IdentifyAccount, Verify, SignedExtension}, + generic::{ + SignedPayload, + UncheckedExtrinsic, + }, + traits::{ + IdentifyAccount, + SignedExtension, + Verify, + }, +}; +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, }; -use std::{future::Future, marker::PhantomData, pin::Pin}; /// Extrinsic signer. pub trait Signer> - where <>::Extra as SignedExtension>::AdditionalSigned: Send + Sync +where + <>::Extra as SignedExtension>::AdditionalSigned: Send + Sync, { /// Returns the account id. fn account_id(&self) -> &T::AccountId; From bc19991b7a2584fbde7a026d85395a8c28f6a53f Mon Sep 17 00:00:00 2001 From: "Demi M. Obenour" Date: Thu, 28 May 2020 12:36:38 -0400 Subject: [PATCH 2/2] Refactor as suggested by Andrew Jones (@ascjones). --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 76d03cd0b8..5c28706056 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,10 +46,7 @@ pub use sp_core; pub use sp_runtime; use codec::Encode; -use futures::{ - future, - future::TryFutureExt as _, -}; +use futures::future; use jsonrpsee::client::Subscription; use sc_rpc_api::state::ReadProof; use sp_core::storage::{ @@ -344,7 +341,8 @@ where let unsigned = self .create_unsigned(call, signer.account_id(), signer.nonce()) .await?; - signer.sign(unsigned).map_err(From::from).await + let signed = signer.sign(unsigned).await?; + Ok(signed) } /// Returns an events decoder for a call.