UnionOf types for merged fungible and fungibles implementations (#2033)

Introduces `UnionOf` types, crafted to merge `fungible` and `fungibles`
implementations or two `fungibles` implementations into a single type
implementing `fungibles`.

This also addresses an issue where `ItemOf` initiates a double drop for
an imbalance type, leading to inaccurate total issuance accounting.

Find the application of these types in this PR -
[link](https://github.com/paritytech/polkadot-sdk/pull/2031), places in
code -
[1](https://github.com/paritytech/polkadot-sdk/blob/4ec7496fa2632385b08fae860fcf28a523a7b5de/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs#L327),
[2](https://github.com/paritytech/polkadot-sdk/blob/4ec7496fa2632385b08fae860fcf28a523a7b5de/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs#L343).

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: joepetrowski <joe@parity.io>
This commit is contained in:
Muharem
2023-12-19 13:51:05 +01:00
committed by GitHub
parent 81156d03ce
commit 0b74812ce8
15 changed files with 2353 additions and 37 deletions
+3 -3
View File
@@ -417,7 +417,7 @@ pub mod pallet {
match T::MultiAssetIdConverter::try_convert(asset1) {
MultiAssetIdConversionResult::Converted(asset) =>
if !T::Assets::contains(&asset, &pool_account) {
T::Assets::touch(asset, pool_account.clone(), sender.clone())?
T::Assets::touch(asset, &pool_account, &sender)?
},
MultiAssetIdConversionResult::Unsupported(_) => Err(Error::<T>::UnsupportedAsset)?,
MultiAssetIdConversionResult::Native => (),
@@ -425,7 +425,7 @@ pub mod pallet {
match T::MultiAssetIdConverter::try_convert(asset2) {
MultiAssetIdConversionResult::Converted(asset) =>
if !T::Assets::contains(&asset, &pool_account) {
T::Assets::touch(asset, pool_account.clone(), sender.clone())?
T::Assets::touch(asset, &pool_account, &sender)?
},
MultiAssetIdConversionResult::Unsupported(_) => Err(Error::<T>::UnsupportedAsset)?,
MultiAssetIdConversionResult::Native => (),
@@ -438,7 +438,7 @@ pub mod pallet {
NextPoolAssetId::<T>::set(Some(next_lp_token_id));
T::PoolAssets::create(lp_token.clone(), pool_account.clone(), false, 1u32.into())?;
T::PoolAssets::touch(lp_token.clone(), pool_account.clone(), sender.clone())?;
T::PoolAssets::touch(lp_token.clone(), &pool_account, &sender)?;
let pool_info = PoolInfo { lp_token: lp_token.clone() };
Pools::<T>::insert(pool_id.clone(), pool_info);