diff --git a/demo/runtime/src/lib.rs b/demo/runtime/src/lib.rs index 69cf3536335b0..dc1b4527529f0 100644 --- a/demo/runtime/src/lib.rs +++ b/demo/runtime/src/lib.rs @@ -177,26 +177,26 @@ impl_outer_dispatch! { #[derive(Clone, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] pub enum Call where aux: ::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, } } diff --git a/substrate/runtime-support/src/dispatch.rs b/substrate/runtime-support/src/dispatch.rs index 903cf9ae04f81..252ac98dcbaf5 100644 --- a/substrate/runtime-support/src/dispatch.rs +++ b/substrate/runtime-support/src/dispatch.rs @@ -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,89 @@ macro_rules! __decl_dispatch_module_common { impl<$trait_instance: $trait_name> $crate::dispatch::Decode for $call_type<$trait_instance> { fn decode(input: &mut I) -> Option { - 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(&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) { + $( + #[allow(non_snake_case)] + 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 { fn is_sub_type(&self) -> Option<&::Call>; } @@ -460,7 +502,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 +513,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 +542,7 @@ macro_rules! impl_outer_dispatch { $(#[$attr:meta])* pub enum $call_type:ident { $( - $camelcase:ident = $id:expr, + $camelcase:ident, )* } $( $rest:tt )* @@ -511,7 +553,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 +583,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(input: &mut I) -> Option { - 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 ( $camelcase ); )*) } } impl $crate::dispatch::Encode for $call_type { fn encode_to(&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( $camelcase ); )*) } } @@ -601,8 +631,7 @@ macro_rules! __calls_to_json { $( $param_name:ident : $param:ty ),* - ) -> $result:ty - = $id:expr ; + ) -> $result:ty; )* } $($rest:tt)* @@ -610,8 +639,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 +656,7 @@ macro_rules! __calls_to_json { $( , $param_name:ident : $param:ty )* - ) -> $result:ty - = $id:expr ; + ) -> $result:ty; )* } $($rest:tt)* @@ -636,8 +664,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 +684,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 +695,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 +719,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 +741,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 +798,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 +818,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 +832,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": [ ] }"#, diff --git a/substrate/runtime/balances/src/lib.rs b/substrate/runtime/balances/src/lib.rs index 225b8bdbf0347..5eeb0007c206b 100644 --- a/substrate/runtime/balances/src/lib.rs +++ b/substrate/runtime/balances/src/lib.rs @@ -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, value: T::Balance) -> Result = 0; + fn transfer(aux, dest: RawAddress, value: T::Balance) -> Result; } #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum PrivCall { - fn set_balance(who: RawAddress, free: T::Balance, reserved: T::Balance) -> Result = 0; + fn set_balance(who: RawAddress, free: T::Balance, reserved: T::Balance) -> Result; } } diff --git a/substrate/runtime/consensus/src/lib.rs b/substrate/runtime/consensus/src/lib.rs index df6d034c8f555..4804fbfb48eea 100644 --- a/substrate/runtime/consensus/src/lib.rs +++ b/substrate/runtime/consensus/src/lib.rs @@ -84,15 +84,15 @@ decl_module! { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum Call where aux: T::PublicAux { - fn report_misbehavior(aux, report: MisbehaviorReport) -> Result = 0; - fn note_offline(aux, offline_val_indices: Vec) -> Result = 1; - fn remark(aux, remark: Vec) -> Result = 2; + fn report_misbehavior(aux, report: MisbehaviorReport) -> Result; + fn note_offline(aux, offline_val_indices: Vec) -> Result; + fn remark(aux, remark: Vec) -> Result; } #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum PrivCall { - fn set_code(new: Vec) -> Result = 0; - fn set_storage(items: Vec) -> Result = 1; + fn set_code(new: Vec) -> Result; + fn set_storage(items: Vec) -> Result; } } diff --git a/substrate/runtime/contract/src/lib.rs b/substrate/runtime/contract/src/lib.rs index 1749a4543c3cc..c0b3cb045534d 100644 --- a/substrate/runtime/contract/src/lib.rs +++ b/substrate/runtime/contract/src/lib.rs @@ -130,7 +130,7 @@ decl_module! { value: T::Balance, gas_limit: T::Gas, data: Vec - ) -> Result = 0; + ) -> Result; fn create( aux, @@ -138,7 +138,7 @@ decl_module! { gas_limit: T::Gas, ctor: Vec, data: Vec - ) -> Result = 1; + ) -> Result; } } diff --git a/substrate/runtime/council/src/lib.rs b/substrate/runtime/council/src/lib.rs index a6e941079b71d..c6ee841fed1d5 100644 --- a/substrate/runtime/council/src/lib.rs +++ b/substrate/runtime/council/src/lib.rs @@ -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, index: VoteIndex) -> Result = 0; - fn reap_inactive_voter(aux, signed_index: u32, who: Address, 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, total: T::Balance, index: VoteIndex) -> Result = 4; + fn set_approvals(aux, votes: Vec, index: VoteIndex) -> Result; + fn reap_inactive_voter(aux, signed_index: u32, who: Address, 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, 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) -> 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) -> 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, } } diff --git a/substrate/runtime/council/src/voting.rs b/substrate/runtime/council/src/voting.rs index 4b38d97dc48b1..41910d2074a02 100644 --- a/substrate/runtime/council/src/voting.rs +++ b/substrate/runtime/council/src/voting.rs @@ -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) -> 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) -> 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; } } diff --git a/substrate/runtime/democracy/src/lib.rs b/substrate/runtime/democracy/src/lib.rs index 473a02318bd3b..046df66bfae07 100644 --- a/substrate/runtime/democracy/src/lib.rs +++ b/substrate/runtime/democracy/src/lib.rs @@ -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, 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, 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, vote_threshold: VoteThreshold) -> Result = 0; - fn cancel_referendum(ref_index: ReferendumIndex) -> Result = 1; + fn start_referendum(proposal: Box, 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, } } diff --git a/substrate/runtime/example/src/lib.rs b/substrate/runtime/example/src/lib.rs index df172d5e01d00..aa17511869572 100644 --- a/substrate/runtime/example/src/lib.rs +++ b/substrate/runtime/example/src/lib.rs @@ -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; } } diff --git a/substrate/runtime/session/src/lib.rs b/substrate/runtime/session/src/lib.rs index 1e4ac22e78197..2fe473eade6db 100644 --- a/substrate/runtime/session/src/lib.rs +++ b/substrate/runtime/session/src/lib.rs @@ -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; } } diff --git a/substrate/runtime/staking/src/lib.rs b/substrate/runtime/staking/src/lib.rs index 42d35c9c3ec85..abaaa994dbb59 100644 --- a/substrate/runtime/staking/src/lib.rs +++ b/substrate/runtime/staking/src/lib.rs @@ -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) -> Result = 2; - fn unnominate(aux, target_index: u32) -> Result = 3; - fn register_preferences(aux, intentions_index: u32, prefs: ValidatorPrefs) -> Result = 4; + fn stake(aux) -> Result; + fn unstake(aux, intentions_index: u32) -> Result; + fn nominate(aux, target: Address) -> Result; + fn unnominate(aux, target_index: u32) -> Result; + fn register_preferences(aux, intentions_index: u32, prefs: ValidatorPrefs) -> 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; } } diff --git a/substrate/runtime/timestamp/src/lib.rs b/substrate/runtime/timestamp/src/lib.rs index 5d9fdad118eb5..416ad72d7fec1 100644 --- a/substrate/runtime/timestamp/src/lib.rs +++ b/substrate/runtime/timestamp/src/lib.rs @@ -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; } } diff --git a/substrate/runtime/treasury/src/lib.rs b/substrate/runtime/treasury/src/lib.rs index 9ecff48f38cc4..919ebb43c47c3 100644 --- a/substrate/runtime/treasury/src/lib.rs +++ b/substrate/runtime/treasury/src/lib.rs @@ -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; } }