Remove requirement of function indices for decl_module! (#666)

This commit is contained in:
Bastian Köcher
2018-09-05 13:41:57 +02:00
committed by Gav Wood
parent be7cb74b06
commit c3e2983af3
13 changed files with 185 additions and 152 deletions
+15 -15
View File
@@ -193,26 +193,26 @@ impl_outer_dispatch! {
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum Call where aux: <Runtime as system::Trait>::PublicAux {
Consensus = 0,
Balances = 1,
Session = 2,
Staking = 3,
Timestamp = 4,
Democracy = 5,
Council = 6,
CouncilVoting = 7,
Consensus,
Balances,
Session,
Staking,
Timestamp,
Democracy,
Council,
CouncilVoting,
}
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum PrivCall {
Consensus = 0,
Balances = 1,
Session = 2,
Staking = 3,
Democracy = 4,
Council = 5,
CouncilVoting = 6,
Consensus,
Balances,
Session,
Staking,
Democracy,
Council,
CouncilVoting,
}
}
@@ -155,8 +155,7 @@ macro_rules! decl_dispatch {
$(
$param_name:ident : $param:ty
),*
) -> $result:ty
= $id:expr ;
) -> $result:ty;
)*
}
$($rest:tt)*
@@ -166,7 +165,7 @@ macro_rules! decl_dispatch {
$(#[$attr])*
pub enum $call_type;
$(
fn $fn_name( $( $param_name: $param ),* ) -> $result = $id;
fn $fn_name( $( $param_name: $param ),* ) -> $result;
)*
}
decl_dispatch! {
@@ -185,8 +184,7 @@ macro_rules! decl_dispatch {
$(
, $param_name:ident : $param:ty
)*
) -> $result:ty
= $id:expr ;
) -> $result:ty;
)*
}
$($rest:tt)*
@@ -196,7 +194,7 @@ macro_rules! decl_dispatch {
$(#[$attr])*
pub enum $call_type where aux: $aux_type;
$(
fn $fn_name(aux $(, $param_name: $param )*) -> $result = $id;
fn $fn_name(aux $(, $param_name: $param )*) -> $result;
)*
}
decl_dispatch! {
@@ -232,15 +230,14 @@ macro_rules! __decl_dispatch_module_without_aux {
$param_name:ident : $param:ty
),*
)
-> $result:ty
= $id:expr ;
-> $result:ty;
)*
) => {
__decl_dispatch_module_common! {
impl for $mod_type<$trait_instance: $trait_name>;
$(#[$attr])*
pub enum $call_type;
$( fn $fn_name( $( $param_name : $param ),* ) -> $result = $id ; )*
$( fn $fn_name( $( $param_name : $param ),* ) -> $result; )*
}
impl<$trait_instance: $trait_name> $crate::dispatch::Dispatchable
for $call_type<$trait_instance>
@@ -277,15 +274,14 @@ macro_rules! __decl_dispatch_module_with_aux {
, $param_name:ident : $param:ty
)*
)
-> $result:ty
= $id:expr ;
-> $result:ty;
)*
) => {
__decl_dispatch_module_common! {
impl for $mod_type<$trait_instance: $trait_name>;
$(#[$attr])*
pub enum $call_type;
$( fn $fn_name( $( $param_name : $param ),* ) -> $result = $id ; )*
$( fn $fn_name( $( $param_name : $param ),* ) -> $result; )*
}
impl<$trait_instance: $trait_name> $crate::dispatch::AuxDispatchable
for $call_type<$trait_instance>
@@ -323,8 +319,7 @@ macro_rules! __decl_dispatch_module_common {
$param_name:ident : $param:ty
),*
)
-> $result:ty
= $id:expr ;
-> $result:ty;
)*
) => {
#[cfg(feature = "std")]
@@ -409,42 +404,88 @@ macro_rules! __decl_dispatch_module_common {
impl<$trait_instance: $trait_name> $crate::dispatch::Decode for $call_type<$trait_instance> {
fn decode<I: $crate::dispatch::Input>(input: &mut I) -> Option<Self> {
match input.read_byte()? {
$(
$id => {
$(
let $param_name = $crate::dispatch::Decode::decode(input)?;
)*
Some($call_type:: $fn_name( $( $param_name ),* ))
}
)*
_ => None,
}
let input_id = input.read_byte()?;
__impl_decode!(input; input_id; 0; $call_type; $( fn $fn_name( $( $param_name ),* ); )*)
}
}
impl<$trait_instance: $trait_name> $crate::dispatch::Encode for $call_type<$trait_instance> {
fn encode_to<W: $crate::dispatch::Output>(&self, dest: &mut W) {
match *self {
$(
$call_type::$fn_name(
$(
ref $param_name
),*
) => {
dest.push_byte($id as u8);
$(
$param_name.encode_to(dest);
)*
}
)*
$call_type::__PhantomItem(_) => unreachable!(),
}
__impl_encode!(dest; *self; 0; $call_type; $( fn $fn_name( $( $param_name ),* ); )*);
if let $call_type::__PhantomItem(_) = *self { unreachable!() }
}
}
}
}
#[macro_export]
macro_rules! __impl_decode {
(
$input:expr;
$input_id:expr;
$fn_id:expr;
$call_type:ident;
fn $fn_name:ident(
$( $param_name:ident ),*
);
$($rest:tt)*
) => {
{
if $input_id == ($fn_id) {
$(
let $param_name = $crate::dispatch::Decode::decode($input)?;
)*
return Some($call_type:: $fn_name( $( $param_name ),* ));
}
__impl_decode!($input; $input_id; $fn_id + 1; $call_type; $($rest)*)
}
};
(
$input:expr;
$input_id:expr;
$fn_id:expr;
$call_type:ident;
) => {
None
}
}
#[macro_export]
macro_rules! __impl_encode {
(
$dest:expr;
$self:expr;
$fn_id:expr;
$call_type:ident;
fn $fn_name:ident(
$( $param_name:ident ),*
);
$($rest:tt)*
) => {
{
if let $call_type::$fn_name(
$(
ref $param_name
),*
) = $self {
$dest.push_byte(($fn_id) as u8);
$(
$param_name.encode_to($dest);
)*
}
__impl_encode!($dest; $self; $fn_id + 1; $call_type; $($rest)*)
}
};
(
$dest:expr;
$self:expr;
$fn_id:expr;
$call_type:ident;
) => {{}}
}
pub trait IsSubType<T: Callable> {
fn is_sub_type(&self) -> Option<&<T as Callable>::Call>;
}
@@ -460,7 +501,7 @@ macro_rules! impl_outer_dispatch {
$(#[$attr:meta])*
pub enum $call_type:ident where aux: $aux:ty {
$(
$camelcase:ident = $id:expr,
$camelcase:ident,
)*
}
$( $rest:tt )*
@@ -471,7 +512,7 @@ macro_rules! impl_outer_dispatch {
$camelcase ( $crate::dispatch::AuxCallableCallFor<$camelcase> )
,)*
}
impl_outer_dispatch_common! { $call_type, $($camelcase = $id,)* }
impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
impl $crate::dispatch::AuxDispatchable for $call_type {
type Aux = $aux;
type Trait = $call_type;
@@ -500,7 +541,7 @@ macro_rules! impl_outer_dispatch {
$(#[$attr:meta])*
pub enum $call_type:ident {
$(
$camelcase:ident = $id:expr,
$camelcase:ident,
)*
}
$( $rest:tt )*
@@ -511,7 +552,7 @@ macro_rules! impl_outer_dispatch {
$camelcase ( $crate::dispatch::CallableCallFor<$camelcase> )
,)*
}
impl_outer_dispatch_common! { $call_type, $($camelcase = $id,)* }
impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
impl $crate::dispatch::Dispatchable for $call_type {
type Trait = $call_type;
fn dispatch(self) -> $crate::dispatch::Result {
@@ -541,30 +582,18 @@ macro_rules! impl_outer_dispatch {
#[macro_export]
macro_rules! impl_outer_dispatch_common {
(
$call_type:ident, $( $camelcase:ident = $id:expr, )*
$call_type:ident, $( $camelcase:ident, )*
) => {
impl $crate::dispatch::Decode for $call_type {
fn decode<I: $crate::dispatch::Input>(input: &mut I) -> Option<Self> {
match input.read_byte()? {
$(
$id =>
Some($call_type::$camelcase( $crate::dispatch::Decode::decode(input)? )),
)*
_ => None,
}
let input_id = input.read_byte()?;
__impl_decode!(input; input_id; 0; $call_type; $( fn $camelcase ( outer_dispatch_param ); )*)
}
}
impl $crate::dispatch::Encode for $call_type {
fn encode_to<W: $crate::dispatch::Output>(&self, dest: &mut W) {
match *self {
$(
$call_type::$camelcase( ref sub ) => {
dest.push_byte($id as u8);
sub.encode_to(dest);
}
)*
}
__impl_encode!(dest; *self; 0; $call_type; $( fn $camelcase( outer_dispatch_param ); )*)
}
}
@@ -601,8 +630,7 @@ macro_rules! __calls_to_json {
$(
$param_name:ident : $param:ty
),*
) -> $result:ty
= $id:expr ;
) -> $result:ty;
)*
}
$($rest:tt)*
@@ -610,8 +638,8 @@ macro_rules! __calls_to_json {
concat!($prefix_str, " ",
r#"{ "name": ""#, stringify!($call_type),
r#"", "functions": {"#,
__functions_to_json!(""; $(
fn $fn_name( $( $param_name: $param ),* ) -> $result = $id;
__functions_to_json!(""; 0; $(
fn $fn_name( $( $param_name: $param ),* ) -> $result;
__function_doc_to_json!(""; $($doc_attr)*);
)*), " } }", __calls_to_json!(","; $($rest)*)
)
@@ -627,8 +655,7 @@ macro_rules! __calls_to_json {
$(
, $param_name:ident : $param:ty
)*
) -> $result:ty
= $id:expr ;
) -> $result:ty;
)*
}
$($rest:tt)*
@@ -636,8 +663,8 @@ macro_rules! __calls_to_json {
concat!($prefix_str, " ",
r#"{ "name": ""#, stringify!($call_type),
r#"", "functions": {"#,
__functions_to_json!(""; $aux_type; $(
fn $fn_name(aux $(, $param_name: $param )* ) -> $result = $id;
__functions_to_json!(""; 0; $aux_type; $(
fn $fn_name(aux $(, $param_name: $param )* ) -> $result;
__function_doc_to_json!(""; $($doc_attr)*);
)*), " } }", __calls_to_json!(","; $($rest)*)
)
@@ -656,9 +683,10 @@ macro_rules! __functions_to_json {
// WITHOUT AUX
(
$prefix_str:tt;
$fn_id:expr;
fn $fn_name:ident(
$($param_name:ident : $param:ty),*
) -> $result:ty = $id:expr ;
) -> $result:ty;
$fn_doc:expr;
$($rest:tt)*
) => {
@@ -666,20 +694,22 @@ macro_rules! __functions_to_json {
__function_to_json!(
fn $fn_name(
$($param_name : $param),*
) -> $result = $id ;
) -> $result;
$fn_doc;
), __functions_to_json!(","; $($rest)*)
$fn_id;
), __functions_to_json!(","; $fn_id + 1; $($rest)*)
)
};
// WITH AUX
(
$prefix_str:tt;
$fn_id:expr;
$aux_type:ty;
fn $fn_name:ident(aux
$(
, $param_name:ident : $param:ty
)*
) -> $result:ty = $id:expr ;
) -> $result:ty;
$fn_doc:expr;
$($rest:tt)*
) => {
@@ -688,14 +718,16 @@ macro_rules! __functions_to_json {
fn $fn_name(
aux: $aux_type
$(, $param_name : $param)*
) -> $result = $id ;
) -> $result;
$fn_doc;
), __functions_to_json!(","; $aux_type; $($rest)*)
$fn_id;
), __functions_to_json!(","; $fn_id + 1; $aux_type; $($rest)*)
)
};
// BASE CASE
(
$prefix_str:tt;
$fn_id:expr;
$($aux_type:ty;)*
) => {
""
@@ -708,11 +740,12 @@ macro_rules! __function_to_json {
(
fn $fn_name:ident(
$first_param_name:ident : $first_param:ty $(, $param_name:ident : $param:ty)*
) -> $result:ty = $id:expr ;
) -> $result:ty;
$fn_doc:tt;
$fn_id:expr;
) => {
concat!(
r#"""#, stringify!($id), r#"""#,
r#"""#, stringify!($fn_id), r#"""#,
r#": { "name": ""#, stringify!($fn_name),
r#"", "params": [ "#,
concat!(r#"{ "name": ""#, stringify!($first_param_name), r#"", "type": ""#, stringify!($first_param), r#"" }"# ),
@@ -764,17 +797,17 @@ mod tests {
#[derive(Serialize, Deserialize)]
pub enum Call where aux: T::PublicAux {
/// Hi, this is a comment.
fn aux_0(aux) -> Result = 0;
fn aux_1(aux, data: i32) -> Result = 1;
fn aux_2(aux, data: i32, data2: String) -> Result = 2;
fn aux_0(aux) -> Result;
fn aux_1(aux, data: i32) -> Result;
fn aux_2(aux, data: i32, data2: String) -> Result;
}
#[derive(Serialize, Deserialize)]
pub enum PrivCall {
/// Hi, this is a comment.
/// Hi, this is a second comment.
fn priv_0(data: String) -> Result = 0;
fn priv_1(data: String, data2: u32) -> Result = 1;
fn priv_0(data: String) -> Result;
fn priv_1(data: String, data2: u32) -> Result;
}
}
@@ -784,11 +817,11 @@ mod tests {
r#""0": { "name": "aux_0", "params": [ "#,
r#"{ "name": "aux", "type": "T::PublicAux" }"#,
r#" ], "description": [ " Hi, this is a comment." ] }, "#,
r#""1": { "name": "aux_1", "params": [ "#,
r#""0 + 1": { "name": "aux_1", "params": [ "#,
r#"{ "name": "aux", "type": "T::PublicAux" }, "#,
r#"{ "name": "data", "type": "i32" }"#,
r#" ], "description": [ ] }, "#,
r#""2": { "name": "aux_2", "params": [ "#,
r#""0 + 1 + 1": { "name": "aux_2", "params": [ "#,
r#"{ "name": "aux", "type": "T::PublicAux" }, "#,
r#"{ "name": "data", "type": "i32" }, "#,
r#"{ "name": "data2", "type": "String" }"#,
@@ -798,7 +831,7 @@ mod tests {
r#""0": { "name": "priv_0", "params": [ "#,
r#"{ "name": "data", "type": "String" }"#,
r#" ], "description": [ " Hi, this is a comment.", " Hi, this is a second comment." ] }, "#,
r#""1": { "name": "priv_1", "params": [ "#,
r#""0 + 1": { "name": "priv_1", "params": [ "#,
r#"{ "name": "data", "type": "String" }, "#,
r#"{ "name": "data2", "type": "u32" }"#,
r#" ], "description": [ ] }"#,
@@ -136,12 +136,12 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn transfer(aux, dest: RawAddress<T::AccountId, T::AccountIndex>, value: T::Balance) -> Result = 0;
fn transfer(aux, dest: RawAddress<T::AccountId, T::AccountIndex>, value: T::Balance) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_balance(who: RawAddress<T::AccountId, T::AccountIndex>, free: T::Balance, reserved: T::Balance) -> Result = 0;
fn set_balance(who: RawAddress<T::AccountId, T::AccountIndex>, free: T::Balance, reserved: T::Balance) -> Result;
}
}
@@ -145,15 +145,15 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn report_misbehavior(aux, report: MisbehaviorReport<T::Hash, T::BlockNumber>) -> Result = 0;
fn note_offline(aux, offline_val_indices: Vec<u32>) -> Result = 1;
fn remark(aux, remark: Vec<u8>) -> Result = 2;
fn report_misbehavior(aux, report: MisbehaviorReport<T::Hash, T::BlockNumber>) -> Result;
fn note_offline(aux, offline_val_indices: Vec<u32>) -> Result;
fn remark(aux, remark: Vec<u8>) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_code(new: Vec<u8>) -> Result = 0;
fn set_storage(items: Vec<KeyValue>) -> Result = 1;
fn set_code(new: Vec<u8>) -> Result;
fn set_storage(items: Vec<KeyValue>) -> Result;
}
}
@@ -130,7 +130,7 @@ decl_module! {
value: T::Balance,
gas_limit: T::Gas,
data: Vec<u8>
) -> Result = 0;
) -> Result;
fn create(
aux,
@@ -138,7 +138,7 @@ decl_module! {
gas_limit: T::Gas,
ctor: Vec<u8>,
data: Vec<u8>
) -> Result = 1;
) -> Result;
}
}
+11 -11
View File
@@ -110,19 +110,19 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn set_approvals(aux, votes: Vec<bool>, index: VoteIndex) -> Result = 0;
fn reap_inactive_voter(aux, signed_index: u32, who: Address<T::AccountId, T::AccountIndex>, who_index: u32, assumed_vote_index: VoteIndex) -> Result = 1;
fn retract_voter(aux, index: u32) -> Result = 2;
fn submit_candidacy(aux, slot: u32) -> Result = 3;
fn present_winner(aux, candidate: Address<T::AccountId, T::AccountIndex>, total: T::Balance, index: VoteIndex) -> Result = 4;
fn set_approvals(aux, votes: Vec<bool>, index: VoteIndex) -> Result;
fn reap_inactive_voter(aux, signed_index: u32, who: Address<T::AccountId, T::AccountIndex>, who_index: u32, assumed_vote_index: VoteIndex) -> Result;
fn retract_voter(aux, index: u32) -> Result;
fn submit_candidacy(aux, slot: u32) -> Result;
fn present_winner(aux, candidate: Address<T::AccountId, T::AccountIndex>, total: T::Balance, index: VoteIndex) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_desired_seats(count: u32) -> Result = 0;
fn remove_member(who: Address<T::AccountId, T::AccountIndex>) -> Result = 1;
fn set_presentation_duration(count: T::BlockNumber) -> Result = 2;
fn set_term_duration(count: T::BlockNumber) -> Result = 3;
fn set_desired_seats(count: u32) -> Result;
fn remove_member(who: Address<T::AccountId, T::AccountIndex>) -> Result;
fn set_presentation_duration(count: T::BlockNumber) -> Result;
fn set_term_duration(count: T::BlockNumber) -> Result;
}
}
@@ -625,8 +625,8 @@ mod tests {
impl_outer_dispatch! {
#[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialEq)]
pub enum Proposal {
Balances = 0,
Democracy = 1,
Balances,
Democracy,
}
}
@@ -30,15 +30,15 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn propose(aux, proposal: Box<T::Proposal>) -> Result = 0;
fn vote(aux, proposal: T::Hash, approve: bool) -> Result = 1;
fn veto(aux, proposal_hash: T::Hash) -> Result = 2;
fn propose(aux, proposal: Box<T::Proposal>) -> Result;
fn vote(aux, proposal: T::Hash, approve: bool) -> Result;
fn veto(aux, proposal_hash: T::Hash) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_cooloff_period(blocks: T::BlockNumber) -> Result = 0;
fn set_voting_period(blocks: T::BlockNumber) -> Result = 1;
fn set_cooloff_period(blocks: T::BlockNumber) -> Result;
fn set_voting_period(blocks: T::BlockNumber) -> Result;
}
}
@@ -67,15 +67,15 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn propose(aux, proposal: Box<T::Proposal>, value: T::Balance) -> Result = 0;
fn second(aux, proposal: PropIndex) -> Result = 1;
fn vote(aux, ref_index: ReferendumIndex, approve_proposal: bool) -> Result = 2;
fn propose(aux, proposal: Box<T::Proposal>, value: T::Balance) -> Result;
fn second(aux, proposal: PropIndex) -> Result;
fn vote(aux, ref_index: ReferendumIndex, approve_proposal: bool) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn start_referendum(proposal: Box<T::Proposal>, vote_threshold: VoteThreshold) -> Result = 0;
fn cancel_referendum(ref_index: ReferendumIndex) -> Result = 1;
fn start_referendum(proposal: Box<T::Proposal>, vote_threshold: VoteThreshold) -> Result;
fn cancel_referendum(ref_index: ReferendumIndex) -> Result;
}
}
@@ -357,8 +357,8 @@ mod tests {
impl_outer_dispatch! {
#[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialEq)]
pub enum Proposal {
Balances = 0,
Democracy = 1,
Balances,
Democracy,
}
}
@@ -100,7 +100,7 @@ decl_module! {
pub enum Call where aux: T::PublicAux {
// This is just a simple example of how to interact with the module from the external
// world.
fn accumulate_dummy(aux, increase_by: T::Balance) -> Result = 0;
fn accumulate_dummy(aux, increase_by: T::Balance) -> Result;
}
// The priviledged entry points. These are provided to allow any governance modules in
@@ -111,7 +111,7 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
// A priviledged call; in this case it resets our dummy value to something new.
fn set_dummy(new_dummy: T::Balance) -> Result = 0;
fn set_dummy(new_dummy: T::Balance) -> Result;
}
}
@@ -79,13 +79,13 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn set_key(aux, key: T::SessionKey) -> Result = 0;
fn set_key(aux, key: T::SessionKey) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_length(new: T::BlockNumber) -> Result = 0;
fn force_new_session(apply_rewards: bool) -> Result = 1;
fn set_length(new: T::BlockNumber) -> Result;
fn force_new_session(apply_rewards: bool) -> Result;
}
}
+10 -10
View File
@@ -109,20 +109,20 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(bound(deserialize = "T::Balance: ::serde::de::DeserializeOwned")))]
pub enum Call where aux: T::PublicAux {
fn stake(aux) -> Result = 0;
fn unstake(aux, intentions_index: u32) -> Result = 1;
fn nominate(aux, target: Address<T::AccountId, T::AccountIndex>) -> Result = 2;
fn unnominate(aux, target_index: u32) -> Result = 3;
fn register_preferences(aux, intentions_index: u32, prefs: ValidatorPrefs<T::Balance>) -> Result = 4;
fn stake(aux) -> Result;
fn unstake(aux, intentions_index: u32) -> Result;
fn nominate(aux, target: Address<T::AccountId, T::AccountIndex>) -> Result;
fn unnominate(aux, target_index: u32) -> Result;
fn register_preferences(aux, intentions_index: u32, prefs: ValidatorPrefs<T::Balance>) -> Result;
}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
fn set_sessions_per_era(new: T::BlockNumber) -> Result = 0;
fn set_bonding_duration(new: T::BlockNumber) -> Result = 1;
fn set_validator_count(new: u32) -> Result = 2;
fn force_new_era(apply_rewards: bool) -> Result = 3;
fn set_offline_slash_grace(new: u32) -> Result = 4;
fn set_sessions_per_era(new: T::BlockNumber) -> Result;
fn set_bonding_duration(new: T::BlockNumber) -> Result;
fn set_validator_count(new: u32) -> Result;
fn force_new_era(apply_rewards: bool) -> Result;
fn set_offline_slash_grace(new: u32) -> Result;
}
}
@@ -56,7 +56,7 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Call where aux: T::PublicAux {
fn set(aux, now: T::Moment) -> Result = 0;
fn set(aux, now: T::Moment) -> Result;
}
}
@@ -70,7 +70,7 @@ decl_module! {
// Put forward a suggestion for spending. A deposit proportional to the value
// is reserved and slashed if the proposal is rejected. It is returned once the
// proposal is awarded.
fn propose_spend(aux, value: T::Balance, beneficiary: T::AccountId) -> Result = 0;
fn propose_spend(aux, value: T::Balance, beneficiary: T::AccountId) -> Result;
}
// The priviledged entry points. These are provided to allow any governance modules in
@@ -81,17 +81,17 @@ decl_module! {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum PrivCall {
// Set the balance of funds available to spend.
fn set_pot(new_pot: T::Balance) -> Result = 0;
fn set_pot(new_pot: T::Balance) -> Result;
// (Re-)configure this module.
fn configure(proposal_bond: Permill, proposal_bond_minimum: T::Balance, spend_period: T::BlockNumber, burn: Permill) -> Result = 1;
fn configure(proposal_bond: Permill, proposal_bond_minimum: T::Balance, spend_period: T::BlockNumber, burn: Permill) -> Result;
// Reject a proposed spend. The original deposit will be slashed.
fn reject_proposal(proposal_id: ProposalIndex) -> Result = 2;
fn reject_proposal(proposal_id: ProposalIndex) -> Result;
// Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
// and the original deposit will be returned.
fn approve_proposal(proposal_id: ProposalIndex) -> Result = 3;
fn approve_proposal(proposal_id: ProposalIndex) -> Result;
}
}