Skip to content

Commit 055456f

Browse files
authored
Merge pull request #12 from availproject/toufeeq/fix-sdk
Fix missing CustomDispatchFee impls for legacy weights
2 parents 15e94d4 + 2a17d12 commit 055456f

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

polkadot/runtime/common/src/claims.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -421,18 +421,17 @@ pub mod pallet {
421421
#[pallet::call_index(3)]
422422
#[pallet::weight((
423423
T::WeightInfo::attest(),
424-
DispatchClass::Normal,
425-
Pays::No
424+
DispatchClass::Normal
426425
))]
427-
pub fn attest(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
426+
pub fn attest(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResultWithPostInfo {
428427
let who = ensure_signed(origin)?;
429428
let signer = Preclaims::<T>::get(&who).ok_or(Error::<T>::SenderHasNoClaim)?;
430429
if let Some(s) = Signing::<T>::get(signer) {
431430
ensure!(s.to_text() == &statement[..], Error::<T>::InvalidStatement);
432431
}
433432
Self::process_claim(signer, who.clone())?;
434433
Preclaims::<T>::remove(&who);
435-
Ok(())
434+
Ok(Pays::No.into())
436435
}
437436

438437
#[pallet::call_index(4)]

substrate/frame/support/src/dispatch.rs

+25
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,31 @@ impl<T> ClassifyDispatch<T> for (Weight, DispatchClass, Pays) {
613613
}
614614
}
615615

616+
// To support legacy v1 weights
617+
impl<T> CustomDispatchFee<T> for u64 {
618+
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
619+
DispatchFeeModifier::default()
620+
}
621+
}
622+
623+
impl<T> CustomDispatchFee<T> for (u64, DispatchClass) {
624+
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
625+
DispatchFeeModifier::default()
626+
}
627+
}
628+
629+
impl<T> CustomDispatchFee<T> for (u64, DispatchFeeModifier) {
630+
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
631+
self.1
632+
}
633+
}
634+
635+
impl<T> CustomDispatchFee<T> for (u64, DispatchClass, DispatchFeeModifier) {
636+
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
637+
self.2
638+
}
639+
}
640+
616641
impl<T> CustomDispatchFee<T> for Weight {
617642
fn custom_dispatch_fee(&self, _: T) -> DispatchFeeModifier {
618643
DispatchFeeModifier::default()

0 commit comments

Comments
 (0)