mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
Add a convert_payload function to Signed (#2320)
* Add a `convert_payload` function to `Signed` * Review feedback
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user