Skip to content

Commit

Permalink
Fix missing CustomDispatchFee impls for legacy weights
Browse files Browse the repository at this point in the history
  • Loading branch information
ToufeeqP committed Aug 1, 2024
1 parent 15e94d4 commit 2a17d12
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
7 changes: 3 additions & 4 deletions polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,17 @@ pub mod pallet {
#[pallet::call_index(3)]
#[pallet::weight((
T::WeightInfo::attest(),
DispatchClass::Normal,
Pays::No
DispatchClass::Normal
))]
pub fn attest(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
pub fn attest(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let signer = Preclaims::<T>::get(&who).ok_or(Error::<T>::SenderHasNoClaim)?;
if let Some(s) = Signing::<T>::get(signer) {
ensure!(s.to_text() == &statement[..], Error::<T>::InvalidStatement);
}
Self::process_claim(signer, who.clone())?;
Preclaims::<T>::remove(&who);
Ok(())
Ok(Pays::No.into())
}

#[pallet::call_index(4)]
Expand Down
25 changes: 25 additions & 0 deletions substrate/frame/support/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,31 @@ impl<T> ClassifyDispatch<T> for (Weight, DispatchClass, Pays) {
}
}

// To support legacy v1 weights
impl<T> CustomDispatchFee<T> for u64 {
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
DispatchFeeModifier::default()
}
}

impl<T> CustomDispatchFee<T> for (u64, DispatchClass) {
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
DispatchFeeModifier::default()
}
}

impl<T> CustomDispatchFee<T> for (u64, DispatchFeeModifier) {
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
self.1
}
}

impl<T> CustomDispatchFee<T> for (u64, DispatchClass, DispatchFeeModifier) {
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
self.2
}
}

impl<T> CustomDispatchFee<T> for Weight {
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
DispatchFeeModifier::default()
Expand Down

0 comments on commit 2a17d12

Please sign in to comment.