@@ -88,7 +88,53 @@ pub fn module(args: TokenStream, input: TokenStream) -> TokenStream {
88
88
module:: module ( args. into ( ) , input. into ( ) ) . into ( )
89
89
}
90
90
91
- decl_derive ! ( [ Call ] => #[ proc_macro_error] call) ;
91
+ decl_derive ! (
92
+ [ Call ] =>
93
+ /// Derive macro that implements [substrate_subxt::Call](../substrate_subxt/trait.Call.html) for your struct
94
+ /// and defines&implements the calls as an extension trait.
95
+ ///
96
+ /// Use the `Call` derive macro in tandem with the [#module](../substrate_subxt/attr.module.html) macro to extend
97
+ /// your struct to enable calls to substrate and to decode events. The struct maps to the corresponding Substrate runtime call, e.g.:
98
+ ///
99
+ /// ```ignore
100
+ /// decl_module! {
101
+ /// /* … */
102
+ /// pub fn fun_stuff(origin, something: Vec<u8>) -> DispatchResult { /* … */ }
103
+ /// /* … */
104
+ /// }
105
+ ///```
106
+ ///
107
+ /// Implements [substrate_subxt::Call](../substrate_subxt/trait.Call.html) and adds an extension trait that
108
+ /// provides two methods named as your struct.
109
+ ///
110
+ /// Example:
111
+ /// ```rust,ignore
112
+ /// pub struct MyRuntime;
113
+ ///
114
+ /// impl System for MyRuntime { /* … */ }
115
+ /// impl Balances for MyRuntime { /* … */ }
116
+ ///
117
+ /// #[module]
118
+ /// pub trait MyTrait: System + Balances {}
119
+ ///
120
+ /// #[derive(Call)]
121
+ /// pub struct FunStuffCall<T: MyTrait> {
122
+ /// /// Runtime marker.
123
+ /// pub _runtime: PhantomData<T>,
124
+ /// /// The argument passed to the call..
125
+ /// pub something: Vec<u8>,
126
+ /// }
127
+ /// ```
128
+ ///
129
+ /// When building a [Client](../substrate_subxt/struct.Client.html) parameterised to `MyRuntime`, you have access to
130
+ /// two new methods: `fun_stuff()` and `fun_stuff_and_watch()` by way of the derived `FunStuffExt`
131
+ /// trait. The `_and_watch` variant makes the call and waits for the result. The fields of the
132
+ /// input struct become arguments to the calls (ignoring the marker field).
133
+ ///
134
+ /// Under the hood the implementation calls [submit()](../substrate_subxt/struct.Client.html#method.submit) and
135
+ /// [watch()](../substrate_subxt/struct.Client.html#method.watch) respectively.
136
+ #[ proc_macro_error] call
137
+ ) ;
92
138
fn call ( s : Structure ) -> TokenStream {
93
139
call:: call ( s) . into ( )
94
140
}
0 commit comments