mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +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
@@ -161,6 +161,14 @@ pub mod pallet {
|
||||
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
// Test for DispatchResult return type
|
||||
#[pallet::weight(1)]
|
||||
fn foo_no_post_info(
|
||||
_origin: OriginFor<T>,
|
||||
) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -425,7 +433,7 @@ fn call_expand() {
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
pallet::Call::<Runtime>::get_call_names(),
|
||||
&["foo", "foo_transactional"],
|
||||
&["foo", "foo_transactional", "foo_no_post_info"],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -669,6 +677,11 @@ fn metadata() {
|
||||
" Doc comment put in metadata".to_string(),
|
||||
]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Decoded("foo_no_post_info".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec![]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
])),
|
||||
event: Some(DecodeDifferent::Decoded(vec![
|
||||
EventMetadata {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#[frame_support::pallet]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::Hooks;
|
||||
use frame_system::pallet_prelude::{BlockNumberFor, OriginFor};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
fn foo(origin: OriginFor<T>) -> ::DispatchResult { todo!() }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected `DispatchResultWithPostInfo` or `DispatchResult`
|
||||
--> $DIR/call_invalid_return.rs:17:35
|
||||
|
|
||||
17 | fn foo(origin: OriginFor<T>) -> ::DispatchResult { todo!() }
|
||||
| ^^
|
||||
Reference in New Issue
Block a user