-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Conversation
abf1b60
to
e79261e
Compare
Couple of questions for a few problems I ran into so far: @thiolliere How to update in the light of paritytech/substrate@63388a4#diff-c41ce90d658462c61a0814b7279026a6 See https://github.com/paritytech/polkadot/pull/171/files#diff-05be5404b10959d460f8302423f24a49R119 @rphmeier What to go with as |
Currency introduce a way to use balance module without inheriting from it directly. Here is the procedure:
It result to the following diff: diff --git a/runtime/src/claims.rs b/runtime/src/claims.rs
index 2e47e012..cce86360 100644
--- a/runtime/src/claims.rs
+++ b/runtime/src/claims.rs
@@ -19,18 +19,19 @@
use rstd::prelude::*;
use sr_io::{keccak_256, secp256k1_ecdsa_recover};
use srml_support::{StorageValue, StorageMap};
-use srml_support::traits::Currency;
+use srml_support::traits::{Currency, ArithmeticType};
use system::ensure_signed;
use codec::Encode;
#[cfg(feature = "std")]
use sr_primitives::traits::Zero;
-use balances;
+
+type BalanceOf<T> = <<T as Trait>::Currency as ArithmeticType>::Type;
/// Configuration trait.
-pub trait Trait: balances::Trait {
+pub trait Trait: system::Trait {
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
- type Currency: Currency<Self::AccountId>;
+ type Currency: ArithmeticType + Currency<Self::AccountId, Balance=BalanceOf<Self>>;
}
type EthereumAddress = [u8; 20];
@@ -60,7 +61,7 @@ impl EcdsaSignature {
/// An event in this module.
decl_event!(
pub enum Event<T> where
- B = <T as balances::Trait>::Balance,
+ B = BalanceOf<T>,
A = <T as system::Trait>::AccountId
{
/// Someone claimed some DOTs.
@@ -75,13 +76,13 @@ decl_storage! {
trait Store for Module<T: Trait> as Claims {
Claims get(claims) build(|config: &GenesisConfig<T>| {
config.claims.iter().map(|(a, b)| (a.clone(), b.clone())).collect::<Vec<_>>()
- }): map EthereumAddress => Option<T::Balance>;
+ }): map EthereumAddress => Option<BalanceOf<T>>;
Total get(total) build(|config: &GenesisConfig<T>| {
- config.claims.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n)
- }): T::Balance;
+ config.claims.iter().fold(Zero::zero(), |acc: BalanceOf<T>, &(_, n)| acc + n)
+ }): BalanceOf<T>;
}
add_extra_genesis {
- config(claims): Vec<(EthereumAddress, T::Balance)>;
+ config(claims): Vec<(EthereumAddress, BalanceOf<T>)>;
}
}
@@ -133,7 +134,7 @@ decl_module! {
*t -= balance_due
});
- //T::Currency::increase_free_balance_creating(&sender, balance_due);
+ T::Currency::increase_free_balance_creating(&sender, balance_due);
// Let's deposit an event to let the outside world know this happened.
Self::deposit_event(RawEvent::Claimed(sender, signer, balance_due)); |
I have a branch for the gossip part, incomplete though. |
Superseded by: #172 |
* Fix block announce * Fix compilation
No description provided.