From 846f4d8d6430f6cfff3b529a89bfc2787c00ae38 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Sat, 8 Jan 2022 22:37:58 +0100
Subject: [PATCH] feat(runtimes): add pallet utility & pallet multisig in all
 runtimes

---
 Cargo.lock                           | 20 +++++++++++
 runtime/common/src/pallets_config.rs | 53 ++++++++++++++++++++--------
 runtime/g1/Cargo.toml                | 10 ++++++
 runtime/g1/src/lib.rs                |  5 ++-
 runtime/g1/src/parameters.rs         |  7 ++++
 runtime/gdev/Cargo.toml              |  5 +++
 runtime/gdev/src/lib.rs              | 12 +------
 runtime/gdev/src/parameters.rs       | 14 ++++----
 runtime/gtest/Cargo.toml             | 11 ++++++
 runtime/gtest/src/lib.rs             |  5 ++-
 runtime/gtest/src/parameters.rs      |  7 ++++
 11 files changed, 115 insertions(+), 34 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 6a425298c..46df2a546 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1842,6 +1842,7 @@ dependencies = [
  "pallet-certification",
  "pallet-grandpa",
  "pallet-identity",
+ "pallet-multisig",
  "pallet-randomness-collective-flip",
  "pallet-sudo",
  "pallet-timestamp",
@@ -1849,6 +1850,7 @@ dependencies = [
  "pallet-transaction-payment-rpc-runtime-api",
  "pallet-ud-accounts-storage",
  "pallet-universal-dividend",
+ "pallet-utility",
  "parity-scale-codec",
  "scale-info",
  "serde",
@@ -1898,6 +1900,7 @@ dependencies = [
  "pallet-transaction-payment-rpc-runtime-api",
  "pallet-ud-accounts-storage",
  "pallet-universal-dividend",
+ "pallet-utility",
  "parity-scale-codec",
  "scale-info",
  "serde",
@@ -2035,6 +2038,7 @@ dependencies = [
  "pallet-certification",
  "pallet-grandpa",
  "pallet-identity",
+ "pallet-multisig",
  "pallet-randomness-collective-flip",
  "pallet-sudo",
  "pallet-timestamp",
@@ -2042,6 +2046,7 @@ dependencies = [
  "pallet-transaction-payment-rpc-runtime-api",
  "pallet-ud-accounts-storage",
  "pallet-universal-dividend",
+ "pallet-utility",
  "parity-scale-codec",
  "scale-info",
  "serde",
@@ -4190,6 +4195,21 @@ dependencies = [
  "sp-std",
 ]
 
+[[package]]
+name = "pallet-utility"
+version = "4.0.0-dev"
+source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#dfa512d0e1475ef671bab9b4d76c17f20a1a297a"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
 [[package]]
 name = "parity-db"
 version = "0.3.5"
diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs
index a9bd788e6..93e22bfa4 100644
--- a/runtime/common/src/pallets_config.rs
+++ b/runtime/common/src/pallets_config.rs
@@ -114,7 +114,35 @@ macro_rules! pallets_config {
             type FeeMultiplierUpdate = ();
         }
 
-        impl pallet_identity::Config for Runtime {
+		// UTILITY //
+
+		impl pallet_utility::Config for Runtime {
+			type Event = Event;
+			type Call = Call;
+			type PalletsOrigin = OriginCaller;
+			type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;
+		}
+
+		// MONEY CREATION //
+
+        impl pallet_universal_dividend::Config for Runtime {
+            type Currency = pallet_balances::Pallet<Runtime>;
+            type Event = Event;
+            type MembersCount = common_runtime::providers::UdAccountsProvider<Runtime>;
+            type MembersIds = common_runtime::providers::UdAccountsProvider<Runtime>;
+            type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
+            type UdCreationPeriod = UdCreationPeriod;
+			type UdFirstReeval = UdFirstReeval;
+            type UdReevalPeriod = UdReevalPeriod;
+            type UdReevalPeriodInBlocks = UdReevalPeriodInBlocks;
+			type UnitsPerUd = frame_support::traits::ConstU64<1_000>;
+        }
+
+        impl pallet_ud_accounts_storage::Config for Runtime {}
+
+		// WEB OF TRUST //
+
+		impl pallet_identity::Config for Runtime {
             type ConfirmPeriod = ConfirmPeriod;
             type Event = Event;
             type AddRightOrigin = EnsureRoot<Self::AccountId>;
@@ -148,19 +176,16 @@ macro_rules! pallets_config {
             type ValidityPeriod = ValidityPeriod;
         }
 
-        impl pallet_universal_dividend::Config for Runtime {
-            type Currency = pallet_balances::Pallet<Runtime>;
-            type Event = Event;
-            type MembersCount = common_runtime::providers::UdAccountsProvider<Runtime>;
-            type MembersIds = common_runtime::providers::UdAccountsProvider<Runtime>;
-            type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
-            type UdCreationPeriod = UdCreationPeriod;
-			type UdFirstReeval = UdFirstReeval;
-            type UdReevalPeriod = UdReevalPeriod;
-            type UdReevalPeriodInBlocks = UdReevalPeriodInBlocks;
-			type UnitsPerUd = frame_support::traits::ConstU64<1_000>;
-        }
+		// MUNTISIG //
 
-        impl pallet_ud_accounts_storage::Config for Runtime {}
+		impl pallet_multisig::Config for Runtime {
+			type Event = Event;
+			type Call = Call;
+			type Currency = Balances;
+			type DepositBase = DepositBase;
+			type DepositFactor = DepositFactor;
+			type MaxSignatories = MaxSignatories;
+			type WeightInfo = pallet_multisig::weights::SubstrateWeight<Self>;
+		}
 	};
 }
diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml
index 815112a98..e12cc5fcf 100644
--- a/runtime/g1/Cargo.toml
+++ b/runtime/g1/Cargo.toml
@@ -126,6 +126,11 @@ default-features = false
 git = 'https://github.com/librelois/substrate.git'
 branch = 'duniter-monthly-2022-01'
 
+[dependencies.pallet-multisig]
+default-features = false
+git = 'https://github.com/librelois/substrate.git'
+branch = 'duniter-monthly-2022-01'
+
 [dependencies.pallet-randomness-collective-flip]
 default-features = false
 git = 'https://github.com/librelois/substrate.git'
@@ -151,6 +156,11 @@ default-features = false
 git = 'https://github.com/librelois/substrate.git'
 branch = 'duniter-monthly-2022-01'
 
+[dependencies.pallet-utility]
+default-features = false
+git = 'https://github.com/librelois/substrate.git'
+branch = 'duniter-monthly-2022-01'
+
 [dependencies.serde]
 version = "1.0.101"
 optional = true
diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs
index 88c2eaf38..c1b765477 100644
--- a/runtime/g1/src/lib.rs
+++ b/runtime/g1/src/lib.rs
@@ -175,7 +175,7 @@ construct_runtime!(
         Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20,
 
         // Cunning utilities.
-        //Utility: pallet_utility::{Pallet, Call, Event} = 30,
+        Utility: pallet_utility::{Pallet, Call, Event} = 30,
 
         // Universal dividend.
         UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40,
@@ -184,6 +184,9 @@ construct_runtime!(
         // Web Of Trust
         Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 50,
         StrongCert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 51,
+
+        // Multisig dispatch.
+        Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 60,
     }
 );
 
diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs
index 952f1b276..6cdd3c1c3 100644
--- a/runtime/g1/src/parameters.rs
+++ b/runtime/g1/src/parameters.rs
@@ -69,3 +69,10 @@ parameter_types! {
     pub const UdReevalPeriod: Balance = 182;
     pub const UdReevalPeriodInBlocks: BlockNumber = 2_620_800; // 86400 * 182 / 6
 }
+
+// Multisig
+parameter_types! {
+    pub const DepositBase: Balance = 1000;
+    pub const DepositFactor: Balance = 10;
+    pub const MaxSignatories: u16 = 5;
+}
diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml
index 973ed82ea..683620625 100644
--- a/runtime/gdev/Cargo.toml
+++ b/runtime/gdev/Cargo.toml
@@ -152,6 +152,11 @@ default-features = false
 git = 'https://github.com/librelois/substrate.git'
 branch = 'duniter-monthly-2022-01'
 
+[dependencies.pallet-utility]
+default-features = false
+git = 'https://github.com/librelois/substrate.git'
+branch = 'duniter-monthly-2022-01'
+
 [dependencies.serde]
 version = "1.0.101"
 optional = true
diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs
index 8ce521229..b32ddf09c 100644
--- a/runtime/gdev/src/lib.rs
+++ b/runtime/gdev/src/lib.rs
@@ -134,16 +134,6 @@ common_runtime::pallets_config! {
         type Event = Event;
         type Call = Call;
     }
-
-    impl pallet_multisig::Config for Runtime {
-        type Event = Event;
-        type Call = Call;
-        type Currency = Balances;
-        type DepositBase = DepositBase;
-        type DepositFactor = DepositFactor;
-        type MaxSignatories = MaxSignatories;
-        type WeightInfo = pallet_multisig::weights::SubstrateWeight<Self>;
-    }
 }
 
 // Create the runtime by composing the FRAME pallets that were previously configured.
@@ -168,7 +158,7 @@ construct_runtime!(
         Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20,
 
         // Cunning utilities.
-        //Utility: pallet_utility::{Pallet, Call, Event} = 30,
+        Utility: pallet_utility::{Pallet, Call, Event} = 30,
 
         // Universal dividend.
         UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40,
diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs
index 13fd4e842..fd3b8fee5 100644
--- a/runtime/gdev/src/parameters.rs
+++ b/runtime/gdev/src/parameters.rs
@@ -35,13 +35,6 @@ frame_support::parameter_types! {
     pub const TransactionByteFee: Balance = 0;
 }
 
-// Multisig
-parameter_types! {
-    pub const DepositBase: Balance = 1000;
-    pub const DepositFactor: Balance = 10;
-    pub const MaxSignatories: u16 = 5;
-}
-
 // Identity
 pub const IDTY_CREATE_PERIOD: BlockNumber = 100;
 frame_support::parameter_types! {
@@ -70,3 +63,10 @@ parameter_types! {
     pub const UdReevalPeriod: Balance = 10;
     pub const UdReevalPeriodInBlocks: BlockNumber = 20 * 10;
 }
+
+// Multisig
+parameter_types! {
+    pub const DepositBase: Balance = 1000;
+    pub const DepositFactor: Balance = 10;
+    pub const MaxSignatories: u16 = 5;
+}
diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml
index 6bc6f3a04..0be68f7c4 100644
--- a/runtime/gtest/Cargo.toml
+++ b/runtime/gtest/Cargo.toml
@@ -126,6 +126,11 @@ default-features = false
 git = 'https://github.com/librelois/substrate.git'
 branch = 'duniter-monthly-2022-01'
 
+[dependencies.pallet-multisig]
+default-features = false
+git = 'https://github.com/librelois/substrate.git'
+branch = 'duniter-monthly-2022-01'
+
 [dependencies.pallet-randomness-collective-flip]
 default-features = false
 git = 'https://github.com/librelois/substrate.git'
@@ -151,6 +156,12 @@ default-features = false
 git = 'https://github.com/librelois/substrate.git'
 branch = 'duniter-monthly-2022-01'
 
+[dependencies.pallet-utility]
+default-features = false
+git = 'https://github.com/librelois/substrate.git'
+branch = 'duniter-monthly-2022-01'
+
+
 [dependencies.serde]
 version = "1.0.101"
 optional = true
diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs
index 6d6f0dbed..daa107033 100644
--- a/runtime/gtest/src/lib.rs
+++ b/runtime/gtest/src/lib.rs
@@ -175,7 +175,7 @@ construct_runtime!(
         Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20,
 
         // Cunning utilities.
-        //Utility: pallet_utility::{Pallet, Call, Event} = 30,
+        Utility: pallet_utility::{Pallet, Call, Event} = 30,
 
         // Universal dividend.
         UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40,
@@ -184,6 +184,9 @@ construct_runtime!(
         // Web Of Trust
         Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 50,
         StrongCert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 51,
+
+        // Multisig dispatch.
+        Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 60,
     }
 );
 
diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs
index 1c6f300eb..8c3f78b74 100644
--- a/runtime/gtest/src/parameters.rs
+++ b/runtime/gtest/src/parameters.rs
@@ -68,3 +68,10 @@ parameter_types! {
     pub const UdReevalPeriod: Balance = 7;
     pub const UdReevalPeriodInBlocks: BlockNumber = 100800; // 86400 *7 / 6
 }
+
+// Multisig
+parameter_types! {
+    pub const DepositBase: Balance = 1000;
+    pub const DepositFactor: Balance = 10;
+    pub const MaxSignatories: u16 = 5;
+}
-- 
GitLab