mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Improve PaysFee trait and dispatch info logic in utility module (#4606)
* pass target to PaysFee trait and allow batch call to be free if all its calls are free * bump version * fix error
This commit is contained in:
@@ -1312,8 +1312,9 @@ macro_rules! decl_module {
|
||||
&$weight,
|
||||
($( $param_name, )*)
|
||||
);
|
||||
let pays_fee = <dyn $crate::dispatch::PaysFee>::pays_fee(
|
||||
&$weight
|
||||
let pays_fee = <dyn $crate::dispatch::PaysFee<( $( & $param, )* )>>::pays_fee(
|
||||
&$weight,
|
||||
($( $param_name, )*)
|
||||
);
|
||||
return $crate::dispatch::DispatchInfo { weight, class, pays_fee };
|
||||
}
|
||||
@@ -1331,8 +1332,9 @@ macro_rules! decl_module {
|
||||
&$crate::dispatch::SimpleDispatchInfo::default(),
|
||||
()
|
||||
);
|
||||
let pays_fee = <dyn $crate::dispatch::PaysFee>::pays_fee(
|
||||
&$crate::dispatch::SimpleDispatchInfo::default()
|
||||
let pays_fee = <dyn $crate::dispatch::PaysFee<_>>::pays_fee(
|
||||
&$crate::dispatch::SimpleDispatchInfo::default(),
|
||||
()
|
||||
);
|
||||
$crate::dispatch::DispatchInfo { weight, class, pays_fee }
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ pub trait WeighBlock<BlockNumber> {
|
||||
|
||||
/// Indicates if dispatch function should pay fees or not.
|
||||
/// If set to false, the block resource limits are applied, yet no fee is deducted.
|
||||
pub trait PaysFee {
|
||||
fn pays_fee(&self) -> bool {
|
||||
pub trait PaysFee<T> {
|
||||
fn pays_fee(&self, _target: T) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -208,8 +208,8 @@ impl<T> ClassifyDispatch<T> for SimpleDispatchInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl PaysFee for SimpleDispatchInfo {
|
||||
fn pays_fee(&self) -> bool {
|
||||
impl<T> PaysFee<T> for SimpleDispatchInfo {
|
||||
fn pays_fee(&self, _: T) -> bool {
|
||||
match self {
|
||||
SimpleDispatchInfo::FixedNormal(_) => true,
|
||||
SimpleDispatchInfo::MaxNormal => true,
|
||||
|
||||
Reference in New Issue
Block a user