diff --git a/src/lib.rs b/src/lib.rs index 689851488d..9f494102e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -308,10 +308,10 @@ impl Client { .and_then(|module| module.call(C::FUNCTION, call))?) } - /// Creates an unsigned extrinsic. + /// Creates an payload for an extrinsic. /// /// If `nonce` is `None` the nonce will be fetched from the chain. - pub async fn create_unsigned>( + pub async fn create_payload>( &self, call: C, account_id: &::AccountId, @@ -336,6 +336,23 @@ impl Client { Ok(raw_payload) } + /// Creates an unsigned extrinsic. + pub async fn create_unsigned + Send + Sync>( + &self, + call: C, + account_id: &::AccountId, + nonce: Option, + ) -> Result, Error> + where + <>::Extra as SignedExtension>::AdditionalSigned: + Send + Sync, + { + let payload = self.create_payload(call, account_id, nonce).await?; + let (call, _, _) = payload.deconstruct(); + let unsigned = UncheckedExtrinsic::::new_unsigned(call); + Ok(unsigned) + } + /// Creates a signed extrinsic. pub async fn create_signed + Send + Sync>( &self, @@ -346,10 +363,10 @@ impl Client { <>::Extra as SignedExtension>::AdditionalSigned: Send + Sync, { - let unsigned = self - .create_unsigned(call, signer.account_id(), signer.nonce()) + let payload = self + .create_payload(call, signer.account_id(), signer.nonce()) .await?; - let signed = signer.sign(unsigned).await?; + let signed = signer.sign(payload).await?; Ok(signed) }