Skip to content

Commit

Permalink
Bridges subtree update (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored Dec 18, 2023
1 parent d941784 commit 792e374
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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 {
Expand All @@ -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> {
Expand Down

0 comments on commit 792e374

Please sign in to comment.