mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 08:41:07 +00:00
Allow pallet::call to return DispatchResult (#8241)
* allow dispatch result * remove custom error message * format * add forgotten UI test * fix test * fix tests
This commit is contained in:
committed by
GitHub
parent
4de4662480
commit
fb8da7ea92
@@ -27,6 +27,8 @@ mod keyword {
|
||||
syn::custom_keyword!(T);
|
||||
syn::custom_keyword!(Pallet);
|
||||
syn::custom_keyword!(origin);
|
||||
syn::custom_keyword!(DispatchResult);
|
||||
syn::custom_keyword!(DispatchResultWithPostInfo);
|
||||
}
|
||||
|
||||
/// A usage of instance, either the trait `Config` has been used with instance or without instance.
|
||||
@@ -596,3 +598,26 @@ pub fn check_type_value_gen(
|
||||
|
||||
Ok(i)
|
||||
}
|
||||
|
||||
/// Check the keyword `DispatchResultWithPostInfo` or `DispatchResult`.
|
||||
pub fn check_pallet_call_return_type(
|
||||
type_: &syn::Type,
|
||||
) -> syn::Result<()> {
|
||||
pub struct Checker;
|
||||
impl syn::parse::Parse for Checker {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
let lookahead = input.lookahead1();
|
||||
if lookahead.peek(keyword::DispatchResultWithPostInfo) {
|
||||
input.parse::<keyword::DispatchResultWithPostInfo>()?;
|
||||
Ok(Self)
|
||||
} else if lookahead.peek(keyword::DispatchResult) {
|
||||
input.parse::<keyword::DispatchResult>()?;
|
||||
Ok(Self)
|
||||
} else {
|
||||
Err(lookahead.error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syn::parse2::<Checker>(type_.to_token_stream()).map(|_| ())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user