Implement to_jsonrpc_signed for CircuitOutboundMessage at primitives
@@ -188,7 +188,7 @@ pub struct CircuitOutboundMessage {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct RpcPayloadUnsigned<'a> {
pub method_name: &'a str,
- pub params: Vec<Bytes>
+ pub params: Vec<Bytes>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -199,29 +199,29 @@ pub struct RpcPayloadSigned<'a> {
}
impl CircuitOutboundMessage {
-
pub fn to_jsonrpc_unsigned(&self) -> Result<RpcPayloadUnsigned, &'static str> {
- let method_name: &str =
- sp_std::str::from_utf8(&self.name[..]).map_err(|_| "`Can't decode method name to &str")?;
+ let method_name: &str = sp_std::str::from_utf8(&self.name[..])
+ .map_err(|_| "`Can't decode method name to &str")?;
- Ok(
- RpcPayloadUnsigned {
+ Ok(RpcPayloadUnsigned {
method_name,
- params: self.arguments.clone()
- }
- )
+ params: self.arguments.clone(),
+ })
}
- pub fn to_jsonrpc_signed(&self) -> Result<RpcPayloadUnsigned, &'static str> {
- let method_name: &str =
- sp_std::str::from_utf8(&self.name[..]).map_err(|_| "`Can't decode method name to &str")?;
+ pub fn to_jsonrpc_signed(&self) -> Result<RpcPayloadSigned, &'static str> {
+ let method_name: &str = sp_std::str::from_utf8(&self.name[..])
+ .map_err(|_| "`Can't decode method name to &str")?;
- Ok(
- RpcPayloadUnsigned {
+ let extra_payload = self
+ .extra_payload
+ .clone()
+ .expect("Expect extra_payload on OutboundMessage when calling 'to_jsonrpc_signed'");
+
+ Ok(RpcPayloadSigned {
method_name,
- params: self.arguments.clone()
- }
- )
+ signed_extrinsic: extra_payload.tx_signed.clone(),
+ })
}
}
@@ -291,7 +291,7 @@ pub struct ExtraMessagePayload {
pub tx_signed: Bytes,
/// Custom message bytes, that would have to be decoded by the receiving end.
/// Could be utilized by custom transmission medium (like Substrate's XCMP)
- pub custom_payload: Option<Bytes>
+ pub custom_payload: Option<Bytes>,
}
/// Retrieves all available gateways for a given ChainId.
