Skip to content
Snippets Groups Projects
Unverified Commit 792e3743 authored by Branislav Kontur's avatar Branislav Kontur Committed by GitHub
Browse files

Bridges subtree update (#2736)

parent d941784b
Branches
No related merge requests found
Pipeline #427163 canceled with stages
in 13 minutes and 32 seconds
......@@ -15,7 +15,7 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use crate::HeaderIdProvider;
use codec::{Decode, Encode, MaxEncodedLen};
use codec::{Codec, Decode, Encode, MaxEncodedLen};
use frame_support::{weights::Weight, Parameter};
use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero};
use sp_runtime::{
......@@ -39,7 +39,7 @@ pub enum EncodedOrDecodedCall<ChainCall> {
Decoded(ChainCall),
}
impl<ChainCall: Clone + Decode> EncodedOrDecodedCall<ChainCall> {
impl<ChainCall: Clone + Codec> EncodedOrDecodedCall<ChainCall> {
/// Returns decoded call.
pub fn to_decoded(&self) -> Result<ChainCall, codec::Error> {
match self {
......@@ -57,6 +57,14 @@ impl<ChainCall: Clone + Decode> EncodedOrDecodedCall<ChainCall> {
Self::Decoded(decoded_call) => Ok(decoded_call),
}
}
/// Converts self to encoded call.
pub fn into_encoded(self) -> Vec<u8> {
match self {
Self::Encoded(encoded_call) => encoded_call,
Self::Decoded(decoded_call) => decoded_call.encode(),
}
}
}
impl<ChainCall> From<ChainCall> for EncodedOrDecodedCall<ChainCall> {
......
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