Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #219 #7407

Merged
merged 14 commits into from
Feb 18, 2025
Merged

Fixes #219 #7407

merged 14 commits into from
Feb 18, 2025

Conversation

aurexav
Copy link
Contributor

@aurexav aurexav commented Jan 31, 2025

Add a new extrinsic dispatch_as_fallible.

It's almost the same as [Pallet::dispatch_as] but forwards any error of the inner call.

Closes #219.

And add more unit tests to cover dispatch_as and dispatch_as_fallible.


Polkadot address: 156HGo9setPcU2qhFMVWLkcmtCEGySLwNqa3DaEiYSWtte4Y

@aurexav aurexav requested a review from a team as a code owner January 31, 2025 10:55
Signed-off-by: Xavier Lau <x@acg.box>
@aurexav aurexav force-pushed the dispatch-as-checked branch from c6b8a3b to 98ccdc1 Compare January 31, 2025 11:32
@@ -454,6 +454,36 @@ pub mod pallet {
let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
res.map(|_| ()).map_err(|e| e.error)
}

/// Dispatches a function call with a provided origin.
/// Almost the same as [`Pallet::dispatch_as`] but check the result of the call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can be more explicit and say it will return an error if the call returns an error.
I find the verb "check" a bit vague here.

dispatch_info.class,
)
})]
pub fn dispatch_as_checked(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn dispatch_as_checked(
pub fn dispatch_as_fallible(

Maybe that sounds better?

Co-authored-by: Bastian Köcher <git@kchr.de>
@bkchr
Copy link
Member

bkchr commented Feb 14, 2025

@aurexav will you finish this?

@aurexav
Copy link
Contributor Author

aurexav commented Feb 14, 2025

@aurexav will you finish this?

Done.

Quite busy these days and forgot about this.

@gui1117 gui1117 added the T2-pallets This PR/Issue is related to a particular pallet. label Feb 17, 2025
@gui1117
Copy link
Contributor

gui1117 commented Feb 17, 2025

It will also need a PRdoc

@bkchr bkchr enabled auto-merge February 17, 2025 20:05
@aurexav
Copy link
Contributor Author

aurexav commented Feb 18, 2025

It will also need a PRdoc

Updated the desc. Does /prdoc work for this?

@gui1117
Copy link
Contributor

gui1117 commented Feb 18, 2025

/cmd prdoc --audience runtime_dev,runtime_user --bump minor

Copy link
Contributor

Command "" has started 🚀 See logs here

Copy link
Contributor

Command "" has finished ✅ See logs here

@gui1117
Copy link
Contributor

gui1117 commented Feb 18, 2025

it doesn't seem to work, the patch from the job is empty.

@gui1117
Copy link
Contributor

gui1117 commented Feb 18, 2025

/cmd prdoc --audience runtime_dev --bump minor

@bkchr
Copy link
Member

bkchr commented Feb 18, 2025

/cmd fmt

@bkchr bkchr added this pull request to the merge queue Feb 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2025
@bkchr bkchr enabled auto-merge February 18, 2025 12:24
@bkchr bkchr added this pull request to the merge queue Feb 18, 2025
Merged via the queue into paritytech:master with commit 1ac2e96 Feb 18, 2025
223 of 232 checks passed
@aurexav aurexav deleted the dispatch-as-checked branch February 18, 2025 14:05
clangenb pushed a commit to clangenb/polkadot-sdk that referenced this pull request Feb 19, 2025
Add a new extrinsic `dispatch_as_fallible`.

It's almost the same as [`Pallet::dispatch_as`] but forwards any error
of the inner call.

Closes paritytech#219.

And add more unit tests to cover `dispatch_as` and
`dispatch_as_fallible`.

---

Polkadot address: 156HGo9setPcU2qhFMVWLkcmtCEGySLwNqa3DaEiYSWtte4Y

---------

Signed-off-by: Xavier Lau <x@acg.box>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

utility.dispatch_as error handling
3 participants