[][src]Derive Macro substrate_subxt_proc_macro::Call


Derive macro that implements substrate_subxt::Call for your struct and defines&implements the calls as an extension trait.

Use the Call derive macro in tandem with the #module macro to extend your struct to enable calls to substrate and to decode events. The struct maps to the corresponding Substrate runtime call, e.g.:

This example is not tested
decl_module! {
    /* … */
    pub fn fun_stuff(origin, something: Vec<u8>) -> DispatchResult { /* … */ }
    /* … */

Implements substrate_subxt::Call and adds an extension trait that provides two methods named as your struct.


This example is not tested
pub struct MyRuntime;

impl System for MyRuntime { /* … */ }
impl Balances for MyRuntime { /* … */ }

pub trait MyTrait: System + Balances {}

pub struct FunStuffCall<T: MyTrait> {
    /// Runtime marker.
    pub _runtime: PhantomData<T>,
    /// The argument passed to the call..
    pub something: Vec<u8>,

When building a Client parameterised to MyRuntime, you have access to two new methods: fun_stuff() and fun_stuff_and_watch() by way of the derived FunStuffExt trait. The _and_watch variant makes the call and waits for the result. The fields of the input struct become arguments to the calls (ignoring the marker field).

Under the hood the implementation calls submit() and watch() respectively.