Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnionOf types for merged fungible and fungibles implementations #2033

Merged
merged 23 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,18 @@ where
}
}

fn should_touch(asset_id: MultiLocation, who: &AccountId) -> bool {
if let Some(asset_id) = LocalAssetIdConverter::convert(&asset_id) {
Assets::should_touch(asset_id, who)
} else {
ForeignAssets::should_touch(asset_id, who)
}
}

fn touch(
asset_id: MultiLocation,
who: AccountId,
depositor: AccountId,
who: &AccountId,
depositor: &AccountId,
) -> Result<(), DispatchError> {
if let Some(asset_id) = LocalAssetIdConverter::convert(&asset_id) {
Assets::touch(asset_id, who, depositor)
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/asset-conversion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ 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 => (),
}
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 => (),
Expand All @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions substrate/frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,8 +1648,16 @@ pub mod pallet {
T::AssetAccountDeposit::get()
}

fn touch(asset: T::AssetId, who: T::AccountId, depositor: T::AccountId) -> DispatchResult {
Self::do_touch(asset, who, depositor, false)
fn should_touch(_: T::AssetId, _: &T::AccountId) -> bool {
true
}

fn touch(
asset: T::AssetId,
who: &T::AccountId,
depositor: &T::AccountId,
) -> DispatchResult {
Self::do_touch(asset, who.clone(), depositor.clone(), false)
}
}

Expand Down
Loading
Loading