Browse Source

runtime: Upgrade the ‘memo’ pallet.

Shamil Gadelshin 4 years ago
parent
commit
f4e964a076
4 changed files with 35 additions and 56 deletions
  1. 12 0
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 14 48
      runtime-modules/memo/Cargo.toml
  4. 8 7
      runtime-modules/memo/src/lib.rs

+ 12 - 0
Cargo.lock

@@ -944,6 +944,18 @@ dependencies = [
  "sp-runtime",
 ]
 
+[[package]]
+name = "pallet-memo"
+version = "3.0.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "pallet-common",
+ "parity-scale-codec",
+ "sp-arithmetic",
+ "sp-runtime",
+]
+
 [[package]]
 name = "pallet-recurring-reward"
 version = "3.0.0"

+ 1 - 1
Cargo.toml

@@ -10,7 +10,7 @@ members = [
 #	"runtime-modules/governance",
 #	"runtime-modules/hiring",
 #	"runtime-modules/membership",
-#	"runtime-modules/memo",
+	"runtime-modules/memo",
 	"runtime-modules/recurring-reward",
 #	"runtime-modules/service-discovery",
 #	"runtime-modules/stake",

+ 14 - 48
runtime-modules/memo/Cargo.toml

@@ -1,58 +1,24 @@
 [package]
-name = 'substrate-memo-module'
-version = '1.0.0'
+name = 'pallet-memo'
+version = '3.0.0'
 authors = ['Joystream contributors']
 edition = '2018'
 
+[dependencies]
+codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 [features]
 default = ['std']
 std = [
-	'sr-primitives/std',
-	'srml-support/std',
-	'system/std',
-	'rstd/std',
 	'codec/std',
-	'serde',
+	'sp-runtime/std',
+	'sp-arithmetic/std',
+	'frame-support/std',
+	'system/std',
 	'common/std',
-]
-
-[dependencies.sr-primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.srml-support]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-support'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.system]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-system'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.rstd]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-std'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '1.0.0'
-
-[dependencies.serde]
-features = ['derive']
-optional = true
-version = '1.0.101'
-
-[dependencies.common]
-default_features = false
-package = 'substrate-common-module'
-path = '../common'
+]

+ 8 - 7
runtime-modules/memo/src/lib.rs

@@ -1,13 +1,13 @@
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 
+use system::{self, ensure_signed};
+use frame_support::traits::Currency;
+use frame_support::{decl_module, decl_storage, decl_event, ensure};
+use sp_arithmetic::traits::{Zero};
+
 use common::currency::GovernanceCurrency;
-use rstd::prelude::*;
-use sr_primitives::traits::Zero;
-use srml_support::traits::Currency;
-use srml_support::{decl_event, decl_module, decl_storage, ensure};
 
-use system::{self, ensure_signed};
 
 pub trait Trait: system::Trait + GovernanceCurrency {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
@@ -17,8 +17,8 @@ pub type MemoText = Vec<u8>;
 
 decl_storage! {
     trait Store for Module<T: Trait> as Memo {
-        Memo get(memo) : map T::AccountId => MemoText;
-        MaxMemoLength get(max_memo_length) : u32 = 4096;
+        Memo get(fn memo) : map hasher(blake2_128_concat) T::AccountId => MemoText;
+        MaxMemoLength get(fn max_memo_length) : u32 = 4096;
     }
 }
 
@@ -32,6 +32,7 @@ decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
         fn deposit_event() = default;
 
+        #[weight = 10_000_000]
         fn update_memo(origin, memo: MemoText) {
             let sender = ensure_signed(origin)?;