Pārlūkot izejas kodu

Add linter fixes

Shamil Gadelshin 4 gadi atpakaļ
vecāks
revīzija
29b5c0d48c

+ 1 - 1
.travis.yml

@@ -15,7 +15,7 @@ matrix:
 
 before_install:
   - rustup component add rustfmt
-#  - cargo fmt --all -- --check
+  - cargo fmt --all -- --check
   - rustup component add clippy
   - BUILD_DUMMY_WASM_BINARY=1 cargo clippy -- -D warnings
   - rustup default stable

+ 1 - 1
Cargo.lock

@@ -1614,7 +1614,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "6.12.1"
+version = "6.12.2"
 dependencies = [
  "parity-scale-codec",
  "safe-mix",

+ 7 - 5
node/src/chain_spec.rs

@@ -14,6 +14,10 @@
 // You should have received a copy of the GNU General Public License
 // along with Joystream node.  If not, see <http://www.gnu.org/licenses/>.
 
+// Clippy linter warning.
+#![allow(clippy::identity_op)] // disable it because we use such syntax for a code readability
+                               // Example:  voting_period: 1 * DAY
+
 use node_runtime::{
     versioned_store::InputValidationLengthConstraint as VsInputValidation, ActorsConfig,
     AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
@@ -154,7 +158,7 @@ impl Alternative {
 }
 
 fn new_vs_validation(min: u16, max_min_diff: u16) -> VsInputValidation {
-    return VsInputValidation { min, max_min_diff };
+    VsInputValidation { min, max_min_diff }
 }
 
 pub fn chain_spec_properties() -> json::map::Map<String, json::Value> {
@@ -218,9 +222,7 @@ pub fn testnet_genesis(
             slash_reward_fraction: Perbill::from_percent(10),
             ..Default::default()
         }),
-        sudo: Some(SudoConfig {
-            key: root_key.clone(),
-        }),
+        sudo: Some(SudoConfig { key: root_key }),
         babe: Some(BabeConfig {
             authorities: vec![],
         }),
@@ -274,7 +276,7 @@ pub fn testnet_genesis(
             class_description_constraint: new_vs_validation(1, 999),
         }),
         content_wg: Some(ContentWorkingGroupConfig {
-            mint_capacity: 100000,
+            mint_capacity: 100_000,
             curator_opening_by_id: vec![],
             next_curator_opening_id: 0,
             curator_application_by_id: vec![],

+ 1 - 1
node/src/cli.rs

@@ -90,7 +90,7 @@ where
         let exit = e
             .into_exit()
             .map_err(|_| error::Error::Other("Exit future failed.".into()));
-        let service = service.map_err(|err| error::Error::Service(err));
+        let service = service.map_err(error::Error::Service);
         let select = service.select(exit).map(|_| ()).map_err(|(err, _)| err);
         runtime.block_on(select)
     };

+ 1 - 1
node/src/forum_config/mod.rs

@@ -6,5 +6,5 @@ pub mod from_serialized;
 use node_runtime::forum::InputValidationLengthConstraint;
 
 pub fn new_validation(min: u16, max_min_diff: u16) -> InputValidationLengthConstraint {
-    return InputValidationLengthConstraint { min, max_min_diff };
+    InputValidationLengthConstraint { min, max_min_diff }
 }

+ 6 - 0
node/src/service.rs

@@ -16,6 +16,12 @@
 
 #![warn(unused_extern_crates)]
 
+// Clippy linter warning.
+#![allow(clippy::type_complexity)] // disable it because this is foreign code and can be changed any time
+
+// Clippy linter warning.
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+
 //! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
 
 use client_db::Backend;

+ 15 - 7
runtime-modules/content-working-group/src/lib.rs

@@ -1,3 +1,10 @@
+// Clippy linter warning. TODO: remove after the Constaninople release
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+
+// Clippy linter warning. TODO: refactor "this function has too many argument"
+#![allow(clippy::too_many_arguments)] // disable it because of possible API break
+
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 
@@ -15,6 +22,7 @@ use serde::{Deserialize, Serialize};
 use codec::{Decode, Encode}; // Codec
                              //use rstd::collections::btree_map::BTreeMap;
 use membership::{members, role_types};
+use rstd::borrow::ToOwned;
 use rstd::collections::btree_map::BTreeMap;
 use rstd::collections::btree_set::BTreeSet;
 use rstd::convert::From;
@@ -310,12 +318,12 @@ impl<BlockNumber: Clone> CuratorExitSummary<BlockNumber> {
     pub fn new(
         origin: &CuratorExitInitiationOrigin,
         initiated_at_block_number: &BlockNumber,
-        rationale_text: &Vec<u8>,
+        rationale_text: &[u8],
     ) -> Self {
         CuratorExitSummary {
             origin: (*origin).clone(),
             initiated_at_block_number: (*initiated_at_block_number).clone(),
-            rationale_text: (*rationale_text).clone(),
+            rationale_text: rationale_text.to_owned(),
         }
     }
 }
@@ -1190,7 +1198,7 @@ decl_module! {
             ChannelById::<T>::insert(next_channel_id, new_channel);
 
             // Add id to ChannelIdByHandle under handle
-            ChannelIdByHandle::<T>::insert(handle.clone(), next_channel_id);
+            ChannelIdByHandle::<T>::insert(handle, next_channel_id);
 
             // Increment NextChannelId
             NextChannelId::<T>::mutate(|id| *id += <ChannelId<T> as One>::one());
@@ -1231,7 +1239,7 @@ decl_module! {
             // Construct new channel with altered properties
             let new_channel = Channel {
                 owner: new_owner,
-                role_account: new_role_account.clone(),
+                role_account: new_role_account,
                 ..channel
             };
 
@@ -2179,7 +2187,7 @@ impl<T: Trait> Module<T> {
         ),
         &'static str,
     > {
-        let next_channel_id = opt_channel_id.unwrap_or(NextChannelId::<T>::get());
+        let next_channel_id = opt_channel_id.unwrap_or_else(NextChannelId::<T>::get);
 
         Self::ensure_can_register_role_on_member(
             member_id,
@@ -2191,7 +2199,7 @@ impl<T: Trait> Module<T> {
 
     // TODO: convert InputConstraint ensurer routines into macroes
 
-    fn ensure_channel_handle_is_valid(handle: &Vec<u8>) -> dispatch::Result {
+    fn ensure_channel_handle_is_valid(handle: &[u8]) -> dispatch::Result {
         ChannelHandleConstraint::get().ensure_valid(
             handle.len(),
             MSG_CHANNEL_HANDLE_TOO_SHORT,
@@ -2638,7 +2646,7 @@ impl<T: Trait> Module<T> {
             PrincipalId<T>,
         >,
         exit_initiation_origin: &CuratorExitInitiationOrigin,
-        rationale_text: &Vec<u8>,
+        rationale_text: &[u8],
     ) {
         // Stop any possible recurring rewards
         let _did_deactivate_recurring_reward = if let Some(ref reward_relationship_id) =

+ 11 - 0
runtime-modules/forum/src/lib.rs

@@ -1,3 +1,8 @@
+// Clippy linter warning
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+// TODO: remove post-Constaninople
+
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 
@@ -947,6 +952,9 @@ impl<T: Trait> Module<T> {
         Self::ensure_can_mutate_in_path_leaf(&category_tree_path)
     }
 
+    // Clippy linter warning
+    #[allow(clippy::ptr_arg)] // disable it because of possible frontend API break
+                              // TODO: remove post-Constaninople
     fn ensure_can_mutate_in_path_leaf(
         category_tree_path: &CategoryTreePath<T::BlockNumber, T::Moment, T::AccountId>,
     ) -> dispatch::Result {
@@ -961,6 +969,9 @@ impl<T: Trait> Module<T> {
         Ok(())
     }
 
+    // TODO: remove post-Constaninople
+    // Clippy linter warning
+    #[allow(clippy::ptr_arg)] // disable it because of possible frontend API break
     fn ensure_can_add_subcategory_path_leaf(
         category_tree_path: &CategoryTreePath<T::BlockNumber, T::Moment, T::AccountId>,
     ) -> dispatch::Result {

+ 28 - 19
runtime-modules/governance/src/election.rs

@@ -21,6 +21,14 @@
 //!
 //! [`set_election_parameters`]: struct.Module.html#method.set_election_parameters
 
+// Clippy linter warning
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+// TODO: remove post-Constaninople
+
+// Clippy linter warning
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+
 use rstd::prelude::*;
 use srml_support::traits::{Currency, ReservableCurrency};
 use srml_support::{decl_event, decl_module, decl_storage, dispatch::Result, ensure};
@@ -297,6 +305,7 @@ impl<T: Trait> Module<T> {
         if len >= applicants.len() {
             &[]
         } else {
+            #[allow(clippy::redundant_closure)] // disable incorrect Clippy linter warning
             applicants.sort_by_key(|applicant| Self::applicant_stakes(applicant));
             &applicants[0..applicants.len() - len]
         }
@@ -351,17 +360,21 @@ impl<T: Trait> Module<T> {
             }
         }
 
-        if new_council.len() == Self::council_size_usize() {
-            // all applicants in the tally will form the new council
-        } else if new_council.len() > Self::council_size_usize() {
-            // we have more than enough applicants to form the new council.
-            // select top staked
-            Self::filter_top_staked(&mut new_council, Self::council_size_usize());
-        } else {
-            // Not enough applicants with votes to form a council.
-            // This may happen if we didn't add applicants with zero votes to the tally,
-            // or in future if we allow applicants to withdraw candidacy during voting or revealing stages.
-            // or council size was increased during voting, revealing stages.
+        match new_council.len() {
+            ncl if ncl == Self::council_size_usize() => {
+                // all applicants in the tally will form the new council
+            }
+            ncl if ncl > Self::council_size_usize() => {
+                // we have more than enough applicants to form the new council.
+                // select top staked
+                Self::filter_top_staked(&mut new_council, Self::council_size_usize());
+            }
+            _ => {
+                // Not enough applicants with votes to form a council.
+                // This may happen if we didn't add applicants with zero votes to the tally,
+                // or in future if we allow applicants to withdraw candidacy during voting or revealing stages.
+                // or council size was increased during voting, revealing stages.
+            }
         }
 
         // unless we want to add more filtering criteria to what is considered a successful election
@@ -380,7 +393,7 @@ impl<T: Trait> Module<T> {
     }
 
     fn teardown_election(
-        votes: &Vec<SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>>,
+        votes: &[SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>],
         new_council: &BTreeMap<T::AccountId, Seat<T::AccountId, BalanceOf<T>>>,
         unlock_ts: bool,
     ) {
@@ -469,7 +482,7 @@ impl<T: Trait> Module<T> {
     }
 
     fn refund_voting_stakes(
-        sealed_votes: &Vec<SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>>,
+        sealed_votes: &[SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>],
         new_council: &BTreeMap<T::AccountId, Seat<T::AccountId, BalanceOf<T>>>,
     ) {
         for sealed_vote in sealed_votes.iter() {
@@ -507,7 +520,7 @@ impl<T: Trait> Module<T> {
     }
 
     fn tally_votes(
-        sealed_votes: &Vec<SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>>,
+        sealed_votes: &[SealedVote<T::AccountId, Stake<BalanceOf<T>>, T::Hash, T::AccountId>],
     ) -> BTreeMap<T::AccountId, Seat<T::AccountId, BalanceOf<T>>> {
         let mut tally: BTreeMap<T::AccountId, Seat<T::AccountId, BalanceOf<T>>> = BTreeMap::new();
 
@@ -912,11 +925,7 @@ decl_module! {
 impl<T: Trait> council::CouncilTermEnded for Module<T> {
     fn council_term_ended() {
         if Self::auto_start() {
-            if Self::start_election(<council::Module<T>>::active_council()).is_ok() {
-                // emit ElectionStarted
-            } else {
-                // emit ElectionFailedStart
-            }
+            let _ = Self::start_election(<council::Module<T>>::active_council());
         }
     }
 }

+ 2 - 2
runtime-modules/membership/src/members.rs

@@ -1,12 +1,12 @@
 // Clippy linter requirement
 #![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-// example:  pub PaidMembershipTermsById get(paid_membership_terms_by_id) build(|config: &GenesisConfig<T>| {}
+                                          // example:  pub PaidMembershipTermsById get(paid_membership_terms_by_id) build(|config: &GenesisConfig<T>| {}
 
 use codec::{Codec, Decode, Encode};
 use common::currency::{BalanceOf, GovernanceCurrency};
 
-use rstd::prelude::*;
 use rstd::borrow::ToOwned;
+use rstd::prelude::*;
 use sr_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic};
 use srml_support::traits::{Currency, Get};
 use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, Parameter};

+ 15 - 10
runtime-modules/proposals/codex/src/lib.rs

@@ -34,6 +34,12 @@
 //! - [governance](../substrate_governance_module/index.html)
 //! - [content_working_group](../substrate_content_working_group_module/index.html)
 //!
+// Clippy linter warning. TODO: remove after the Constaninople release
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+
+// Clippy linter warning. TODO: refactor "this function has too many argument"
+#![allow(clippy::too_many_arguments)] // disable it because of possible API break
 
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
@@ -336,7 +342,7 @@ decl_module! {
             Self::ensure_council_election_parameters_valid(&election_parameters)?;
 
             let proposal_code =
-                <governance::election::Call<T>>::set_election_parameters(election_parameters.clone());
+                <governance::election::Call<T>>::set_election_parameters(election_parameters);
 
             let proposal_parameters =
                 proposal_types::parameters::set_election_parameters_proposal::<T>();
@@ -373,7 +379,7 @@ decl_module! {
             );
 
             let proposal_code =
-                <content_working_group::Call<T>>::set_mint_capacity(mint_balance.clone());
+                <content_working_group::Call<T>>::set_mint_capacity(mint_balance);
 
             let proposal_parameters =
                 proposal_types::parameters::set_content_working_group_mint_capacity_proposal::<T>();
@@ -416,7 +422,7 @@ decl_module! {
             );
 
             let proposal_code = <governance::council::Call<T>>::spend_from_council_mint(
-                balance.clone(),
+                balance,
                 destination.clone()
             );
 
@@ -552,7 +558,7 @@ decl_module! {
 
             let proposal_code = <roles::actors::Call<T>>::set_role_parameters(
                 Role::StorageProvider,
-                role_parameters.clone()
+                role_parameters
             );
 
             let proposal_parameters =
@@ -646,8 +652,7 @@ impl<T: Trait> Module<T> {
             T::MemberId,
         >,
     ) -> DispatchResult<Error> {
-        let account_id =
-            T::MembershipOriginValidator::ensure_actor_origin(origin, member_id.clone())?;
+        let account_id = T::MembershipOriginValidator::ensure_actor_origin(origin, member_id)?;
 
         <proposal_engine::Module<T>>::ensure_create_proposal_parameters_are_valid(
             &proposal_parameters,
@@ -656,7 +661,7 @@ impl<T: Trait> Module<T> {
             stake_balance,
         )?;
 
-        <proposal_discussion::Module<T>>::ensure_can_create_thread(member_id.clone(), &title)?;
+        <proposal_discussion::Module<T>>::ensure_can_create_thread(member_id, &title)?;
 
         let discussion_thread_id =
             <proposal_discussion::Module<T>>::create_thread(member_id, title.clone())?;
@@ -829,7 +834,7 @@ impl<T: Trait> Module<T> {
 
         ensure!(
             election_parameters.min_voting_stake
-                <= <BalanceOfGovernanceCurrency<T>>::from(100000u32),
+                <= <BalanceOfGovernanceCurrency<T>>::from(100_000_u32),
             Error::InvalidCouncilElectionParameterMinVotingStake
         );
 
@@ -839,7 +844,7 @@ impl<T: Trait> Module<T> {
         );
 
         ensure!(
-            election_parameters.new_term_duration <= T::BlockNumber::from(432000),
+            election_parameters.new_term_duration <= T::BlockNumber::from(432_000),
             Error::InvalidCouncilElectionParameterNewTermDuration
         );
 
@@ -880,7 +885,7 @@ impl<T: Trait> Module<T> {
 
         ensure!(
             election_parameters.min_council_stake
-                <= <BalanceOfGovernanceCurrency<T>>::from(100000u32),
+                <= <BalanceOfGovernanceCurrency<T>>::from(100_000_u32),
             Error::InvalidCouncilElectionParameterMinCouncilStake
         );
 

+ 1 - 1
runtime-modules/proposals/codex/src/proposal_types/parameters.rs

@@ -46,7 +46,7 @@ pub(crate) fn set_election_parameters_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
         voting_period: T::BlockNumber::from(72000u32),
-        grace_period: T::BlockNumber::from(201601u32),
+        grace_period: T::BlockNumber::from(201_601_u32),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,

+ 7 - 0
runtime-modules/recurring-reward/src/lib.rs

@@ -1,3 +1,10 @@
+// Clippy linter warning. TODO: remove after the Constaninople release
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+
+// Clippy linter warning. TODO: refactor the Option<Option<>>
+#![allow(clippy::option_option)] // disable it because of possible API break
+
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 use rstd::prelude::*;

+ 2 - 3
runtime-modules/roles/src/actors.rs

@@ -1,6 +1,6 @@
-// Clippy linter requirement
+// Clippy linter warning
 #![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-// example:  pub Parameters get(parameters) build(|config: &GenesisConfig| {..}
+                                          // example:  pub Parameters get(parameters) build(|config: &GenesisConfig| {..}
 
 use codec::{Decode, Encode};
 use common::currency::{BalanceOf, GovernanceCurrency};
@@ -17,7 +17,6 @@ use serde::{Deserialize, Serialize};
 
 pub use membership::members::Role;
 
-
 const STAKING_ID: LockIdentifier = *b"role_stk";
 
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]

+ 1 - 1
runtime-modules/storage/src/data_directory.rs

@@ -164,7 +164,7 @@ decl_module! {
 
         fn reject_content(origin, content_id: T::ContentId) {
             let who = ensure_signed(origin)?;
-            Self::update_content_judgement(&who, content_id.clone(), LiaisonJudgement::Rejected)?;
+            Self::update_content_judgement(&who, content_id, LiaisonJudgement::Rejected)?;
             Self::deposit_event(RawEvent::ContentRejected(content_id, who));
         }
 

+ 6 - 2
runtime-modules/storage/src/data_object_storage_registry.rs

@@ -1,3 +1,7 @@
+// Clippy linter requirement
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+                                          // example:  pub NextRelationshipId get(next_relationship_id) build(|config: &GenesisConfig<T>|
+
 use crate::data_directory::Trait as DDTrait;
 use crate::traits::{ContentHasStorage, ContentIdExists};
 use codec::{Codec, Decode, Encode};
@@ -97,14 +101,14 @@ impl<T: Trait> ContentHasStorage<T> for Module<T> {
     // TODO deprecated
     fn has_storage_provider(which: &T::ContentId) -> bool {
         let dosr_list = Self::relationships_by_content_id(which);
-        return dosr_list.iter().any(|&dosr_id| {
+        dosr_list.iter().any(|&dosr_id| {
             let res = Self::relationships(dosr_id);
             if res.is_none() {
                 return false;
             }
             let dosr = res.unwrap();
             dosr.ready
-        });
+        })
     }
 
     // TODO deprecated

+ 4 - 0
runtime-modules/storage/src/data_object_type_registry.rs

@@ -1,3 +1,7 @@
+// Clippy linter requirement
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+                                          // example:   NextDataObjectTypeId get(next_data_object_type_id) build(|config: &GenesisConfig<T>|
+
 use crate::traits;
 use codec::{Codec, Decode, Encode};
 use rstd::prelude::*;

+ 5 - 0
runtime-modules/token-minting/src/lib.rs

@@ -1,3 +1,8 @@
+// Clippy linter warning
+#![allow(clippy::type_complexity)]
+// disable it because of possible frontend API break
+// TODO: remove post-Constaninople
+
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 

+ 1 - 1
runtime/Cargo.toml

@@ -5,7 +5,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '6.12.1'
+version = '6.12.2'
 
 [features]
 default = ['std']

+ 4 - 4
runtime/src/lib.rs

@@ -483,7 +483,7 @@ impl versioned_store_permissions::CredentialChecker<Runtime> for ContentWorkingG
                     }
                 }
 
-                return false;
+                false
             }
             // Any Active Channel Owner
             credential if credential == AnyActiveChannelOwnerCredential::get() => {
@@ -498,7 +498,7 @@ impl versioned_store_permissions::CredentialChecker<Runtime> for ContentWorkingG
                     }
                 }
 
-                return false;
+                false
             }
             // mapping to workging group principal id
             n if n >= PrincipalIdMappingStartsAtCredential::get() => {
@@ -737,7 +737,7 @@ impl roles::traits::Roles<Runtime> for LookupRoles {
             .filter(|id| !<discovery::Module<Runtime>>::is_account_info_expired(id))
             .collect();
 
-        if live_ids.len() == 0 {
+        if live_ids.is_empty() {
             Err("no staked account found")
         } else {
             let index = random_index(live_ids.len());
@@ -841,7 +841,7 @@ impl Default for Call {
 
 parameter_types! {
     pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
-    pub const ProposalMaxThreadInARowNumber: u32 = 100000; // will not be used
+    pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
     pub const ProposalThreadTitleLengthLimit: u32 = 40;
     pub const ProposalPostLengthLimit: u32 = 1000;
 }

+ 3 - 0
runtime/src/migration.rs

@@ -1,3 +1,6 @@
+// Clippy linter warning
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+
 use crate::VERSION;
 use sr_primitives::{print, traits::Zero};
 use srml_support::{decl_event, decl_module, decl_storage};

+ 2 - 2
utils/chain-spec-builder/src/main.rs

@@ -152,11 +152,11 @@ fn generate_chain_spec(
         None, // Default::default(),
     );
 
-    chain_spec.to_json(false).map_err(|err| err.to_string())
+    chain_spec.to_json(false).map_err(|err| err)
 }
 
 fn generate_authority_keys_and_store(seeds: &[String], keystore_path: &Path) -> Result<(), String> {
-    for (n, seed) in seeds.into_iter().enumerate() {
+    for (n, seed) in seeds.iter().enumerate() {
         let keystore = Keystore::open(keystore_path.join(format!("auth-{}", n)), None)
             .map_err(|err| err.to_string())?;