Implement transfer_asset on CurrencyAdapter (#4549)

* Implement transfer_asset on CurrencyAdapter

* Use Currency::transfer in transfer_asset

* Add a test to assert that Currency::transfer was indeed used

* Remove superfluous balance conversion to u128

* Rename transfer_asset and beam_asset

Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
Keith Yeung
2022-03-29 12:23:18 +02:00
committed by GitHub
parent 9fdc059363
commit 0e3f36224a
6 changed files with 80 additions and 34 deletions
@@ -118,14 +118,14 @@ impl<
AccountId: Clone, // can't get away without it since Currency is generic over it.
> TransactAsset for FungiblesTransferAdapter<Assets, Matcher, AccountIdConverter, AccountId>
{
fn transfer_asset(
fn internal_transfer_asset(
what: &MultiAsset,
from: &MultiLocation,
to: &MultiLocation,
) -> result::Result<xcm_executor::Assets, XcmError> {
log::trace!(
target: "xcm::fungibles_adapter",
"transfer_asset what: {:?}, from: {:?}, to: {:?}",
"internal_transfer_asset what: {:?}, from: {:?}, to: {:?}",
what, from, to
);
// Check we handle this asset.
@@ -325,12 +325,12 @@ impl<
>::withdraw_asset(what, who)
}
fn transfer_asset(
fn internal_transfer_asset(
what: &MultiAsset,
from: &MultiLocation,
to: &MultiLocation,
) -> result::Result<xcm_executor::Assets, XcmError> {
FungiblesTransferAdapter::<Assets, Matcher, AccountIdConverter, AccountId>::transfer_asset(
FungiblesTransferAdapter::<Assets, Matcher, AccountIdConverter, AccountId>::internal_transfer_asset(
what, from, to,
)
}