From 2a17d12b8eb512e02a79110bf2c384c8ce042056 Mon Sep 17 00:00:00 2001 From: Toufeeq Pasha Date: Thu, 1 Aug 2024 10:53:53 +0530 Subject: [PATCH] Fix missing CustomDispatchFee impls for legacy weights --- polkadot/runtime/common/src/claims.rs | 7 +++---- substrate/frame/support/src/dispatch.rs | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/polkadot/runtime/common/src/claims.rs b/polkadot/runtime/common/src/claims.rs index 86550ea8b4eb..9e9c85725d80 100644 --- a/polkadot/runtime/common/src/claims.rs +++ b/polkadot/runtime/common/src/claims.rs @@ -421,10 +421,9 @@ pub mod pallet { #[pallet::call_index(3)] #[pallet::weight(( T::WeightInfo::attest(), - DispatchClass::Normal, - Pays::No + DispatchClass::Normal ))] - pub fn attest(origin: OriginFor, statement: Vec) -> DispatchResult { + pub fn attest(origin: OriginFor, statement: Vec) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let signer = Preclaims::::get(&who).ok_or(Error::::SenderHasNoClaim)?; if let Some(s) = Signing::::get(signer) { @@ -432,7 +431,7 @@ pub mod pallet { } Self::process_claim(signer, who.clone())?; Preclaims::::remove(&who); - Ok(()) + Ok(Pays::No.into()) } #[pallet::call_index(4)] diff --git a/substrate/frame/support/src/dispatch.rs b/substrate/frame/support/src/dispatch.rs index 59d2b15c6c8d..991fe33a2220 100644 --- a/substrate/frame/support/src/dispatch.rs +++ b/substrate/frame/support/src/dispatch.rs @@ -613,6 +613,31 @@ impl ClassifyDispatch for (Weight, DispatchClass, Pays) { } } +// To support legacy v1 weights +impl CustomDispatchFee for u64 { + fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier { + DispatchFeeModifier::default() + } +} + +impl CustomDispatchFee for (u64, DispatchClass) { + fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier { + DispatchFeeModifier::default() + } +} + +impl CustomDispatchFee for (u64, DispatchFeeModifier) { + fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier { + self.1 + } +} + +impl CustomDispatchFee for (u64, DispatchClass, DispatchFeeModifier) { + fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier { + self.2 + } +} + impl CustomDispatchFee for Weight { fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier { DispatchFeeModifier::default()