Unverified Commit a03b329a authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Add a `convert_payload` function to `Signed` (#2320)

* Add a `convert_payload` function to `Signed`

* Review feedback
parent 78e426ce
Pipeline #121683 passed with stages
in 30 minutes and 51 seconds
......@@ -85,6 +85,12 @@ impl Statement {
}
}
impl From<&'_ Statement> for CompactStatement {
fn from(stmt: &Statement) -> Self {
stmt.to_compact()
}
}
impl EncodeAs<CompactStatement> for Statement {
fn encode_as(&self) -> Vec<u8> {
self.to_compact().encode()
......
......@@ -921,6 +921,16 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> Signed<Payload, RealPa
pub fn into_payload(self) -> Payload {
self.payload
}
/// Convert `Payload` into `RealPayload`.
pub fn convert_payload(&self) -> Signed<RealPayload> where for<'a> &'a Payload: Into<RealPayload> {
Signed {
signature: self.signature.clone(),
validator_index: self.validator_index,
payload: self.payload().into(),
real_payload: sp_std::marker::PhantomData,
}
}
}
/// Custom validity errors used in Polkadot while validating transactions.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment