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

Callbacks for pallet-assets #12279

Closed
2 tasks done
Dinonard opened this issue Sep 15, 2022 · 4 comments · Fixed by #12307
Closed
2 tasks done

Callbacks for pallet-assets #12279

Dinonard opened this issue Sep 15, 2022 · 4 comments · Fixed by #12307
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@Dinonard
Copy link
Contributor

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

Hi there,

it would be very useful if we could register callback methods for when new assets in pallet-assets are created, destroyed or manipulated in some other way.
The motivation behind is making assets cross-chain compatible for EVM contracts - in order to do this automatically, we need to do some actions after a new asset has been created. Being able to do this just using what pallet-assets provides would be great.

E.g. introduce a trait like:

/// Callbacks for various asset manipulation functions
pub trait AssetsCallback<AssetId, AccountId> {

	/// Indicates that asset with `id` was successfully created by the `owner`
	fn created(id: &AssetId, owner: &AccountId);

	/// Indicates that asset with `id` has just been destroyed
    fn destroyed(id: &AssetId);
}

and have it as part of pallet-assets Config:

	pub trait Config<I: 'static = ()>: frame_system::Config {
                ....
		/// Callback methods for asset state change (e.g. asset created or destroyed)
		type Callback: AssetsCallback<Self::AssetId, Self::AccountId>;
	}

Then it's just a matter of calling it once create or destroy have been successfully executed.
This would be a lightweight change, no benchmarks would really need to be changed if user doesn't introduce any custom hooks.

Is this a feasible change for pallet-assets?
Or should it just be handled by another pallet in chains that require it?

Related to this discussion basically.

Steps to reproduce

No response

@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Sep 15, 2022
@joepetrowski
Copy link
Contributor

Seems reasonable to me at first glance. @tonyalaribe - can you look into it more?

@kianenigma
Copy link
Contributor

Should be an easy addition -- and a () impl does nothing.

@Dinonard
Copy link
Contributor Author

Thanks for the feedback!

I'll prepare a PR during tomorrow and reference this issue.

Repository owner moved this from Backlog to Done in Runtime / FRAME Dec 21, 2022
@Polkadot-Forum
Copy link

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-37/1736/1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants