@@ -55,6 +55,7 @@ use xcm_executor::traits::WeightBounds;
55
55
pub use module:: * ;
56
56
use orml_traits:: {
57
57
location:: { Parse , Reserve } ,
58
+ xcm_transfer:: Transferred ,
58
59
GetByKey , XcmTransfer ,
59
60
} ;
60
61
@@ -220,7 +221,7 @@ pub mod module {
220
221
) -> DispatchResult {
221
222
let who = ensure_signed ( origin) ?;
222
223
let dest: MultiLocation = ( * dest) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
223
- Self :: do_transfer ( who, currency_id, amount, dest, dest_weight_limit)
224
+ Self :: do_transfer ( who, currency_id, amount, dest, dest_weight_limit) . map ( |_| ( ) )
224
225
}
225
226
226
227
/// Transfer `MultiAsset`.
@@ -246,7 +247,7 @@ pub mod module {
246
247
let who = ensure_signed ( origin) ?;
247
248
let asset: MultiAsset = ( * asset) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
248
249
let dest: MultiLocation = ( * dest) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
249
- Self :: do_transfer_multiasset ( who, asset, dest, dest_weight_limit)
250
+ Self :: do_transfer_multiasset ( who, asset, dest, dest_weight_limit) . map ( |_| ( ) )
250
251
}
251
252
252
253
/// Transfer native currencies specifying the fee and amount as
@@ -283,7 +284,7 @@ pub mod module {
283
284
let who = ensure_signed ( origin) ?;
284
285
let dest: MultiLocation = ( * dest) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
285
286
286
- Self :: do_transfer_with_fee ( who, currency_id, amount, fee, dest, dest_weight_limit)
287
+ Self :: do_transfer_with_fee ( who, currency_id, amount, fee, dest, dest_weight_limit) . map ( |_| ( ) )
287
288
}
288
289
289
290
/// Transfer `MultiAsset` specifying the fee and amount as separate.
@@ -321,7 +322,7 @@ pub mod module {
321
322
let fee: MultiAsset = ( * fee) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
322
323
let dest: MultiLocation = ( * dest) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
323
324
324
- Self :: do_transfer_multiasset_with_fee ( who, asset, fee, dest, dest_weight_limit)
325
+ Self :: do_transfer_multiasset_with_fee ( who, asset, fee, dest, dest_weight_limit) . map ( |_| ( ) )
325
326
}
326
327
327
328
/// Transfer several currencies specifying the item to be used as fee
@@ -351,7 +352,7 @@ pub mod module {
351
352
let who = ensure_signed ( origin) ?;
352
353
let dest: MultiLocation = ( * dest) . try_into ( ) . map_err ( |( ) | Error :: < T > :: BadVersion ) ?;
353
354
354
- Self :: do_transfer_multicurrencies ( who, currencies, fee_item, dest, dest_weight_limit)
355
+ Self :: do_transfer_multicurrencies ( who, currencies, fee_item, dest, dest_weight_limit) . map ( |_| ( ) )
355
356
}
356
357
357
358
/// Transfer several `MultiAsset` specifying the item to be used as fee
@@ -385,7 +386,7 @@ pub mod module {
385
386
// We first grab the fee
386
387
let fee: & MultiAsset = assets. get ( fee_item as usize ) . ok_or ( Error :: < T > :: AssetIndexNonExistent ) ?;
387
388
388
- Self :: do_transfer_multiassets ( who, assets. clone ( ) , fee. clone ( ) , dest, dest_weight_limit)
389
+ Self :: do_transfer_multiassets ( who, assets. clone ( ) , fee. clone ( ) , dest, dest_weight_limit) . map ( |_| ( ) )
389
390
}
390
391
}
391
392
@@ -396,7 +397,7 @@ pub mod module {
396
397
amount : T :: Balance ,
397
398
dest : MultiLocation ,
398
399
dest_weight_limit : WeightLimit ,
399
- ) -> DispatchResult {
400
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
400
401
let location: MultiLocation =
401
402
T :: CurrencyIdConvert :: convert ( currency_id) . ok_or ( Error :: < T > :: NotCrossChainTransferableCurrency ) ?;
402
403
@@ -417,7 +418,7 @@ pub mod module {
417
418
fee : T :: Balance ,
418
419
dest : MultiLocation ,
419
420
dest_weight_limit : WeightLimit ,
420
- ) -> DispatchResult {
421
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
421
422
let location: MultiLocation =
422
423
T :: CurrencyIdConvert :: convert ( currency_id) . ok_or ( Error :: < T > :: NotCrossChainTransferableCurrency ) ?;
423
424
@@ -444,7 +445,7 @@ pub mod module {
444
445
asset : MultiAsset ,
445
446
dest : MultiLocation ,
446
447
dest_weight_limit : WeightLimit ,
447
- ) -> DispatchResult {
448
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
448
449
Self :: do_transfer_multiassets ( who, vec ! [ asset. clone( ) ] . into ( ) , asset, dest, dest_weight_limit)
449
450
}
450
451
@@ -454,15 +455,13 @@ pub mod module {
454
455
fee : MultiAsset ,
455
456
dest : MultiLocation ,
456
457
dest_weight_limit : WeightLimit ,
457
- ) -> DispatchResult {
458
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
458
459
// Push contains saturated addition, so we should be able to use it safely
459
460
let mut assets = MultiAssets :: new ( ) ;
460
461
assets. push ( asset) ;
461
462
assets. push ( fee. clone ( ) ) ;
462
463
463
- Self :: do_transfer_multiassets ( who, assets, fee, dest, dest_weight_limit) ?;
464
-
465
- Ok ( ( ) )
464
+ Self :: do_transfer_multiassets ( who, assets, fee, dest, dest_weight_limit)
466
465
}
467
466
468
467
fn do_transfer_multicurrencies (
@@ -471,7 +470,7 @@ pub mod module {
471
470
fee_item : u32 ,
472
471
dest : MultiLocation ,
473
472
dest_weight_limit : WeightLimit ,
474
- ) -> DispatchResult {
473
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
475
474
ensure ! (
476
475
currencies. len( ) <= T :: MaxAssetsForTransfer :: get( ) ,
477
476
Error :: <T >:: TooManyAssetsBeingSent
@@ -513,7 +512,7 @@ pub mod module {
513
512
fee : MultiAsset ,
514
513
dest : MultiLocation ,
515
514
dest_weight_limit : WeightLimit ,
516
- ) -> DispatchResult {
515
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
517
516
ensure ! (
518
517
assets. len( ) <= T :: MaxAssetsForTransfer :: get( ) ,
519
518
Error :: <T >:: TooManyAssetsBeingSent
@@ -621,13 +620,18 @@ pub mod module {
621
620
}
622
621
623
622
Self :: deposit_event ( Event :: < T > :: TransferredMultiAssets {
623
+ sender : who. clone ( ) ,
624
+ assets : assets. clone ( ) ,
625
+ fee : fee. clone ( ) ,
626
+ dest,
627
+ } ) ;
628
+
629
+ Ok ( Transferred {
624
630
sender : who,
625
631
assets,
626
632
fee,
627
633
dest,
628
- } ) ;
629
-
630
- Ok ( ( ) )
634
+ } )
631
635
}
632
636
633
637
/// Execute and send xcm with given assets and fee to dest chain or
@@ -947,30 +951,64 @@ pub mod module {
947
951
amount : T :: Balance ,
948
952
dest : MultiLocation ,
949
953
dest_weight_limit : WeightLimit ,
950
- ) -> DispatchResult {
954
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
951
955
Self :: do_transfer ( who, currency_id, amount, dest, dest_weight_limit)
952
956
}
953
957
954
958
#[ require_transactional]
955
- fn transfer_multi_asset (
959
+ fn transfer_multiasset (
956
960
who : T :: AccountId ,
957
961
asset : MultiAsset ,
958
962
dest : MultiLocation ,
959
963
dest_weight_limit : WeightLimit ,
960
- ) -> DispatchResult {
964
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
961
965
Self :: do_transfer_multiasset ( who, asset, dest, dest_weight_limit)
962
966
}
963
967
968
+ #[ require_transactional]
969
+ fn transfer_with_fee (
970
+ who : T :: AccountId ,
971
+ currency_id : T :: CurrencyId ,
972
+ amount : T :: Balance ,
973
+ fee : T :: Balance ,
974
+ dest : MultiLocation ,
975
+ dest_weight_limit : WeightLimit ,
976
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
977
+ Self :: do_transfer_with_fee ( who, currency_id, amount, fee, dest, dest_weight_limit)
978
+ }
979
+
964
980
#[ require_transactional]
965
981
fn transfer_multiasset_with_fee (
966
982
who : T :: AccountId ,
967
983
asset : MultiAsset ,
968
984
fee : MultiAsset ,
969
985
dest : MultiLocation ,
970
986
dest_weight_limit : WeightLimit ,
971
- ) -> DispatchResult {
987
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
972
988
Self :: do_transfer_multiasset_with_fee ( who, asset, fee, dest, dest_weight_limit)
973
989
}
990
+
991
+ #[ require_transactional]
992
+ fn transfer_multicurrencies (
993
+ who : T :: AccountId ,
994
+ currencies : Vec < ( T :: CurrencyId , T :: Balance ) > ,
995
+ fee_item : u32 ,
996
+ dest : MultiLocation ,
997
+ dest_weight_limit : WeightLimit ,
998
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
999
+ Self :: do_transfer_multicurrencies ( who, currencies, fee_item, dest, dest_weight_limit)
1000
+ }
1001
+
1002
+ #[ require_transactional]
1003
+ fn transfer_multiassets (
1004
+ who : T :: AccountId ,
1005
+ assets : MultiAssets ,
1006
+ fee : MultiAsset ,
1007
+ dest : MultiLocation ,
1008
+ dest_weight_limit : WeightLimit ,
1009
+ ) -> Result < Transferred < T :: AccountId > , DispatchError > {
1010
+ Self :: do_transfer_multiassets ( who, assets, fee, dest, dest_weight_limit)
1011
+ }
974
1012
}
975
1013
}
976
1014
0 commit comments