Acala icon indicating copy to clipboard operation
Acala copied to clipboard

support metadata operation on asset-registry

Open zqhxuyuan opened this issue 3 years ago • 1 comments

with existence of asset-registry module, we can not only register statemine/statemint inner assets, I think we can also register Token(TokenSymbol) asset (may be also including our own native asset). here is quick thought:

  1. a trait used to simulate all kinds of asset operation, and asset-registry module can implement this trait. we could extend the metadata of asset-registry to include Token/CurrencyId so that it will store currency_id to location and vice versa.
pub trait CurrencyMetadataOps {
        // replace ExistentialDeposits
	fn existential_deposit(currency_id: &CurrencyId) -> Balance;

        // replace Convert<CurrencyId, Option<MultiLocation>>
	fn currency_to_location(currency_id: CurrencyId) -> Option<MultiLocation>;
        // replace Convert<MultiLocation, Option<CurrencyId>>
	fn location_to_currency(location: MultiLocation) -> Option<CurrencyId>;
        // replace Convert<MultiAsset, Option<CurrencyId>>
	fn asset_to_currency(asset: MultiAsset) -> Option<CurrencyId> {
		if let MultiAsset {
			id: Concrete(location), ..
		} = asset
		{
			Self::location_to_currency(location)
		} else {
			None
		}
	}
        // Trader
	fn units_per_second(currency_id: CurrencyId) -> Balance;
}
  1. refactor CurrencyId related mapping, such as CurrencyIdConvert, Trader, ExistentialDeposits.

IMO this will simplify new foreign asset onboard on acala side. what do you think @xlc @shaunxw @zjb0807

zqhxuyuan avatar Jan 12 '22 09:01 zqhxuyuan

This could be helpful to handle breaking changes of MultiLocation

xlc avatar Jan 12 '22 22:01 xlc