Skip to content
Snippets Groups Projects
Unverified Commit 9dbcc0e4 authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Improve metadata for `SkipCheckIfFeeless` (#7813)


If the inner transaction extension used inside `SkipCheckIfFeeless` are
multiples then the metadata is not correct, it is now fixed.

E.g. if the transaction extension is `SkipCheckIfFeeless::<Runtime,
(Payment1, Payment2)>` then the metadata was wrong.

---------

Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarBastian Köcher <git@kchr.de>
parent 4f7a9388
Branches
No related merge requests found
Pipeline #518184 waiting for manual action with stages
in 1 hour, 26 minutes, and 53 seconds
title: Improve metadata for `SkipCheckIfFeeless`
doc:
- audience: Runtime Dev
description: |-
If the inner transaction extension used inside `SkipCheckIfFeeless` are multiples then the metadata is not correct, it is now fixed.
E.g. if the transaction extension is `SkipCheckIfFeeless::<Runtime, (Payment1, Payment2)>` then the metadata was wrong.
crates:
- name: pallet-skip-feeless-payment
bump: patch
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use codec::{Decode, DecodeWithMemTracking, Encode}; use codec::{Decode, DecodeWithMemTracking, Encode};
use frame_support::{ use frame_support::{
dispatch::{CheckIfFeeless, DispatchResult}, dispatch::{CheckIfFeeless, DispatchResult},
...@@ -129,6 +131,10 @@ where ...@@ -129,6 +131,10 @@ where
const IDENTIFIER: &'static str = S::IDENTIFIER; const IDENTIFIER: &'static str = S::IDENTIFIER;
type Implicit = S::Implicit; type Implicit = S::Implicit;
fn metadata() -> alloc::vec::Vec<sp_runtime::traits::TransactionExtensionMetadata> {
S::metadata()
}
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> { fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
self.0.implicit() self.0.implicit()
} }
......
...@@ -94,3 +94,18 @@ fn validate_prepare_works() { ...@@ -94,3 +94,18 @@ fn validate_prepare_works() {
assert_eq!(ValidateCount::get(), 2); assert_eq!(ValidateCount::get(), 2);
assert_eq!(PrepareCount::get(), 2); assert_eq!(PrepareCount::get(), 2);
} }
#[test]
fn metadata_for_wrap_multiple_tx_ext() {
let metadata = SkipCheckIfFeeless::<Runtime, (DummyExtension, DummyExtension)>::metadata();
let mut expected_metadata = vec![];
expected_metadata.extend(DummyExtension::metadata().into_iter());
expected_metadata.extend(DummyExtension::metadata().into_iter());
assert_eq!(metadata.len(), expected_metadata.len());
for i in 0..expected_metadata.len() {
assert_eq!(metadata[i].identifier, expected_metadata[i].identifier);
assert_eq!(metadata[i].ty, expected_metadata[i].ty);
assert_eq!(metadata[i].implicit, expected_metadata[i].implicit);
}
}
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