@paraspell/sdk-core 10.0.0 → 10.0.1

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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, hasDryRunSupport, findAsset, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, isSymbolSpecifier, getAssetId, getExistentialDeposit, findAssetOnDestOrThrow, normalizeSymbol } from '@paraspell/assets';
2
+ import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, findAsset, isTMultiAsset, hasDryRunSupport, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, isSymbolSpecifier, getAssetId, getExistentialDeposit, findAssetOnDestOrThrow, normalizeSymbol } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { ethers, Contract } from 'ethers';
@@ -2592,12 +2592,15 @@ var getMultiLocationTokenId = function getMultiLocationTokenId(location, node) {
2592
2592
  };
2593
2593
 
2594
2594
  var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, node, executionFee) {
2595
+ var isFeeAsset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2595
2596
  // Extract delivery fees from emitted events
2596
2597
  var deliveryFees = [];
2598
+ var assetConversionFee = 0n;
2597
2599
  var _iterator = _createForOfIteratorHelper(dryRun.value.emitted_events),
2598
2600
  _step;
2599
2601
  try {
2600
2602
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2603
+ var _e$value, _e$value2;
2601
2604
  var e = _step.value;
2602
2605
  var isXcmEvent = e.type === 'XcmPallet' || e.type === 'PolkadotXcm' || e.type === 'CumulusXcm';
2603
2606
  var isFeesPaid = e.value.type === 'FeesPaid';
@@ -2622,20 +2625,26 @@ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, node, execution
2622
2625
  _iterator2.f();
2623
2626
  }
2624
2627
  }
2628
+ if (isFeeAsset && e.type === 'AssetConversion' && ((_e$value = e.value) === null || _e$value === void 0 ? void 0 : _e$value.type) === 'SwapCreditExecuted' && (_e$value2 = e.value) !== null && _e$value2 !== void 0 && _e$value2.value && e.value.value.amount_in !== undefined && e.value.value.amount_in !== null) {
2629
+ assetConversionFee += e.value.value.amount_in;
2630
+ }
2625
2631
  }
2626
2632
  } catch (err) {
2627
2633
  _iterator.e(err);
2628
2634
  } finally {
2629
2635
  _iterator.f();
2630
2636
  }
2631
- var nativeAssetSymbol = getNativeAssetSymbol(node);
2632
- // Sum the fees that match the feeToken
2633
- var totalDeliveryFees = deliveryFees.filter(function (df) {
2634
- return df.tokenSymbol === nativeAssetSymbol;
2635
- }).reduce(function (acc, df) {
2636
- return acc + df.plancks;
2637
- }, 0n);
2638
- return totalDeliveryFees + executionFee;
2637
+ if (isFeeAsset && assetConversionFee > 0n) {
2638
+ return assetConversionFee;
2639
+ } else {
2640
+ var nativeAssetSymbol = getNativeAssetSymbol(node);
2641
+ var totalDeliveryFees = deliveryFees.filter(function (df) {
2642
+ return df.tokenSymbol === nativeAssetSymbol;
2643
+ }).reduce(function (acc, df) {
2644
+ return acc + df.plancks;
2645
+ }, 0n);
2646
+ return totalDeliveryFees + executionFee;
2647
+ }
2639
2648
  };
2640
2649
 
2641
2650
  var getMultiLocationTokenIdPjs = function getMultiLocationTokenIdPjs(location, node) {
@@ -2952,6 +2961,15 @@ var getTNode = function getTNode(paraId, ecosystem) {
2952
2961
  })) !== null && _NODE_NAMES_DOT_KSM$f !== void 0 ? _NODE_NAMES_DOT_KSM$f : null;
2953
2962
  };
2954
2963
 
2964
+ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
2965
+ var asset = findAsset(origin, feeAsset, !isTMultiLocation(destination) ? destination : null);
2966
+ var usesRawOverriddenMultiAssets = 'multiasset' in currency && currency.multiasset.every(isTMultiAsset);
2967
+ if (!asset && !usesRawOverriddenMultiAssets) {
2968
+ throwUnsupportedCurrency(feeAsset, origin);
2969
+ }
2970
+ return asset !== null && asset !== void 0 ? asset : undefined;
2971
+ };
2972
+
2955
2973
  var isAssetHub = function isAssetHub(chain) {
2956
2974
  return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
2957
2975
  };
@@ -3031,11 +3049,12 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
3031
3049
  };
3032
3050
  var getDestXcmFee = /*#__PURE__*/function () {
3033
3051
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
3034
- var api, origin, destination, currency, forwardedXcms, disableFallback, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
3052
+ var api, origin, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
3035
3053
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3036
3054
  while (1) switch (_context2.prev = _context2.next) {
3037
3055
  case 0:
3038
- api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, disableFallback = options.disableFallback;
3056
+ api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
3057
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
3039
3058
  calcPaymentInfoFee = /*#__PURE__*/function () {
3040
3059
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3041
3060
  var originAsset;
@@ -3093,42 +3112,46 @@ var getDestXcmFee = /*#__PURE__*/function () {
3093
3112
  };
3094
3113
  }();
3095
3114
  if (!(!hasDryRunSupport(destination) || !forwardedXcms)) {
3096
- _context2.next = 7;
3115
+ _context2.next = 8;
3097
3116
  break;
3098
3117
  }
3099
- _context2.next = 5;
3118
+ _context2.next = 6;
3100
3119
  return calcPaymentInfoFee();
3101
- case 5:
3120
+ case 6:
3102
3121
  _context2.t0 = _context2.sent;
3103
3122
  return _context2.abrupt("return", {
3104
3123
  fee: _context2.t0,
3105
3124
  feeType: 'paymentInfo'
3106
3125
  });
3107
- case 7:
3108
- _context2.next = 9;
3126
+ case 8:
3127
+ _context2.next = 10;
3109
3128
  return api.getDryRunXcm({
3110
3129
  originLocation: addXcmVersionHeader(createOriginLocation(origin, destination), Version.V4),
3111
3130
  xcm: forwardedXcms[1][0],
3112
3131
  node: destination,
3113
- origin: origin
3132
+ origin: origin,
3133
+ asset: asset,
3134
+ originFee: originFee,
3135
+ feeAsset: resolvedFeeAsset,
3136
+ amount: BigInt(currency.amount)
3114
3137
  });
3115
- case 9:
3138
+ case 10:
3116
3139
  dryRunResult = _context2.sent;
3117
3140
  if (dryRunResult.success) {
3118
- _context2.next = 18;
3141
+ _context2.next = 19;
3119
3142
  break;
3120
3143
  }
3121
3144
  if (!disableFallback) {
3122
- _context2.next = 13;
3145
+ _context2.next = 14;
3123
3146
  break;
3124
3147
  }
3125
3148
  return _context2.abrupt("return", {
3126
3149
  dryRunError: dryRunResult.failureReason
3127
3150
  });
3128
- case 13:
3129
- _context2.next = 15;
3151
+ case 14:
3152
+ _context2.next = 16;
3130
3153
  return calcPaymentInfoFee();
3131
- case 15:
3154
+ case 16:
3132
3155
  _context2.t1 = _context2.sent;
3133
3156
  _context2.t2 = dryRunResult.failureReason;
3134
3157
  return _context2.abrupt("return", {
@@ -3136,7 +3159,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
3136
3159
  feeType: 'paymentInfo',
3137
3160
  dryRunError: _context2.t2
3138
3161
  });
3139
- case 18:
3162
+ case 19:
3140
3163
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
3141
3164
  return _context2.abrupt("return", {
3142
3165
  fee: fee,
@@ -3144,7 +3167,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
3144
3167
  forwardedXcms: newForwardedXcms,
3145
3168
  destParaId: destParaId
3146
3169
  });
3147
- case 20:
3170
+ case 21:
3148
3171
  case "end":
3149
3172
  return _context2.stop();
3150
3173
  }
@@ -3158,49 +3181,51 @@ var getDestXcmFee = /*#__PURE__*/function () {
3158
3181
  var dryRunInternal = /*#__PURE__*/function () {
3159
3182
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
3160
3183
  var _intermediateFees$ass, _intermediateFees$bri, _destinationDryRun;
3161
- var origin, destination, currency, api, tx, senderAddress, asset, originDryRun, initialForwardedXcms, initialDestParaId, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationDryRun, nextChain, hopApi, hopDryRun, newXcms, destParaId;
3184
+ var origin, destination, currency, api, tx, senderAddress, feeAsset, resolvedFeeAsset, asset, originDryRun, initialForwardedXcms, initialDestParaId, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationDryRun, nextChain, hopApi, hopDryRun, newXcms, destParaId;
3162
3185
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3163
3186
  while (1) switch (_context.prev = _context.next) {
3164
3187
  case 0:
3165
- origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress;
3188
+ origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
3189
+ resolvedFeeAsset = feeAsset && origin === 'AssetHubPolkadot' ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
3166
3190
  asset = findAssetForNodeOrThrow(origin, currency, destination);
3167
- _context.next = 4;
3191
+ _context.next = 5;
3168
3192
  return api.getDryRunCall({
3169
3193
  tx: tx,
3170
3194
  node: origin,
3171
- address: senderAddress
3195
+ address: senderAddress,
3196
+ isFeeAsset: !!resolvedFeeAsset
3172
3197
  });
3173
- case 4:
3198
+ case 5:
3174
3199
  originDryRun = _context.sent;
3175
3200
  if (originDryRun.success) {
3176
- _context.next = 7;
3201
+ _context.next = 8;
3177
3202
  break;
3178
3203
  }
3179
3204
  return _context.abrupt("return", {
3180
3205
  origin: originDryRun
3181
3206
  });
3182
- case 7:
3207
+ case 8:
3183
3208
  initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
3184
3209
  currentOrigin = origin;
3185
3210
  forwardedXcms = initialForwardedXcms;
3186
3211
  nextParaId = initialDestParaId;
3187
3212
  intermediateFees = {};
3188
- case 12:
3213
+ case 13:
3189
3214
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length && forwardedXcms[1].length && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
3190
- _context.next = 39;
3215
+ _context.next = 40;
3191
3216
  break;
3192
3217
  }
3193
3218
  nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
3194
3219
  if (nextChain) {
3195
- _context.next = 16;
3220
+ _context.next = 17;
3196
3221
  break;
3197
3222
  }
3198
3223
  throw new Error("Unable to find TNode for paraId ".concat(nextParaId));
3199
- case 16:
3224
+ case 17:
3200
3225
  hopApi = api.clone();
3201
- _context.prev = 17;
3226
+ _context.prev = 18;
3202
3227
  if (hasDryRunSupport(nextChain)) {
3203
- _context.next = 21;
3228
+ _context.next = 22;
3204
3229
  break;
3205
3230
  }
3206
3231
  if (nextChain === destination) {
@@ -3209,19 +3234,23 @@ var dryRunInternal = /*#__PURE__*/function () {
3209
3234
  failureReason: "DryRunApi is not available on node ".concat(nextChain)
3210
3235
  };
3211
3236
  }
3212
- return _context.abrupt("break", 39);
3213
- case 21:
3214
- _context.next = 23;
3237
+ return _context.abrupt("break", 40);
3238
+ case 22:
3239
+ _context.next = 24;
3215
3240
  return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
3216
- case 23:
3217
- _context.next = 25;
3241
+ case 24:
3242
+ _context.next = 26;
3218
3243
  return hopApi.getDryRunXcm({
3219
3244
  originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, nextChain), Version.V4),
3220
3245
  xcm: forwardedXcms[1][0],
3221
3246
  node: nextChain,
3222
- origin: currentOrigin
3247
+ origin: currentOrigin,
3248
+ asset: asset,
3249
+ feeAsset: resolvedFeeAsset,
3250
+ originFee: originDryRun.fee,
3251
+ amount: BigInt(currency.amount)
3223
3252
  });
3224
- case 25:
3253
+ case 26:
3225
3254
  hopDryRun = _context.sent;
3226
3255
  if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
3227
3256
  destinationDryRun = hopDryRun;
@@ -3231,28 +3260,28 @@ var dryRunInternal = /*#__PURE__*/function () {
3231
3260
  intermediateFees.bridgeHub = hopDryRun;
3232
3261
  }
3233
3262
  if (hopDryRun.success) {
3234
- _context.next = 29;
3263
+ _context.next = 30;
3235
3264
  break;
3236
3265
  }
3237
- return _context.abrupt("break", 39);
3238
- case 29:
3266
+ return _context.abrupt("break", 40);
3267
+ case 30:
3239
3268
  newXcms = hopDryRun.forwardedXcms, destParaId = hopDryRun.destParaId;
3240
3269
  forwardedXcms = newXcms;
3241
3270
  nextParaId = destParaId;
3242
3271
  currentOrigin = nextChain;
3243
- case 33:
3244
- _context.prev = 33;
3245
- _context.next = 36;
3272
+ case 34:
3273
+ _context.prev = 34;
3274
+ _context.next = 37;
3246
3275
  return hopApi.disconnect();
3247
- case 36:
3248
- return _context.finish(33);
3249
3276
  case 37:
3250
- _context.next = 12;
3277
+ return _context.finish(34);
3278
+ case 38:
3279
+ _context.next = 13;
3251
3280
  break;
3252
- case 39:
3281
+ case 40:
3253
3282
  return _context.abrupt("return", {
3254
3283
  origin: originDryRun.success ? _objectSpread2(_objectSpread2({}, originDryRun), {}, {
3255
- currency: getNativeAssetSymbol(origin)
3284
+ currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(origin)
3256
3285
  }) : originDryRun,
3257
3286
  assetHub: (_intermediateFees$ass = intermediateFees.assetHub) !== null && _intermediateFees$ass !== void 0 && _intermediateFees$ass.success ? _objectSpread2(_objectSpread2({}, intermediateFees.assetHub), {}, {
3258
3287
  currency: getNativeAssetSymbol('AssetHubPolkadot')
@@ -3264,11 +3293,11 @@ var dryRunInternal = /*#__PURE__*/function () {
3264
3293
  currency: asset.symbol
3265
3294
  }) : destinationDryRun
3266
3295
  });
3267
- case 40:
3296
+ case 41:
3268
3297
  case "end":
3269
3298
  return _context.stop();
3270
3299
  }
3271
- }, _callee, null, [[17,, 33, 37]]);
3300
+ }, _callee, null, [[18,, 34, 38]]);
3272
3301
  }));
3273
3302
  return function dryRunInternal(_x) {
3274
3303
  return _ref.apply(this, arguments);
@@ -4385,69 +4414,71 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
4385
4414
 
4386
4415
  var getOriginXcmFee = /*#__PURE__*/function () {
4387
4416
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4388
- var api, tx, origin, destination, senderAddress, disableFallback, currency, rawFee, dryRunResult, _rawFee, fee, forwardedXcms, destParaId;
4417
+ var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, resolvedFeeAsset, currencySymbol, rawFee, dryRunResult, _rawFee, fee, forwardedXcms, destParaId;
4389
4418
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4390
4419
  while (1) switch (_context.prev = _context.next) {
4391
4420
  case 0:
4392
- api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback;
4393
- _context.next = 3;
4421
+ api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency;
4422
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4423
+ _context.next = 4;
4394
4424
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
4395
- case 3:
4396
- currency = getNativeAssetSymbol(origin);
4425
+ case 4:
4426
+ currencySymbol = resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(origin);
4397
4427
  if (hasDryRunSupport(origin)) {
4398
- _context.next = 9;
4428
+ _context.next = 10;
4399
4429
  break;
4400
4430
  }
4401
- _context.next = 7;
4431
+ _context.next = 8;
4402
4432
  return api.calculateTransactionFee(tx, senderAddress);
4403
- case 7:
4433
+ case 8:
4404
4434
  rawFee = _context.sent;
4405
4435
  return _context.abrupt("return", {
4406
4436
  fee: padFee(rawFee, origin, destination, 'origin'),
4407
- currency: currency,
4437
+ currency: currencySymbol,
4408
4438
  feeType: 'paymentInfo'
4409
4439
  });
4410
- case 9:
4411
- _context.next = 11;
4440
+ case 10:
4441
+ _context.next = 12;
4412
4442
  return api.getDryRunCall({
4413
4443
  tx: tx,
4414
4444
  node: origin,
4415
- address: senderAddress
4445
+ address: senderAddress,
4446
+ isFeeAsset: !!resolvedFeeAsset
4416
4447
  });
4417
- case 11:
4448
+ case 12:
4418
4449
  dryRunResult = _context.sent;
4419
4450
  if (dryRunResult.success) {
4420
- _context.next = 19;
4451
+ _context.next = 20;
4421
4452
  break;
4422
4453
  }
4423
4454
  if (!disableFallback) {
4424
- _context.next = 15;
4455
+ _context.next = 16;
4425
4456
  break;
4426
4457
  }
4427
4458
  return _context.abrupt("return", {
4428
4459
  dryRunError: dryRunResult.failureReason
4429
4460
  });
4430
- case 15:
4431
- _context.next = 17;
4461
+ case 16:
4462
+ _context.next = 18;
4432
4463
  return api.calculateTransactionFee(tx, senderAddress);
4433
- case 17:
4464
+ case 18:
4434
4465
  _rawFee = _context.sent;
4435
4466
  return _context.abrupt("return", {
4436
4467
  fee: padFee(_rawFee, origin, destination, 'origin'),
4437
- currency: currency,
4468
+ currency: currencySymbol,
4438
4469
  feeType: 'paymentInfo',
4439
4470
  dryRunError: dryRunResult.failureReason
4440
4471
  });
4441
- case 19:
4472
+ case 20:
4442
4473
  fee = dryRunResult.fee, forwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
4443
4474
  return _context.abrupt("return", {
4444
4475
  fee: fee,
4445
4476
  feeType: 'dryRun',
4446
- currency: currency,
4477
+ currency: currencySymbol,
4447
4478
  forwardedXcms: forwardedXcms,
4448
4479
  destParaId: destParaId
4449
4480
  });
4450
- case 21:
4481
+ case 22:
4451
4482
  case "end":
4452
4483
  return _context.stop();
4453
4484
  }
@@ -4487,11 +4518,11 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
4487
4518
 
4488
4519
  var getXcmFee = /*#__PURE__*/function () {
4489
4520
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4490
- var api, tx, origin, destination, senderAddress, address, currency, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4521
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback;
4491
4522
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4492
4523
  while (1) switch (_context.prev = _context.next) {
4493
4524
  case 0:
4494
- api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, disableFallback = _ref.disableFallback;
4525
+ api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset, disableFallback = _ref.disableFallback;
4495
4526
  asset = findAssetForNodeOrThrow(origin, currency, destination); // Origin fee = execution fee + delivery fees
4496
4527
  _context.next = 4;
4497
4528
  return getOriginXcmFee({
@@ -4500,6 +4531,8 @@ var getXcmFee = /*#__PURE__*/function () {
4500
4531
  origin: origin,
4501
4532
  destination: destination,
4502
4533
  senderAddress: senderAddress,
4534
+ feeAsset: feeAsset,
4535
+ currency: currency,
4503
4536
  disableFallback: disableFallback
4504
4537
  });
4505
4538
  case 4:
@@ -4533,6 +4566,8 @@ var getXcmFee = /*#__PURE__*/function () {
4533
4566
  destination: destination,
4534
4567
  currency: currency,
4535
4568
  address: address,
4569
+ asset: asset,
4570
+ originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
4536
4571
  senderAddress: senderAddress,
4537
4572
  disableFallback: disableFallback
4538
4573
  });
@@ -4596,6 +4631,9 @@ var getXcmFee = /*#__PURE__*/function () {
4596
4631
  currency: currency,
4597
4632
  address: address,
4598
4633
  senderAddress: senderAddress,
4634
+ asset: asset,
4635
+ feeAsset: feeAsset,
4636
+ originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
4599
4637
  disableFallback: disableFallback
4600
4638
  });
4601
4639
  case 45:
@@ -4633,6 +4671,8 @@ var getXcmFee = /*#__PURE__*/function () {
4633
4671
  destination: destination,
4634
4672
  currency: currency,
4635
4673
  address: address,
4674
+ asset: asset,
4675
+ originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
4636
4676
  senderAddress: senderAddress,
4637
4677
  disableFallback: disableFallback
4638
4678
  });
@@ -4847,15 +4887,6 @@ var resolveAsset = function resolveAsset(currency, origin, destination, assetChe
4847
4887
  return assetCheckEnabled ? findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null) : null;
4848
4888
  };
4849
4889
 
4850
- var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
4851
- var asset = findAsset(origin, feeAsset, !isTMultiLocation(destination) ? destination : null);
4852
- var usesRawOverriddenMultiAssets = 'multiasset' in currency && currency.multiasset.every(isTMultiAsset);
4853
- if (!asset && !usesRawOverriddenMultiAssets) {
4854
- throwUnsupportedCurrency(feeAsset, origin);
4855
- }
4856
- return asset !== null && asset !== void 0 ? asset : undefined;
4857
- };
4858
-
4859
4890
  var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
4860
4891
  var origin = _ref.from,
4861
4892
  destination = _ref.to,
@@ -6346,7 +6377,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6346
6377
  key: "handleExecuteTransfer",
6347
6378
  value: function () {
6348
6379
  var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
6349
- var api, senderAddress, asset, MIN_FEE, maxU64, dummyTx, dryRunResult, feeDotShifted, toMl, feeConverted, feeConvertedPadded;
6380
+ var api, senderAddress, asset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult, feeDotShifted, toMl, feeConverted, feeConvertedPadded;
6350
6381
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6351
6382
  while (1) switch (_context3.prev = _context3.next) {
6352
6383
  case 0:
@@ -6358,53 +6389,58 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6358
6389
  throw new Error('Please provide senderAddress');
6359
6390
  case 3:
6360
6391
  validateAddress(senderAddress, this.node, false);
6361
- MIN_FEE = 150000n;
6392
+ decimals = asset.decimals;
6393
+ multiplier = decimals > 10 ? 0.4 : 0.15;
6394
+ base = BigInt(Math.pow(10, decimals));
6395
+ scaledMultiplier = BigInt(Math.floor(multiplier * Math.pow(10, decimals)));
6396
+ MIN_FEE = base * scaledMultiplier / BigInt(Math.pow(10, decimals));
6362
6397
  maxU64 = (1n << 64n) - 1n;
6363
6398
  dummyTx = createExecuteXcm(input, {
6364
6399
  refTime: maxU64,
6365
6400
  proofSize: maxU64
6366
6401
  }, MIN_FEE);
6367
- _context3.next = 9;
6402
+ _context3.next = 13;
6368
6403
  return api.getDryRunCall({
6369
6404
  node: this.node,
6370
6405
  tx: dummyTx,
6371
- address: senderAddress
6406
+ address: senderAddress,
6407
+ isFeeAsset: false
6372
6408
  });
6373
- case 9:
6409
+ case 13:
6374
6410
  dryRunResult = _context3.sent;
6375
6411
  if (dryRunResult.success) {
6376
- _context3.next = 12;
6412
+ _context3.next = 16;
6377
6413
  break;
6378
6414
  }
6379
6415
  throw new Error("Dry run failed: ".concat(dryRunResult.failureReason));
6380
- case 12:
6416
+ case 16:
6381
6417
  if (dryRunResult.weight) {
6382
- _context3.next = 14;
6418
+ _context3.next = 18;
6383
6419
  break;
6384
6420
  }
6385
6421
  throw new Error('Dry run failed: weight not found');
6386
- case 14:
6422
+ case 18:
6387
6423
  feeDotShifted = dryRunResult.fee / 10n;
6388
6424
  toMl = transformMultiLocation(asset.multiLocation);
6389
- _context3.next = 18;
6425
+ _context3.next = 22;
6390
6426
  return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
6391
- case 18:
6427
+ case 22:
6392
6428
  feeConverted = _context3.sent;
6393
6429
  if (feeConverted) {
6394
- _context3.next = 21;
6430
+ _context3.next = 25;
6395
6431
  break;
6396
6432
  }
6397
6433
  throw new Error("Pool DOT -> ".concat(asset.symbol, " not found."));
6398
- case 21:
6434
+ case 25:
6399
6435
  if (!(BigInt(asset.amount) - feeConverted < 0)) {
6400
- _context3.next = 23;
6436
+ _context3.next = 27;
6401
6437
  break;
6402
6438
  }
6403
6439
  throw new Error("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
6404
- case 23:
6440
+ case 27:
6405
6441
  feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
6406
6442
  return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
6407
- case 25:
6443
+ case 29:
6408
6444
  case "end":
6409
6445
  return _context3.stop();
6410
6446
  }
@@ -6430,7 +6466,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6430
6466
  if (!isAssetEqual(feeAsset, asset)) {
6431
6467
  throw new InvalidCurrencyError("Fee asset does not match transfer asset.");
6432
6468
  }
6433
- return Promise.resolve(this.handleExecuteTransfer(input));
6469
+ var isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
6470
+ if (!isNativeAsset) {
6471
+ return Promise.resolve(this.handleExecuteTransfer(input));
6472
+ }
6434
6473
  }
6435
6474
  if (destination === 'AssetHubKusama') {
6436
6475
  return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
@@ -8741,59 +8780,63 @@ var getOriginFeeDetails = /*#__PURE__*/function () {
8741
8780
 
8742
8781
  var getTransferableAmountInternal = /*#__PURE__*/function () {
8743
8782
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8744
- var api, senderAddress, node, currency, tx, asset, balance, ed, edBN, isNativeAsset, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
8783
+ var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, edBN, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
8745
8784
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8746
8785
  while (1) switch (_context.prev = _context.next) {
8747
8786
  case 0:
8748
- api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.node, currency = _ref.currency, tx = _ref.tx;
8787
+ api = _ref.api, senderAddress = _ref.senderAddress, node = _ref.origin, destination = _ref.destination, currency = _ref.currency, tx = _ref.tx, feeAsset = _ref.feeAsset;
8749
8788
  validateAddress(senderAddress, node, false);
8789
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, node, destination, currency) : undefined;
8750
8790
  asset = findAssetForNodeOrThrow(node, currency, null);
8751
- _context.next = 5;
8791
+ _context.next = 6;
8752
8792
  return getAssetBalanceInternal({
8753
8793
  api: api,
8754
8794
  address: senderAddress,
8755
8795
  node: node,
8756
8796
  currency: currency
8757
8797
  });
8758
- case 5:
8798
+ case 6:
8759
8799
  balance = _context.sent;
8760
8800
  ed = getExistentialDeposit(node, currency);
8761
8801
  if (!(ed === null)) {
8762
- _context.next = 9;
8802
+ _context.next = 10;
8763
8803
  break;
8764
8804
  }
8765
8805
  throw new Error("Cannot get existential deposit for currency ".concat(JSON.stringify(currency), "."));
8766
- case 9:
8806
+ case 10:
8767
8807
  edBN = BigInt(ed);
8768
8808
  isNativeAsset = getNativeAssetSymbol(node) === asset.symbol;
8809
+ shouldSubstractFee = isNativeAsset || node === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
8769
8810
  feeToSubtract = 0n;
8770
- if (!isNativeAsset) {
8771
- _context.next = 20;
8811
+ if (!shouldSubstractFee) {
8812
+ _context.next = 22;
8772
8813
  break;
8773
8814
  }
8774
- _context.next = 15;
8815
+ _context.next = 17;
8775
8816
  return getOriginXcmFee({
8776
8817
  api: api,
8777
8818
  tx: tx,
8778
8819
  origin: node,
8779
8820
  destination: node,
8780
8821
  senderAddress: senderAddress,
8822
+ feeAsset: feeAsset,
8823
+ currency: currency,
8781
8824
  disableFallback: false
8782
8825
  });
8783
- case 15:
8826
+ case 17:
8784
8827
  _yield$getOriginXcmFe = _context.sent;
8785
8828
  fee = _yield$getOriginXcmFe.fee;
8786
8829
  if (!(fee === undefined)) {
8787
- _context.next = 19;
8830
+ _context.next = 21;
8788
8831
  break;
8789
8832
  }
8790
8833
  throw new Error("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(node, "."));
8791
- case 19:
8834
+ case 21:
8792
8835
  feeToSubtract = fee;
8793
- case 20:
8836
+ case 22:
8794
8837
  transferable = balance - edBN - feeToSubtract;
8795
8838
  return _context.abrupt("return", transferable > 0n ? transferable : 0n);
8796
- case 22:
8839
+ case 24:
8797
8840
  case "end":
8798
8841
  return _context.stop();
8799
8842
  }
@@ -8836,70 +8879,89 @@ var getTransferableAmount = /*#__PURE__*/function () {
8836
8879
 
8837
8880
  var getTransferInfo = /*#__PURE__*/function () {
8838
8881
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8839
- var api, tx, origin, destination, senderAddress, address, currency, destApi, destAsset, destCurrency, originBalanceNative, originBalance, destBalance, edOrigin, edOriginBn, edDest, edDestBn, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, _yield$getXcmFee$dest, destFee, destFeeCurrency, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, originBalanceAfter, originBalanceNativeAfter, originBalanceNativeSufficient, originBalanceSufficient, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, destXcmFeeBalanceAfter;
8882
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, resolvedFeeAsset, destApi, destAsset, destCurrency, originBalanceFee, originBalance, destBalance, edOrigin, edOriginBn, edDest, edDestBn, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, _yield$getXcmFee$dest, destFee, destFeeCurrency, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, destAmount, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, destXcmFeeBalanceAfter;
8840
8883
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8841
8884
  while (1) switch (_context.prev = _context.next) {
8842
8885
  case 0:
8843
- api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
8844
- _context.next = 3;
8886
+ api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
8887
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
8888
+ _context.next = 4;
8845
8889
  return api.init(origin);
8846
- case 3:
8890
+ case 4:
8847
8891
  api.setDisconnectAllowed(false);
8848
8892
  destApi = api.clone();
8849
- _context.next = 7;
8893
+ _context.next = 8;
8850
8894
  return destApi.init(destination);
8851
- case 7:
8895
+ case 8:
8852
8896
  destApi.setDisconnectAllowed(false);
8853
- _context.prev = 8;
8897
+ _context.prev = 9;
8854
8898
  destAsset = findAssetOnDestOrThrow(origin, destination, currency);
8855
8899
  destCurrency = destAsset.multiLocation ? {
8856
8900
  multilocation: destAsset.multiLocation
8857
8901
  } : {
8858
8902
  symbol: destAsset.symbol
8859
8903
  };
8860
- _context.next = 13;
8861
- return getBalanceNativeInternal({
8904
+ if (!(feeAsset && resolvedFeeAsset)) {
8905
+ _context.next = 18;
8906
+ break;
8907
+ }
8908
+ _context.next = 15;
8909
+ return getAssetBalanceInternal({
8910
+ api: api,
8862
8911
  address: senderAddress,
8863
8912
  node: origin,
8864
- api: api
8913
+ currency: feeAsset
8865
8914
  });
8866
- case 13:
8867
- originBalanceNative = _context.sent;
8868
- _context.next = 16;
8915
+ case 15:
8916
+ _context.t0 = _context.sent;
8917
+ _context.next = 21;
8918
+ break;
8919
+ case 18:
8920
+ _context.next = 20;
8921
+ return getBalanceNativeInternal({
8922
+ api: api,
8923
+ address: senderAddress,
8924
+ node: origin
8925
+ });
8926
+ case 20:
8927
+ _context.t0 = _context.sent;
8928
+ case 21:
8929
+ originBalanceFee = _context.t0;
8930
+ _context.next = 24;
8869
8931
  return getAssetBalanceInternal({
8870
8932
  api: api,
8871
8933
  address: senderAddress,
8872
8934
  node: origin,
8873
8935
  currency: currency
8874
8936
  });
8875
- case 16:
8937
+ case 24:
8876
8938
  originBalance = _context.sent;
8877
- _context.next = 19;
8939
+ _context.next = 27;
8878
8940
  return getAssetBalanceInternal({
8879
8941
  api: destApi,
8880
8942
  address: address,
8881
8943
  node: destination,
8882
8944
  currency: destCurrency
8883
8945
  });
8884
- case 19:
8946
+ case 27:
8885
8947
  destBalance = _context.sent;
8886
8948
  edOrigin = getExistentialDeposit(origin, currency);
8887
8949
  if (edOrigin) {
8888
- _context.next = 23;
8950
+ _context.next = 31;
8889
8951
  break;
8890
8952
  }
8891
8953
  throw new InvalidParameterError("Existential deposit not found for ".concat(origin, " with currency ").concat(JSON.stringify(currency)));
8892
- case 23:
8954
+ case 31:
8893
8955
  edOriginBn = BigInt(edOrigin);
8894
8956
  edDest = getExistentialDeposit(destination, destCurrency);
8895
8957
  if (edDest) {
8896
- _context.next = 27;
8958
+ _context.next = 35;
8897
8959
  break;
8898
8960
  }
8899
8961
  throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency)));
8900
- case 27:
8962
+ case 35:
8901
8963
  edDestBn = BigInt(edDest);
8902
- _context.next = 30;
8964
+ _context.next = 38;
8903
8965
  return getXcmFee({
8904
8966
  api: api,
8905
8967
  tx: tx,
@@ -8908,9 +8970,10 @@ var getTransferInfo = /*#__PURE__*/function () {
8908
8970
  senderAddress: senderAddress,
8909
8971
  address: address,
8910
8972
  currency: currency,
8973
+ feeAsset: feeAsset,
8911
8974
  disableFallback: false
8912
8975
  });
8913
- case 30:
8976
+ case 38:
8914
8977
  _yield$getXcmFee = _context.sent;
8915
8978
  _yield$getXcmFee$orig = _yield$getXcmFee.origin;
8916
8979
  originFee = _yield$getXcmFee$orig.fee;
@@ -8919,39 +8982,42 @@ var getTransferInfo = /*#__PURE__*/function () {
8919
8982
  destFee = _yield$getXcmFee$dest.fee;
8920
8983
  destFeeCurrency = _yield$getXcmFee$dest.currency;
8921
8984
  if (!(originFee === undefined)) {
8922
- _context.next = 39;
8985
+ _context.next = 47;
8923
8986
  break;
8924
8987
  }
8925
8988
  throw new Error("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(origin, "."));
8926
- case 39:
8989
+ case 47:
8927
8990
  isDestFeeInNativeCurrency = destFeeCurrency === getNativeAssetSymbol(destination);
8928
8991
  if (!isDestFeeInNativeCurrency) {
8929
- _context.next = 47;
8992
+ _context.next = 55;
8930
8993
  break;
8931
8994
  }
8932
- _context.next = 43;
8995
+ _context.next = 51;
8933
8996
  return getBalanceNativeInternal({
8934
8997
  address: address,
8935
8998
  node: destination,
8936
8999
  api: destApi
8937
9000
  });
8938
- case 43:
9001
+ case 51:
8939
9002
  destRecipientNativeBalance = _context.sent;
8940
9003
  destXcmFeeBalance = destRecipientNativeBalance;
8941
- _context.next = 48;
9004
+ _context.next = 56;
8942
9005
  break;
8943
- case 47:
9006
+ case 55:
8944
9007
  destXcmFeeBalance = destBalance;
8945
- case 48:
9008
+ case 56:
9009
+ isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, destAsset);
8946
9010
  originBalanceAfter = originBalance - BigInt(currency.amount);
8947
- originBalanceNativeAfter = originBalanceNative - originFee;
8948
- originBalanceNativeSufficient = originBalanceNative >= originFee;
9011
+ originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - BigInt(currency.amount) : originBalanceFee - originFee;
9012
+ originBalanceNativeSufficient = originBalanceFee >= originFee;
8949
9013
  originBalanceSufficient = originBalanceAfter >= edOriginBn;
8950
- destBalanceSufficient = BigInt(currency.amount) - destFee > (destBalance < edDestBn ? edDestBn : 0);
9014
+ destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
9015
+ destBalanceSufficient = destAmount - destFee > (destBalance < edDestBn ? edDestBn : 0);
8951
9016
  destBalanceSufficientResult = destFeeCurrency !== destAsset.symbol ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
8952
- destBalanceAfter = destBalance - (destFeeCurrency === destAsset.symbol ? destFee : 0n) + BigInt(currency.amount);
9017
+ destBalanceAfter = destBalance - (destFeeCurrency === destAsset.symbol ? destFee : 0n) + destAmount;
8953
9018
  destbalanceAfterResult = destFeeCurrency !== destAsset.symbol ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
8954
- destXcmFeeBalanceAfter = destXcmFeeBalance - destFee + (destFeeCurrency === destAsset.symbol ? BigInt(currency.amount) : 0n);
9019
+ receivedAmount = destbalanceAfterResult instanceof UnableToComputeError ? destbalanceAfterResult : destbalanceAfterResult - destBalance;
9020
+ destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFee + (destFeeCurrency === destAsset.symbol ? BigInt(currency.amount) : 0n);
8955
9021
  return _context.abrupt("return", {
8956
9022
  chain: {
8957
9023
  origin: origin,
@@ -8969,14 +9035,15 @@ var getTransferInfo = /*#__PURE__*/function () {
8969
9035
  xcmFee: {
8970
9036
  sufficient: originBalanceNativeSufficient,
8971
9037
  fee: originFee,
8972
- balance: originBalanceNative,
8973
- balanceAfter: originBalanceNativeAfter,
9038
+ balance: originBalanceFee,
9039
+ balanceAfter: originBalanceFeeAfter,
8974
9040
  currencySymbol: originFeeCurrency
8975
9041
  }
8976
9042
  },
8977
9043
  destination: {
8978
9044
  receivedCurrency: {
8979
9045
  sufficient: destBalanceSufficientResult,
9046
+ receivedAmount: receivedAmount,
8980
9047
  balance: destBalance,
8981
9048
  balanceAfter: destbalanceAfterResult,
8982
9049
  currencySymbol: destAsset.symbol,
@@ -8990,22 +9057,22 @@ var getTransferInfo = /*#__PURE__*/function () {
8990
9057
  }
8991
9058
  }
8992
9059
  });
8993
- case 58:
8994
- _context.prev = 58;
9060
+ case 69:
9061
+ _context.prev = 69;
8995
9062
  api.setDisconnectAllowed(true);
8996
9063
  destApi.setDisconnectAllowed(true);
8997
- _context.next = 63;
9064
+ _context.next = 74;
8998
9065
  return api.disconnect();
8999
- case 63:
9000
- _context.next = 65;
9066
+ case 74:
9067
+ _context.next = 76;
9001
9068
  return destApi.disconnect();
9002
- case 65:
9003
- return _context.finish(58);
9004
- case 66:
9069
+ case 76:
9070
+ return _context.finish(69);
9071
+ case 77:
9005
9072
  case "end":
9006
9073
  return _context.stop();
9007
9074
  }
9008
- }, _callee, null, [[8,, 58, 66]]);
9075
+ }, _callee, null, [[9,, 69, 77]]);
9009
9076
  }));
9010
9077
  return function getTransferInfo(_x) {
9011
9078
  return _ref2.apply(this, arguments);
@@ -9014,11 +9081,11 @@ var getTransferInfo = /*#__PURE__*/function () {
9014
9081
 
9015
9082
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9016
9083
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9017
- var api, tx, origin, destination, address, senderAddress, currency, destApi, asset, destCurrency, ed, edBN, balance, _yield$getXcmFee, dryRunError, _yield$getXcmFee$dest, destFee, destFeeCurrency, destDryRunError;
9084
+ var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, _yield$getXcmFee, dryRunError, _yield$getXcmFee$dest, destFee, destFeeCurrency, destDryRunError;
9018
9085
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9019
9086
  while (1) switch (_context.prev = _context.next) {
9020
9087
  case 0:
9021
- api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, address = _ref.address, senderAddress = _ref.senderAddress, currency = _ref.currency;
9088
+ api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, address = _ref.address, senderAddress = _ref.senderAddress, feeAsset = _ref.feeAsset, currency = _ref.currency;
9022
9089
  validateAddress(address, destination);
9023
9090
  destApi = api.clone();
9024
9091
  _context.next = 5;
@@ -9056,6 +9123,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9056
9123
  senderAddress: senderAddress,
9057
9124
  address: address,
9058
9125
  currency: currency,
9126
+ feeAsset: feeAsset,
9059
9127
  disableFallback: false
9060
9128
  });
9061
9129
  case 16:
@@ -9447,11 +9515,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
9447
9515
  key: "dryRun",
9448
9516
  value: function () {
9449
9517
  var _dryRun2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
9450
- var _this$_options2, to, address, senderAddress, tx;
9518
+ var _this$_options2, to, address, senderAddress, feeAsset, tx;
9451
9519
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
9452
9520
  while (1) switch (_context3.prev = _context3.next) {
9453
9521
  case 0:
9454
- _this$_options2 = this._options, to = _this$_options2.to, address = _this$_options2.address, senderAddress = _this$_options2.senderAddress;
9522
+ _this$_options2 = this._options, to = _this$_options2.to, address = _this$_options2.address, senderAddress = _this$_options2.senderAddress, feeAsset = _this$_options2.feeAsset;
9455
9523
  _context3.next = 3;
9456
9524
  return this.build();
9457
9525
  case 3:
@@ -9481,7 +9549,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
9481
9549
  origin: this._options.from,
9482
9550
  destination: to,
9483
9551
  currency: this._options.currency,
9484
- senderAddress: this._options.senderAddress
9552
+ senderAddress: this._options.senderAddress,
9553
+ feeAsset: feeAsset
9485
9554
  }));
9486
9555
  case 11:
9487
9556
  case "end":
@@ -9510,6 +9579,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
9510
9579
  to,
9511
9580
  address,
9512
9581
  senderAddress,
9582
+ feeAsset,
9513
9583
  tx,
9514
9584
  _args4 = arguments;
9515
9585
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -9518,7 +9588,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
9518
9588
  _ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {
9519
9589
  disableFallback: false
9520
9590
  }, disableFallback = _ref.disableFallback;
9521
- _this$_options3 = this._options, from = _this$_options3.from, to = _this$_options3.to, address = _this$_options3.address, senderAddress = _this$_options3.senderAddress;
9591
+ _this$_options3 = this._options, from = _this$_options3.from, to = _this$_options3.to, address = _this$_options3.address, senderAddress = _this$_options3.senderAddress, feeAsset = _this$_options3.feeAsset;
9522
9592
  assertToIsStringAndNoEthereum(to);
9523
9593
  assertAddressIsString(address);
9524
9594
  _context4.next = 6;
@@ -9535,6 +9605,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
9535
9605
  senderAddress: senderAddress,
9536
9606
  address: address,
9537
9607
  currency: this._options.currency,
9608
+ feeAsset: feeAsset,
9538
9609
  disableFallback: disableFallback
9539
9610
  });
9540
9611
  case 10:
@@ -9572,6 +9643,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
9572
9643
  from,
9573
9644
  to,
9574
9645
  senderAddress,
9646
+ currency,
9647
+ feeAsset,
9575
9648
  tx,
9576
9649
  _args5 = arguments;
9577
9650
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -9580,7 +9653,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
9580
9653
  _ref2 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {
9581
9654
  disableFallback: false
9582
9655
  }, disableFallback = _ref2.disableFallback;
9583
- _this$_options4 = this._options, from = _this$_options4.from, to = _this$_options4.to, senderAddress = _this$_options4.senderAddress;
9656
+ _this$_options4 = this._options, from = _this$_options4.from, to = _this$_options4.to, senderAddress = _this$_options4.senderAddress, currency = _this$_options4.currency, feeAsset = _this$_options4.feeAsset;
9584
9657
  assertToIsStringAndNoEthereum(to);
9585
9658
  _context5.next = 5;
9586
9659
  return this.build();
@@ -9594,6 +9667,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
9594
9667
  origin: from,
9595
9668
  destination: to,
9596
9669
  senderAddress: senderAddress,
9670
+ currency: currency,
9671
+ feeAsset: feeAsset,
9597
9672
  disableFallback: disableFallback
9598
9673
  });
9599
9674
  case 9:
@@ -9724,26 +9799,29 @@ var GeneralBuilder = /*#__PURE__*/function () {
9724
9799
  key: "getTransferableAmount",
9725
9800
  value: (function () {
9726
9801
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9727
- var _this$_options7, from, senderAddress, currency, tx;
9802
+ var _this$_options7, from, to, senderAddress, currency, feeAsset, tx;
9728
9803
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9729
9804
  while (1) switch (_context8.prev = _context8.next) {
9730
9805
  case 0:
9731
- _this$_options7 = this._options, from = _this$_options7.from, senderAddress = _this$_options7.senderAddress, currency = _this$_options7.currency;
9732
- _context8.next = 3;
9806
+ _this$_options7 = this._options, from = _this$_options7.from, to = _this$_options7.to, senderAddress = _this$_options7.senderAddress, currency = _this$_options7.currency, feeAsset = _this$_options7.feeAsset;
9807
+ assertToIsStringAndNoEthereum(to);
9808
+ _context8.next = 4;
9733
9809
  return this.build();
9734
- case 3:
9810
+ case 4:
9735
9811
  tx = _context8.sent;
9736
- _context8.next = 6;
9812
+ _context8.next = 7;
9737
9813
  return getTransferableAmount({
9738
9814
  api: this.api,
9739
9815
  tx: tx,
9740
- node: from,
9816
+ origin: from,
9817
+ destination: to,
9741
9818
  senderAddress: senderAddress,
9819
+ feeAsset: feeAsset,
9742
9820
  currency: currency
9743
9821
  });
9744
- case 6:
9745
- return _context8.abrupt("return", _context8.sent);
9746
9822
  case 7:
9823
+ return _context8.abrupt("return", _context8.sent);
9824
+ case 8:
9747
9825
  case "end":
9748
9826
  return _context8.stop();
9749
9827
  }
@@ -9764,11 +9842,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
9764
9842
  key: "verifyEdOnDestination",
9765
9843
  value: (function () {
9766
9844
  var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9767
- var _this$_options8, from, to, address, currency, senderAddress, tx;
9845
+ var _this$_options8, from, to, address, currency, senderAddress, feeAsset, tx;
9768
9846
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9769
9847
  while (1) switch (_context9.prev = _context9.next) {
9770
9848
  case 0:
9771
- _this$_options8 = this._options, from = _this$_options8.from, to = _this$_options8.to, address = _this$_options8.address, currency = _this$_options8.currency, senderAddress = _this$_options8.senderAddress;
9849
+ _this$_options8 = this._options, from = _this$_options8.from, to = _this$_options8.to, address = _this$_options8.address, currency = _this$_options8.currency, senderAddress = _this$_options8.senderAddress, feeAsset = _this$_options8.feeAsset;
9772
9850
  assertToIsStringAndNoEthereum(to);
9773
9851
  assertAddressIsString(address);
9774
9852
  _context9.next = 5;
@@ -9782,6 +9860,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
9782
9860
  destination: to,
9783
9861
  address: address,
9784
9862
  senderAddress: senderAddress,
9863
+ feeAsset: feeAsset,
9785
9864
  currency: currency
9786
9865
  }));
9787
9866
  case 7:
@@ -9805,11 +9884,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
9805
9884
  key: "getTransferInfo",
9806
9885
  value: (function () {
9807
9886
  var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0() {
9808
- var _this$_options9, from, to, address, currency, senderAddress, tx;
9887
+ var _this$_options9, from, to, address, currency, senderAddress, feeAsset, tx;
9809
9888
  return _regeneratorRuntime().wrap(function _callee0$(_context0) {
9810
9889
  while (1) switch (_context0.prev = _context0.next) {
9811
9890
  case 0:
9812
- _this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, senderAddress = _this$_options9.senderAddress;
9891
+ _this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
9813
9892
  assertToIsStringAndNoEthereum(to);
9814
9893
  assertAddressIsString(address);
9815
9894
  _context0.next = 5;
@@ -9823,7 +9902,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
9823
9902
  destination: to,
9824
9903
  address: address,
9825
9904
  senderAddress: senderAddress,
9826
- currency: currency
9905
+ currency: currency,
9906
+ feeAsset: feeAsset
9827
9907
  }));
9828
9908
  case 7:
9829
9909
  case "end":