mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +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:
@@ -204,9 +204,9 @@ impl<Call: GetDispatchInfo> ClassifyDispatch<(&u16, &Box<Call>)> for Passthrough
|
||||
call.get_dispatch_info().class
|
||||
}
|
||||
}
|
||||
impl<Call: GetDispatchInfo> PaysFee for Passthrough<Call> {
|
||||
fn pays_fee(&self) -> bool {
|
||||
true
|
||||
impl<Call: GetDispatchInfo> PaysFee<(&u16, &Box<Call>)> for Passthrough<Call> {
|
||||
fn pays_fee(&self, (_, call): (&u16, &Box<Call>)) -> bool {
|
||||
call.get_dispatch_info().pays_fee
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,13 +226,21 @@ impl<Call: GetDispatchInfo> WeighData<(&Vec<Call>,)> for BatchPassthrough<Call>
|
||||
}
|
||||
}
|
||||
impl<Call: GetDispatchInfo> ClassifyDispatch<(&Vec<Call>,)> for BatchPassthrough<Call> {
|
||||
fn classify_dispatch(&self, (_,): (&Vec<Call>,)) -> DispatchClass {
|
||||
DispatchClass::Normal
|
||||
fn classify_dispatch(&self, (calls,): (&Vec<Call>,)) -> DispatchClass {
|
||||
let all_operational = calls.iter()
|
||||
.map(|call| call.get_dispatch_info().class)
|
||||
.all(|class| class == DispatchClass::Operational);
|
||||
if all_operational {
|
||||
DispatchClass::Operational
|
||||
} else {
|
||||
DispatchClass::Normal
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<Call: GetDispatchInfo> PaysFee for BatchPassthrough<Call> {
|
||||
fn pays_fee(&self) -> bool {
|
||||
true
|
||||
impl<Call: GetDispatchInfo> PaysFee<(&Vec<Call>,)> for BatchPassthrough<Call> {
|
||||
fn pays_fee(&self, (calls,): (&Vec<Call>,)) -> bool {
|
||||
calls.iter()
|
||||
.any(|call| call.get_dispatch_info().pays_fee)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,16 +262,16 @@ for MultiPassthrough<Call, AccountId, Timepoint>
|
||||
impl<Call: GetDispatchInfo, AccountId, Timepoint> ClassifyDispatch<(&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)>
|
||||
for MultiPassthrough<Call, AccountId, Timepoint>
|
||||
{
|
||||
fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>))
|
||||
fn classify_dispatch(&self, (_, _, _, call): (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>))
|
||||
-> DispatchClass
|
||||
{
|
||||
DispatchClass::Normal
|
||||
call.get_dispatch_info().class
|
||||
}
|
||||
}
|
||||
impl<Call: GetDispatchInfo, AccountId, Timepoint> PaysFee
|
||||
impl<Call: GetDispatchInfo, AccountId, Timepoint> PaysFee<(&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)>
|
||||
for MultiPassthrough<Call, AccountId, Timepoint>
|
||||
{
|
||||
fn pays_fee(&self) -> bool {
|
||||
fn pays_fee(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -286,16 +294,16 @@ for SigsLen<AccountId, Timepoint>
|
||||
impl<AccountId, Timepoint> ClassifyDispatch<(&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])>
|
||||
for SigsLen<AccountId, Timepoint>
|
||||
{
|
||||
fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32]))
|
||||
fn classify_dispatch(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32]))
|
||||
-> DispatchClass
|
||||
{
|
||||
DispatchClass::Normal
|
||||
}
|
||||
}
|
||||
impl<AccountId, Timepoint> PaysFee
|
||||
impl<AccountId, Timepoint> PaysFee<(&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])>
|
||||
for SigsLen<AccountId, Timepoint>
|
||||
{
|
||||
fn pays_fee(&self) -> bool {
|
||||
fn pays_fee(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user