From ab5524f5d41a60c1a6152d1f51a9878673dc586b Mon Sep 17 00:00:00 2001
From: bgallois <benjamin@gallois.cc>
Date: Wed, 20 Mar 2024 17:28:54 +0100
Subject: [PATCH] remove impl-for-tuples

---
 Cargo.lock                       |  2 --
 Cargo.toml                       |  1 -
 pallets/identity/Cargo.toml      |  1 -
 pallets/identity/src/traits.rs   | 32 ++++++++++----------------------
 primitives/membership/Cargo.toml |  1 -
 primitives/membership/src/lib.rs | 26 ++++++--------------------
 6 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 59fb60db4..7ec7e9a8b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6413,7 +6413,6 @@ dependencies = [
  "frame-benchmarking",
  "frame-support",
  "frame-system",
- "impl-trait-for-tuples",
  "parity-scale-codec",
  "scale-info",
  "serde",
@@ -10366,7 +10365,6 @@ name = "sp-membership"
 version = "1.0.0"
 dependencies = [
  "frame-support",
- "impl-trait-for-tuples",
  "parity-scale-codec",
  "scale-info",
  "serde",
diff --git a/Cargo.toml b/Cargo.toml
index ff092519e..1a2dc0b34 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -63,7 +63,6 @@ graphql_client = { version = "0.10.0" }
 bs58 = { version = "0.5.0", default-features = false }
 placeholder = { version = "1.1.3", default-features = false }
 getrandom = { version = "0.2.12", default-features = false }
-impl-trait-for-tuples = { version = "0.2.2", default-features = false }
 clap = { version = "4.4.18" }
 clap_complete = { version = "4.4.10" }
 reqwest = { version = "0.11.11", default-features = false }
diff --git a/pallets/identity/Cargo.toml b/pallets/identity/Cargo.toml
index 4cbd9dab0..c62eaa2cc 100644
--- a/pallets/identity/Cargo.toml
+++ b/pallets/identity/Cargo.toml
@@ -52,7 +52,6 @@ duniter-primitives = { workspace = true }
 frame-benchmarking = { workspace = true, optional = true }
 frame-support = { workspace = true }
 frame-system = { workspace = true }
-impl-trait-for-tuples = { workspace = true }
 scale-info = { workspace = true, features = ["derive"] }
 serde = { workspace = true, features = ["derive"] }
 sp-core = { workspace = true }
diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs
index 1a7b30093..ed8a2e2e4 100644
--- a/pallets/identity/src/traits.rs
+++ b/pallets/identity/src/traits.rs
@@ -17,7 +17,6 @@
 use crate::*;
 use frame_support::pallet_prelude::*;
 use frame_support::weights::Weight;
-use impl_trait_for_tuples::impl_for_tuples;
 
 /// A trait defining operations for checking if identity-related calls are allowed.
 pub trait CheckIdtyCallAllowed<T: Config> {
@@ -25,10 +24,8 @@ pub trait CheckIdtyCallAllowed<T: Config> {
     fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>;
 }
 
-#[impl_for_tuples(5)]
-impl<T: Config> CheckIdtyCallAllowed<T> for Tuple {
-    fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError> {
-        for_tuples!( #( Tuple::check_create_identity(creator)?; )* );
+impl<T: Config> CheckIdtyCallAllowed<T> for () {
+    fn check_create_identity(_creator: T::IdtyIndex) -> Result<(), DispatchError> {
         Ok(())
     }
 }
@@ -55,27 +52,17 @@ pub trait OnRemoveIdty<T: Config> {
     fn on_revoked(idty_index: &T::IdtyIndex) -> Weight;
 }
 
-#[impl_for_tuples(5)]
-#[allow(clippy::let_and_return)]
-impl<T: Config> OnNewIdty<T> for Tuple {
-    fn on_created(idty_index: &T::IdtyIndex, creator: &T::IdtyIndex) {
-        for_tuples!( #( Tuple::on_created(idty_index, creator); )* );
-    }
+impl<T: Config> OnNewIdty<T> for () {
+    fn on_created(_idty_index: &T::IdtyIndex, _creator: &T::IdtyIndex) {}
 }
 
-#[impl_for_tuples(5)]
-#[allow(clippy::let_and_return)]
-impl<T: Config> OnRemoveIdty<T> for Tuple {
-    fn on_removed(idty_index: &T::IdtyIndex) -> Weight {
-        let mut weight = Weight::zero();
-        for_tuples!( #( weight = weight.saturating_add(Tuple::on_removed(idty_index)); )* );
-        weight
+impl<T: Config> OnRemoveIdty<T> for () {
+    fn on_removed(_idty_index: &T::IdtyIndex) -> Weight {
+        Weight::zero()
     }
 
-    fn on_revoked(idty_index: &T::IdtyIndex) -> Weight {
-        let mut weight = Weight::zero();
-        for_tuples!( #( weight = weight.saturating_add(Tuple::on_revoked(idty_index)); )* );
-        weight
+    fn on_revoked(_idty_index: &T::IdtyIndex) -> Weight {
+        Weight::zero()
     }
 }
 
@@ -84,6 +71,7 @@ pub trait LinkIdty<AccountId, IdtyIndex> {
     /// Links an identity to an account.
     fn link_identity(account_id: &AccountId, idty_index: IdtyIndex) -> Result<(), DispatchError>;
 }
+
 impl<AccountId, IdtyIndex> LinkIdty<AccountId, IdtyIndex> for () {
     fn link_identity(_: &AccountId, _: IdtyIndex) -> Result<(), DispatchError> {
         Ok(())
diff --git a/primitives/membership/Cargo.toml b/primitives/membership/Cargo.toml
index 0a7973390..d7ac4600f 100644
--- a/primitives/membership/Cargo.toml
+++ b/primitives/membership/Cargo.toml
@@ -30,7 +30,6 @@ runtime-benchmarks = []
 
 codec = { workspace = true, features = ["derive"] }
 frame-support = { workspace = true }
-impl-trait-for-tuples = { workspace = true }
 scale-info = { workspace = true, features = ["derive"] }
 serde = { workspace = true }
 sp-runtime = { workspace = true }
diff --git a/primitives/membership/src/lib.rs b/primitives/membership/src/lib.rs
index e74247356..49756dda2 100644
--- a/primitives/membership/src/lib.rs
+++ b/primitives/membership/src/lib.rs
@@ -55,28 +55,14 @@ pub struct MembershipData<BlockNumber: Decode + Encode + TypeInfo> {
     pub expire_on: BlockNumber,
 }
 
-use impl_trait_for_tuples::impl_for_tuples;
-// use sp_std::prelude::*;
-// use frame_support::pallet_prelude::*;
-// use frame_system::pallet_prelude::*;
+impl<IdtyId> traits::OnNewMembership<IdtyId> for () {
+    fn on_created(_idty_index: &IdtyId) {}
 
-#[impl_for_tuples(5)]
-impl<IdtyId> traits::OnNewMembership<IdtyId> for Tuple {
-    fn on_created(idty_index: &IdtyId) {
-        for_tuples!( #(Tuple::on_created(idty_index); )* );
-    }
-
-    fn on_renewed(idty_index: &IdtyId) {
-        for_tuples!( #( Tuple::on_renewed(idty_index); )* );
-    }
+    fn on_renewed(_idty_index: &IdtyId) {}
 }
 
-#[impl_for_tuples(5)]
-#[allow(clippy::let_and_return)]
-impl<IdtyId> traits::OnRemoveMembership<IdtyId> for Tuple {
-    fn on_removed(idty_index: &IdtyId) -> Weight {
-        let mut weight = Weight::zero();
-        for_tuples!( #( weight = weight.saturating_add(Tuple::on_removed(idty_index)); )* );
-        weight
+impl<IdtyId> traits::OnRemoveMembership<IdtyId> for () {
+    fn on_removed(_idty_index: &IdtyId) -> Weight {
+        Weight::zero()
     }
 }
-- 
GitLab