Skip to content

Commit 9dbcc0e

Browse files
gui1117github-actions[bot]bkchr
authored
Improve metadata for SkipCheckIfFeeless (paritytech#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: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
1 parent 4f7a938 commit 9dbcc0e

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

prdoc/pr_7813.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: Improve metadata for `SkipCheckIfFeeless`
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
If the inner transaction extension used inside `SkipCheckIfFeeless` are multiples then the metadata is not correct, it is now fixed.
6+
7+
E.g. if the transaction extension is `SkipCheckIfFeeless::<Runtime, (Payment1, Payment2)>` then the metadata was wrong.
8+
crates:
9+
- name: pallet-skip-feeless-payment
10+
bump: patch

substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
3737
#![cfg_attr(not(feature = "std"), no_std)]
3838

39+
extern crate alloc;
40+
3941
use codec::{Decode, DecodeWithMemTracking, Encode};
4042
use frame_support::{
4143
dispatch::{CheckIfFeeless, DispatchResult},
@@ -129,6 +131,10 @@ where
129131
const IDENTIFIER: &'static str = S::IDENTIFIER;
130132
type Implicit = S::Implicit;
131133

134+
fn metadata() -> alloc::vec::Vec<sp_runtime::traits::TransactionExtensionMetadata> {
135+
S::metadata()
136+
}
137+
132138
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
133139
self.0.implicit()
134140
}

substrate/frame/transaction-payment/skip-feeless-payment/src/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,18 @@ fn validate_prepare_works() {
9494
assert_eq!(ValidateCount::get(), 2);
9595
assert_eq!(PrepareCount::get(), 2);
9696
}
97+
98+
#[test]
99+
fn metadata_for_wrap_multiple_tx_ext() {
100+
let metadata = SkipCheckIfFeeless::<Runtime, (DummyExtension, DummyExtension)>::metadata();
101+
let mut expected_metadata = vec![];
102+
expected_metadata.extend(DummyExtension::metadata().into_iter());
103+
expected_metadata.extend(DummyExtension::metadata().into_iter());
104+
105+
assert_eq!(metadata.len(), expected_metadata.len());
106+
for i in 0..expected_metadata.len() {
107+
assert_eq!(metadata[i].identifier, expected_metadata[i].identifier);
108+
assert_eq!(metadata[i].ty, expected_metadata[i].ty);
109+
assert_eq!(metadata[i].implicit, expected_metadata[i].implicit);
110+
}
111+
}

0 commit comments

Comments
 (0)