Browse Source

runtime: memo: Refactor balances trait.

- Change common::GovernanceCurrency to the balances::Trait.
Shamil Gadelshin 4 years ago
parent
commit
beae8a793e
3 changed files with 5 additions and 7 deletions
  1. 1 1
      Cargo.lock
  2. 2 2
      runtime-modules/memo/Cargo.toml
  3. 2 4
      runtime-modules/memo/src/lib.rs

+ 1 - 1
Cargo.lock

@@ -3901,7 +3901,7 @@ version = "3.1.0"
 dependencies = [
  "frame-support",
  "frame-system",
- "pallet-common",
+ "pallet-balances",
  "parity-scale-codec",
  "sp-arithmetic",
  "sp-std",

+ 2 - 2
runtime-modules/memo/Cargo.toml

@@ -10,7 +10,7 @@ sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'ht
 sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-common = { package = 'pallet-common', default-features = false, path = '../common'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 [features]
 default = ['std']
@@ -20,5 +20,5 @@ std = [
 	'sp-std/std',
 	'frame-support/std',
 	'frame-system/std',
-	'common/std',
+	'balances/std',
 ]

+ 2 - 4
runtime-modules/memo/src/lib.rs

@@ -7,9 +7,7 @@ use frame_system::ensure_signed;
 use sp_arithmetic::traits::Zero;
 use sp_std::vec::Vec;
 
-use common::currency::GovernanceCurrency;
-
-pub trait Trait: frame_system::Trait + GovernanceCurrency {
+pub trait Trait: frame_system::Trait + balances::Trait {
     type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 }
 
@@ -36,7 +34,7 @@ decl_module! {
         fn update_memo(origin, memo: MemoText) {
             let sender = ensure_signed(origin)?;
 
-            ensure!(!T::Currency::total_balance(&sender).is_zero(), "account must have a balance");
+            ensure!(!<balances::Module<T>>::total_balance(&sender).is_zero(), "account must have a balance");
             ensure!(memo.len() as u32 <= Self::max_memo_length(), "memo too long");
 
             <Memo<T>>::insert(&sender, memo);