Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit a03b329

Browse files
authored
Add a convert_payload function to Signed (#2320)
* Add a `convert_payload` function to `Signed` * Review feedback
1 parent 78e426c commit a03b329

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

node/primitives/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ impl Statement {
8585
}
8686
}
8787

88+
impl From<&'_ Statement> for CompactStatement {
89+
fn from(stmt: &Statement) -> Self {
90+
stmt.to_compact()
91+
}
92+
}
93+
8894
impl EncodeAs<CompactStatement> for Statement {
8995
fn encode_as(&self) -> Vec<u8> {
9096
self.to_compact().encode()

primitives/src/v0.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,16 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> Signed<Payload, RealPa
921921
pub fn into_payload(self) -> Payload {
922922
self.payload
923923
}
924+
925+
/// Convert `Payload` into `RealPayload`.
926+
pub fn convert_payload(&self) -> Signed<RealPayload> where for<'a> &'a Payload: Into<RealPayload> {
927+
Signed {
928+
signature: self.signature.clone(),
929+
validator_index: self.validator_index,
930+
payload: self.payload().into(),
931+
real_payload: sp_std::marker::PhantomData,
932+
}
933+
}
924934
}
925935

926936
/// Custom validity errors used in Polkadot while validating transactions.

0 commit comments

Comments
 (0)