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

Callbacks for pallet-assets #12279

@Dinonard

Description

@Dinonard

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    J2-unconfirmedIssue might be valid, but it’s not yet known.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions