Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridges subtree update #2736

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading