-
Notifications
You must be signed in to change notification settings - Fork 2.7k
pallet-assets callback improvement #13543
pallet-assets callback improvement #13543
Conversation
jsidorenko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
Can someone else also please take a look? 🙏 |
| status: AssetStatus::Live, | ||
| }, | ||
| ); | ||
| ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::<T, I>::CallbackFailed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relies on transactional stroage since the insert above happens after the failure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional since my understanding is that this is the default behavior (also got this comment below).
I also thought it would be good to have Assets entry in the DB before the callback (just in case the data from it is needed for the callback).
Open to suggestions though 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use require_transactional to annotate it
substrate/frame/support/src/lib.rs
Line 657 in 959c5b6
| /// #[require_transactional] |
kianenigma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a step in the right direction. We should leverage transactional-by-default more and more.
|
bot merge |
Improves
AssetsCallbacktrait by introducingResult<(), ()>as the return type.This allows callback to inform the pallet whether the asset creation (or destruction) should complete or not.
Also moves the
destroyedcallback invocation todo_finish_destroyfunction.