Raw payload return SignedPayload struct (#92)

* create SignedPayload struct

* align with generic extra updates

Co-authored-by: bwty <whalelephant@users.noreply.github.com>
This commit is contained in:
bwty
2020-04-20 13:25:37 +07:00
committed by GitHub
parent b8159efcab
commit 216b5614dd
+7 -6
View File
@@ -303,13 +303,14 @@ where
} }
/// Creates raw payload to be signed for the supplied `Call` without private key /// Creates raw payload to be signed for the supplied `Call` without private key
pub async fn create_raw_payload<C>( pub async fn create_raw_payload<C: Encode>(
&self, &self,
account_id: <T as System>::AccountId, account_id: <T as System>::AccountId,
call: Call<C>, call: Call<C>,
) -> Result<Vec<u8>, Error> ) -> Result<
where SignedPayload<Encoded, <E as SignedExtra<T>>::Extra>,
C: codec::Encode, Error
>
{ {
let account_nonce = self.account(account_id).await?.nonce; let account_nonce = self.account(account_id).await?.nonce;
let version = self.runtime_version.spec_version; let version = self.runtime_version.spec_version;
@@ -320,7 +321,7 @@ where
.and_then(|module| module.call(&call.function, call.args))?; .and_then(|module| module.call(&call.function, call.args))?;
let extra: E = E::new(version, account_nonce, genesis_hash); let extra: E = E::new(version, account_nonce, genesis_hash);
let raw_payload = SignedPayload::new(call, extra.extra())?; let raw_payload = SignedPayload::new(call, extra.extra())?;
Ok(raw_payload.encode()) Ok(raw_payload)
} }
/// Create a transaction builder for a private key. /// Create a transaction builder for a private key.
@@ -632,7 +633,7 @@ mod tests {
) )
.await?; .await?;
let raw_signature = let raw_signature =
signer_pair.sign(raw_payload.encode().split_off(2).as_slice()); signer_pair.sign(raw_payload.encode().as_slice());
let raw_multisig = MultiSignature::from(raw_signature); let raw_multisig = MultiSignature::from(raw_signature);
// create signature with Xtbuilder // create signature with Xtbuilder