@paraspell/sdk-core 13.7.2 → 13.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +193 -133
  2. package/dist/index.mjs +824 -790
  3. package/package.json +6 -9
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, extractAssetLocation, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrowImpl, getExistentialDepositOrThrow, hasDryRunSupport, normalizeSymbol, Native, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, normalizeCustomAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isSymbolSpecifier, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrowImpl, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, normalizeCustomAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, pad, toHex, getAddress, concat, keccak256, isHex, createPublicClient, http, getContract, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
@@ -1076,7 +1076,7 @@ var assertCurrencyCore = function assertCurrencyCore(value) {
1076
1076
  throw new InvalidCurrencyError('A currency selector is required.');
1077
1077
  }
1078
1078
  if (Array.isArray(value)) {
1079
- throw new InvalidCurrencyError('Multi-asset currency input is not supported here. Provide a single currency selector ({ symbol }, { id }, or { location }).');
1079
+ throw new InvalidCurrencyError('An array of currencies is not supported here. Provide a single currency selector ({ symbol }, { id }, or { location }).');
1080
1080
  }
1081
1081
  if (_typeof(value) === 'object' && 'location' in value && isOverrideLocationSpecifier(value.location)) {
1082
1082
  throw new InvalidCurrencyError('Override location specifier is not supported here. Provide a regular location.');
@@ -2172,14 +2172,6 @@ var AssetHubPolkadot$1 = {
2172
2172
  name: "Dwellir",
2173
2173
  endpoint: "wss://asset-hub-polkadot-rpc.n.dwellir.com"
2174
2174
  },
2175
- {
2176
- name: "IBP1",
2177
- endpoint: "wss://asset-hub-polkadot.ibp.network"
2178
- },
2179
- {
2180
- name: "IBP2",
2181
- endpoint: "wss://asset-hub-polkadot.dotters.network"
2182
- },
2183
2175
  {
2184
2176
  name: "LuckyFriday",
2185
2177
  endpoint: "wss://rpc-asset-hub-polkadot.luckyfriday.io"
@@ -2191,10 +2183,6 @@ var AssetHubPolkadot$1 = {
2191
2183
  {
2192
2184
  name: "Parity",
2193
2185
  endpoint: "wss://polkadot-asset-hub-rpc.polkadot.io"
2194
- },
2195
- {
2196
- name: "RadiumBlock",
2197
- endpoint: "wss://statemint.public.curie.radiumblock.co/ws"
2198
2186
  }
2199
2187
  ]
2200
2188
  };
@@ -2248,10 +2236,6 @@ var Astar$1 = {
2248
2236
  {
2249
2237
  name: "OnFinality",
2250
2238
  endpoint: "wss://astar.api.onfinality.io/public-ws"
2251
- },
2252
- {
2253
- name: "RadiumBlock",
2254
- endpoint: "wss://astar.public.curie.radiumblock.co/ws"
2255
2239
  }
2256
2240
  ]
2257
2241
  };
@@ -2279,14 +2263,6 @@ var BridgeHubPolkadot$1 = {
2279
2263
  name: "Dwellir",
2280
2264
  endpoint: "wss://bridge-hub-polkadot-rpc.n.dwellir.com"
2281
2265
  },
2282
- {
2283
- name: "IBP1",
2284
- endpoint: "wss://bridge-hub-polkadot.ibp.network"
2285
- },
2286
- {
2287
- name: "IBP2",
2288
- endpoint: "wss://bridge-hub-polkadot.dotters.network"
2289
- },
2290
2266
  {
2291
2267
  name: "LuckyFriday",
2292
2268
  endpoint: "wss://rpc-bridge-hub-polkadot.luckyfriday.io"
@@ -2299,10 +2275,6 @@ var BridgeHubPolkadot$1 = {
2299
2275
  name: "Parity",
2300
2276
  endpoint: "wss://polkadot-bridge-hub-rpc.polkadot.io"
2301
2277
  },
2302
- {
2303
- name: "RadiumBlock",
2304
- endpoint: "wss://bridgehub-polkadot.public.curie.radiumblock.co/ws"
2305
- },
2306
2278
  {
2307
2279
  name: "Spectrum",
2308
2280
  endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/mgX--uWlEtmNKw/polkadotbridgehub/mainnet/"
@@ -2356,16 +2328,12 @@ var Hydration$1 = {
2356
2328
  paraId: 2034,
2357
2329
  providers: [
2358
2330
  {
2359
- name: "Helikon",
2360
- endpoint: "wss://rpc.helikon.io/hydradx"
2361
- },
2362
- {
2363
- name: "IBP1",
2364
- endpoint: "wss://hydration.ibp.network"
2331
+ name: "Dwellir",
2332
+ endpoint: "wss://hydration-rpc.n.dwellir.com"
2365
2333
  },
2366
2334
  {
2367
- name: "IBP2",
2368
- endpoint: "wss://hydration.dotters.network"
2335
+ name: "Helikon",
2336
+ endpoint: "wss://rpc.helikon.io/hydradx"
2369
2337
  }
2370
2338
  ]
2371
2339
  };
@@ -2446,14 +2414,6 @@ var CoretimePolkadot$1 = {
2446
2414
  name: "Dwellir",
2447
2415
  endpoint: "wss://coretime-polkadot-rpc.n.dwellir.com"
2448
2416
  },
2449
- {
2450
- name: "IBP1",
2451
- endpoint: "wss://coretime-polkadot.ibp.network"
2452
- },
2453
- {
2454
- name: "IBP2",
2455
- endpoint: "wss://coretime-polkadot.dotters.network"
2456
- },
2457
2417
  {
2458
2418
  name: "LuckyFriday",
2459
2419
  endpoint: "wss://rpc-coretime-polkadot.luckyfriday.io"
@@ -2465,10 +2425,6 @@ var CoretimePolkadot$1 = {
2465
2425
  {
2466
2426
  name: "Parity",
2467
2427
  endpoint: "wss://polkadot-coretime-rpc.polkadot.io"
2468
- },
2469
- {
2470
- name: "RadiumBlock",
2471
- endpoint: "wss://coretime-polkadot.public.curie.radiumblock.co/ws"
2472
2428
  }
2473
2429
  ]
2474
2430
  };
@@ -2481,14 +2437,6 @@ var Collectives$1 = {
2481
2437
  name: "Dwellir",
2482
2438
  endpoint: "wss://collectives-polkadot-rpc.n.dwellir.com"
2483
2439
  },
2484
- {
2485
- name: "IBP1",
2486
- endpoint: "wss://collectives-polkadot.ibp.network"
2487
- },
2488
- {
2489
- name: "IBP2",
2490
- endpoint: "wss://collectives-polkadot.dotters.network"
2491
- },
2492
2440
  {
2493
2441
  name: "LuckyFriday",
2494
2442
  endpoint: "wss://rpc-collectives-polkadot.luckyfriday.io"
@@ -2500,10 +2448,6 @@ var Collectives$1 = {
2500
2448
  {
2501
2449
  name: "Parity",
2502
2450
  endpoint: "wss://polkadot-collectives-rpc.polkadot.io"
2503
- },
2504
- {
2505
- name: "RadiumBlock",
2506
- endpoint: "wss://collectives.public.curie.radiumblock.co/ws"
2507
2451
  }
2508
2452
  ]
2509
2453
  };
@@ -2583,14 +2527,6 @@ var PeoplePolkadot$1 = {
2583
2527
  name: "Dwellir",
2584
2528
  endpoint: "wss://people-polkadot-rpc.n.dwellir.com"
2585
2529
  },
2586
- {
2587
- name: "IBP1",
2588
- endpoint: "wss://people-polkadot.ibp.network"
2589
- },
2590
- {
2591
- name: "IBP2",
2592
- endpoint: "wss://people-polkadot.dotters.network"
2593
- },
2594
2530
  {
2595
2531
  name: "LuckyFriday",
2596
2532
  endpoint: "wss://rpc-people-polkadot.luckyfriday.io"
@@ -2602,10 +2538,6 @@ var PeoplePolkadot$1 = {
2602
2538
  {
2603
2539
  name: "Parity",
2604
2540
  endpoint: "wss://polkadot-people-rpc.polkadot.io"
2605
- },
2606
- {
2607
- name: "RadiumBlock",
2608
- endpoint: "wss://people-polkadot.public.curie.radiumblock.co/ws"
2609
2541
  }
2610
2542
  ]
2611
2543
  };
@@ -2648,14 +2580,6 @@ var AssetHubKusama$1 = {
2648
2580
  name: "Dwellir",
2649
2581
  endpoint: "wss://asset-hub-kusama-rpc.n.dwellir.com"
2650
2582
  },
2651
- {
2652
- name: "IBP1",
2653
- endpoint: "wss://asset-hub-kusama.ibp.network"
2654
- },
2655
- {
2656
- name: "IBP2",
2657
- endpoint: "wss://asset-hub-kusama.dotters.network"
2658
- },
2659
2583
  {
2660
2584
  name: "LuckyFriday",
2661
2585
  endpoint: "wss://rpc-asset-hub-kusama.luckyfriday.io"
@@ -2667,10 +2591,6 @@ var AssetHubKusama$1 = {
2667
2591
  {
2668
2592
  name: "Parity",
2669
2593
  endpoint: "wss://kusama-asset-hub-rpc.polkadot.io"
2670
- },
2671
- {
2672
- name: "RadiumBlock",
2673
- endpoint: "wss://statemine.public.curie.radiumblock.co/ws"
2674
2594
  }
2675
2595
  ]
2676
2596
  };
@@ -2683,14 +2603,6 @@ var BridgeHubKusama$1 = {
2683
2603
  name: "Dwellir",
2684
2604
  endpoint: "wss://bridge-hub-kusama-rpc.n.dwellir.com"
2685
2605
  },
2686
- {
2687
- name: "IBP1",
2688
- endpoint: "wss://bridge-hub-kusama.ibp.network"
2689
- },
2690
- {
2691
- name: "IBP2",
2692
- endpoint: "wss://bridge-hub-kusama.dotters.network"
2693
- },
2694
2606
  {
2695
2607
  name: "LuckyFriday",
2696
2608
  endpoint: "wss://rpc-bridge-hub-kusama.luckyfriday.io"
@@ -2703,10 +2615,6 @@ var BridgeHubKusama$1 = {
2703
2615
  name: "Parity",
2704
2616
  endpoint: "wss://kusama-bridge-hub-rpc.polkadot.io"
2705
2617
  },
2706
- {
2707
- name: "RadiumBlock",
2708
- endpoint: "wss://bridgehub-kusama.public.curie.radiumblock.co/ws"
2709
- },
2710
2618
  {
2711
2619
  name: "Spectrum",
2712
2620
  endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/balkpUVauqyv8g/kusamabridgehub/mainnet/"
@@ -2791,14 +2699,6 @@ var CoretimeKusama$1 = {
2791
2699
  name: "Dwellir",
2792
2700
  endpoint: "wss://coretime-kusama-rpc.n.dwellir.com"
2793
2701
  },
2794
- {
2795
- name: "IBP1",
2796
- endpoint: "wss://coretime-kusama.ibp.network"
2797
- },
2798
- {
2799
- name: "IBP2",
2800
- endpoint: "wss://coretime-kusama.dotters.network"
2801
- },
2802
2702
  {
2803
2703
  name: "LuckyFriday",
2804
2704
  endpoint: "wss://rpc-coretime-kusama.luckyfriday.io"
@@ -2826,14 +2726,6 @@ var Encointer$1 = {
2826
2726
  name: "Encointer Association",
2827
2727
  endpoint: "wss://kusama.api.encointer.org"
2828
2728
  },
2829
- {
2830
- name: "IBP1",
2831
- endpoint: "wss://encointer-kusama.ibp.network"
2832
- },
2833
- {
2834
- name: "IBP2",
2835
- endpoint: "wss://encointer-kusama.dotters.network"
2836
- },
2837
2729
  {
2838
2730
  name: "LuckyFriday",
2839
2731
  endpoint: "wss://rpc-encointer-kusama.luckyfriday.io"
@@ -2939,14 +2831,6 @@ var PeopleKusama$1 = {
2939
2831
  name: "Helixstreet",
2940
2832
  endpoint: "wss://rpc-people-kusama.helixstreet.io"
2941
2833
  },
2942
- {
2943
- name: "IBP1",
2944
- endpoint: "wss://people-kusama.ibp.network"
2945
- },
2946
- {
2947
- name: "IBP2",
2948
- endpoint: "wss://people-kusama.dotters.network"
2949
- },
2950
2834
  {
2951
2835
  name: "LuckyFriday",
2952
2836
  endpoint: "wss://rpc-people-kusama.luckyfriday.io"
@@ -2958,10 +2842,6 @@ var PeopleKusama$1 = {
2958
2842
  {
2959
2843
  name: "Parity",
2960
2844
  endpoint: "wss://kusama-people-rpc.polkadot.io"
2961
- },
2962
- {
2963
- name: "RadiumBlock",
2964
- endpoint: "wss://people-kusama.public.curie.radiumblock.co/ws"
2965
2845
  }
2966
2846
  ]
2967
2847
  };
@@ -2981,10 +2861,6 @@ var Shiden$1 = {
2981
2861
  {
2982
2862
  name: "OnFinality",
2983
2863
  endpoint: "wss://shiden.api.onfinality.io/public-ws"
2984
- },
2985
- {
2986
- name: "RadiumBlock",
2987
- endpoint: "wss://shiden.public.curie.radiumblock.co/ws"
2988
2864
  }
2989
2865
  ]
2990
2866
  };
@@ -3105,17 +2981,13 @@ var AssetHubPaseo$1 = {
3105
2981
  name: "Dwellir",
3106
2982
  endpoint: "wss://asset-hub-paseo-rpc.n.dwellir.com"
3107
2983
  },
3108
- {
3109
- name: "IBP1",
3110
- endpoint: "wss://asset-hub-paseo.ibp.network"
3111
- },
3112
- {
3113
- name: "IBP2",
3114
- endpoint: "wss://asset-hub-paseo.dotters.network"
3115
- },
3116
2984
  {
3117
2985
  name: "TurboFlakes",
3118
2986
  endpoint: "wss://sys.turboflakes.io/asset-hub-paseo"
2987
+ },
2988
+ {
2989
+ name: "Zondax",
2990
+ endpoint: "wss://api2.zondax.ch/pas/assethub/node/rpc"
3119
2991
  }
3120
2992
  ]
3121
2993
  };
@@ -3140,12 +3012,8 @@ var BridgeHubPaseo$1 = {
3140
3012
  paraId: 1002,
3141
3013
  providers: [
3142
3014
  {
3143
- name: "IBP1",
3144
- endpoint: "wss://bridge-hub-paseo.ibp.network"
3145
- },
3146
- {
3147
- name: "IBP2",
3148
- endpoint: "wss://bridge-hub-paseo.dotters.network"
3015
+ name: "Zondax",
3016
+ endpoint: "wss://api2.zondax.ch/pas/bridgehub/node/rpc"
3149
3017
  }
3150
3018
  ]
3151
3019
  };
@@ -3155,12 +3023,8 @@ var CoretimePaseo$1 = {
3155
3023
  paraId: 1005,
3156
3024
  providers: [
3157
3025
  {
3158
- name: "IBP1",
3159
- endpoint: "wss://coretime-paseo.ibp.network"
3160
- },
3161
- {
3162
- name: "IBP2",
3163
- endpoint: "wss://coretime-paseo.dotters.network"
3026
+ name: "Zondax",
3027
+ endpoint: "wss://api2.zondax.ch/pas/coretime/node/rpc"
3164
3028
  }
3165
3029
  ]
3166
3030
  };
@@ -3218,12 +3082,8 @@ var PeoplePaseo$1 = {
3218
3082
  endpoint: "wss://people-paseo.rpc.amforc.com"
3219
3083
  },
3220
3084
  {
3221
- name: "IBP1",
3222
- endpoint: "wss://people-paseo.ibp.network"
3223
- },
3224
- {
3225
- name: "IBP2",
3226
- endpoint: "wss://people-paseo.dotters.network"
3085
+ name: "Zondax",
3086
+ endpoint: "wss://api2.zondax.ch/pas/people/node/rpc"
3227
3087
  }
3228
3088
  ]
3229
3089
  };
@@ -3255,14 +3115,6 @@ var Polkadot$1 = {
3255
3115
  name: "Helixstreet",
3256
3116
  endpoint: "wss://rpc-polkadot.helixstreet.io"
3257
3117
  },
3258
- {
3259
- name: "IBP1",
3260
- endpoint: "wss://polkadot.ibp.network"
3261
- },
3262
- {
3263
- name: "IBP2",
3264
- endpoint: "wss://polkadot.dotters.network"
3265
- },
3266
3118
  {
3267
3119
  name: "LuckyFriday",
3268
3120
  endpoint: "wss://rpc-polkadot.luckyfriday.io"
@@ -3271,10 +3123,6 @@ var Polkadot$1 = {
3271
3123
  name: "OnFinality",
3272
3124
  endpoint: "wss://polkadot.api.onfinality.io/public-ws"
3273
3125
  },
3274
- {
3275
- name: "RadiumBlock",
3276
- endpoint: "wss://polkadot.public.curie.radiumblock.co/ws"
3277
- },
3278
3126
  {
3279
3127
  name: "Spectrum",
3280
3128
  endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/LjwBJpV3dIKyWQ/polkadot/mainnet/"
@@ -3306,14 +3154,6 @@ var Kusama$1 = {
3306
3154
  name: "Helixstreet",
3307
3155
  endpoint: "wss://rpc-kusama.helixstreet.io"
3308
3156
  },
3309
- {
3310
- name: "IBP1",
3311
- endpoint: "wss://kusama.ibp.network"
3312
- },
3313
- {
3314
- name: "IBP2",
3315
- endpoint: "wss://kusama.dotters.network"
3316
- },
3317
3157
  {
3318
3158
  name: "LuckyFriday",
3319
3159
  endpoint: "wss://rpc-kusama.luckyfriday.io"
@@ -3322,10 +3162,6 @@ var Kusama$1 = {
3322
3162
  name: "OnFinality",
3323
3163
  endpoint: "wss://kusama.api.onfinality.io/public-ws"
3324
3164
  },
3325
- {
3326
- name: "RadiumBlock",
3327
- endpoint: "wss://kusama.public.curie.radiumblock.co/ws"
3328
- },
3329
3165
  {
3330
3166
  name: "Spectrum",
3331
3167
  endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/QXq7QZ6Q60NDzA/kusama/mainnet/"
@@ -3352,10 +3188,6 @@ var Westend$1 = {
3352
3188
  {
3353
3189
  name: "Parity",
3354
3190
  endpoint: "wss://westend-rpc.polkadot.io"
3355
- },
3356
- {
3357
- name: "RadiumBlock",
3358
- endpoint: "wss://rpc.public.curie.radiumblock.xyz/ws-westend"
3359
3191
  }
3360
3192
  ]
3361
3193
  };
@@ -3373,12 +3205,8 @@ var Paseo$1 = {
3373
3205
  endpoint: "wss://paseo-rpc.n.dwellir.com"
3374
3206
  },
3375
3207
  {
3376
- name: "IBP1",
3377
- endpoint: "wss://paseo.ibp.network"
3378
- },
3379
- {
3380
- name: "IBP2",
3381
- endpoint: "wss://paseo.dotters.network"
3208
+ name: "Zondax",
3209
+ endpoint: "wss://api2.zondax.ch/pas/relay/node/rpc"
3382
3210
  }
3383
3211
  ]
3384
3212
  };
@@ -4196,17 +4024,159 @@ var resolveAsset = function resolveAsset(currency, origin, destination, assetChe
4196
4024
  return api.findAssetInfo(origin, currency, dest);
4197
4025
  };
4198
4026
 
4027
+ var assertNotRawAssets = function assertNotRawAssets(currency) {
4028
+ if (Array.isArray(currency) && currency.length > 0 && currency.every(function (asset) {
4029
+ return isTAsset(asset);
4030
+ })) {
4031
+ throw new InvalidCurrencyError('Raw asset overrides are no longer supported. Please use custom assets instead.');
4032
+ }
4033
+ };
4034
+ var validateCurrency = function validateCurrency(currency, feeAsset) {
4035
+ if (Array.isArray(currency)) {
4036
+ if (currency.length === 0) {
4037
+ throw new InvalidCurrencyError('Overridden assets cannot be empty');
4038
+ }
4039
+ if (currency.length === 1) {
4040
+ throw new InvalidCurrencyError('Please provide more than one asset');
4041
+ }
4042
+ assertNotRawAssets(currency);
4043
+ if (!feeAsset) {
4044
+ throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
4045
+ }
4046
+ }
4047
+ };
4048
+ var validateDestination = function validateDestination(origin, destination, api) {
4049
+ if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
4050
+ throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4051
+ }
4052
+ if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
4053
+ throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
4054
+ }
4055
+ var isLocationDestination = _typeof(destination) === 'object';
4056
+ var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
4057
+ if (!isLocationDestination) {
4058
+ var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
4059
+ var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
4060
+ if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
4061
+ throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
4062
+ }
4063
+ }
4064
+ if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
4065
+ var chain = getChain(destination);
4066
+ if (!chain.isRelayToParaEnabled()) {
4067
+ throw new ScenarioNotSupportedError({
4068
+ chain: destination,
4069
+ scenario: 'RelayToPara'
4070
+ });
4071
+ }
4072
+ }
4073
+ };
4074
+ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4075
+ if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
4076
+ throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4077
+ }
4078
+ if (!assetCheckEnabled && 'id' in currency) {
4079
+ throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4080
+ }
4081
+ };
4082
+ var validateTransact = function validateTransact(_ref) {
4083
+ var api = _ref.api,
4084
+ from = _ref.from,
4085
+ to = _ref.to,
4086
+ sender = _ref.sender,
4087
+ address = _ref.recipient,
4088
+ currency = _ref.currency,
4089
+ transactOptions = _ref.transactOptions;
4090
+ var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
4091
+ if (!call) return;
4092
+ if (from === to) {
4093
+ throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
4094
+ }
4095
+ if (Array.isArray(currency)) {
4096
+ throw new UnsupportedOperationError('Cannot use transact options with multiple currencies.');
4097
+ }
4098
+ if (typeof call === 'string' && !isHex(call)) {
4099
+ throw new ValidationError('Transact call hex must be a valid hex string.');
4100
+ }
4101
+ if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
4102
+ throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
4103
+ }
4104
+ if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
4105
+ return new ValidationError('Sender address must match the destination address for transact to work.');
4106
+ }
4107
+ };
4108
+
4109
+ var resolveCurrency = function resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, onAsset) {
4110
+ var dest = !isTLocation(destination) ? destination : null;
4111
+ if (Array.isArray(currency)) {
4112
+ var _resolvedFeeAsset$amo;
4113
+ if (!resolvedFeeAsset) {
4114
+ throw new InvalidCurrencyError('Fee asset is required when providing more than one asset');
4115
+ }
4116
+ assertNotRawAssets(currency);
4117
+ var assets = currency.map(function (item) {
4118
+ if (item.amount === AMOUNT_ALL) {
4119
+ throw new InvalidCurrencyError('Provided assets cannot use amount all. Please specify amount.');
4120
+ }
4121
+ var asset = api.findAssetInfo(origin, item, dest);
4122
+ if (!asset) {
4123
+ throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(item, replaceBigInt)));
4124
+ }
4125
+ onAsset === null || onAsset === void 0 || onAsset(asset);
4126
+ return _objectSpread2(_objectSpread2({}, asset), {}, {
4127
+ amount: abstractDecimals(item.amount, asset.decimals, api),
4128
+ isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
4129
+ });
4130
+ });
4131
+ var feeAssetCount = assets.filter(function (asset) {
4132
+ return asset.isFeeAsset;
4133
+ }).length;
4134
+ if (feeAssetCount > 1) {
4135
+ throw new InvalidCurrencyError("Fee asset matches more than one of the provided assets");
4136
+ }
4137
+ if (feeAssetCount === 0) {
4138
+ throw new InvalidCurrencyError("Fee asset must be one of the provided assets");
4139
+ }
4140
+ return {
4141
+ assets: assets,
4142
+ asset: _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
4143
+ amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
4144
+ })
4145
+ };
4146
+ }
4147
+ var asset = api.findAssetInfoOrThrow(origin, currency, dest);
4148
+ var resolved = _objectSpread2(_objectSpread2({}, asset), {}, {
4149
+ amount: abstractDecimals(currency.amount, asset.decimals, api)
4150
+ });
4151
+ return {
4152
+ assets: [resolved],
4153
+ asset: resolved
4154
+ };
4155
+ };
4156
+
4199
4157
  var resolveFeeAsset = function resolveFeeAsset(api, feeAsset, origin, destination, currency) {
4200
- if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
4158
+ if (!Array.isArray(currency) && !origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
4201
4159
  throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
4202
4160
  }
4161
+ assertNotRawAssets(currency);
4203
4162
  var dest = !isTLocation(destination) ? destination : null;
4204
4163
  var asset = api.findAssetInfo(origin, feeAsset, dest);
4205
- var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
4206
- if (!asset && !usesRawOverriddenMultiAssets) {
4207
- throwUnsupportedCurrency(feeAsset, origin);
4164
+ if (!asset) {
4165
+ return throwUnsupportedCurrency(feeAsset, origin);
4208
4166
  }
4209
- return asset !== null && asset !== void 0 ? asset : undefined;
4167
+ if (!Array.isArray(currency)) {
4168
+ return asset;
4169
+ }
4170
+ var feeElement = currency.find(function (item) {
4171
+ var resolved = api.findAssetInfo(origin, item, dest);
4172
+ return resolved !== null && isAssetEqual(resolved, asset);
4173
+ });
4174
+ if (!feeElement) {
4175
+ throw new InvalidCurrencyError('Fee asset must be one of the provided assets');
4176
+ }
4177
+ return _objectSpread2(_objectSpread2({}, asset), {}, {
4178
+ amount: abstractDecimals(feeElement.amount, asset.decimals, api)
4179
+ });
4210
4180
  };
4211
4181
 
4212
4182
  var resolveHopAsset = function resolveHopAsset(_ref) {
@@ -4218,9 +4188,10 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
4218
4188
  destination = _ref.destination,
4219
4189
  swapConfig = _ref.swapConfig,
4220
4190
  asset = _ref.asset,
4191
+ currentAsset = _ref.currentAsset,
4221
4192
  hasPassedExchange = _ref.hasPassedExchange,
4222
4193
  currency = _ref.currency;
4223
- var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
4194
+ var isRelayAssetIncluded = !Array.isArray(currency) && api.getTypeThenAssetCount(tx) === 2;
4224
4195
  var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
4225
4196
  if (useRelayAssetAsFee) {
4226
4197
  return api.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
@@ -4228,7 +4199,7 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
4228
4199
  if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
4229
4200
  return api.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
4230
4201
  }
4231
- return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
4202
+ return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : currentAsset;
4232
4203
  };
4233
4204
 
4234
4205
  var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge, api) {
@@ -4304,60 +4275,22 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
4304
4275
  }
4305
4276
  if (Array.isArray(currency)) {
4306
4277
  if (!feeAsset) {
4307
- throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
4278
+ throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
4308
4279
  }
4309
4280
  if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
4310
4281
  throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
4311
4282
  }
4312
- if (currency.every(function (asset) {
4313
- return isTAsset(asset);
4314
- })) {
4315
- if (!feeAsset) {
4316
- throw new InvalidCurrencyError('Fee asset not provided');
4317
- }
4318
- if (!('location' in feeAsset)) {
4319
- throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
4320
- }
4321
- return currency.map(function (asset) {
4322
- var ml = extractAssetLocation(asset);
4323
- return _objectSpread2(_objectSpread2({}, asset), {}, {
4324
- fun: {
4325
- Fungible: BigInt(asset.fun.Fungible)
4326
- },
4327
- isFeeAsset: deepEqual(ml, feeAsset.location)
4328
- });
4329
- });
4330
- }
4331
- // MultiAsset is an array of TCurrencyCore, search for assets
4332
- var assets = currency.map(function (currency) {
4333
- if (currency.amount === AMOUNT_ALL) {
4334
- throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
4335
- }
4336
- var asset = api.findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
4337
- if (!asset) {
4338
- throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
4339
- }
4340
- if (!resolvedFeeAsset) {
4341
- throw new InvalidCurrencyError('Fee asset not found');
4342
- }
4343
- validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
4344
- var version = getChainVersion(api, origin);
4345
- var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
4283
+ assertNotRawAssets(currency);
4284
+ var version = getChainVersion(api, origin);
4285
+ var _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, function (asset) {
4286
+ return validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
4287
+ }),
4288
+ assets = _resolveCurrency.assets;
4289
+ return sortAssets(assets.map(function (asset) {
4346
4290
  return _objectSpread2({
4347
- isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
4348
- }, createAsset(version, abstractedAmount, asset.location));
4349
- });
4350
- if (assets.filter(function (asset) {
4351
- return asset.isFeeAsset;
4352
- }).length > 1) {
4353
- throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
4354
- }
4355
- if (assets.filter(function (asset) {
4356
- return asset.isFeeAsset;
4357
- }).length === 0) {
4358
- throw new InvalidCurrencyError("Fee asset not found in multiassets");
4359
- }
4360
- return assets;
4291
+ isFeeAsset: asset.isFeeAsset
4292
+ }, createAsset(version, asset.amount, asset.location));
4293
+ }));
4361
4294
  }
4362
4295
  return undefined;
4363
4296
  };
@@ -4369,79 +4302,8 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
4369
4302
  return !(isMultipleAssets || hasOverriddenLocation);
4370
4303
  };
4371
4304
 
4372
- var validateCurrency = function validateCurrency(currency, feeAsset) {
4373
- if (Array.isArray(currency)) {
4374
- if (currency.length === 0) {
4375
- throw new InvalidCurrencyError('Overridden assets cannot be empty');
4376
- }
4377
- if (currency.length === 1) {
4378
- throw new InvalidCurrencyError('Please provide more than one asset');
4379
- }
4380
- if (currency.length > 1 && !currency.every(function (asset) {
4381
- return isTAsset(asset);
4382
- }) && !feeAsset) {
4383
- throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
4384
- }
4385
- }
4386
- };
4387
- var validateDestination = function validateDestination(origin, destination, api) {
4388
- if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
4389
- throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
4390
- }
4391
- if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
4392
- throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
4393
- }
4394
- var isLocationDestination = _typeof(destination) === 'object';
4395
- var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
4396
- if (!isLocationDestination) {
4397
- var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
4398
- var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
4399
- if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
4400
- throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
4401
- }
4402
- }
4403
- if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
4404
- var chain = getChain(destination);
4405
- if (!chain.isRelayToParaEnabled()) {
4406
- throw new ScenarioNotSupportedError({
4407
- chain: destination,
4408
- scenario: 'RelayToPara'
4409
- });
4410
- }
4411
- }
4412
- };
4413
- var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
4414
- if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
4415
- throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
4416
- }
4417
- if (!assetCheckEnabled && 'id' in currency) {
4418
- throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
4419
- }
4420
- };
4421
- var validateTransact = function validateTransact(_ref) {
4422
- var api = _ref.api,
4423
- from = _ref.from,
4424
- to = _ref.to,
4425
- sender = _ref.sender,
4426
- address = _ref.recipient,
4427
- transactOptions = _ref.transactOptions;
4428
- var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
4429
- if (!call) return;
4430
- if (from === to) {
4431
- throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
4432
- }
4433
- if (typeof call === 'string' && !isHex(call)) {
4434
- throw new ValidationError('Transact call hex must be a valid hex string.');
4435
- }
4436
- if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
4437
- throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
4438
- }
4439
- if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
4440
- return new ValidationError('Sender address must match the destination address for transact to work.');
4441
- }
4442
- };
4443
-
4444
4305
  var resolveTransferParams = function resolveTransferParams(options) {
4306
+ var _resolvedFeeAsset$amo;
4445
4307
  var api = options.api,
4446
4308
  origin = options.from,
4447
4309
  currency = options.currency,
@@ -4469,18 +4331,8 @@ var resolveTransferParams = function resolveTransferParams(options) {
4469
4331
  var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
4470
4332
  symbol: 'symbol' in currency ? currency.symbol : undefined
4471
4333
  };
4472
- var finalAsset = Array.isArray(currency) ? // TODO: Refactor this
4473
- // We use a dummy values when overriding with multi-assets
4474
- // since these values won't be used but need to pass checks
4475
- _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
4476
- amount: 0n,
4477
- assetId: '1',
4478
- location: {
4479
- parents: Parents.ZERO,
4480
- interior: {
4481
- Here: null
4482
- }
4483
- }
4334
+ var finalAsset = Array.isArray(currency) && resolvedFeeAsset ? _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
4335
+ amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
4484
4336
  }) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
4485
4337
  amount: finalAmount
4486
4338
  });
@@ -5816,16 +5668,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
5816
5668
  return _getOriginXcmFee2.apply(this, arguments);
5817
5669
  }
5818
5670
  return getOriginXcmFee$1;
5819
- }()
5820
- /**
5821
- * Returns the max transferable amount for the transfer
5822
- *
5823
- * @returns The max transferable amount.
5824
- */
5825
- )
5671
+ }())
5826
5672
  }, {
5827
5673
  key: "getTransferableAmount",
5828
- value: (function () {
5674
+ value: function () {
5829
5675
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
5830
5676
  var senderSource, _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
5831
5677
  return _regenerator().w(function (_context11) {
@@ -5870,15 +5716,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
5870
5716
  }
5871
5717
  return getTransferableAmount$1;
5872
5718
  }()
5873
- /**
5874
- * Returns the min transferable amount for the transfer
5875
- *
5876
- * @returns The min transferable amount.
5877
- */
5878
- )
5879
5719
  }, {
5880
5720
  key: "getMinTransferableAmount",
5881
- value: (function () {
5721
+ value: function () {
5882
5722
  var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
5883
5723
  var senderSource, _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
5884
5724
  return _regenerator().w(function (_context12) {
@@ -5931,7 +5771,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
5931
5771
  *
5932
5772
  * @returns The max transferable amount.
5933
5773
  */
5934
- )
5935
5774
  }, {
5936
5775
  key: "verifyEdOnDestination",
5937
5776
  value: (function () {
@@ -5969,17 +5808,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
5969
5808
  function verifyEdOnDestination$1() {
5970
5809
  return _verifyEdOnDestination2.apply(this, arguments);
5971
5810
  }
5972
- return verifyEdOnDestination$1;
5973
- }()
5974
- /**
5975
- * Returns the transfer info for the transfer
5976
- *
5977
- * @returns The transfer info.
5978
- */
5979
- )
5811
+ return verifyEdOnDestination$1;
5812
+ }())
5980
5813
  }, {
5981
5814
  key: "getTransferInfo",
5982
- value: (function () {
5815
+ value: function () {
5983
5816
  var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
5984
5817
  var senderSource, _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
5985
5818
  return _regenerator().w(function (_context14) {
@@ -6028,18 +5861,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
6028
5861
  }
6029
5862
  return getTransferInfo$1;
6030
5863
  }()
6031
- /**
6032
- * Returns the receivable amount on the destination after the transfer
6033
- *
6034
- * @returns The computed receivable amount.
6035
- * @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
6036
- */
6037
- )
6038
5864
  }, {
6039
5865
  key: "getReceivableAmount",
6040
- value: (function () {
5866
+ value: function () {
6041
5867
  var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
6042
- var _yield$this$getTransf, receivedAmount;
5868
+ var _yield$this$getTransf, receivedCurrency, getAmountOrThrow;
6043
5869
  return _regenerator().w(function (_context15) {
6044
5870
  while (1) switch (_context15.n) {
6045
5871
  case 0:
@@ -6047,14 +5873,15 @@ var GeneralBuilder = /*#__PURE__*/function () {
6047
5873
  return this.getTransferInfo();
6048
5874
  case 1:
6049
5875
  _yield$this$getTransf = _context15.v;
6050
- receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
6051
- if (!(receivedAmount instanceof UnableToComputeError)) {
6052
- _context15.n = 2;
6053
- break;
6054
- }
6055
- throw receivedAmount;
6056
- case 2:
6057
- return _context15.a(2, receivedAmount);
5876
+ receivedCurrency = _yield$this$getTransf.destination.receivedCurrency;
5877
+ getAmountOrThrow = function getAmountOrThrow(_ref) {
5878
+ var receivedAmount = _ref.receivedAmount;
5879
+ if (receivedAmount instanceof UnableToComputeError) {
5880
+ throw receivedAmount;
5881
+ }
5882
+ return receivedAmount;
5883
+ };
5884
+ return _context15.a(2, Array.isArray(receivedCurrency) ? receivedCurrency.map(getAmountOrThrow) : getAmountOrThrow(receivedCurrency));
6058
5885
  }
6059
5886
  }, _callee15, this);
6060
5887
  }));
@@ -6062,7 +5889,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
6062
5889
  return _getReceivableAmount.apply(this, arguments);
6063
5890
  }
6064
5891
  return getReceivableAmount;
6065
- }())
5892
+ }()
6066
5893
  }, {
6067
5894
  key: "getBestAmountOut",
6068
5895
  value: function () {
@@ -6494,7 +6321,7 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
6494
6321
  }();
6495
6322
 
6496
6323
  var isSufficientOrigin = /*#__PURE__*/function () {
6497
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, currency, asset, feeAsset) {
6324
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, asset, feeAsset) {
6498
6325
  var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
6499
6326
  return _regenerator().w(function (_context) {
6500
6327
  while (1) switch (_context.n) {
@@ -6520,7 +6347,7 @@ var isSufficientOrigin = /*#__PURE__*/function () {
6520
6347
  _context.n = 3;
6521
6348
  break;
6522
6349
  }
6523
- return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
6350
+ return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
6524
6351
  case 3:
6525
6352
  if (isNativeAssetToOrigin) {
6526
6353
  _context.n = 5;
@@ -6540,18 +6367,18 @@ var isSufficientOrigin = /*#__PURE__*/function () {
6540
6367
  isSufficientAsset = balanceAsset - edAsset > 0n;
6541
6368
  return _context.a(2, isSufficientNative && isSufficientAsset);
6542
6369
  case 5:
6543
- return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
6370
+ return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
6544
6371
  case 6:
6545
6372
  return _context.a(2);
6546
6373
  }
6547
6374
  }, _callee);
6548
6375
  }));
6549
- return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
6376
+ return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
6550
6377
  return _ref.apply(this, arguments);
6551
6378
  };
6552
6379
  }();
6553
6380
  var isSufficientDestination = /*#__PURE__*/function () {
6554
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
6381
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, asset, feeNative) {
6555
6382
  var isNativeAsset, existentialDeposit, nativeBalance;
6556
6383
  return _regenerator().w(function (_context2) {
6557
6384
  while (1) switch (_context2.n) {
@@ -6572,11 +6399,11 @@ var isSufficientDestination = /*#__PURE__*/function () {
6572
6399
  });
6573
6400
  case 2:
6574
6401
  nativeBalance = _context2.v;
6575
- return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
6402
+ return _context2.a(2, nativeBalance + asset.amount - existentialDeposit - feeNative > 0n);
6576
6403
  }
6577
6404
  }, _callee2);
6578
6405
  }));
6579
- return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
6406
+ return function isSufficientDestination(_x8, _x9, _x0, _x1, _x10) {
6580
6407
  return _ref2.apply(this, arguments);
6581
6408
  };
6582
6409
  }();
@@ -6592,15 +6419,15 @@ var createOriginLocation = function createOriginLocation(origin, destination, ve
6592
6419
  };
6593
6420
  var getDestXcmFee = /*#__PURE__*/function () {
6594
6421
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
6595
- var api, origin, hopChain, destination, currency, forwardedXcms, asset, recipient, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
6422
+ var api, origin, hopChain, destination, currency, asset, currentAsset, forwardedXcms, recipient, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
6596
6423
  return _regenerator().w(function (_context3) {
6597
6424
  while (1) switch (_context3.n) {
6598
6425
  case 0:
6599
- api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, recipient = options.recipient, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
6426
+ api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, asset = options.asset, currentAsset = options.currentAsset, forwardedXcms = options.forwardedXcms, recipient = options.recipient, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
6600
6427
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
6601
6428
  calcPaymentInfoFee = /*#__PURE__*/function () {
6602
6429
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
6603
- var attempt, _t2;
6430
+ var reverseFeeFor, swapAsset, _t2;
6604
6431
  return _regenerator().w(function (_context2) {
6605
6432
  while (1) switch (_context2.p = _context2.n) {
6606
6433
  case 0:
@@ -6610,53 +6437,52 @@ var getDestXcmFee = /*#__PURE__*/function () {
6610
6437
  }
6611
6438
  return _context2.a(2, 0n);
6612
6439
  case 1:
6613
- attempt = /*#__PURE__*/function () {
6614
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
6615
- var assetInfo, _t;
6440
+ reverseFeeFor = /*#__PURE__*/function () {
6441
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(assetInfo, amount) {
6442
+ var _t;
6616
6443
  return _regenerator().w(function (_context) {
6617
6444
  while (1) switch (_context.p = _context.n) {
6618
6445
  case 0:
6619
- assetInfo = api.findAssetInfoOrThrow(chain, curr, destination);
6620
- _context.p = 1;
6621
- _context.n = 2;
6446
+ _context.p = 0;
6447
+ _context.n = 1;
6622
6448
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
6623
6449
  destination: destination
6624
6450
  }), {
6625
6451
  location: assetInfo.location,
6626
- amount: amt
6452
+ amount: amount
6627
6453
  });
6628
- case 2:
6454
+ case 1:
6629
6455
  return _context.a(2, _context.v);
6630
- case 3:
6631
- _context.p = 3;
6456
+ case 2:
6457
+ _context.p = 2;
6632
6458
  _t = _context.v;
6633
6459
  if (!(_t instanceof InvalidCurrencyError)) {
6634
- _context.n = 5;
6460
+ _context.n = 4;
6635
6461
  break;
6636
6462
  }
6637
- _context.n = 4;
6463
+ _context.n = 3;
6638
6464
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
6639
6465
  destination: destination
6640
6466
  }), {
6641
6467
  symbol: assetInfo.symbol,
6642
- amount: amt
6468
+ amount: amount
6643
6469
  });
6644
- case 4:
6470
+ case 3:
6645
6471
  return _context.a(2, _context.v);
6646
- case 5:
6472
+ case 4:
6647
6473
  throw _t;
6648
- case 6:
6474
+ case 5:
6649
6475
  return _context.a(2);
6650
6476
  }
6651
- }, _callee, null, [[1, 3]]);
6477
+ }, _callee, null, [[0, 2]]);
6652
6478
  }));
6653
- return function attempt(_x2, _x3, _x4) {
6479
+ return function reverseFeeFor(_x2, _x3) {
6654
6480
  return _ref3.apply(this, arguments);
6655
6481
  };
6656
6482
  }();
6657
6483
  _context2.p = 2;
6658
6484
  _context2.n = 3;
6659
- return attempt(origin, currency, currency.amount);
6485
+ return reverseFeeFor(asset, asset.amount);
6660
6486
  case 3:
6661
6487
  return _context2.a(2, _context2.v);
6662
6488
  case 4:
@@ -6668,8 +6494,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
6668
6494
  }
6669
6495
  return _context2.a(2, 0n);
6670
6496
  case 5:
6497
+ swapAsset = api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, destination);
6671
6498
  _context2.n = 6;
6672
- return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
6499
+ return reverseFeeFor(swapAsset, swapConfig.amountOut);
6673
6500
  case 6:
6674
6501
  return _context2.a(2, _context2.v);
6675
6502
  }
@@ -6688,14 +6515,14 @@ var getDestXcmFee = /*#__PURE__*/function () {
6688
6515
  case 1:
6689
6516
  _fee = _context3.v;
6690
6517
  _context3.n = 2;
6691
- return isSufficientDestination(api, destination, recipient, currency.amount, asset, _fee);
6518
+ return isSufficientDestination(api, destination, recipient, currentAsset, _fee);
6692
6519
  case 2:
6693
6520
  sufficient = _context3.v;
6694
6521
  return _context3.a(2, {
6695
6522
  fee: _fee,
6696
6523
  feeType: 'paymentInfo',
6697
6524
  sufficient: sufficient,
6698
- asset: asset
6525
+ asset: currentAsset
6699
6526
  });
6700
6527
  case 3:
6701
6528
  _context3.n = 4;
@@ -6705,11 +6532,11 @@ var getDestXcmFee = /*#__PURE__*/function () {
6705
6532
  xcm: forwardedXcms[1][0],
6706
6533
  chain: destination,
6707
6534
  origin: origin,
6708
- asset: asset,
6535
+ asset: currentAsset,
6709
6536
  version: version,
6710
6537
  originFee: originFee,
6711
6538
  feeAsset: resolvedFeeAsset,
6712
- amount: normalizeAmount(currency.amount)
6539
+ amount: normalizeAmount(currentAsset.amount)
6713
6540
  });
6714
6541
  case 4:
6715
6542
  dryRunResult = _context3.v;
@@ -6736,7 +6563,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
6736
6563
  dryRunError: dryRunResult.failureReason,
6737
6564
  dryRunSubError: dryRunResult.failureSubReason,
6738
6565
  sufficient: false,
6739
- asset: asset
6566
+ asset: currentAsset
6740
6567
  });
6741
6568
  case 7:
6742
6569
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
@@ -6746,7 +6573,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
6746
6573
  sufficient: true,
6747
6574
  forwardedXcms: newForwardedXcms,
6748
6575
  destParaId: destParaId,
6749
- asset: asset
6576
+ asset: currentAsset
6750
6577
  });
6751
6578
  }
6752
6579
  }, _callee3);
@@ -7503,15 +7330,14 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
7503
7330
 
7504
7331
  var traverseXcmHops = /*#__PURE__*/function () {
7505
7332
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
7506
- var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, destinationResult, nextChain, hopApi, isDestination, hopResult, _extractNextHopData, newXcms, destParaId;
7333
+ var api, origin, destination, asset, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, currentOrigin, forwardedXcms, nextParaId, currentAsset, hasPassedExchange, hops, destinationResult, nextChain, hopApi, isDestination, hopResult, _extractNextHopData, newXcms, destParaId;
7507
7334
  return _regenerator().w(function (_context) {
7508
7335
  while (1) switch (_context.p = _context.n) {
7509
7336
  case 0:
7510
- api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
7337
+ api = config.api, origin = config.origin, destination = config.destination, asset = config.asset, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
7511
7338
  currentOrigin = origin;
7512
7339
  forwardedXcms = initialForwardedXcms;
7513
7340
  nextParaId = initialDestParaId;
7514
- asset = api.findAssetInfoOrThrow(origin, currency, destination);
7515
7341
  currentAsset = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain) ? api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo) : asset;
7516
7342
  hasPassedExchange = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain);
7517
7343
  hops = [];
@@ -7631,15 +7457,14 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
7631
7457
 
7632
7458
  var dryRunInternal = /*#__PURE__*/function () {
7633
7459
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
7634
- var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, asset, resolvedFeeAsset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
7460
+ var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
7635
7461
  return _regenerator().w(function (_context2) {
7636
7462
  while (1) switch (_context2.n) {
7637
7463
  case 0:
7638
7464
  api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
7639
- assertCurrencyCore(currency);
7640
- asset = api.findAssetInfoOrThrow(origin, currency, destination);
7641
7465
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
7642
- amount = abstractDecimals(currency.amount, asset.decimals, api);
7466
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
7467
+ amount = asset.amount;
7643
7468
  resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
7644
7469
  _context2.n = 1;
7645
7470
  return api.getDryRunCall({
@@ -7650,6 +7475,7 @@ var dryRunInternal = /*#__PURE__*/function () {
7650
7475
  asset: _objectSpread2(_objectSpread2({}, asset), {}, {
7651
7476
  amount: amount
7652
7477
  }),
7478
+ assets: assets,
7653
7479
  feeAsset: resolvedFeeAsset,
7654
7480
  version: resolvedVersion,
7655
7481
  bypassOptions: bypassOptions,
@@ -7707,7 +7533,8 @@ var dryRunInternal = /*#__PURE__*/function () {
7707
7533
  originChain: origin,
7708
7534
  currentChain: currentChain,
7709
7535
  destination: destination,
7710
- asset: currentAsset,
7536
+ asset: asset,
7537
+ currentAsset: currentAsset,
7711
7538
  currency: currency,
7712
7539
  swapConfig: swapConfig,
7713
7540
  hasPassedExchange: hasPassedExchange
@@ -7753,7 +7580,7 @@ var dryRunInternal = /*#__PURE__*/function () {
7753
7580
  api: api,
7754
7581
  origin: origin,
7755
7582
  destination: destination,
7756
- currency: currency,
7583
+ asset: asset,
7757
7584
  initialForwardedXcms: initialForwardedXcms,
7758
7585
  initialDestParaId: initialDestParaId,
7759
7586
  swapConfig: swapConfig,
@@ -7965,7 +7792,8 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
7965
7792
  }) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
7966
7793
  };
7967
7794
  var wrapTxBypass = /*#__PURE__*/function () {
7968
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dryRunOptions) {
7795
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dryRunOptions) {
7796
+ var _dryRunOptions$assets;
7969
7797
  var options,
7970
7798
  api,
7971
7799
  chain,
@@ -7983,21 +7811,15 @@ var wrapTxBypass = /*#__PURE__*/function () {
7983
7811
  mintRelayAssetRes,
7984
7812
  mintFeeAssetRes,
7985
7813
  amount,
7986
- balance,
7987
- bonus,
7988
- mintAmount,
7989
- _calcPreviewMintAmoun,
7990
- missing,
7991
- total,
7992
- mintAssetRes,
7993
- _args = arguments,
7814
+ mintSentAsset,
7815
+ mintAssetResults,
7816
+ _args2 = arguments,
7994
7817
  _t,
7995
- _t2,
7996
- _t3;
7997
- return _regenerator().w(function (_context) {
7998
- while (1) switch (_context.n) {
7818
+ _t2;
7819
+ return _regenerator().w(function (_context2) {
7820
+ while (1) switch (_context2.n) {
7999
7821
  case 0:
8000
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {
7822
+ options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {
8001
7823
  mintFeeAssets: true,
8002
7824
  sentAssetMintMode: 'bypass'
8003
7825
  };
@@ -8016,84 +7838,87 @@ var wrapTxBypass = /*#__PURE__*/function () {
8016
7838
  relayInfo = mintFeeAssets ? api.findAssetInfo(chain, relayCurrency) : null;
8017
7839
  sameNativeRelay = !!(nativeInfo && relayInfo && isAssetXcEqual(nativeInfo, relayInfo));
8018
7840
  if (!mintFeeAssets) {
8019
- _context.n = 2;
7841
+ _context2.n = 2;
8020
7842
  break;
8021
7843
  }
8022
- _context.n = 1;
7844
+ _context2.n = 1;
8023
7845
  return createRequiredMintTxs(chain, api.findNativeAssetInfoOrThrow(chain), bypassMintAmount, 0n, address, api);
8024
7846
  case 1:
8025
- _t = _context.v;
8026
- _context.n = 3;
7847
+ _t = _context2.v;
7848
+ _context2.n = 3;
8027
7849
  break;
8028
7850
  case 2:
8029
7851
  _t = null;
8030
7852
  case 3:
8031
7853
  mintNativeAssetRes = _t;
8032
7854
  if (!(mintFeeAssets && !sameNativeRelay)) {
8033
- _context.n = 5;
7855
+ _context2.n = 5;
8034
7856
  break;
8035
7857
  }
8036
- _context.n = 4;
7858
+ _context2.n = 4;
8037
7859
  return createOptionalMintTxs(chain, relayCurrency, bypassMintAmount, 0n, address, api);
8038
7860
  case 4:
8039
- _t2 = _context.v;
8040
- _context.n = 6;
7861
+ _t2 = _context2.v;
7862
+ _context2.n = 6;
8041
7863
  break;
8042
7864
  case 5:
8043
7865
  _t2 = null;
8044
7866
  case 6:
8045
7867
  mintRelayAssetRes = _t2;
8046
7868
  if (!(feeAsset && mintFeeAssets)) {
8047
- _context.n = 8;
7869
+ _context2.n = 8;
8048
7870
  break;
8049
7871
  }
8050
7872
  amount = parseUnits(bypassMintAmount, feeAsset.decimals);
8051
- _context.n = 7;
7873
+ _context2.n = 7;
8052
7874
  return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
8053
7875
  amount: amount
8054
7876
  }), 0n, address, api);
8055
7877
  case 7:
8056
- mintFeeAssetRes = _context.v;
7878
+ mintFeeAssetRes = _context2.v;
8057
7879
  case 8:
8058
- _context.n = 9;
8059
- return getAssetBalanceInternal({
8060
- api: api,
8061
- chain: chain,
8062
- address: address,
8063
- asset: asset
8064
- });
7880
+ mintSentAsset = /*#__PURE__*/function () {
7881
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
7882
+ var balance, bonus, mintAmount, _calcPreviewMintAmoun, missing, total;
7883
+ return _regenerator().w(function (_context) {
7884
+ while (1) switch (_context.n) {
7885
+ case 0:
7886
+ _context.n = 1;
7887
+ return getAssetBalanceInternal({
7888
+ api: api,
7889
+ chain: chain,
7890
+ address: address,
7891
+ asset: sentAsset
7892
+ });
7893
+ case 1:
7894
+ balance = _context.v;
7895
+ bonus = mintBonusForSent(chain, sentAsset, feeAsset, !!mintFeeAssets, api);
7896
+ if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
7897
+ mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
7898
+ } else {
7899
+ missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, sentAsset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
7900
+ total = missing + bonus;
7901
+ mintAmount = total > 0n ? total : null;
7902
+ }
7903
+ return _context.a(2, mintAmount !== null ? createMintTxs(chain, _objectSpread2(_objectSpread2({}, sentAsset), {}, {
7904
+ amount: mintAmount
7905
+ }), balance, address, api) : null);
7906
+ }
7907
+ }, _callee);
7908
+ }));
7909
+ return function mintSentAsset(_x2) {
7910
+ return _ref3.apply(this, arguments);
7911
+ };
7912
+ }(); // mint assets that are being sent
7913
+ _context2.n = 9;
7914
+ return Promise.all(((_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset]).map(mintSentAsset));
8065
7915
  case 9:
8066
- balance = _context.v;
8067
- bonus = mintBonusForSent(chain, asset, feeAsset, !!mintFeeAssets, api);
8068
- if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
8069
- mintAmount = parseUnits(bypassMintAmount, asset.decimals) + asset.amount;
8070
- } else {
8071
- missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
8072
- total = missing + bonus;
8073
- mintAmount = total > 0n ? total : null;
8074
- }
8075
- // mint asset that is being sent
8076
- if (!(mintAmount !== null)) {
8077
- _context.n = 11;
8078
- break;
8079
- }
8080
- _context.n = 10;
8081
- return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
8082
- amount: mintAmount
8083
- }), balance, address, api);
8084
- case 10:
8085
- _t3 = _context.v;
8086
- _context.n = 12;
8087
- break;
8088
- case 11:
8089
- _t3 = null;
8090
- case 12:
8091
- mintAssetRes = _t3;
8092
- return _context.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes, mintAssetRes].flatMap(function (tx) {
7916
+ mintAssetResults = _context2.v;
7917
+ return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
8093
7918
  return tx ? resultToExtrinsics(api, address, tx) : [];
8094
7919
  })), [api.callDispatchAsMethod(tx, address)]), BatchMode.BATCH_ALL));
8095
7920
  }
8096
- }, _callee);
7921
+ }, _callee2);
8097
7922
  }));
8098
7923
  return function wrapTxBypass(_x) {
8099
7924
  return _ref2.apply(this, arguments);
@@ -8315,14 +8140,13 @@ var getBypassResultWithRetries = /*#__PURE__*/function () {
8315
8140
 
8316
8141
  var getOriginXcmFeeInternal = /*#__PURE__*/function () {
8317
8142
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8318
- var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin, asset, amount, resolvedFeeAsset, _yield$api$getPayment, rawFee, paddedFee, sufficient, resolvedVersion, dryRunResult, _yield$api$getPayment2, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight;
8143
+ var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, _yield$api$getPayment, rawFee, paddedFee, sufficient, resolvedVersion, dryRunResult, _yield$api$getPayment2, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight;
8319
8144
  return _regenerator().w(function (_context) {
8320
8145
  while (1) switch (_context.n) {
8321
8146
  case 0:
8322
8147
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency, version = _ref.version, _ref$useRootOrigin = _ref.useRootOrigin, useRootOrigin = _ref$useRootOrigin === void 0 ? false : _ref$useRootOrigin;
8323
- asset = api.findAssetInfoOrThrow(origin, currency, destination);
8324
- amount = abstractDecimals(currency.amount, asset.decimals, api);
8325
8148
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
8149
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
8326
8150
  _context.n = 1;
8327
8151
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
8328
8152
  case 1:
@@ -8337,9 +8161,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
8337
8161
  rawFee = _yield$api$getPayment.partialFee;
8338
8162
  paddedFee = padFee(rawFee, origin, destination, 'origin');
8339
8163
  _context.n = 3;
8340
- return isSufficientOrigin(api, origin, destination, sender, paddedFee, _objectSpread2(_objectSpread2({}, currency), {}, {
8341
- amount: amount
8342
- }), asset, resolvedFeeAsset);
8164
+ return isSufficientOrigin(api, origin, destination, sender, paddedFee, asset, resolvedFeeAsset);
8343
8165
  case 3:
8344
8166
  sufficient = _context.v;
8345
8167
  return _context.a(2, {
@@ -8356,9 +8178,8 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
8356
8178
  chain: origin,
8357
8179
  destination: destination,
8358
8180
  address: sender,
8359
- asset: _objectSpread2(_objectSpread2({}, asset), {}, {
8360
- amount: amount
8361
- }),
8181
+ asset: asset,
8182
+ assets: assets,
8362
8183
  version: resolvedVersion,
8363
8184
  feeAsset: resolvedFeeAsset,
8364
8185
  // Force dryRun pass
@@ -8499,13 +8320,13 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
8499
8320
  };
8500
8321
  var getXcmFeeOnce = /*#__PURE__*/function () {
8501
8322
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
8502
- var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, asset, amount, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, _failureSubReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _inferFeeAsset2, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, failureSubReason, _t, _t2, _t3, _t4;
8323
+ var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, _failureSubReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _inferFeeAsset2, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, failureSubReason, _t, _t2, _t3, _t4;
8503
8324
  return _regenerator().w(function (_context2) {
8504
8325
  while (1) switch (_context2.p = _context2.n) {
8505
8326
  case 0:
8506
8327
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
8507
- asset = api.findAssetInfoOrThrow(origin, currency, destination);
8508
- amount = abstractDecimals(currency.amount, asset.decimals, api);
8328
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
8329
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset;
8509
8330
  resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
8510
8331
  _context2.n = 1;
8511
8332
  return getOriginXcmFeeInternal({
@@ -8566,12 +8387,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8566
8387
  origin: origin,
8567
8388
  prevChain: origin,
8568
8389
  destination: destination,
8569
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
8570
- amount: amount
8571
- }),
8390
+ currency: currency,
8391
+ asset: asset,
8392
+ currentAsset: asset,
8572
8393
  sender: sender,
8573
8394
  recipient: recipient,
8574
- asset: asset,
8575
8395
  version: resolvedVersion,
8576
8396
  tx: tx,
8577
8397
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
@@ -8638,7 +8458,8 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8638
8458
  originChain: origin,
8639
8459
  currentChain: currentChain,
8640
8460
  destination: destination,
8641
- asset: currentAsset,
8461
+ asset: asset,
8462
+ currentAsset: currentAsset,
8642
8463
  currency: currency,
8643
8464
  swapConfig: swapConfig,
8644
8465
  hasPassedExchange: hasPassedExchange
@@ -8651,12 +8472,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8651
8472
  origin: origin,
8652
8473
  prevChain: currentOrigin,
8653
8474
  destination: currentChain,
8654
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
8655
- amount: amount
8475
+ currency: currency,
8476
+ asset: asset,
8477
+ currentAsset: _objectSpread2(_objectSpread2({}, hopAsset), {}, {
8478
+ amount: asset.amount
8656
8479
  }),
8657
8480
  sender: sender,
8658
8481
  recipient: recipient,
8659
- asset: hopAsset,
8660
8482
  version: resolvedVersion,
8661
8483
  feeAsset: feeAsset,
8662
8484
  tx: tx,
@@ -8681,7 +8503,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8681
8503
  api: api,
8682
8504
  origin: origin,
8683
8505
  destination: destination,
8684
- currency: currency,
8506
+ asset: asset,
8685
8507
  initialForwardedXcms: initialForwardedXcm,
8686
8508
  initialDestParaId: initialDestParaId,
8687
8509
  swapConfig: swapConfig,
@@ -8728,12 +8550,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8728
8550
  origin: origin,
8729
8551
  prevChain: traversalResult.lastProcessedChain || origin,
8730
8552
  destination: destination,
8731
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
8732
- amount: amount
8553
+ currency: currency,
8554
+ asset: asset,
8555
+ currentAsset: _objectSpread2(_objectSpread2({}, (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset), {}, {
8556
+ amount: asset.amount
8733
8557
  }),
8734
8558
  sender: sender,
8735
8559
  recipient: recipient,
8736
- asset: (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset,
8737
8560
  version: resolvedVersion,
8738
8561
  tx: tx,
8739
8562
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
@@ -8961,11 +8784,11 @@ var aggregateHopFees = function aggregateHopFees(hops, matchAsset) {
8961
8784
 
8962
8785
  var buildDestInfo = /*#__PURE__*/function () {
8963
8786
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8964
- var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8787
+ var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, paysDestFee, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8965
8788
  return _regenerator().w(function (_context) {
8966
8789
  while (1) switch (_context.n) {
8967
8790
  case 0:
8968
- api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
8791
+ api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, paysDestFee = _ref.paysDestFee, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
8969
8792
  destApi = api.clone();
8970
8793
  _context.n = 1;
8971
8794
  return destApi.init(destination);
@@ -8983,14 +8806,14 @@ var buildDestInfo = /*#__PURE__*/function () {
8983
8806
  destBalance = _context.v;
8984
8807
  destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
8985
8808
  destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
8986
- effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
8809
+ effectiveDestFee = paysDestFee && destFeeAssetEqual ? destFeeDetail.fee : 0n;
8987
8810
  effectiveAmountForBalance = destAmount - totalHopFee;
8988
8811
  destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
8989
8812
  destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
8990
8813
  createUnableToComputeError = function createUnableToComputeError() {
8991
8814
  return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
8992
8815
  };
8993
- isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
8816
+ isUnableToCompute = paysDestFee && destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
8994
8817
  destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
8995
8818
  destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
8996
8819
  isSubBridge = isSubstrateBridge(origin, destination);
@@ -9109,24 +8932,49 @@ var buildHopInfo = /*#__PURE__*/function () {
9109
8932
  };
9110
8933
  }();
9111
8934
 
8935
+ var _excluded$1 = ["amount"];
9112
8936
  var buildOriginInfo = /*#__PURE__*/function () {
9113
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
9114
- var api, origin, sender, currency, originAsset, amount, originFee, originFeeAsset, isFeeAssetAh, originBalance, edOrigin, originBalanceFee, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient;
9115
- return _regenerator().w(function (_context) {
9116
- while (1) switch (_context.n) {
8937
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
8938
+ var api, origin, sender, assets, amount, originFee, originFeeAsset, isFeeAssetAh, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
8939
+ return _regenerator().w(function (_context2) {
8940
+ while (1) switch (_context2.n) {
9117
8941
  case 0:
9118
- api = _ref.api, origin = _ref.origin, sender = _ref.sender, currency = _ref.currency, originAsset = _ref.originAsset, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
9119
- _context.n = 1;
9120
- return getAssetBalanceInternal({
9121
- api: api,
9122
- address: sender,
9123
- chain: origin,
9124
- asset: originAsset
9125
- });
8942
+ api = _ref.api, origin = _ref.origin, sender = _ref.sender, assets = _ref.assets, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
8943
+ buildSelectedCurrency = /*#__PURE__*/function () {
8944
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref3) {
8945
+ var assetAmount, asset, balance, balanceAfter;
8946
+ return _regenerator().w(function (_context) {
8947
+ while (1) switch (_context.n) {
8948
+ case 0:
8949
+ assetAmount = _ref3.amount, asset = _objectWithoutProperties(_ref3, _excluded$1);
8950
+ _context.n = 1;
8951
+ return getAssetBalanceInternal({
8952
+ api: api,
8953
+ address: sender,
8954
+ chain: origin,
8955
+ asset: asset
8956
+ });
8957
+ case 1:
8958
+ balance = _context.v;
8959
+ balanceAfter = balance - assetAmount;
8960
+ return _context.a(2, {
8961
+ sufficient: balanceAfter >= getEdFromAssetOrThrow(asset),
8962
+ balance: balance,
8963
+ balanceAfter: balanceAfter,
8964
+ asset: asset
8965
+ });
8966
+ }
8967
+ }, _callee);
8968
+ }));
8969
+ return function buildSelectedCurrency(_x2) {
8970
+ return _ref4.apply(this, arguments);
8971
+ };
8972
+ }();
8973
+ _context2.n = 1;
8974
+ return Promise.all(assets.map(buildSelectedCurrency));
9126
8975
  case 1:
9127
- originBalance = _context.v;
9128
- edOrigin = getExistentialDepositOrThrow(origin, currency);
9129
- _context.n = 2;
8976
+ selectedCurrency = _context2.v;
8977
+ _context2.n = 2;
9130
8978
  return getAssetBalanceInternal({
9131
8979
  api: api,
9132
8980
  address: sender,
@@ -9134,20 +8982,12 @@ var buildOriginInfo = /*#__PURE__*/function () {
9134
8982
  asset: originFeeAsset
9135
8983
  });
9136
8984
  case 2:
9137
- originBalanceFee = _context.v;
9138
- originBalanceAfter = originBalance - amount;
8985
+ originBalanceFee = _context2.v;
9139
8986
  originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
9140
- originBalanceNativeSufficient = originBalanceFee >= originFee;
9141
- originBalanceSufficient = originBalanceAfter >= edOrigin;
9142
- return _context.a(2, {
9143
- selectedCurrency: {
9144
- sufficient: originBalanceSufficient,
9145
- balance: originBalance,
9146
- balanceAfter: originBalanceAfter,
9147
- asset: originAsset
9148
- },
8987
+ return _context2.a(2, {
8988
+ selectedCurrency: selectedCurrency,
9149
8989
  xcmFee: {
9150
- sufficient: originBalanceNativeSufficient,
8990
+ sufficient: originBalanceFee >= originFee,
9151
8991
  fee: originFee,
9152
8992
  balance: originBalanceFee,
9153
8993
  balanceAfter: originBalanceFeeAfter,
@@ -9155,7 +8995,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
9155
8995
  }
9156
8996
  });
9157
8997
  }
9158
- }, _callee);
8998
+ }, _callee2);
9159
8999
  }));
9160
9000
  return function buildOriginInfo(_x) {
9161
9001
  return _ref2.apply(this, arguments);
@@ -9164,7 +9004,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
9164
9004
 
9165
9005
  var getTransferInfo = /*#__PURE__*/function () {
9166
9006
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
9167
- var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, originInfo, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, destinationInfo;
9007
+ var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, _resolveCurrency, assets, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, feeAssetIndex, feeCurrency, _yield$buildOriginInf, selectedCurrency, originXcmFee, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, buildDestInfoForAsset, destResults, feeResult, result, _t, _t2;
9168
9008
  return _regenerator().w(function (_context2) {
9169
9009
  while (1) switch (_context2.p = _context2.n) {
9170
9010
  case 0:
@@ -9175,14 +9015,15 @@ var getTransferInfo = /*#__PURE__*/function () {
9175
9015
  }
9176
9016
  throw new MissingParameterError('ahAddress', "ahAddress is required for EVM origin ".concat(origin, "."));
9177
9017
  case 1:
9018
+ assertNotRawAssets(currency);
9178
9019
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
9179
9020
  _context2.n = 2;
9180
9021
  return api.init(origin);
9181
9022
  case 2:
9182
9023
  api.disconnectAllowed = false;
9183
9024
  _context2.p = 3;
9184
- originAsset = api.findAssetInfoOrThrow(origin, currency, destination);
9185
- amount = abstractDecimals(currency.amount, originAsset.decimals, api);
9025
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, originAsset = _resolveCurrency.asset;
9026
+ amount = originAsset.amount;
9186
9027
  _context2.n = 4;
9187
9028
  return getXcmFee({
9188
9029
  api: api,
@@ -9204,20 +9045,25 @@ var getTransferInfo = /*#__PURE__*/function () {
9204
9045
  destFeeDetail = _yield$getXcmFeeInter.destination;
9205
9046
  hops = _yield$getXcmFeeInter.hops;
9206
9047
  isFeeAssetAh = origin === 'AssetHubPolkadot' && !!resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
9048
+ feeAssetIndex = assets.findIndex(function (asset) {
9049
+ return isAssetEqual(asset, originAsset);
9050
+ });
9051
+ feeCurrency = Array.isArray(currency) ? currency[feeAssetIndex] : currency;
9207
9052
  _context2.n = 5;
9208
9053
  return buildOriginInfo({
9209
9054
  api: api,
9210
9055
  origin: origin,
9211
9056
  sender: sender,
9212
- currency: currency,
9213
- originAsset: originAsset,
9057
+ assets: assets,
9214
9058
  amount: amount,
9215
9059
  originFee: originFee,
9216
9060
  originFeeAsset: originFeeAsset,
9217
9061
  isFeeAssetAh: isFeeAssetAh
9218
9062
  });
9219
9063
  case 5:
9220
- originInfo = _context2.v;
9064
+ _yield$buildOriginInf = _context2.v;
9065
+ selectedCurrency = _yield$buildOriginInf.selectedCurrency;
9066
+ originXcmFee = _yield$buildOriginInf.xcmFee;
9221
9067
  builtHops = [];
9222
9068
  if (!(hops && hops.length > 0)) {
9223
9069
  _context2.n = 7;
@@ -9236,7 +9082,7 @@ var getTransferInfo = /*#__PURE__*/function () {
9236
9082
  chain: hop.chain,
9237
9083
  fee: hop.result.fee,
9238
9084
  originChain: origin,
9239
- currency: currency,
9085
+ currency: feeCurrency,
9240
9086
  asset: hop.result.asset,
9241
9087
  sender: sender,
9242
9088
  ahAddress: ahAddress
@@ -9258,44 +9104,76 @@ var getTransferInfo = /*#__PURE__*/function () {
9258
9104
  builtHops = _context2.v;
9259
9105
  case 7:
9260
9106
  _aggregateHopFees = aggregateHopFees(hops, originAsset), totalHopFee = _aggregateHopFees.totalHopFee, bridgeFee = _aggregateHopFees.bridgeFee;
9107
+ buildDestInfoForAsset = function buildDestInfoForAsset(item, isFeeElement) {
9108
+ return buildDestInfo({
9109
+ api: api,
9110
+ origin: origin,
9111
+ destination: destination,
9112
+ recipient: recipient,
9113
+ currency: item,
9114
+ originFee: originFee,
9115
+ isFeeAssetAh: isFeeAssetAh && isFeeElement,
9116
+ paysDestFee: isFeeElement,
9117
+ destFeeDetail: destFeeDetail,
9118
+ totalHopFee: isFeeElement ? totalHopFee : 0n,
9119
+ bridgeFee: bridgeFee
9120
+ });
9121
+ };
9122
+ if (!Array.isArray(currency)) {
9123
+ _context2.n = 9;
9124
+ break;
9125
+ }
9261
9126
  _context2.n = 8;
9262
- return buildDestInfo({
9263
- api: api,
9264
- origin: origin,
9265
- destination: destination,
9266
- recipient: recipient,
9267
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
9268
- amount: amount
9269
- }),
9270
- originFee: originFee,
9271
- isFeeAssetAh: isFeeAssetAh,
9272
- destFeeDetail: destFeeDetail,
9273
- totalHopFee: totalHopFee,
9274
- bridgeFee: bridgeFee
9275
- });
9127
+ return Promise.all(currency.map(function (item, index) {
9128
+ return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, item), {}, {
9129
+ amount: assets[index].amount
9130
+ }), index === feeAssetIndex);
9131
+ }));
9276
9132
  case 8:
9277
- destinationInfo = _context2.v;
9278
- return _context2.a(2, {
9133
+ _t = _context2.v;
9134
+ _context2.n = 11;
9135
+ break;
9136
+ case 9:
9137
+ _context2.n = 10;
9138
+ return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, currency), {}, {
9139
+ amount: amount
9140
+ }), true);
9141
+ case 10:
9142
+ _t2 = _context2.v;
9143
+ _t = [_t2];
9144
+ case 11:
9145
+ destResults = _t;
9146
+ feeResult = destResults[Array.isArray(currency) ? feeAssetIndex : 0];
9147
+ result = {
9279
9148
  chain: {
9280
9149
  origin: origin,
9281
9150
  destination: destination,
9282
9151
  ecosystem: api.getRelayChainSymbol(origin)
9283
9152
  },
9284
- origin: originInfo,
9153
+ origin: {
9154
+ selectedCurrency: Array.isArray(currency) ? selectedCurrency : selectedCurrency[0],
9155
+ xcmFee: originXcmFee
9156
+ },
9285
9157
  hops: builtHops,
9286
- destination: destinationInfo
9287
- });
9288
- case 9:
9289
- _context2.p = 9;
9158
+ destination: {
9159
+ receivedCurrency: Array.isArray(currency) ? destResults.map(function (result) {
9160
+ return result.receivedCurrency;
9161
+ }) : destResults[0].receivedCurrency,
9162
+ xcmFee: feeResult.xcmFee
9163
+ }
9164
+ };
9165
+ return _context2.a(2, result);
9166
+ case 12:
9167
+ _context2.p = 12;
9290
9168
  api.disconnectAllowed = true;
9291
- _context2.n = 10;
9169
+ _context2.n = 13;
9292
9170
  return api.disconnect();
9293
- case 10:
9294
- return _context2.f(9);
9295
- case 11:
9171
+ case 13:
9172
+ return _context2.f(12);
9173
+ case 14:
9296
9174
  return _context2.a(2);
9297
9175
  }
9298
- }, _callee2, null, [[3,, 9, 11]]);
9176
+ }, _callee2, null, [[3,, 12, 14]]);
9299
9177
  }));
9300
9178
  return function getTransferInfo(_x) {
9301
9179
  return _ref2.apply(this, arguments);
@@ -9358,35 +9236,26 @@ var computeAllFees = /*#__PURE__*/function () {
9358
9236
  }();
9359
9237
 
9360
9238
  var getMinTransferableAmountInternal = /*#__PURE__*/function () {
9361
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
9362
- var api, origin, sender, recipient, chain, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, asset, destAsset, destApi, destBalance, destEd, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, amount, result, originFee, hopFeeTotal, destinationFee, edComponent, minAmount, createTx, tx, dryRunResult, _t;
9363
- return _regenerator().w(function (_context2) {
9364
- while (1) switch (_context2.p = _context2.n) {
9239
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref) {
9240
+ var api, origin, sender, recipient, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, _resolveCurrency, assets, selectors, toResult, destApi, nativeAssetInfo, result, minAmounts, buildMinCurrency, createTx, amounts, tx, dryRunResult, _t;
9241
+ return _regenerator().w(function (_context3) {
9242
+ while (1) switch (_context3.p = _context3.n) {
9365
9243
  case 0:
9366
- api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder, version = _ref.version;
9367
- validateAddress(api, sender, chain, false);
9368
- resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
9369
- asset = api.findAssetInfoOrThrow(chain, currency);
9370
- destAsset = api.findAssetOnDestOrThrow(origin, destination, currency);
9244
+ api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder, version = _ref.version;
9245
+ validateAddress(api, sender, origin, false);
9246
+ assertNotRawAssets(currency);
9247
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
9248
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets;
9249
+ selectors = Array.isArray(currency) ? currency : [currency];
9250
+ toResult = function toResult(values) {
9251
+ return Array.isArray(currency) ? values : values[0];
9252
+ };
9371
9253
  destApi = api.clone();
9372
- _context2.n = 1;
9254
+ _context3.n = 1;
9373
9255
  return destApi.init(destination);
9374
9256
  case 1:
9375
- _context2.n = 2;
9376
- return getAssetBalanceInternal({
9377
- api: destApi,
9378
- address: recipient,
9379
- chain: destination,
9380
- asset: destAsset
9381
- });
9382
- case 2:
9383
- destBalance = _context2.v;
9384
- destEd = getEdFromAssetOrThrow(destAsset);
9385
- nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
9386
- isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
9387
- paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
9388
- amount = abstractDecimals(currency.amount, asset.decimals, api);
9389
- _context2.n = 3;
9257
+ nativeAssetInfo = api.findNativeAssetInfoOrThrow(origin);
9258
+ _context3.n = 2;
9390
9259
  return getXcmFee({
9391
9260
  api: api,
9392
9261
  origin: origin,
@@ -9394,164 +9263,179 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
9394
9263
  buildTx: buildTx,
9395
9264
  sender: sender,
9396
9265
  recipient: recipient,
9397
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
9398
- amount: amount
9266
+ currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
9267
+ amount: assets[0].amount
9399
9268
  }),
9400
9269
  feeAsset: feeAsset,
9401
9270
  version: version,
9402
9271
  disableFallback: false
9403
9272
  });
9404
- case 3:
9405
- result = _context2.v;
9406
- originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
9407
- hopFeeTotal = result.hops.reduce(function (acc, hop) {
9408
- // only add if asset is equal
9409
- return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
9410
- }, 0n);
9411
- destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
9412
- edComponent = destBalance === 0n ? destEd : 0n;
9413
- minAmount = hopFeeTotal + destinationFee + originFee + edComponent + 1n;
9414
- createTx = /*#__PURE__*/function () {
9415
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(amount) {
9416
- var _yield$builder$curren, tx;
9273
+ case 2:
9274
+ result = _context3.v;
9275
+ _context3.n = 3;
9276
+ return Promise.all(assets.map(/*#__PURE__*/function () {
9277
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, index) {
9278
+ var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, hopFeeTotal, destinationFee, edComponent;
9417
9279
  return _regenerator().w(function (_context) {
9418
9280
  while (1) switch (_context.n) {
9419
9281
  case 0:
9282
+ destAsset = api.findAssetOnDestOrThrow(origin, destination, selectors[index]);
9420
9283
  _context.n = 1;
9421
- return builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
9422
- amount: amount
9423
- }))['buildInternal']();
9284
+ return getAssetBalanceInternal({
9285
+ api: destApi,
9286
+ address: recipient,
9287
+ chain: destination,
9288
+ asset: destAsset
9289
+ });
9424
9290
  case 1:
9425
- _yield$builder$curren = _context.v;
9426
- tx = _yield$builder$curren.tx;
9427
- return _context.a(2, tx);
9291
+ destBalance = _context.v;
9292
+ destEd = getEdFromAssetOrThrow(destAsset);
9293
+ paysOriginInSendingAsset = !resolvedFeeAsset && isAssetEqual(nativeAssetInfo, asset) || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
9294
+ originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
9295
+ hopFeeTotal = result.hops.reduce(function (acc, hop) {
9296
+ // only add if asset is equal
9297
+ return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
9298
+ }, 0n);
9299
+ destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
9300
+ edComponent = destBalance === 0n ? destEd : 0n;
9301
+ return _context.a(2, hopFeeTotal + destinationFee + originFee + edComponent + 1n);
9428
9302
  }
9429
9303
  }, _callee);
9430
9304
  }));
9431
- return function createTx(_x2) {
9305
+ return function (_x2, _x3) {
9432
9306
  return _ref3.apply(this, arguments);
9433
9307
  };
9308
+ }()));
9309
+ case 3:
9310
+ minAmounts = _context3.v;
9311
+ buildMinCurrency = function buildMinCurrency(amounts) {
9312
+ assertNotRawAssets(currency);
9313
+ return Array.isArray(currency) ? currency.map(function (item, index) {
9314
+ return _objectSpread2(_objectSpread2({}, item), {}, {
9315
+ amount: amounts[index]
9316
+ });
9317
+ }) : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
9318
+ amount: amounts[0]
9319
+ });
9320
+ };
9321
+ createTx = /*#__PURE__*/function () {
9322
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(amounts) {
9323
+ var _yield$builder$curren, tx;
9324
+ return _regenerator().w(function (_context2) {
9325
+ while (1) switch (_context2.n) {
9326
+ case 0:
9327
+ _context2.n = 1;
9328
+ return builder.currency(buildMinCurrency(amounts))['buildInternal']();
9329
+ case 1:
9330
+ _yield$builder$curren = _context2.v;
9331
+ tx = _yield$builder$curren.tx;
9332
+ return _context2.a(2, tx);
9333
+ }
9334
+ }, _callee2);
9335
+ }));
9336
+ return function createTx(_x4) {
9337
+ return _ref4.apply(this, arguments);
9338
+ };
9434
9339
  }();
9435
- _context2.p = 4;
9436
- _context2.n = 5;
9437
- return createTx(minAmount);
9340
+ amounts = minAmounts;
9341
+ _context3.p = 4;
9342
+ _context3.n = 5;
9343
+ return createTx(amounts);
9438
9344
  case 5:
9439
- tx = _context2.v;
9440
- _context2.n = 10;
9345
+ tx = _context3.v;
9346
+ _context3.n = 10;
9441
9347
  break;
9442
9348
  case 6:
9443
- _context2.p = 6;
9444
- _t = _context2.v;
9349
+ _context3.p = 6;
9350
+ _t = _context3.v;
9445
9351
  if (!(_t instanceof AmountTooLowError)) {
9446
- _context2.n = 10;
9352
+ _context3.n = 10;
9447
9353
  break;
9448
9354
  }
9449
- minAmount = padValueBy(minAmount, FEE_PADDING);
9450
- _context2.p = 7;
9451
- _context2.n = 8;
9452
- return createTx(minAmount);
9355
+ amounts = amounts.map(function (amount) {
9356
+ return padValueBy(amount, FEE_PADDING);
9357
+ });
9358
+ _context3.p = 7;
9359
+ _context3.n = 8;
9360
+ return createTx(amounts);
9453
9361
  case 8:
9454
- tx = _context2.v;
9455
- _context2.n = 10;
9362
+ tx = _context3.v;
9363
+ _context3.n = 10;
9456
9364
  break;
9457
9365
  case 9:
9458
- _context2.p = 9;
9459
- _context2.v;
9460
- if (!(_t instanceof AmountTooLowError)) {
9461
- _context2.n = 10;
9462
- break;
9463
- }
9464
- return _context2.a(2, 0n);
9366
+ _context3.p = 9;
9367
+ _context3.v;
9368
+ return _context3.a(2, toResult(amounts.map(function () {
9369
+ return 0n;
9370
+ })));
9465
9371
  case 10:
9466
- _context2.n = 11;
9372
+ _context3.n = 11;
9467
9373
  return dryRunInternal({
9468
9374
  api: api,
9469
9375
  tx: tx,
9470
- origin: chain,
9376
+ origin: origin,
9471
9377
  destination: destination,
9472
9378
  sender: sender,
9473
9379
  version: version,
9474
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
9475
- amount: minAmount
9476
- }),
9380
+ currency: buildMinCurrency(amounts),
9477
9381
  feeAsset: feeAsset
9478
9382
  });
9479
9383
  case 11:
9480
- dryRunResult = _context2.v;
9384
+ dryRunResult = _context3.v;
9481
9385
  if (!dryRunResult.failureReason) {
9482
- _context2.n = 12;
9386
+ _context3.n = 12;
9483
9387
  break;
9484
9388
  }
9485
- return _context2.a(2, 0n);
9389
+ return _context3.a(2, toResult(amounts.map(function () {
9390
+ return 0n;
9391
+ })));
9486
9392
  case 12:
9487
- return _context2.a(2, minAmount);
9393
+ return _context3.a(2, toResult(amounts));
9488
9394
  }
9489
- }, _callee2, null, [[7, 9], [4, 6]]);
9395
+ }, _callee3, null, [[7, 9], [4, 6]]);
9490
9396
  }));
9491
9397
  return function getMinTransferableAmountInternal(_x) {
9492
9398
  return _ref2.apply(this, arguments);
9493
9399
  };
9494
9400
  }();
9495
9401
  var getMinTransferableAmount = /*#__PURE__*/function () {
9496
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
9402
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
9497
9403
  var api;
9498
- return _regenerator().w(function (_context3) {
9499
- while (1) switch (_context3.p = _context3.n) {
9404
+ return _regenerator().w(function (_context4) {
9405
+ while (1) switch (_context4.p = _context4.n) {
9500
9406
  case 0:
9501
9407
  api = options.api;
9502
9408
  api.disconnectAllowed = false;
9503
- _context3.p = 1;
9504
- _context3.n = 2;
9409
+ _context4.p = 1;
9410
+ _context4.n = 2;
9505
9411
  return getMinTransferableAmountInternal(options);
9506
9412
  case 2:
9507
- return _context3.a(2, _context3.v);
9413
+ return _context4.a(2, _context4.v);
9508
9414
  case 3:
9509
- _context3.p = 3;
9415
+ _context4.p = 3;
9510
9416
  api.disconnectAllowed = true;
9511
- _context3.n = 4;
9417
+ _context4.n = 4;
9512
9418
  return api.disconnect();
9513
9419
  case 4:
9514
- return _context3.f(3);
9420
+ return _context4.f(3);
9515
9421
  case 5:
9516
- return _context3.a(2);
9422
+ return _context4.a(2);
9517
9423
  }
9518
- }, _callee3, null, [[1,, 3, 5]]);
9424
+ }, _callee4, null, [[1,, 3, 5]]);
9519
9425
  }));
9520
- return function getMinTransferableAmount(_x3) {
9521
- return _ref4.apply(this, arguments);
9426
+ return function getMinTransferableAmount(_x5) {
9427
+ return _ref5.apply(this, arguments);
9522
9428
  };
9523
9429
  }();
9524
9430
 
9525
- var getTransferableAmountInternal = /*#__PURE__*/function () {
9526
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
9527
- var api, sender, chain, destination, currency, buildTx, feeAsset, version, resolvedFeeAsset, asset, amount, balance, ed, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
9431
+ var getOriginFeeOrThrow = /*#__PURE__*/function () {
9432
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
9433
+ var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
9528
9434
  return _regenerator().w(function (_context) {
9529
9435
  while (1) switch (_context.n) {
9530
9436
  case 0:
9531
- api = _ref.api, sender = _ref.sender, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, buildTx = _ref.buildTx, feeAsset = _ref.feeAsset, version = _ref.version;
9532
- validateAddress(api, sender, chain, false);
9533
- resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
9534
- asset = api.findAssetInfoOrThrow(chain, currency);
9535
- amount = abstractDecimals(currency.amount, asset.decimals, api);
9437
+ api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
9536
9438
  _context.n = 1;
9537
- return getAssetBalanceInternal({
9538
- api: api,
9539
- address: sender,
9540
- chain: chain,
9541
- asset: asset
9542
- });
9543
- case 1:
9544
- balance = _context.v;
9545
- ed = getEdFromAssetOrThrow(asset);
9546
- nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
9547
- isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
9548
- paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
9549
- feeToSubtract = 0n;
9550
- if (!paysOriginInSendingAsset) {
9551
- _context.n = 4;
9552
- break;
9553
- }
9554
- _context.n = 2;
9555
9439
  return getOriginXcmFee({
9556
9440
  api: api,
9557
9441
  buildTx: buildTx,
@@ -9560,58 +9444,157 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
9560
9444
  sender: sender,
9561
9445
  feeAsset: feeAsset,
9562
9446
  version: version,
9563
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
9564
- amount: amount
9565
- }),
9447
+ currency: feeCurrency,
9566
9448
  disableFallback: false
9567
9449
  });
9568
- case 2:
9450
+ case 1:
9569
9451
  _yield$getOriginXcmFe = _context.v;
9570
9452
  fee = _yield$getOriginXcmFe.fee;
9571
9453
  if (!(fee === undefined)) {
9572
- _context.n = 3;
9454
+ _context.n = 2;
9573
9455
  break;
9574
9456
  }
9575
9457
  throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
9576
- case 3:
9577
- feeToSubtract = fee;
9578
- case 4:
9579
- transferable = balance - ed - feeToSubtract;
9580
- return _context.a(2, transferable > 0n ? transferable : 0n);
9458
+ case 2:
9459
+ return _context.a(2, fee);
9581
9460
  }
9582
9461
  }, _callee);
9583
9462
  }));
9584
- return function getTransferableAmountInternal(_x) {
9463
+ return function getOriginFeeOrThrow(_x, _x2) {
9585
9464
  return _ref2.apply(this, arguments);
9586
9465
  };
9587
9466
  }();
9467
+ var computeTransferableAmount = /*#__PURE__*/function () {
9468
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
9469
+ var balance, transferable;
9470
+ return _regenerator().w(function (_context2) {
9471
+ while (1) switch (_context2.n) {
9472
+ case 0:
9473
+ _context2.n = 1;
9474
+ return getAssetBalanceInternal({
9475
+ api: api,
9476
+ address: sender,
9477
+ chain: chain,
9478
+ asset: asset
9479
+ });
9480
+ case 1:
9481
+ balance = _context2.v;
9482
+ transferable = balance - getEdFromAssetOrThrow(asset) - fee;
9483
+ return _context2.a(2, transferable > 0n ? transferable : 0n);
9484
+ }
9485
+ }, _callee2);
9486
+ }));
9487
+ return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
9488
+ return _ref3.apply(this, arguments);
9489
+ };
9490
+ }();
9491
+ var getTransferableAmountForAsset = /*#__PURE__*/function () {
9492
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
9493
+ var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
9494
+ return _regenerator().w(function (_context3) {
9495
+ while (1) switch (_context3.n) {
9496
+ case 0:
9497
+ api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
9498
+ asset = api.findAssetInfoOrThrow(chain, currency);
9499
+ amount = abstractDecimals(currency.amount, asset.decimals, api);
9500
+ nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
9501
+ isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
9502
+ paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
9503
+ if (!paysOriginInSendingAsset) {
9504
+ _context3.n = 2;
9505
+ break;
9506
+ }
9507
+ _context3.n = 1;
9508
+ return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
9509
+ amount: amount
9510
+ }));
9511
+ case 1:
9512
+ _t = _context3.v;
9513
+ _context3.n = 3;
9514
+ break;
9515
+ case 2:
9516
+ _t = 0n;
9517
+ case 3:
9518
+ fee = _t;
9519
+ return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
9520
+ }
9521
+ }, _callee3);
9522
+ }));
9523
+ return function getTransferableAmountForAsset(_x8, _x9) {
9524
+ return _ref4.apply(this, arguments);
9525
+ };
9526
+ }();
9527
+ var getTransferableAmountForAssets = /*#__PURE__*/function () {
9528
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
9529
+ var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
9530
+ return _regenerator().w(function (_context4) {
9531
+ while (1) switch (_context4.n) {
9532
+ case 0:
9533
+ api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
9534
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
9535
+ _context4.n = 1;
9536
+ return getOriginFeeOrThrow(options, currency);
9537
+ case 1:
9538
+ fee = _context4.v;
9539
+ return _context4.a(2, Promise.all(assets.map(function (asset) {
9540
+ return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
9541
+ })));
9542
+ }
9543
+ }, _callee4);
9544
+ }));
9545
+ return function getTransferableAmountForAssets(_x0, _x1) {
9546
+ return _ref5.apply(this, arguments);
9547
+ };
9548
+ }();
9549
+ var getTransferableAmountInternal = /*#__PURE__*/function () {
9550
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
9551
+ var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
9552
+ return _regenerator().w(function (_context5) {
9553
+ while (1) switch (_context5.n) {
9554
+ case 0:
9555
+ api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
9556
+ validateAddress(api, sender, chain, false);
9557
+ assertNotRawAssets(currency);
9558
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
9559
+ return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
9560
+ currency: currency
9561
+ }), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
9562
+ currency: currency
9563
+ }), resolvedFeeAsset));
9564
+ }
9565
+ }, _callee5);
9566
+ }));
9567
+ return function getTransferableAmountInternal(_x10) {
9568
+ return _ref6.apply(this, arguments);
9569
+ };
9570
+ }();
9588
9571
  var getTransferableAmount = /*#__PURE__*/function () {
9589
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
9572
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
9590
9573
  var api;
9591
- return _regenerator().w(function (_context2) {
9592
- while (1) switch (_context2.p = _context2.n) {
9574
+ return _regenerator().w(function (_context6) {
9575
+ while (1) switch (_context6.p = _context6.n) {
9593
9576
  case 0:
9594
9577
  api = options.api;
9595
9578
  api.disconnectAllowed = false;
9596
- _context2.p = 1;
9597
- _context2.n = 2;
9579
+ _context6.p = 1;
9580
+ _context6.n = 2;
9598
9581
  return getTransferableAmountInternal(options);
9599
9582
  case 2:
9600
- return _context2.a(2, _context2.v);
9583
+ return _context6.a(2, _context6.v);
9601
9584
  case 3:
9602
- _context2.p = 3;
9585
+ _context6.p = 3;
9603
9586
  api.disconnectAllowed = true;
9604
- _context2.n = 4;
9587
+ _context6.n = 4;
9605
9588
  return api.disconnect();
9606
9589
  case 4:
9607
- return _context2.f(3);
9590
+ return _context6.f(3);
9608
9591
  case 5:
9609
- return _context2.a(2);
9592
+ return _context6.a(2);
9610
9593
  }
9611
- }, _callee2, null, [[1,, 3, 5]]);
9594
+ }, _callee6, null, [[1,, 3, 5]]);
9612
9595
  }));
9613
- return function getTransferableAmount(_x2) {
9614
- return _ref3.apply(this, arguments);
9596
+ return function getTransferableAmount(_x11) {
9597
+ return _ref7.apply(this, arguments);
9615
9598
  };
9616
9599
  }();
9617
9600
 
@@ -9804,6 +9787,8 @@ var createCustomXcm = /*#__PURE__*/function () {
9804
9787
  paraIdTo,
9805
9788
  sender,
9806
9789
  ahAddress,
9790
+ overriddenAsset,
9791
+ overriddenAssets,
9807
9792
  buildRefundInstruction,
9808
9793
  hopFees,
9809
9794
  destFee,
@@ -9815,6 +9800,7 @@ var createCustomXcm = /*#__PURE__*/function () {
9815
9800
  asset,
9816
9801
  allOfSelector,
9817
9802
  depositInstruction,
9803
+ localizeFilterAsset,
9818
9804
  assetsFilter,
9819
9805
  isAssetEthereumNative,
9820
9806
  buyExecutionAmount,
@@ -9835,7 +9821,8 @@ var createCustomXcm = /*#__PURE__*/function () {
9835
9821
  destFee: 0n
9836
9822
  };
9837
9823
  origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, options = context.options;
9838
- destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress;
9824
+ destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, overriddenAsset = options.overriddenAsset;
9825
+ overriddenAssets = Array.isArray(overriddenAsset) ? overriddenAsset : null;
9839
9826
  buildRefundInstruction = function buildRefundInstruction() {
9840
9827
  if (!sender || isSubBridge) return null;
9841
9828
  var resolveRefundAddress = function resolveRefundAddress() {
@@ -9882,8 +9869,8 @@ var createCustomXcm = /*#__PURE__*/function () {
9882
9869
  depositInstruction = {
9883
9870
  DepositAsset: {
9884
9871
  assets: {
9885
- Wild: assetCount > 1 ? allOfSelector : {
9886
- AllCounted: 1
9872
+ Wild: assetCount > 1 && !overriddenAssets ? allOfSelector : {
9873
+ AllCounted: assetCount
9887
9874
  }
9888
9875
  },
9889
9876
  beneficiary: createBeneficiaryLocation({
@@ -9893,9 +9880,18 @@ var createCustomXcm = /*#__PURE__*/function () {
9893
9880
  })
9894
9881
  }
9895
9882
  };
9883
+ localizeFilterAsset = function localizeFilterAsset(amount, location) {
9884
+ return createAsset(version, amount, normalizeLocation(localizeLocationImpl(origin.api, reserve.chain, location), version));
9885
+ };
9896
9886
  assetsFilter = [];
9897
- if (!isRelayAsset && !isExternalChain(dest.chain)) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocationImpl(origin.api, reserve.chain, RELAY_LOCATION)));
9898
- assetsFilter.push(createAsset(version, assetInfo.amount, normalizeLocation(localizeLocationImpl(origin.api, reserve.chain, assetInfo.location), version)));
9887
+ if (overriddenAssets) {
9888
+ assetsFilter.push.apply(assetsFilter, _toConsumableArray(overriddenAssets.map(function (asset) {
9889
+ return localizeFilterAsset(asset.fun.Fungible, extractAssetLocation(asset));
9890
+ })));
9891
+ } else {
9892
+ if (!isRelayAsset && !isExternalChain(dest.chain)) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocationImpl(origin.api, reserve.chain, RELAY_LOCATION)));
9893
+ assetsFilter.push(localizeFilterAsset(assetInfo.amount, assetInfo.location));
9894
+ }
9899
9895
  isAssetEthereumNative = deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), getEthereumJunction(origin.api, origin.chain, false).GlobalConsensus);
9900
9896
  if (!(isSubBridge || bridgeHopChain || origin.chain !== reserve.chain && dest.chain !== reserve.chain)) {
9901
9897
  _context.n = 6;
@@ -10271,44 +10267,58 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
10271
10267
  return totalHopFee + destFee;
10272
10268
  };
10273
10269
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
10274
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10275
- var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, totalFee, method, feeToSubtract;
10276
- return _regenerator().w(function (_context) {
10277
- while (1) switch (_context.n) {
10270
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
10271
+ var _destAssets$find;
10272
+ var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, isTypeAndThenMethod, verifyAsset, results;
10273
+ return _regenerator().w(function (_context2) {
10274
+ while (1) switch (_context2.n) {
10278
10275
  case 0:
10279
10276
  api = options.api, buildTx = options.buildTx, origin = options.origin, destination = options.destination, currency = options.currency, sender = options.sender, recipient = options.recipient, feeAsset = options.feeAsset, version = options.version;
10280
10277
  if (!isExternalChain(destination)) {
10281
- _context.n = 1;
10278
+ _context2.n = 1;
10282
10279
  break;
10283
10280
  }
10284
- return _context.a(2, true);
10281
+ return _context2.a(2, true);
10285
10282
  case 1:
10286
10283
  validateAddress(api, recipient, destination, true);
10287
10284
  isSubBridge = isSubstrateBridge(origin, destination);
10288
10285
  if (!isSubBridge) {
10289
- _context.n = 2;
10286
+ _context2.n = 2;
10290
10287
  break;
10291
10288
  }
10292
10289
  throw new ScenarioNotSupportedError('Unable to verify the existential deposit for substrate bridge scenarios');
10293
10290
  case 2:
10291
+ assertNotRawAssets(currency);
10292
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
10294
10293
  destApi = api.clone();
10295
- _context.n = 3;
10294
+ _context2.n = 3;
10296
10295
  return destApi.init(destination);
10297
10296
  case 3:
10298
- asset = api.findAssetOnDestOrThrow(origin, destination, currency);
10299
- amount = abstractDecimals(currency.amount, asset.decimals, api);
10300
- destAsset = api.findAssetOnDestOrThrow(origin, destination, currency);
10301
- ed = getEdFromAssetOrThrow(destAsset);
10302
- _context.n = 4;
10303
- return getAssetBalanceInternal({
10304
- address: recipient,
10305
- chain: destination,
10306
- api: destApi,
10307
- asset: destAsset
10297
+ resolvedAssets = Array.isArray(currency) ? resolveCurrency(api, currency, resolvedFeeAsset, origin, destination).assets.map(function (asset, index) {
10298
+ return {
10299
+ selector: currency[index],
10300
+ paysDestFee: !!asset.isFeeAsset
10301
+ };
10302
+ }) : [{
10303
+ selector: currency,
10304
+ paysDestFee: true
10305
+ }];
10306
+ destAssets = resolvedAssets.map(function (_ref2) {
10307
+ var selector = _ref2.selector,
10308
+ paysDestFee = _ref2.paysDestFee;
10309
+ var destAsset = api.findAssetOnDestOrThrow(origin, destination, selector);
10310
+ return {
10311
+ destAsset: destAsset,
10312
+ amount: abstractDecimals(selector.amount, destAsset.decimals, api),
10313
+ paysDestFee: paysDestFee
10314
+ };
10308
10315
  });
10309
- case 4:
10310
- balance = _context.v;
10311
- _context.n = 5;
10316
+ _destAssets = _slicedToArray(destAssets, 1), firstAsset = _destAssets[0];
10317
+ feeElement = (_destAssets$find = destAssets.find(function (_ref3) {
10318
+ var paysDestFee = _ref3.paysDestFee;
10319
+ return paysDestFee;
10320
+ })) !== null && _destAssets$find !== void 0 ? _destAssets$find : firstAsset;
10321
+ _context2.n = 4;
10312
10322
  return getXcmFeeInternal({
10313
10323
  api: api,
10314
10324
  buildTx: buildTx,
@@ -10316,59 +10326,84 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
10316
10326
  destination: destination,
10317
10327
  sender: sender,
10318
10328
  recipient: recipient,
10319
- currency: _objectSpread2(_objectSpread2({}, currency), {}, {
10320
- amount: amount
10329
+ currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, currency), {}, {
10330
+ amount: feeElement.amount
10321
10331
  }),
10322
10332
  version: version,
10323
10333
  feeAsset: feeAsset,
10324
10334
  disableFallback: false
10325
10335
  });
10326
- case 5:
10327
- xcmFeeResult = _context.v;
10336
+ case 4:
10337
+ xcmFeeResult = _context2.v;
10328
10338
  dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
10329
10339
  if (!dryRunError) {
10330
- _context.n = 6;
10340
+ _context2.n = 5;
10331
10341
  break;
10332
10342
  }
10333
10343
  throw new DryRunFailedError(dryRunError, 'origin');
10334
- case 6:
10344
+ case 5:
10335
10345
  erroredHop = hops.find(function (hop) {
10336
10346
  return hop.result.dryRunError;
10337
10347
  });
10338
10348
  hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
10339
10349
  if (!hopError) {
10340
- _context.n = 7;
10350
+ _context2.n = 6;
10341
10351
  break;
10342
10352
  }
10343
10353
  throw new DryRunFailedError(hopError, erroredHop.chain);
10344
- case 7:
10354
+ case 6:
10345
10355
  if (!destDryRunError) {
10346
- _context.n = 8;
10356
+ _context2.n = 7;
10347
10357
  break;
10348
10358
  }
10349
10359
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
10350
- case 8:
10351
- isUnableToCompute = !isSymbolMatch(normalizeSymbol(destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
10360
+ case 7:
10361
+ isUnableToCompute = !isSymbolMatch(normalizeSymbol(feeElement.destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
10352
10362
  if (!isUnableToCompute) {
10353
- _context.n = 9;
10363
+ _context2.n = 8;
10354
10364
  break;
10355
10365
  }
10356
10366
  throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
10357
- case 9:
10358
- _context.n = 10;
10367
+ case 8:
10368
+ _context2.n = 9;
10359
10369
  return buildTx();
10360
- case 10:
10361
- tx = _context.v;
10362
- totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
10370
+ case 9:
10371
+ tx = _context2.v;
10363
10372
  method = api.getMethod(tx);
10364
- if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
10365
- feeToSubtract = totalFee;
10366
- } else {
10367
- feeToSubtract = destFee;
10368
- }
10369
- return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
10373
+ isTypeAndThenMethod = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen';
10374
+ verifyAsset = /*#__PURE__*/function () {
10375
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
10376
+ var destAsset, amount, paysDestFee, ed, balance, feeToSubtract;
10377
+ return _regenerator().w(function (_context) {
10378
+ while (1) switch (_context.n) {
10379
+ case 0:
10380
+ destAsset = _ref4.destAsset, amount = _ref4.amount, paysDestFee = _ref4.paysDestFee;
10381
+ ed = getEdFromAssetOrThrow(destAsset);
10382
+ _context.n = 1;
10383
+ return getAssetBalanceInternal({
10384
+ address: recipient,
10385
+ chain: destination,
10386
+ api: destApi,
10387
+ asset: destAsset
10388
+ });
10389
+ case 1:
10390
+ balance = _context.v;
10391
+ feeToSubtract = isTypeAndThenMethod ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee ? destFee : 0n;
10392
+ return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
10393
+ }
10394
+ }, _callee);
10395
+ }));
10396
+ return function verifyAsset(_x2) {
10397
+ return _ref5.apply(this, arguments);
10398
+ };
10399
+ }();
10400
+ _context2.n = 10;
10401
+ return Promise.all(destAssets.map(verifyAsset));
10402
+ case 10:
10403
+ results = _context2.v;
10404
+ return _context2.a(2, results.every(Boolean));
10370
10405
  }
10371
- }, _callee);
10406
+ }, _callee2);
10372
10407
  }));
10373
10408
  return function verifyEdOnDestinationInternal(_x) {
10374
10409
  return _ref.apply(this, arguments);
@@ -11758,34 +11793,28 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Chain) {
11758
11793
  while (1) switch (_context.n) {
11759
11794
  case 0:
11760
11795
  api = options.api, assetInfo = options.assetInfo, feeAssetInfo = options.feeAssetInfo, overriddenAsset = options.overriddenAsset;
11761
- if (!feeAssetInfo) {
11762
- _context.n = 4;
11763
- break;
11764
- }
11765
- if (!overriddenAsset) {
11766
- _context.n = 1;
11796
+ if (!(feeAssetInfo && !overriddenAsset)) {
11797
+ _context.n = 3;
11767
11798
  break;
11768
11799
  }
11769
- throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
11770
- case 1:
11771
11800
  if (!isSymbolMatch(assetInfo.symbol, 'KSM')) {
11772
- _context.n = 2;
11801
+ _context.n = 1;
11773
11802
  break;
11774
11803
  }
11775
11804
  return _context.a(2, transferPolkadotXcm(options));
11776
- case 2:
11805
+ case 1:
11777
11806
  isNativeAsset = isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol(api));
11778
11807
  isNativeFeeAsset = isSymbolMatch(feeAssetInfo.symbol, this.getNativeAssetSymbol(api));
11779
11808
  if (!(!isNativeAsset || !isNativeFeeAsset)) {
11780
- _context.n = 4;
11809
+ _context.n = 3;
11781
11810
  break;
11782
11811
  }
11783
11812
  _t = api;
11784
- _context.n = 3;
11813
+ _context.n = 2;
11785
11814
  return handleExecuteTransfer(options);
11786
- case 3:
11815
+ case 2:
11787
11816
  return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
11788
- case 4:
11817
+ case 3:
11789
11818
  return _context.a(2, transferPolkadotXcm(options));
11790
11819
  }
11791
11820
  }, _callee, this);
@@ -11961,34 +11990,28 @@ var Hydration = /*#__PURE__*/function (_Chain) {
11961
11990
  while (1) switch (_context.n) {
11962
11991
  case 0:
11963
11992
  destination = input.destination, asset = input.assetInfo, feeAsset = input.feeAssetInfo, overriddenAsset = input.overriddenAsset, api = input.api;
11964
- if (!feeAsset) {
11965
- _context.n = 3;
11966
- break;
11967
- }
11968
- if (!overriddenAsset) {
11969
- _context.n = 1;
11993
+ if (!(feeAsset && !overriddenAsset)) {
11994
+ _context.n = 2;
11970
11995
  break;
11971
11996
  }
11972
- throw new InvalidCurrencyError('Cannot use overridden assets with XCM execute');
11973
- case 1:
11974
11997
  isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol(api));
11975
11998
  isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol(api));
11976
11999
  if (!(!isNativeAsset || !isNativeFeeAsset)) {
11977
- _context.n = 3;
12000
+ _context.n = 2;
11978
12001
  break;
11979
12002
  }
11980
12003
  _t = api;
11981
- _context.n = 2;
12004
+ _context.n = 1;
11982
12005
  return handleExecuteTransfer(input);
11983
- case 2:
12006
+ case 1:
11984
12007
  return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
11985
- case 3:
12008
+ case 2:
11986
12009
  if (!(isMoonbeamWhAsset(asset.location) && destination === 'Moonbeam')) {
11987
- _context.n = 4;
12010
+ _context.n = 3;
11988
12011
  break;
11989
12012
  }
11990
12013
  return _context.a(2, this.transferMoonbeamWhAsset(input));
11991
- case 4:
12014
+ case 3:
11992
12015
  return _context.a(2, transferPolkadotXcm(input));
11993
12016
  }
11994
12017
  }, _callee, this);
@@ -14013,12 +14036,23 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
14013
14036
  };
14014
14037
  var overrideTxAmount = /*#__PURE__*/function () {
14015
14038
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount, relative) {
14016
- var modifiedBuilder, _yield$modifiedBuilde, tx;
14039
+ var currency, overrideAmount, modifiedBuilder, _yield$modifiedBuilde, tx;
14017
14040
  return _regenerator().w(function (_context) {
14018
14041
  while (1) switch (_context.n) {
14019
14042
  case 0:
14020
- modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
14021
- amount: computeOverridenAmount(options, amount, relative)
14043
+ currency = options.currency;
14044
+ assertNotRawAssets(currency);
14045
+ overrideAmount = function overrideAmount(item) {
14046
+ return computeOverridenAmount(_objectSpread2(_objectSpread2({}, options), {}, {
14047
+ currency: item
14048
+ }), amount, relative);
14049
+ };
14050
+ modifiedBuilder = builder.currency(Array.isArray(currency) ? currency.map(function (item) {
14051
+ return _objectSpread2(_objectSpread2({}, item), {}, {
14052
+ amount: overrideAmount(item)
14053
+ });
14054
+ }) : _objectSpread2(_objectSpread2({}, currency), {}, {
14055
+ amount: overrideAmount(currency)
14022
14056
  }));
14023
14057
  _context.n = 1;
14024
14058
  return modifiedBuilder['buildInternal']();
@@ -14879,4 +14913,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
14879
14913
  };
14880
14914
  };
14881
14915
 
14882
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
14916
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertNotRawAssets, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };