Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

pallet-assets callback improvement #13543

Merged

Conversation

Dinonard
Copy link
Contributor

@Dinonard Dinonard commented Mar 6, 2023

Improves AssetsCallback trait by introducing Result<(), ()> as the return type.
This allows callback to inform the pallet whether the asset creation (or destruction) should complete or not.

Also moves the destroyed callback invocation to do_finish_destroy function.

@dmitry-markin dmitry-markin added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Mar 6, 2023
Copy link
Contributor

@jsidorenko jsidorenko left a comment

Choose a reason for hiding this comment

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

👍

@Dinonard
Copy link
Contributor Author

Can someone else also please take a look? 🙏

@@ -661,8 +661,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
status: AssetStatus::Live,
},
);
ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::<T, I>::CallbackFailed);
Copy link
Member

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.

Copy link
Contributor Author

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 🙂

Copy link
Contributor

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

/// #[require_transactional]

Copy link
Contributor

@kianenigma kianenigma left a 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.

@jsidorenko
Copy link
Contributor

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 30aa444 into paritytech:master Mar 13, 2023
ukint-vs pushed a commit to gear-tech/substrate that referenced this pull request Apr 10, 2023
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants