@paraspell/sdk-core 8.9.10 → 8.11.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.
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@
3
3
  var sdkCommon = require('@paraspell/sdk-common');
4
4
  var ethers = require('ethers');
5
5
  var assets = require('@paraspell/assets');
6
- var viem = require('viem');
7
6
  var pallets = require('@paraspell/pallets');
7
+ var viem = require('viem');
8
8
 
9
9
  function _arrayLikeToArray(r, a) {
10
10
  (null == a || a > r.length) && (a = r.length);
@@ -824,156 +824,23 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
824
824
  }]);
825
825
  }();
826
826
 
827
- var getParaEthTransferFees = /*#__PURE__*/function () {
828
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
829
- var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, transferAssethubExecutionFee, finalBridgeFee, finalAssethubExecutionFee;
830
- return _regeneratorRuntime().wrap(function _callee$(_context) {
831
- while (1) switch (_context.prev = _context.next) {
832
- case 0:
833
- DEFAULT_FEE = 2750872500000n;
834
- _context.next = 3;
835
- return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
836
- case 3:
837
- feeStorageItem = _context.sent;
838
- leFeeHex = feeStorageItem.replace('0x', '');
839
- _context.next = 7;
840
- return ahApi.disconnect();
841
- case 7:
842
- bytes = leFeeHex.match(/.{1,2}/g) || [];
843
- reversedHex = bytes.reverse().join('');
844
- validReversedHex = reversedHex === '' ? '0' : reversedHex;
845
- leFee = BigInt('0x' + validReversedHex);
846
- transferBridgeFee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
847
- transferAssethubExecutionFee = 2200000000n;
848
- finalBridgeFee = transferBridgeFee * 110n / 100n;
849
- finalAssethubExecutionFee = transferAssethubExecutionFee * 110n / 100n;
850
- return _context.abrupt("return", [finalBridgeFee, finalAssethubExecutionFee]);
851
- case 16:
852
- case "end":
853
- return _context.stop();
854
- }
855
- }, _callee);
856
- }));
857
- return function getParaEthTransferFees(_x) {
858
- return _ref.apply(this, arguments);
859
- };
860
- }();
861
-
862
- var isEthersSigner = function isEthersSigner(signer) {
863
- return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
864
- };
865
- var isEthersContract = function isEthersContract(contract) {
866
- return !('abi' in contract);
867
- };
868
-
869
- var abi$1 = [
870
- {
871
- inputs: [
872
- {
873
- internalType: "address",
874
- name: "currencyAddress",
875
- type: "address"
876
- },
877
- {
878
- internalType: "uint256",
879
- name: "amount",
880
- type: "uint256"
881
- },
882
- {
883
- components: [
884
- {
885
- internalType: "uint8",
886
- name: "parents",
887
- type: "uint8"
888
- },
889
- {
890
- internalType: "bytes[]",
891
- name: "interior",
892
- type: "bytes[]"
893
- }
894
- ],
895
- internalType: "struct Xtokens.Multilocation",
896
- name: "destination",
897
- type: "tuple"
898
- },
899
- {
900
- internalType: "uint64",
901
- name: "weight",
902
- type: "uint64"
903
- }
904
- ],
905
- name: "transfer",
906
- outputs: [
907
- ],
908
- stateMutability: "nonpayable",
909
- type: "function"
910
- },
911
- {
912
- inputs: [
913
- {
914
- components: [
915
- {
916
- internalType: "address",
917
- name: "currencyAddress",
918
- type: "address"
919
- },
920
- {
921
- internalType: "uint256",
922
- name: "amount",
923
- type: "uint256"
924
- }
925
- ],
926
- internalType: "struct Xtokens.Currency[]",
927
- name: "currencies",
928
- type: "tuple[]"
929
- },
930
- {
931
- internalType: "uint32",
932
- name: "feeItem",
933
- type: "uint32"
934
- },
935
- {
936
- components: [
937
- {
938
- internalType: "uint8",
939
- name: "parents",
940
- type: "uint8"
941
- },
942
- {
943
- internalType: "bytes[]",
944
- name: "interior",
945
- type: "bytes[]"
946
- }
947
- ],
948
- internalType: "struct Xtokens.Multilocation",
949
- name: "destination",
950
- type: "tuple"
951
- },
952
- {
953
- internalType: "uint64",
954
- name: "weight",
955
- type: "uint64"
956
- }
957
- ],
958
- name: "transferMultiCurrencies",
959
- outputs: [
960
- ],
961
- stateMutability: "nonpayable",
962
- type: "function"
963
- }
964
- ];
965
-
966
- // Inspired by Moonbeam XCM-SDK
967
- // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/utils/src/format/asset.ts#L1
968
- var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
969
- if (id.startsWith('0x')) {
970
- return id;
971
- }
972
- if (!(/^\d{38,39}$/.test(id) || /^\d{4}$/.test(id))) {
973
- throw new Error("Asset id: ".concat(id, " must be a string and have either 4 digits or 38-39 digits"));
827
+ var DEFAULT_FEE_ASSET = 0;
828
+ var ETH_PARA_ID = 1;
829
+ var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
830
+ var ETHEREUM_JUNCTION = {
831
+ GlobalConsensus: {
832
+ Ethereum: {
833
+ chainId: ETH_CHAIN_ID
834
+ }
974
835
  }
975
- return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
976
836
  };
837
+ var DOT_MULTILOCATION = {
838
+ parents: sdkCommon.Parents.ONE,
839
+ interior: 'Here'
840
+ };
841
+ var SYSTEM_NODES_POLKADOT = ['PeoplePolkadot', 'CoretimePolkadot', 'Collectives'];
842
+ var SYSTEM_NODES_KUSAMA = ['PeopleKusama', 'CoretimeKusama'];
843
+ var ASSET_HUB_EXECUTION_FEE = 2200000000n; // 0.22 DOT
977
844
 
978
845
  var AssetHubPolkadot$1 = {
979
846
  name: "AssetHub",
@@ -2322,22 +2189,18 @@ var getNodeProviders = function getNodeProviders(node) {
2322
2189
  });
2323
2190
  };
2324
2191
 
2325
- var DEFAULT_FEE_ASSET = 0;
2326
- var ETH_PARA_ID = 1;
2327
- var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
2328
- var ETHEREUM_JUNCTION = {
2329
- GlobalConsensus: {
2330
- Ethereum: {
2331
- chainId: ETH_CHAIN_ID
2332
- }
2192
+ /**
2193
+ * Retrieves the parachain ID for a specified node.
2194
+ *
2195
+ * @param node - The node for which to get the paraId.
2196
+ * @returns The parachain ID of the node.
2197
+ */
2198
+ var getParaId = function getParaId(node) {
2199
+ if (node === 'Ethereum') {
2200
+ return ETH_PARA_ID;
2333
2201
  }
2202
+ return getNodeConfig(node).paraId;
2334
2203
  };
2335
- var DOT_MULTILOCATION = {
2336
- parents: sdkCommon.Parents.ONE,
2337
- interior: 'Here'
2338
- };
2339
- var SYSTEM_NODES_POLKADOT = ['PeoplePolkadot', 'CoretimePolkadot', 'Collectives'];
2340
- var SYSTEM_NODES_KUSAMA = ['PeopleKusama', 'CoretimeKusama'];
2341
2204
 
2342
2205
  var shuffleArray = function shuffleArray(array) {
2343
2206
  var copy = _toConsumableArray(array);
@@ -2858,6 +2721,26 @@ var BridgeHaltedError = /*#__PURE__*/function (_Error) {
2858
2721
  return _createClass(BridgeHaltedError);
2859
2722
  }(/*#__PURE__*/_wrapNativeSuper(Error));
2860
2723
 
2724
+ /**
2725
+ * Error thrown when the Dry Run fails.
2726
+ */
2727
+ var DryRunFailedError = /*#__PURE__*/function (_Error) {
2728
+ /**
2729
+ * Constructs a new DryRunFailedError.
2730
+ *
2731
+ * @param message - Optional custom error message.
2732
+ */
2733
+ function DryRunFailedError(reason) {
2734
+ var _this;
2735
+ _classCallCheck(this, DryRunFailedError);
2736
+ _this = _callSuper(this, DryRunFailedError, ["Dry run failed: ".concat(reason)]);
2737
+ _this.name = 'DryRunFailedError';
2738
+ return _this;
2739
+ }
2740
+ _inherits(DryRunFailedError, _Error);
2741
+ return _createClass(DryRunFailedError);
2742
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
2743
+
2861
2744
  /**
2862
2745
  * Error thrown when nodes from different relay chains are incompatible.
2863
2746
  */
@@ -3168,7 +3051,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version, messag
3168
3051
  if (!ethAsset) {
3169
3052
  throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
3170
3053
  }
3171
- var interior_sb = ethAsset.symbol === 'ETH' ? {
3054
+ var interiorSb = ethAsset.symbol === 'ETH' ? {
3172
3055
  Here: null
3173
3056
  } : {
3174
3057
  X1: [{
@@ -3214,7 +3097,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version, messag
3214
3097
  fees: {
3215
3098
  id: {
3216
3099
  parents: sdkCommon.Parents.ZERO,
3217
- interior: interior_sb
3100
+ interior: interiorSb
3218
3101
  },
3219
3102
  fun: {
3220
3103
  Fungible: 1n
@@ -3319,14 +3202,16 @@ var ParachainNode = /*#__PURE__*/function () {
3319
3202
  }
3320
3203
  }, {
3321
3204
  key: "canUseXTokens",
3322
- value: function canUseXTokens(_) {
3323
- return true;
3205
+ value: function canUseXTokens(_ref) {
3206
+ var asset = _ref.asset;
3207
+ var isEthAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
3208
+ return !isEthAsset;
3324
3209
  }
3325
3210
  }, {
3326
3211
  key: "transfer",
3327
3212
  value: function () {
3328
3213
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
3329
- var api, asset, feeAsset, address, destination, paraIdTo, overriddenAsset, version, senderAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
3214
+ var api, asset, feeAsset, address, destination, paraIdTo, overriddenAsset, version, senderAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isLocalTransfer, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input, _options, isEthAsset, isAHPOrigin, isAHPDest, isEthDest;
3330
3215
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3331
3216
  while (1) switch (_context.prev = _context.next) {
3332
3217
  case 0:
@@ -3334,15 +3219,22 @@ var ParachainNode = /*#__PURE__*/function () {
3334
3219
  isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
3335
3220
  scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
3336
3221
  paraId = resolveParaId(paraIdTo, destination);
3337
- if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot' && this.node !== 'Hydration')) {
3222
+ if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot' && this.node !== 'Hydration' && this.node !== destination)) {
3338
3223
  _context.next = 6;
3339
3224
  break;
3340
3225
  }
3341
3226
  throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot and Hydration');
3342
3227
  case 6:
3343
3228
  versionOrDefault = version !== null && version !== void 0 ? version : this.version;
3229
+ isLocalTransfer = this.node === destination;
3230
+ if (!isLocalTransfer) {
3231
+ _context.next = 10;
3232
+ break;
3233
+ }
3234
+ return _context.abrupt("return", this.transferLocal(options));
3235
+ case 10:
3344
3236
  if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
3345
- _context.next = 17;
3237
+ _context.next = 20;
3346
3238
  break;
3347
3239
  }
3348
3240
  isBifrostOrigin = this.node === 'BifrostPolkadot' || this.node === 'BifrostKusama';
@@ -3369,15 +3261,15 @@ var ParachainNode = /*#__PURE__*/function () {
3369
3261
  method: method
3370
3262
  };
3371
3263
  if (!shouldUseMultiasset) {
3372
- _context.next = 14;
3264
+ _context.next = 17;
3373
3265
  break;
3374
3266
  }
3375
3267
  return _context.abrupt("return", XTokensTransferImpl.transferXTokens(input, undefined));
3376
- case 14:
3377
- return _context.abrupt("return", this.transferXTokens(input));
3378
3268
  case 17:
3269
+ return _context.abrupt("return", this.transferXTokens(input));
3270
+ case 20:
3379
3271
  if (!supportsXTransfer(this)) {
3380
- _context.next = 21;
3272
+ _context.next = 24;
3381
3273
  break;
3382
3274
  }
3383
3275
  return _context.abrupt("return", this.transferXTransfer({
@@ -3391,12 +3283,12 @@ var ParachainNode = /*#__PURE__*/function () {
3391
3283
  pallet: pallet,
3392
3284
  method: method
3393
3285
  }));
3394
- case 21:
3286
+ case 24:
3395
3287
  if (!supportsPolkadotXCM(this)) {
3396
- _context.next = 25;
3288
+ _context.next = 37;
3397
3289
  break;
3398
3290
  }
3399
- return _context.abrupt("return", this.transferPolkadotXCM({
3291
+ _options = {
3400
3292
  api: api,
3401
3293
  header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraId),
3402
3294
  addressSelection: createVersionedBeneficiary({
@@ -3419,10 +3311,27 @@ var ParachainNode = /*#__PURE__*/function () {
3419
3311
  senderAddress: senderAddress,
3420
3312
  pallet: pallet,
3421
3313
  method: method
3422
- }));
3423
- case 25:
3314
+ }; // Handle common cases
3315
+ isEthAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
3316
+ isAHPOrigin = this.node === 'AssetHubPolkadot' || this.node === 'AssetHubKusama';
3317
+ isAHPDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
3318
+ isEthDest = destination === 'Ethereum'; // Any origin to any dest via AH - DestinationReserve - multiple instructions
3319
+ if (!(isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest)) {
3320
+ _context.next = 32;
3321
+ break;
3322
+ }
3323
+ return _context.abrupt("return", this.transferEthAssetViaAH(_options));
3324
+ case 32:
3325
+ if (!(isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest)) {
3326
+ _context.next = 34;
3327
+ break;
3328
+ }
3329
+ return _context.abrupt("return", this.transferToEthereum(_options, true));
3330
+ case 34:
3331
+ return _context.abrupt("return", this.transferPolkadotXCM(_options));
3332
+ case 37:
3424
3333
  throw new NoXCMSupportImplementedError(this._node);
3425
- case 26:
3334
+ case 38:
3426
3335
  case "end":
3427
3336
  return _context.stop();
3428
3337
  }
@@ -3478,91 +3387,306 @@ var ParachainNode = /*#__PURE__*/function () {
3478
3387
  return assets.getNativeAssetSymbol(this.node);
3479
3388
  }
3480
3389
  }, {
3481
- key: "transferToEthereum",
3390
+ key: "transferLocal",
3391
+ value: function transferLocal(options) {
3392
+ var asset = options.asset,
3393
+ address = options.address;
3394
+ if (sdkCommon.isTMultiLocation(address)) {
3395
+ throw new InvalidAddressError('Multi-Location address is not supported for local transfers');
3396
+ }
3397
+ var validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
3398
+ address: address
3399
+ });
3400
+ var isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(asset);
3401
+ if (isNativeAsset) {
3402
+ return this.transferLocalNativeAsset(validatedOptions);
3403
+ } else {
3404
+ return this.transferLocalNonNativeAsset(validatedOptions);
3405
+ }
3406
+ }
3407
+ }, {
3408
+ key: "transferLocalNativeAsset",
3409
+ value: function transferLocalNativeAsset(options) {
3410
+ var api = options.api,
3411
+ asset = options.asset,
3412
+ address = options.address;
3413
+ return api.callTxMethod({
3414
+ module: 'Balances',
3415
+ section: 'transfer_keep_alive',
3416
+ parameters: {
3417
+ dest: assets.isNodeEvm(this.node) ? address : {
3418
+ Id: address
3419
+ },
3420
+ value: BigInt(asset.amount)
3421
+ }
3422
+ });
3423
+ }
3424
+ }, {
3425
+ key: "transferLocalNonNativeAsset",
3426
+ value: function transferLocalNonNativeAsset(options) {
3427
+ var api = options.api,
3428
+ asset = options.asset,
3429
+ address = options.address;
3430
+ if (!assets.isForeignAsset(asset)) {
3431
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
3432
+ }
3433
+ if (asset.assetId === undefined) {
3434
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
3435
+ }
3436
+ return api.callTxMethod({
3437
+ module: 'Tokens',
3438
+ section: 'transfer',
3439
+ parameters: {
3440
+ dest: {
3441
+ Id: address
3442
+ },
3443
+ currency_id: BigInt(asset.assetId),
3444
+ amount: BigInt(asset.amount)
3445
+ }
3446
+ });
3447
+ }
3448
+ }, {
3449
+ key: "transferEthAssetViaAH",
3482
3450
  value: function () {
3483
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
3484
- var api, asset, scenario, version, destination, address, senderAddress, bridgeStatus, versionOrDefault, ethMultiAsset, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, fee, ethAsset, messageId, call;
3451
+ var _transferEthAssetViaAH = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
3452
+ var _feeAsset$multiLocati;
3453
+ var api, asset, scenario, _input$version, version, destination, address, senderAddress, feeAsset, paraIdTo, ethMultiAsset, PARA_TO_PARA_FEE_DOT, AH_EXECUTION_FEE_PADDED, dryRunResult, dryRunFeePadded, destWithHeader, _extractVersionFromHe, _extractVersionFromHe2, dest, call;
3485
3454
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3486
3455
  while (1) switch (_context2.prev = _context2.next) {
3487
3456
  case 0:
3488
- api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress;
3489
- _context2.next = 3;
3490
- return getBridgeStatus(api.clone());
3457
+ api = input.api, asset = input.asset, scenario = input.scenario, _input$version = input.version, version = _input$version === void 0 ? exports.Version.V4 : _input$version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset, paraIdTo = input.paraIdTo;
3458
+ if (asset.multiLocation) {
3459
+ _context2.next = 3;
3460
+ break;
3461
+ }
3462
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
3491
3463
  case 3:
3492
- bridgeStatus = _context2.sent;
3493
- if (!(bridgeStatus !== 'Normal')) {
3494
- _context2.next = 6;
3464
+ if (!(senderAddress === undefined)) {
3465
+ _context2.next = 5;
3495
3466
  break;
3496
3467
  }
3497
- throw new BridgeHaltedError();
3498
- case 6:
3499
- if (assets.isForeignAsset(asset)) {
3500
- _context2.next = 8;
3468
+ throw new Error('Sender address is required for transfers to Ethereum');
3469
+ case 5:
3470
+ if (!sdkCommon.isTMultiLocation(address)) {
3471
+ _context2.next = 7;
3501
3472
  break;
3502
3473
  }
3503
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
3504
- case 8:
3474
+ throw new Error('Multi-location address is not supported for Ethereum transfers');
3475
+ case 7:
3476
+ ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
3477
+ PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
3478
+ // Pad by 25%
3479
+ AH_EXECUTION_FEE_PADDED = ASSET_HUB_EXECUTION_FEE * 125n / 100n; // Perform a dry run AH -> dest to calculate the BuyExecution amount
3480
+ _context2.next = 12;
3481
+ return Builder(api.clone()).from('AssetHubPolkadot').to(destination).currency({
3482
+ symbol: 'DOT',
3483
+ amount: AH_EXECUTION_FEE_PADDED
3484
+ }).address(address).dryRun(senderAddress);
3485
+ case 12:
3486
+ dryRunResult = _context2.sent;
3487
+ if (dryRunResult.success) {
3488
+ _context2.next = 15;
3489
+ break;
3490
+ }
3491
+ throw new DryRunFailedError(dryRunResult.failureReason);
3492
+ case 15:
3493
+ // Pad fee by 50%
3494
+ dryRunFeePadded = BigInt(dryRunResult.fee) * BigInt(3) / BigInt(2);
3495
+ destWithHeader = createPolkadotXcmHeader(scenario, version, destination, paraIdTo);
3496
+ _extractVersionFromHe = extractVersionFromHeader(destWithHeader), _extractVersionFromHe2 = _slicedToArray(_extractVersionFromHe, 2), _extractVersionFromHe2[0], dest = _extractVersionFromHe2[1];
3497
+ call = {
3498
+ module: 'PolkadotXcm',
3499
+ section: 'transfer_assets_using_type_and_then',
3500
+ parameters: {
3501
+ dest: this.createPolkadotXcmHeader(scenario, version, destination, getParaId('AssetHubPolkadot')),
3502
+ assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
3503
+ assets_transfer_type: 'DestinationReserve',
3504
+ remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : DOT_MULTILOCATION, version),
3505
+ fees_transfer_type: 'DestinationReserve',
3506
+ custom_xcm_on_dest: addXcmVersionHeader([{
3507
+ SetAppendix: [{
3508
+ DepositAsset: {
3509
+ assets: {
3510
+ Wild: 'All'
3511
+ },
3512
+ beneficiary: createBeneficiaryMultiLocation({
3513
+ api: api,
3514
+ scenario: scenario,
3515
+ pallet: 'PolkadotXcm',
3516
+ recipientAddress: senderAddress,
3517
+ version: version
3518
+ })
3519
+ }
3520
+ }]
3521
+ }, {
3522
+ DepositReserveAsset: {
3523
+ assets: {
3524
+ Wild: 'All'
3525
+ },
3526
+ dest: dest,
3527
+ xcm: [{
3528
+ BuyExecution: {
3529
+ fees: {
3530
+ id: DOT_MULTILOCATION,
3531
+ fun: {
3532
+ Fungible: dryRunFeePadded
3533
+ }
3534
+ },
3535
+ weight_limit: 'Unlimited'
3536
+ }
3537
+ }, {
3538
+ DepositAsset: {
3539
+ assets: {
3540
+ Wild: 'All'
3541
+ },
3542
+ beneficiary: createBeneficiaryMultiLocation({
3543
+ api: api,
3544
+ scenario: scenario,
3545
+ pallet: 'PolkadotXcm',
3546
+ recipientAddress: address,
3547
+ version: version
3548
+ })
3549
+ }
3550
+ }]
3551
+ }
3552
+ }], version),
3553
+ weight_limit: 'Unlimited'
3554
+ }
3555
+ };
3556
+ return _context2.abrupt("return", api.callTxMethod(call));
3557
+ case 20:
3558
+ case "end":
3559
+ return _context2.stop();
3560
+ }
3561
+ }, _callee2, this);
3562
+ }));
3563
+ function transferEthAssetViaAH(_x2) {
3564
+ return _transferEthAssetViaAH.apply(this, arguments);
3565
+ }
3566
+ return transferEthAssetViaAH;
3567
+ }()
3568
+ }, {
3569
+ key: "transferToEthereum",
3570
+ value: function () {
3571
+ var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
3572
+ var _feeAsset$multiLocati2;
3573
+ var useOnlyDepositInstruction,
3574
+ api,
3575
+ asset,
3576
+ scenario,
3577
+ _input$version2,
3578
+ version,
3579
+ destination,
3580
+ address,
3581
+ senderAddress,
3582
+ feeAsset,
3583
+ bridgeStatus,
3584
+ ethMultiAsset,
3585
+ ahApi,
3586
+ _yield$getParaEthTran,
3587
+ _yield$getParaEthTran2,
3588
+ bridgeFee,
3589
+ executionFee,
3590
+ PARA_TO_PARA_FEE_DOT,
3591
+ fee,
3592
+ ethAsset,
3593
+ messageId,
3594
+ call,
3595
+ _args3 = arguments;
3596
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3597
+ while (1) switch (_context3.prev = _context3.next) {
3598
+ case 0:
3599
+ useOnlyDepositInstruction = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
3600
+ api = input.api, asset = input.asset, scenario = input.scenario, _input$version2 = input.version, version = _input$version2 === void 0 ? exports.Version.V4 : _input$version2, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset;
3601
+ _context3.next = 4;
3602
+ return getBridgeStatus(api.clone());
3603
+ case 4:
3604
+ bridgeStatus = _context3.sent;
3605
+ if (!(bridgeStatus !== 'Normal')) {
3606
+ _context3.next = 7;
3607
+ break;
3608
+ }
3609
+ throw new BridgeHaltedError();
3610
+ case 7:
3611
+ if (asset.multiLocation) {
3612
+ _context3.next = 9;
3613
+ break;
3614
+ }
3615
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
3616
+ case 9:
3505
3617
  if (!(senderAddress === undefined)) {
3506
- _context2.next = 10;
3618
+ _context3.next = 11;
3507
3619
  break;
3508
3620
  }
3509
3621
  throw new Error('Sender address is required for transfers to Ethereum');
3510
- case 10:
3622
+ case 11:
3511
3623
  if (!sdkCommon.isTMultiLocation(address)) {
3512
- _context2.next = 12;
3624
+ _context3.next = 13;
3513
3625
  break;
3514
3626
  }
3515
3627
  throw new Error('Multi-location address is not supported for Ethereum transfers');
3516
- case 12:
3517
- versionOrDefault = version !== null && version !== void 0 ? version : exports.Version.V4;
3518
- ethMultiAsset = createMultiAsset(versionOrDefault, asset.amount, asset.multiLocation);
3519
- _context2.next = 16;
3628
+ case 13:
3629
+ ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
3630
+ _context3.next = 16;
3520
3631
  return api.createApiForNode('AssetHubPolkadot');
3521
3632
  case 16:
3522
- ahApi = _context2.sent;
3523
- _context2.next = 19;
3633
+ ahApi = _context3.sent;
3634
+ _context3.next = 19;
3524
3635
  return getParaEthTransferFees(ahApi);
3525
3636
  case 19:
3526
- _yield$getParaEthTran = _context2.sent;
3637
+ _yield$getParaEthTran = _context3.sent;
3527
3638
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3528
3639
  bridgeFee = _yield$getParaEthTran2[0];
3529
3640
  executionFee = _yield$getParaEthTran2[1];
3530
- fee = (bridgeFee + executionFee).toString();
3641
+ PARA_TO_PARA_FEE_DOT = 500000000; // 0.5 DOT
3642
+ fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
3531
3643
  ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
3532
3644
  if (!(!ethAsset || !ethAsset.assetId)) {
3533
- _context2.next = 27;
3645
+ _context3.next = 28;
3534
3646
  break;
3535
3647
  }
3536
3648
  throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
3537
- case 27:
3538
- _context2.next = 29;
3649
+ case 28:
3650
+ _context3.next = 30;
3539
3651
  return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
3540
- case 29:
3541
- messageId = _context2.sent;
3652
+ case 30:
3653
+ messageId = _context3.sent;
3542
3654
  call = {
3543
3655
  module: 'PolkadotXcm',
3544
3656
  section: 'transfer_assets_using_type_and_then',
3545
3657
  parameters: {
3546
- dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
3547
- assets: _defineProperty({}, versionOrDefault, [createMultiAsset(versionOrDefault, fee, DOT_MULTILOCATION), ethMultiAsset]),
3658
+ dest: this.createPolkadotXcmHeader(scenario, version, destination, getParaId('AssetHubPolkadot')),
3659
+ assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, fee, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
3548
3660
  assets_transfer_type: 'DestinationReserve',
3549
- remote_fees_id: _defineProperty({}, versionOrDefault, {
3550
- parents: sdkCommon.Parents.ONE,
3551
- interior: 'Here'
3552
- }),
3661
+ remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati2 = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati2 !== void 0 ? _feeAsset$multiLocati2 : DOT_MULTILOCATION, version),
3553
3662
  fees_transfer_type: 'DestinationReserve',
3554
- custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault, messageId),
3663
+ custom_xcm_on_dest: useOnlyDepositInstruction ? addXcmVersionHeader([{
3664
+ DepositAsset: {
3665
+ assets: {
3666
+ Wild: {
3667
+ AllCounted: 1
3668
+ }
3669
+ },
3670
+ beneficiary: createBeneficiaryMultiLocation({
3671
+ api: api,
3672
+ scenario: scenario,
3673
+ pallet: 'PolkadotXcm',
3674
+ recipientAddress: address,
3675
+ version: version
3676
+ })
3677
+ }
3678
+ }], version) : createCustomXcmOnDest(input, version, messageId),
3555
3679
  weight_limit: 'Unlimited'
3556
3680
  }
3557
3681
  };
3558
- return _context2.abrupt("return", api.callTxMethod(call));
3559
- case 32:
3682
+ return _context3.abrupt("return", api.callTxMethod(call));
3683
+ case 33:
3560
3684
  case "end":
3561
- return _context2.stop();
3685
+ return _context3.stop();
3562
3686
  }
3563
- }, _callee2, this);
3687
+ }, _callee3, this);
3564
3688
  }));
3565
- function transferToEthereum(_x2) {
3689
+ function transferToEthereum(_x3) {
3566
3690
  return _transferToEthereum.apply(this, arguments);
3567
3691
  }
3568
3692
  return transferToEthereum;
@@ -3577,16 +3701,61 @@ var Acala = /*#__PURE__*/function (_ParachainNode) {
3577
3701
  }
3578
3702
  _inherits(Acala, _ParachainNode);
3579
3703
  return _createClass(Acala, [{
3580
- key: "transferXTokens",
3581
- value: function transferXTokens(input) {
3582
- var asset = input.asset;
3583
- var currencySelection = assets.isForeignAsset(asset) ? {
3704
+ key: "getCurrencySelection",
3705
+ value: function getCurrencySelection(asset) {
3706
+ return assets.isForeignAsset(asset) ? {
3584
3707
  ForeignAsset: Number(asset.assetId)
3585
3708
  } : {
3586
3709
  Token: asset.symbol
3587
3710
  };
3711
+ }
3712
+ }, {
3713
+ key: "transferXTokens",
3714
+ value: function transferXTokens(input) {
3715
+ var asset = input.asset;
3716
+ var currencySelection = this.getCurrencySelection(asset);
3588
3717
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
3589
3718
  }
3719
+ }, {
3720
+ key: "transferLocalNativeAsset",
3721
+ value: function transferLocalNativeAsset(options) {
3722
+ var api = options.api,
3723
+ asset = options.asset,
3724
+ address = options.address;
3725
+ return api.callTxMethod({
3726
+ module: 'Currencies',
3727
+ section: 'transfer_native_currency',
3728
+ parameters: {
3729
+ dest: {
3730
+ Id: address
3731
+ },
3732
+ amount: BigInt(asset.amount)
3733
+ }
3734
+ });
3735
+ }
3736
+ }, {
3737
+ key: "transferLocalNonNativeAsset",
3738
+ value: function transferLocalNonNativeAsset(options) {
3739
+ var api = options.api,
3740
+ asset = options.asset,
3741
+ address = options.address;
3742
+ if (asset.symbol.toLowerCase() === 'lcdot') {
3743
+ throw new assets.InvalidCurrencyError('LcDOT local transfers are not supported');
3744
+ }
3745
+ return api.callTxMethod({
3746
+ module: 'Currencies',
3747
+ section: 'transfer',
3748
+ parameters: {
3749
+ dest: {
3750
+ Id: address
3751
+ },
3752
+ currency_id: this.getCurrencySelection(_objectSpread2(_objectSpread2({}, asset), {}, {
3753
+ symbol: asset.symbol === 'aSEED' ? 'AUSD' : asset.symbol
3754
+ })),
3755
+ amount: BigInt(asset.amount)
3756
+ }
3757
+ });
3758
+ }
3590
3759
  }]);
3591
3760
  }(ParachainNode);
3592
3761
 
@@ -3614,6 +3783,30 @@ var Altair = /*#__PURE__*/function (_ParachainNode) {
3614
3783
  var currencySelection = this.getCurrencySelection(asset);
3615
3784
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
3616
3785
  }
3786
+ }, {
3787
+ key: "transferLocalNonNativeAsset",
3788
+ value: function transferLocalNonNativeAsset(options) {
3789
+ var api = options.api,
3790
+ asset = options.asset,
3791
+ address = options.address;
3792
+ if (!assets.isForeignAsset(asset)) {
3793
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
3794
+ }
3795
+ if (asset.assetId === undefined) {
3796
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
3797
+ }
3798
+ return api.callTxMethod({
3799
+ module: 'Tokens',
3800
+ section: 'transfer',
3801
+ parameters: {
3802
+ dest: {
3803
+ Id: address
3804
+ },
3805
+ currency_id: this.getCurrencySelection(asset),
3806
+ amount: BigInt(asset.amount)
3807
+ }
3808
+ });
3809
+ }
3617
3810
  }]);
3618
3811
  }(ParachainNode);
3619
3812
 
@@ -3719,6 +3912,11 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
3719
3912
  value: function createCurrencySpec(amount, scenario, version, asset, isOverridenAsset) {
3720
3913
  return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, asset, isOverridenAsset);
3721
3914
  }
3915
+ }, {
3916
+ key: "transferLocalNonNativeAsset",
3917
+ value: function transferLocalNonNativeAsset(options) {
3918
+ return getNode('AssetHubPolkadot').transferLocalNonNativeAsset(options);
3919
+ }
3722
3920
  }]);
3723
3921
  }(ParachainNode);
3724
3922
 
@@ -3846,28 +4044,29 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
3846
4044
  _classCallCheck(this, AssetHubPolkadot);
3847
4045
  _this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', exports.Version.V3]);
3848
4046
  _this.handleBifrostEthTransfer = function (input) {
4047
+ var useDOTAsFeeAsset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3849
4048
  var api = input.api,
3850
4049
  scenario = input.scenario,
3851
4050
  _input$version = input.version,
3852
- version = _input$version === void 0 ? _this.version : _input$version,
4051
+ version = _input$version === void 0 ? exports.Version.V4 : _input$version,
3853
4052
  destination = input.destination,
3854
- asset = input.asset;
4053
+ asset = input.asset,
4054
+ paraIdTo = input.paraIdTo;
3855
4055
  if (!assets.isForeignAsset(asset)) {
3856
4056
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
3857
4057
  }
3858
4058
  if (!asset.multiLocation) {
3859
4059
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
3860
4060
  }
4061
+ var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
3861
4062
  var call = {
3862
4063
  module: 'PolkadotXcm',
3863
4064
  section: 'transfer_assets_using_type_and_then',
3864
4065
  parameters: {
3865
- dest: _this.createPolkadotXcmHeader(scenario, version, destination, getParaId('BifrostPolkadot')),
3866
- assets: _defineProperty({}, version, [createMultiAsset(version, asset.amount, asset.multiLocation)]),
4066
+ dest: _this.createPolkadotXcmHeader(scenario, version, destination, paraIdTo),
4067
+ assets: addXcmVersionHeader([].concat(_toConsumableArray(useDOTAsFeeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [createMultiAsset(version, asset.amount, asset.multiLocation)]), version),
3867
4068
  assets_transfer_type: 'LocalReserve',
3868
- remote_fees_id: _defineProperty({}, version, {
3869
- Concrete: asset.multiLocation
3870
- }),
4069
+ remote_fees_id: addXcmVersionHeader(useDOTAsFeeAsset ? DOT_MULTILOCATION : asset.multiLocation, version),
3871
4070
  fees_transfer_type: 'LocalReserve',
3872
4071
  custom_xcm_on_dest: createCustomXcmToBifrost(input, version),
3873
4072
  weight_limit: 'Unlimited'
@@ -3909,14 +4108,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
3909
4108
  throw new assets.InvalidCurrencyError("Polkadot <-> Kusama bridge does not support currency ".concat(input.asset.symbol));
3910
4109
  }
3911
4110
  }, {
3912
- key: "handleEthBridgeTransfer",
4111
+ key: "handleEthBridgeNativeTransfer",
3913
4112
  value: function () {
3914
- var _handleEthBridgeTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
3915
- var api, scenario, destination, paraIdTo, address, asset, bridgeStatus, modifiedInput;
4113
+ var _handleEthBridgeNativeTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
4114
+ var api, _input$version2, version, scenario, destination, senderAddress, address, paraIdTo, asset, bridgeStatus, messageId, multiLocation, call;
3916
4115
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3917
4116
  while (1) switch (_context.prev = _context.next) {
3918
4117
  case 0:
3919
- api = input.api, scenario = input.scenario, destination = input.destination, paraIdTo = input.paraIdTo, address = input.address, asset = input.asset;
4118
+ api = input.api, _input$version2 = input.version, version = _input$version2 === void 0 ? exports.Version.V4 : _input$version2, scenario = input.scenario, destination = input.destination, senderAddress = input.senderAddress, address = input.address, paraIdTo = input.paraIdTo, asset = input.asset;
3920
4119
  _context.next = 3;
3921
4120
  return getBridgeStatus(api.clone());
3922
4121
  case 3:
@@ -3927,24 +4126,120 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
3927
4126
  }
3928
4127
  throw new BridgeHaltedError();
3929
4128
  case 6:
3930
- if (ethers.ethers.isAddress(address)) {
4129
+ if (!(senderAddress === undefined)) {
3931
4130
  _context.next = 8;
3932
4131
  break;
3933
4132
  }
4133
+ throw new Error('Sender address is required for transfers to Ethereum');
4134
+ case 8:
4135
+ if (!sdkCommon.isTMultiLocation(address)) {
4136
+ _context.next = 10;
4137
+ break;
4138
+ }
4139
+ throw new Error('Multi-location address is not supported for Ethereum transfers');
4140
+ case 10:
4141
+ if (assets.isForeignAsset(asset)) {
4142
+ _context.next = 12;
4143
+ break;
4144
+ }
4145
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
4146
+ case 12:
4147
+ if (asset.multiLocation) {
4148
+ _context.next = 14;
4149
+ break;
4150
+ }
4151
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
4152
+ case 14:
4153
+ _context.next = 16;
4154
+ return generateMessageId(api, senderAddress, getParaId(this.node), JSON.stringify(asset.multiLocation), address, asset.amount);
4155
+ case 16:
4156
+ messageId = _context.sent;
4157
+ multiLocation = asset.symbol === this.getNativeAssetSymbol() ? DOT_MULTILOCATION : asset.multiLocation;
4158
+ call = {
4159
+ module: 'PolkadotXcm',
4160
+ section: 'transfer_assets_using_type_and_then',
4161
+ parameters: {
4162
+ dest: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
4163
+ assets: addXcmVersionHeader([createMultiAsset(version, asset.amount, multiLocation)], version),
4164
+ assets_transfer_type: 'LocalReserve',
4165
+ remote_fees_id: addXcmVersionHeader(multiLocation, version),
4166
+ fees_transfer_type: 'LocalReserve',
4167
+ custom_xcm_on_dest: addXcmVersionHeader([{
4168
+ DepositAsset: {
4169
+ assets: {
4170
+ Wild: {
4171
+ AllCounted: 1
4172
+ }
4173
+ },
4174
+ beneficiary: createBeneficiaryMultiLocation({
4175
+ api: api,
4176
+ scenario: scenario,
4177
+ pallet: 'PolkadotXcm',
4178
+ recipientAddress: address,
4179
+ version: version
4180
+ })
4181
+ }
4182
+ }, {
4183
+ SetTopic: messageId
4184
+ }], version),
4185
+ weight_limit: 'Unlimited'
4186
+ }
4187
+ };
4188
+ return _context.abrupt("return", api.callTxMethod(call));
4189
+ case 20:
4190
+ case "end":
4191
+ return _context.stop();
4192
+ }
4193
+ }, _callee, this);
4194
+ }));
4195
+ function handleEthBridgeNativeTransfer(_x) {
4196
+ return _handleEthBridgeNativeTransfer.apply(this, arguments);
4197
+ }
4198
+ return handleEthBridgeNativeTransfer;
4199
+ }()
4200
+ }, {
4201
+ key: "handleEthBridgeTransfer",
4202
+ value: function () {
4203
+ var _handleEthBridgeTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
4204
+ var api, scenario, destination, paraIdTo, address, asset, bridgeStatus, modifiedInput;
4205
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4206
+ while (1) switch (_context2.prev = _context2.next) {
4207
+ case 0:
4208
+ api = input.api, scenario = input.scenario, destination = input.destination, paraIdTo = input.paraIdTo, address = input.address, asset = input.asset;
4209
+ _context2.next = 3;
4210
+ return getBridgeStatus(api.clone());
4211
+ case 3:
4212
+ bridgeStatus = _context2.sent;
4213
+ if (!(bridgeStatus !== 'Normal')) {
4214
+ _context2.next = 6;
4215
+ break;
4216
+ }
4217
+ throw new BridgeHaltedError();
4218
+ case 6:
4219
+ if (ethers.ethers.isAddress(address)) {
4220
+ _context2.next = 8;
4221
+ break;
4222
+ }
3934
4223
  throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
3935
4224
  case 8:
3936
4225
  if (assets.isForeignAsset(asset)) {
3937
- _context.next = 10;
4226
+ _context2.next = 10;
3938
4227
  break;
3939
4228
  }
3940
4229
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
3941
4230
  case 10:
3942
4231
  if (asset.multiLocation) {
3943
- _context.next = 12;
4232
+ _context2.next = 12;
3944
4233
  break;
3945
4234
  }
3946
4235
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
3947
4236
  case 12:
4237
+ if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === assets.getNativeAssetSymbol('Kusama'))) {
4238
+ _context2.next = 14;
4239
+ break;
4240
+ }
4241
+ return _context2.abrupt("return", this.handleEthBridgeNativeTransfer(input));
4242
+ case 14:
3948
4243
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
3949
4244
  header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
3950
4245
  addressSelection: createVersionedBeneficiary({
@@ -3957,14 +4252,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
3957
4252
  }),
3958
4253
  currencySelection: createVersionedMultiAssets(exports.Version.V3, asset.amount, asset.multiLocation)
3959
4254
  });
3960
- return _context.abrupt("return", PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited'));
3961
- case 14:
4255
+ return _context2.abrupt("return", PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited'));
4256
+ case 16:
3962
4257
  case "end":
3963
- return _context.stop();
4258
+ return _context2.stop();
3964
4259
  }
3965
- }, _callee, this);
4260
+ }, _callee2, this);
3966
4261
  }));
3967
- function handleEthBridgeTransfer(_x) {
4262
+ function handleEthBridgeTransfer(_x2) {
3968
4263
  return _handleEthBridgeTransfer.apply(this, arguments);
3969
4264
  }
3970
4265
  return handleEthBridgeTransfer;
@@ -4011,12 +4306,12 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4011
4306
  paraIdTo = input.paraIdTo,
4012
4307
  scenario = input.scenario,
4013
4308
  api = input.api,
4014
- _input$version2 = input.version,
4015
- version = _input$version2 === void 0 ? this.version : _input$version2,
4309
+ _input$version3 = input.version,
4310
+ version = _input$version3 === void 0 ? this.version : _input$version3,
4016
4311
  address = input.address;
4017
4312
  if ((((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toUpperCase()) === 'USDT' || ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot') {
4018
- var _input$version3;
4019
- var versionOrDefault = (_input$version3 = input.version) !== null && _input$version3 !== void 0 ? _input$version3 : exports.Version.V2;
4313
+ var _input$version4;
4314
+ var versionOrDefault = (_input$version4 = input.version) !== null && _input$version4 !== void 0 ? _input$version4 : exports.Version.V2;
4020
4315
  return _objectSpread2(_objectSpread2({}, input), {}, {
4021
4316
  header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
4022
4317
  addressSelection: createVersionedBeneficiary({
@@ -4047,14 +4342,14 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4047
4342
  }, {
4048
4343
  key: "handleExecuteTransfer",
4049
4344
  value: function () {
4050
- var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
4345
+ var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
4051
4346
  var api, senderAddress, asset, MIN_FEE, maxU64, dummyTx, dryRunResult, feeDotShifted, toMl, feeConverted, feeConvertedPadded;
4052
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4053
- while (1) switch (_context2.prev = _context2.next) {
4347
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4348
+ while (1) switch (_context3.prev = _context3.next) {
4054
4349
  case 0:
4055
4350
  api = input.api, senderAddress = input.senderAddress, asset = input.asset;
4056
4351
  if (senderAddress) {
4057
- _context2.next = 3;
4352
+ _context3.next = 3;
4058
4353
  break;
4059
4354
  }
4060
4355
  throw new Error('Please provide senderAddress');
@@ -4066,53 +4361,53 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4066
4361
  refTime: maxU64,
4067
4362
  proofSize: maxU64
4068
4363
  }, MIN_FEE);
4069
- _context2.next = 9;
4364
+ _context3.next = 9;
4070
4365
  return api.getDryRun({
4071
4366
  node: this.node,
4072
4367
  tx: dummyTx,
4073
4368
  address: senderAddress
4074
4369
  });
4075
4370
  case 9:
4076
- dryRunResult = _context2.sent;
4371
+ dryRunResult = _context3.sent;
4077
4372
  if (dryRunResult.success) {
4078
- _context2.next = 12;
4373
+ _context3.next = 12;
4079
4374
  break;
4080
4375
  }
4081
4376
  throw new Error("Dry run failed: ".concat(dryRunResult.failureReason));
4082
4377
  case 12:
4083
4378
  if (dryRunResult.weight) {
4084
- _context2.next = 14;
4379
+ _context3.next = 14;
4085
4380
  break;
4086
4381
  }
4087
4382
  throw new Error('Dry run failed: weight not found');
4088
4383
  case 14:
4089
4384
  feeDotShifted = dryRunResult.fee / 10n;
4090
4385
  toMl = transformMultiLocation(asset.multiLocation);
4091
- _context2.next = 18;
4386
+ _context3.next = 18;
4092
4387
  return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
4093
4388
  case 18:
4094
- feeConverted = _context2.sent;
4389
+ feeConverted = _context3.sent;
4095
4390
  if (feeConverted) {
4096
- _context2.next = 21;
4391
+ _context3.next = 21;
4097
4392
  break;
4098
4393
  }
4099
4394
  throw new Error("Pool DOT -> ".concat(asset.symbol, " not found."));
4100
4395
  case 21:
4101
4396
  if (!(BigInt(asset.amount) - feeConverted < 0)) {
4102
- _context2.next = 23;
4397
+ _context3.next = 23;
4103
4398
  break;
4104
4399
  }
4105
4400
  throw new Error("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
4106
4401
  case 23:
4107
4402
  feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
4108
- return _context2.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
4403
+ return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
4109
4404
  case 25:
4110
4405
  case "end":
4111
- return _context2.stop();
4406
+ return _context3.stop();
4112
4407
  }
4113
- }, _callee2, this);
4408
+ }, _callee3, this);
4114
4409
  }));
4115
- function handleExecuteTransfer(_x2) {
4410
+ function handleExecuteTransfer(_x3) {
4116
4411
  return _handleExecuteTransfer.apply(this, arguments);
4117
4412
  }
4118
4413
  return handleExecuteTransfer;
@@ -4143,15 +4438,13 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4143
4438
  if (destination === 'Mythos') {
4144
4439
  return Promise.resolve(this.handleMythosTransfer(input));
4145
4440
  }
4146
- var ethereumAssets = assets.getOtherAssets('Ethereum');
4147
- var isEthereumAsset = ethereumAssets.some(function (_ref3) {
4148
- var symbol = _ref3.symbol,
4149
- assetId = _ref3.assetId;
4150
- return asset.symbol === symbol && assets.isForeignAsset(asset) && asset.assetId === assetId;
4151
- });
4441
+ var isEthereumAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
4152
4442
  if (destination === 'BifrostPolkadot' && isEthereumAsset) {
4153
4443
  return Promise.resolve(this.handleBifrostEthTransfer(input));
4154
4444
  }
4445
+ if (isEthereumAsset) {
4446
+ return Promise.resolve(this.handleBifrostEthTransfer(input, true));
4447
+ }
4155
4448
  var isSystemNode = !sdkCommon.isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
4156
4449
  if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && !isSystemNode) {
4157
4450
  throw new ScenarioNotSupportedError(this.node, scenario, 'Para to Para scenarios for DOT transfer from AssetHub are not supported, you have to transfer DOT to Relay chain and transfer to destination chain from Relay chain.');
@@ -4190,6 +4483,40 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4190
4483
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
4191
4484
  }
4192
4485
  }
4486
+ }, {
4487
+ key: "transferLocalNonNativeAsset",
4488
+ value: function transferLocalNonNativeAsset(options) {
4489
+ var api = options.api,
4490
+ asset = options.asset,
4491
+ address = options.address;
4492
+ if (!assets.isForeignAsset(asset)) {
4493
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
4494
+ }
4495
+ if (asset.assetId !== undefined) {
4496
+ return api.callTxMethod({
4497
+ module: 'Assets',
4498
+ section: 'transfer',
4499
+ parameters: {
4500
+ id: Number(asset.assetId),
4501
+ target: {
4502
+ Id: address
4503
+ },
4504
+ amount: BigInt(asset.amount)
4505
+ }
4506
+ });
4507
+ }
4508
+ return api.callTxMethod({
4509
+ module: 'ForeignAssets',
4510
+ section: 'transfer',
4511
+ parameters: {
4512
+ id: asset.multiLocation,
4513
+ target: {
4514
+ Id: address
4515
+ },
4516
+ amount: BigInt(asset.amount)
4517
+ }
4518
+ });
4519
+ }
4193
4520
  }]);
4194
4521
  }(ParachainNode);
4195
4522
 
@@ -4220,6 +4547,30 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
4220
4547
  var asset = _ref.asset;
4221
4548
  return asset.symbol !== this.getNativeAssetSymbol();
4222
4549
  }
4550
+ }, {
4551
+ key: "transferLocalNonNativeAsset",
4552
+ value: function transferLocalNonNativeAsset(options) {
4553
+ var api = options.api,
4554
+ asset = options.asset,
4555
+ address = options.address;
4556
+ if (!assets.isForeignAsset(asset)) {
4557
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
4558
+ }
4559
+ if (asset.assetId === undefined) {
4560
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
4561
+ }
4562
+ return api.callTxMethod({
4563
+ module: 'Assets',
4564
+ section: 'transfer',
4565
+ parameters: {
4566
+ id: Number(asset.assetId),
4567
+ target: {
4568
+ Id: address
4569
+ },
4570
+ amount: BigInt(asset.amount)
4571
+ }
4572
+ });
4573
+ }
4223
4574
  }]);
4224
4575
  }(ParachainNode);
4225
4576
 
@@ -4238,6 +4589,16 @@ var Basilisk = /*#__PURE__*/function (_ParachainNode) {
4238
4589
  }
4239
4590
  return XTokensTransferImpl.transferXTokens(input, Number(asset.assetId));
4240
4591
  }
4592
+ }, {
4593
+ key: "transferLocalNativeAsset",
4594
+ value: function transferLocalNativeAsset(options) {
4595
+ return getNode('Hydration').transferLocalNativeAsset(options);
4596
+ }
4597
+ }, {
4598
+ key: "transferLocalNonNativeAsset",
4599
+ value: function transferLocalNonNativeAsset(options) {
4600
+ return getNode('Hydration').transferLocalNonNativeAsset(options);
4601
+ }
4241
4602
  }]);
4242
4603
  }(ParachainNode);
4243
4604
 
@@ -4252,6 +4613,11 @@ var BifrostKusama = /*#__PURE__*/function (_ParachainNode) {
4252
4613
  value: function transferXTokens(input) {
4253
4614
  return getNode('BifrostPolkadot').transferXTokens(input);
4254
4615
  }
4616
+ }, {
4617
+ key: "transferLocalNonNativeAsset",
4618
+ value: function transferLocalNonNativeAsset(options) {
4619
+ return getNode('BifrostPolkadot').transferLocalNonNativeAsset(options);
4620
+ }
4255
4621
  }]);
4256
4622
  }(ParachainNode);
4257
4623
 
@@ -4331,9 +4697,29 @@ var BifrostPolkadot = /*#__PURE__*/function (_ParachainNode) {
4331
4697
  value: function canUseXTokens(_ref) {
4332
4698
  var asset = _ref.asset,
4333
4699
  destination = _ref.to;
4700
+ var isEthAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
4701
+ if (isEthAsset) return false;
4334
4702
  if (destination === 'Ethereum') return false;
4335
4703
  return asset.symbol !== 'WETH' && asset.symbol !== 'DOT' || destination !== 'AssetHubPolkadot';
4336
4704
  }
4705
+ }, {
4706
+ key: "transferLocalNonNativeAsset",
4707
+ value: function transferLocalNonNativeAsset(options) {
4708
+ var api = options.api,
4709
+ asset = options.asset,
4710
+ address = options.address;
4711
+ return api.callTxMethod({
4712
+ module: 'Tokens',
4713
+ section: 'transfer',
4714
+ parameters: {
4715
+ dest: {
4716
+ Id: address
4717
+ },
4718
+ currency_id: this.getCurrencySelection(asset),
4719
+ amount: BigInt(asset.amount)
4720
+ }
4721
+ });
4722
+ }
4337
4723
  }]);
4338
4724
  }(ParachainNode);
4339
4725
 
@@ -4452,6 +4838,30 @@ var Centrifuge = /*#__PURE__*/function (_ParachainNode) {
4452
4838
  var currencySelection = this.getCurrencySelection(asset);
4453
4839
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4454
4840
  }
4841
+ }, {
4842
+ key: "transferLocalNonNativeAsset",
4843
+ value: function transferLocalNonNativeAsset(options) {
4844
+ var api = options.api,
4845
+ asset = options.asset,
4846
+ address = options.address;
4847
+ if (!assets.isForeignAsset(asset)) {
4848
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
4849
+ }
4850
+ if (asset.assetId === undefined) {
4851
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
4852
+ }
4853
+ return api.callTxMethod({
4854
+ module: 'Tokens',
4855
+ section: 'transfer',
4856
+ parameters: {
4857
+ dest: {
4858
+ Id: address
4859
+ },
4860
+ currency_id: this.getCurrencySelection(asset),
4861
+ amount: BigInt(asset.amount)
4862
+ }
4863
+ });
4864
+ }
4455
4865
  }]);
4456
4866
  }(ParachainNode);
4457
4867
 
@@ -4595,6 +5005,11 @@ var Crab = /*#__PURE__*/function (_ParachainNode) {
4595
5005
  return _superPropGet(Crab, "createCurrencySpec", this, 3)([amount, scenario, version]);
4596
5006
  }
4597
5007
  }
5008
+ }, {
5009
+ key: "transferLocalNonNativeAsset",
5010
+ value: function transferLocalNonNativeAsset(options) {
5011
+ return getNode('Darwinia').transferLocalNonNativeAsset(options);
5012
+ }
4598
5013
  }]);
4599
5014
  }(ParachainNode);
4600
5015
 
@@ -4624,6 +5039,30 @@ var Crust = /*#__PURE__*/function (_ParachainNode) {
4624
5039
  var currencySelection = this.getCurrencySelection(asset);
4625
5040
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4626
5041
  }
5042
+ }, {
5043
+ key: "transferLocalNonNativeAsset",
5044
+ value: function transferLocalNonNativeAsset(options) {
5045
+ var api = options.api,
5046
+ asset = options.asset,
5047
+ address = options.address;
5048
+ if (!assets.isForeignAsset(asset)) {
5049
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5050
+ }
5051
+ if (asset.assetId === undefined) {
5052
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5053
+ }
5054
+ return api.callTxMethod({
5055
+ module: 'Assets',
5056
+ section: 'transfer',
5057
+ parameters: {
5058
+ id: BigInt(asset.assetId),
5059
+ target: {
5060
+ Id: address
5061
+ },
5062
+ amount: BigInt(asset.amount)
5063
+ }
5064
+ });
5065
+ }
4627
5066
  }]);
4628
5067
  }(ParachainNode);
4629
5068
 
@@ -4653,6 +5092,11 @@ var CrustShadow = /*#__PURE__*/function (_ParachainNode) {
4653
5092
  var currencySelection = this.getCurrencySelection(asset);
4654
5093
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4655
5094
  }
5095
+ }, {
5096
+ key: "transferLocalNonNativeAsset",
5097
+ value: function transferLocalNonNativeAsset(options) {
5098
+ return getNode('Crust').transferLocalNonNativeAsset(options);
5099
+ }
4656
5100
  }]);
4657
5101
  }(ParachainNode);
4658
5102
 
@@ -4691,6 +5135,28 @@ var Darwinia = /*#__PURE__*/function (_ParachainNode) {
4691
5135
  }
4692
5136
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
4693
5137
  }
5138
+ }, {
5139
+ key: "transferLocalNonNativeAsset",
5140
+ value: function transferLocalNonNativeAsset(options) {
5141
+ var api = options.api,
5142
+ asset = options.asset,
5143
+ address = options.address;
5144
+ if (!assets.isForeignAsset(asset)) {
5145
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5146
+ }
5147
+ if (asset.assetId === undefined) {
5148
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5149
+ }
5150
+ return api.callTxMethod({
5151
+ module: 'Assets',
5152
+ section: 'transfer',
5153
+ parameters: {
5154
+ id: BigInt(asset.assetId),
5155
+ target: address,
5156
+ amount: BigInt(asset.amount)
5157
+ }
5158
+ });
5159
+ }
4694
5160
  }]);
4695
5161
  }(ParachainNode);
4696
5162
 
@@ -4902,6 +5368,30 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
4902
5368
  }), version, 'Teleport');
4903
5369
  return call;
4904
5370
  }
5371
+ }, {
5372
+ key: "transferLocalNonNativeAsset",
5373
+ value: function transferLocalNonNativeAsset(options) {
5374
+ var api = options.api,
5375
+ asset = options.asset,
5376
+ address = options.address;
5377
+ if (!assets.isForeignAsset(asset)) {
5378
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5379
+ }
5380
+ if (asset.multiLocation === undefined) {
5381
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
5382
+ }
5383
+ return api.callTxMethod({
5384
+ module: 'ForeignAssets',
5385
+ section: 'transfer',
5386
+ parameters: {
5387
+ id: asset.multiLocation,
5388
+ target: {
5389
+ Id: address
5390
+ },
5391
+ amount: BigInt(asset.amount)
5392
+ }
5393
+ });
5394
+ }
4905
5395
  }]);
4906
5396
  }(ParachainNode);
4907
5397
 
@@ -5028,7 +5518,45 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
5028
5518
  value: function canUseXTokens(_ref3) {
5029
5519
  var destination = _ref3.to,
5030
5520
  asset = _ref3.asset;
5031
- return destination !== 'Ethereum' && destination !== 'Polimec' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT');
5521
+ var isEthAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
5522
+ return destination !== 'Ethereum' && destination !== 'Polimec' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT') && !isEthAsset;
5523
+ }
5524
+ }, {
5525
+ key: "transferLocalNativeAsset",
5526
+ value: function transferLocalNativeAsset(options) {
5527
+ var api = options.api,
5528
+ asset = options.asset,
5529
+ address = options.address;
5530
+ return api.callTxMethod({
5531
+ module: 'Balances',
5532
+ section: 'transfer_keep_alive',
5533
+ parameters: {
5534
+ dest: address,
5535
+ value: BigInt(asset.amount)
5536
+ }
5537
+ });
5538
+ }
5539
+ }, {
5540
+ key: "transferLocalNonNativeAsset",
5541
+ value: function transferLocalNonNativeAsset(options) {
5542
+ var api = options.api,
5543
+ asset = options.asset,
5544
+ address = options.address;
5545
+ if (!assets.isForeignAsset(asset)) {
5546
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5547
+ }
5548
+ if (asset.assetId === undefined) {
5549
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5550
+ }
5551
+ return api.callTxMethod({
5552
+ module: 'Tokens',
5553
+ section: 'transfer',
5554
+ parameters: {
5555
+ dest: address,
5556
+ currency_id: Number(asset.assetId),
5557
+ amount: BigInt(asset.amount)
5558
+ }
5559
+ });
5032
5560
  }
5033
5561
  }]);
5034
5562
  }(ParachainNode);
@@ -5041,16 +5569,42 @@ var Interlay = /*#__PURE__*/function (_ParachainNode) {
5041
5569
  }
5042
5570
  _inherits(Interlay, _ParachainNode);
5043
5571
  return _createClass(Interlay, [{
5044
- key: "transferXTokens",
5045
- value: function transferXTokens(input) {
5046
- var asset = input.asset;
5047
- var currencySelection = assets.isForeignAsset(asset) ? {
5572
+ key: "getCurrencySelection",
5573
+ value: function getCurrencySelection(asset) {
5574
+ return assets.isForeignAsset(asset) ? {
5048
5575
  ForeignAsset: Number(asset.assetId)
5049
5576
  } : {
5050
5577
  Token: asset.symbol
5051
5578
  };
5579
+ }
5580
+ }, {
5581
+ key: "transferXTokens",
5582
+ value: function transferXTokens(input) {
5583
+ var asset = input.asset;
5584
+ var currencySelection = this.getCurrencySelection(asset);
5052
5585
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5053
5586
  }
5587
+ }, {
5588
+ key: "transferLocalNativeAsset",
5589
+ value: function transferLocalNativeAsset(options) {
5590
+ return this.transferLocalNonNativeAsset(options);
5591
+ }
5592
+ }, {
5593
+ key: "transferLocalNonNativeAsset",
5594
+ value: function transferLocalNonNativeAsset(options) {
5595
+ var api = options.api,
5596
+ asset = options.asset,
5597
+ address = options.address;
5598
+ return api.callTxMethod({
5599
+ module: 'Tokens',
5600
+ section: 'transfer',
5601
+ parameters: {
5602
+ dest: address,
5603
+ currency_id: this.getCurrencySelection(asset),
5604
+ value: BigInt(asset.amount)
5605
+ }
5606
+ });
5607
+ }
5054
5608
  }]);
5055
5609
  }(ParachainNode);
5056
5610
 
@@ -5083,6 +5637,16 @@ var Karura = /*#__PURE__*/function (_ParachainNode) {
5083
5637
  value: function transferXTokens(input) {
5084
5638
  return getNode('Acala').transferXTokens(input);
5085
5639
  }
5640
+ }, {
5641
+ key: "transferLocalNativeAsset",
5642
+ value: function transferLocalNativeAsset(options) {
5643
+ return getNode('Acala').transferLocalNativeAsset(options);
5644
+ }
5645
+ }, {
5646
+ key: "transferLocalNonNativeAsset",
5647
+ value: function transferLocalNonNativeAsset(options) {
5648
+ return getNode('Acala').transferLocalNonNativeAsset(options);
5649
+ }
5086
5650
  }]);
5087
5651
  }(ParachainNode);
5088
5652
 
@@ -5115,16 +5679,42 @@ var Kintsugi = /*#__PURE__*/function (_ParachainNode) {
5115
5679
  }
5116
5680
  _inherits(Kintsugi, _ParachainNode);
5117
5681
  return _createClass(Kintsugi, [{
5118
- key: "transferXTokens",
5119
- value: function transferXTokens(input) {
5120
- var asset = input.asset;
5121
- var currencySelection = assets.isForeignAsset(asset) ? {
5682
+ key: "getCurrencySelection",
5683
+ value: function getCurrencySelection(asset) {
5684
+ return assets.isForeignAsset(asset) ? {
5122
5685
  ForeignAsset: Number(asset.assetId)
5123
5686
  } : {
5124
5687
  Token: asset.symbol
5125
5688
  };
5689
+ }
5690
+ }, {
5691
+ key: "transferXTokens",
5692
+ value: function transferXTokens(input) {
5693
+ var asset = input.asset;
5694
+ var currencySelection = this.getCurrencySelection(asset);
5126
5695
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5127
5696
  }
5697
+ }, {
5698
+ key: "transferLocalNativeAsset",
5699
+ value: function transferLocalNativeAsset(options) {
5700
+ return this.transferLocalNonNativeAsset(options);
5701
+ }
5702
+ }, {
5703
+ key: "transferLocalNonNativeAsset",
5704
+ value: function transferLocalNonNativeAsset(options) {
5705
+ var api = options.api,
5706
+ asset = options.asset,
5707
+ address = options.address;
5708
+ return api.callTxMethod({
5709
+ module: 'Tokens',
5710
+ section: 'transfer',
5711
+ parameters: {
5712
+ dest: address,
5713
+ currency_id: this.getCurrencySelection(asset),
5714
+ value: BigInt(asset.amount)
5715
+ }
5716
+ });
5717
+ }
5128
5718
  }]);
5129
5719
  }(ParachainNode);
5130
5720
 
@@ -5152,6 +5742,30 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
5152
5742
  };
5153
5743
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5154
5744
  }
5745
+ }, {
5746
+ key: "transferLocalNonNativeAsset",
5747
+ value: function transferLocalNonNativeAsset(options) {
5748
+ var api = options.api,
5749
+ asset = options.asset,
5750
+ address = options.address;
5751
+ if (!assets.isForeignAsset(asset)) {
5752
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5753
+ }
5754
+ if (asset.assetId === undefined) {
5755
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5756
+ }
5757
+ return api.callTxMethod({
5758
+ module: 'Assets',
5759
+ section: 'transfer',
5760
+ parameters: {
5761
+ id: BigInt(asset.assetId),
5762
+ target: {
5763
+ Id: address
5764
+ },
5765
+ amount: BigInt(asset.amount)
5766
+ }
5767
+ });
5768
+ }
5155
5769
  }]);
5156
5770
  }(ParachainNode);
5157
5771
  Manta.NATIVE_ASSET_ID = 1n;
@@ -5199,6 +5813,28 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
5199
5813
  includeFee: true
5200
5814
  };
5201
5815
  }
5816
+ }, {
5817
+ key: "transferLocalNonNativeAsset",
5818
+ value: function transferLocalNonNativeAsset(options) {
5819
+ var api = options.api,
5820
+ asset = options.asset,
5821
+ address = options.address;
5822
+ if (!assets.isForeignAsset(asset)) {
5823
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5824
+ }
5825
+ if (asset.assetId === undefined) {
5826
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5827
+ }
5828
+ return api.callTxMethod({
5829
+ module: 'Assets',
5830
+ section: 'transfer',
5831
+ parameters: {
5832
+ id: BigInt(asset.assetId),
5833
+ target: address,
5834
+ amount: BigInt(asset.amount)
5835
+ }
5836
+ });
5837
+ }
5202
5838
  }]);
5203
5839
  }(ParachainNode);
5204
5840
 
@@ -5245,6 +5881,11 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
5245
5881
  includeFee: true
5246
5882
  };
5247
5883
  }
5884
+ }, {
5885
+ key: "transferLocalNonNativeAsset",
5886
+ value: function transferLocalNonNativeAsset(options) {
5887
+ return getNode('Moonbeam').transferLocalNonNativeAsset(options);
5888
+ }
5248
5889
  }]);
5249
5890
  }(ParachainNode);
5250
5891
 
@@ -5342,6 +5983,30 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
5342
5983
  value: function transferRelayToPara() {
5343
5984
  throw new NodeNotSupportedError();
5344
5985
  }
5986
+ }, {
5987
+ key: "transferLocalNonNativeAsset",
5988
+ value: function transferLocalNonNativeAsset(options) {
5989
+ var api = options.api,
5990
+ asset = options.asset,
5991
+ address = options.address;
5992
+ if (!assets.isForeignAsset(asset)) {
5993
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
5994
+ }
5995
+ if (asset.assetId === undefined) {
5996
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5997
+ }
5998
+ return api.callTxMethod({
5999
+ module: 'Assets',
6000
+ section: 'transfer',
6001
+ parameters: {
6002
+ id: BigInt(asset.assetId),
6003
+ target: {
6004
+ Id: address
6005
+ },
6006
+ amount: BigInt(asset.amount)
6007
+ }
6008
+ });
6009
+ }
5345
6010
  }]);
5346
6011
  }(ParachainNode);
5347
6012
 
@@ -5531,6 +6196,30 @@ var Phala = /*#__PURE__*/function (_ParachainNode) {
5531
6196
  }
5532
6197
  return XTransferTransferImpl.transferXTransfer(input);
5533
6198
  }
6199
+ }, {
6200
+ key: "transferLocalNonNativeAsset",
6201
+ value: function transferLocalNonNativeAsset(options) {
6202
+ var api = options.api,
6203
+ asset = options.asset,
6204
+ address = options.address;
6205
+ if (!assets.isForeignAsset(asset)) {
6206
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6207
+ }
6208
+ if (asset.assetId === undefined) {
6209
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
6210
+ }
6211
+ return api.callTxMethod({
6212
+ module: 'Assets',
6213
+ section: 'transfer',
6214
+ parameters: {
6215
+ id: BigInt(asset.assetId),
6216
+ target: {
6217
+ Id: address
6218
+ },
6219
+ amount: BigInt(asset.amount)
6220
+ }
6221
+ });
6222
+ }
5534
6223
  }]);
5535
6224
  }(ParachainNode);
5536
6225
 
@@ -5567,6 +6256,11 @@ var RobonomicsKusama = /*#__PURE__*/function (_ParachainNode) {
5567
6256
  value: function transferPolkadotXCM(input) {
5568
6257
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
5569
6258
  }
6259
+ }, {
6260
+ key: "transferLocalNonNativeAsset",
6261
+ value: function transferLocalNonNativeAsset(options) {
6262
+ return getNode('RobonomicsPolkadot').transferLocalNonNativeAsset(options);
6263
+ }
5570
6264
  }]);
5571
6265
  }(ParachainNode);
5572
6266
 
@@ -5581,6 +6275,30 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_ParachainNode) {
5581
6275
  value: function transferPolkadotXCM(input) {
5582
6276
  return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
5583
6277
  }
6278
+ }, {
6279
+ key: "transferLocalNonNativeAsset",
6280
+ value: function transferLocalNonNativeAsset(options) {
6281
+ var api = options.api,
6282
+ asset = options.asset,
6283
+ address = options.address;
6284
+ if (!assets.isForeignAsset(asset)) {
6285
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6286
+ }
6287
+ if (asset.assetId === undefined) {
6288
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
6289
+ }
6290
+ return api.callTxMethod({
6291
+ module: 'Assets',
6292
+ section: 'transfer',
6293
+ parameters: {
6294
+ id: BigInt(asset.assetId),
6295
+ target: {
6296
+ Id: address
6297
+ },
6298
+ amount: BigInt(asset.amount)
6299
+ }
6300
+ });
6301
+ }
5584
6302
  }]);
5585
6303
  }(ParachainNode);
5586
6304
 
@@ -5608,6 +6326,11 @@ var Shiden = /*#__PURE__*/function (_ParachainNode) {
5608
6326
  var asset = _ref.asset;
5609
6327
  return asset.symbol !== this.getNativeAssetSymbol();
5610
6328
  }
6329
+ }, {
6330
+ key: "transferLocalNonNativeAsset",
6331
+ value: function transferLocalNonNativeAsset(options) {
6332
+ return getNode('Astar').transferLocalNonNativeAsset(options);
6333
+ }
5611
6334
  }]);
5612
6335
  }(ParachainNode);
5613
6336
 
@@ -5650,6 +6373,30 @@ var Turing = /*#__PURE__*/function (_ParachainNode) {
5650
6373
  useMultiAssetTransfer: true
5651
6374
  }), BigInt(asset.assetId));
5652
6375
  }
6376
+ }, {
6377
+ key: "transferLocalNonNativeAsset",
6378
+ value: function transferLocalNonNativeAsset(options) {
6379
+ var api = options.api,
6380
+ asset = options.asset,
6381
+ address = options.address;
6382
+ if (!assets.isForeignAsset(asset)) {
6383
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6384
+ }
6385
+ if (asset.assetId === undefined) {
6386
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
6387
+ }
6388
+ return api.callTxMethod({
6389
+ module: 'Currencies',
6390
+ section: 'transfer',
6391
+ parameters: {
6392
+ dest: {
6393
+ Id: address
6394
+ },
6395
+ currency_id: BigInt(asset.assetId),
6396
+ amount: BigInt(asset.amount)
6397
+ }
6398
+ });
6399
+ }
5653
6400
  }]);
5654
6401
  }(ParachainNode);
5655
6402
 
@@ -5671,6 +6418,11 @@ var Unique = /*#__PURE__*/function (_ParachainNode) {
5671
6418
  }
5672
6419
  return XTokensTransferImpl.transferXTokens(input, Number(asset.assetId));
5673
6420
  }
6421
+ }, {
6422
+ key: "transferLocalNonNativeAsset",
6423
+ value: function transferLocalNonNativeAsset(_options) {
6424
+ throw new ScenarioNotSupportedError(this.node, 'ParaToPara', "".concat(this.node, " does not support foreign assets local transfers"));
6425
+ }
5674
6426
  }]);
5675
6427
  }(ParachainNode);
5676
6428
  Unique.NATIVE_ASSET_ID = 0;
@@ -5699,6 +6451,30 @@ var Zeitgeist = /*#__PURE__*/function (_ParachainNode) {
5699
6451
  var currencySelection = this.getCurrencySelection(asset);
5700
6452
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5701
6453
  }
6454
+ }, {
6455
+ key: "transferLocalNonNativeAsset",
6456
+ value: function transferLocalNonNativeAsset(options) {
6457
+ var api = options.api,
6458
+ asset = options.asset,
6459
+ address = options.address;
6460
+ if (!assets.isForeignAsset(asset)) {
6461
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6462
+ }
6463
+ if (asset.assetId === undefined) {
6464
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
6465
+ }
6466
+ return api.callTxMethod({
6467
+ module: 'AssetManager',
6468
+ section: 'transfer',
6469
+ parameters: {
6470
+ dest: {
6471
+ Id: address
6472
+ },
6473
+ currency_id: this.getCurrencySelection(asset),
6474
+ amount: BigInt(asset.amount)
6475
+ }
6476
+ });
6477
+ }
5702
6478
  }]);
5703
6479
  }(ParachainNode);
5704
6480
 
@@ -5758,17 +6534,154 @@ var nodes = function nodes() {
5758
6534
  };
5759
6535
  };
5760
6536
 
5761
- /**
5762
- * Retrieves the parachain ID for a specified node.
5763
- *
5764
- * @param node - The node for which to get the paraId.
5765
- * @returns The parachain ID of the node.
5766
- */
5767
- var getParaId = function getParaId(node) {
5768
- if (node === 'Ethereum') {
5769
- return ETH_PARA_ID;
6537
+ var getParaEthTransferFees = /*#__PURE__*/function () {
6538
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
6539
+ var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
6540
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6541
+ while (1) switch (_context.prev = _context.next) {
6542
+ case 0:
6543
+ DEFAULT_FEE = 2750872500000n;
6544
+ _context.next = 3;
6545
+ return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
6546
+ case 3:
6547
+ feeStorageItem = _context.sent;
6548
+ leFeeHex = feeStorageItem.replace('0x', '');
6549
+ _context.next = 7;
6550
+ return ahApi.disconnect();
6551
+ case 7:
6552
+ bytes = leFeeHex.match(/.{1,2}/g) || [];
6553
+ reversedHex = bytes.reverse().join('');
6554
+ validReversedHex = reversedHex === '' ? '0' : reversedHex;
6555
+ leFee = BigInt('0x' + validReversedHex);
6556
+ transferBridgeFee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
6557
+ finalBridgeFee = transferBridgeFee * 110n / 100n;
6558
+ finalAssethubExecutionFee = ASSET_HUB_EXECUTION_FEE * 110n / 100n;
6559
+ return _context.abrupt("return", [finalBridgeFee, finalAssethubExecutionFee]);
6560
+ case 15:
6561
+ case "end":
6562
+ return _context.stop();
6563
+ }
6564
+ }, _callee);
6565
+ }));
6566
+ return function getParaEthTransferFees(_x) {
6567
+ return _ref.apply(this, arguments);
6568
+ };
6569
+ }();
6570
+
6571
+ var isEthersSigner = function isEthersSigner(signer) {
6572
+ return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
6573
+ };
6574
+ var isEthersContract = function isEthersContract(contract) {
6575
+ return !('abi' in contract);
6576
+ };
6577
+
6578
+ var abi$1 = [
6579
+ {
6580
+ inputs: [
6581
+ {
6582
+ internalType: "address",
6583
+ name: "currencyAddress",
6584
+ type: "address"
6585
+ },
6586
+ {
6587
+ internalType: "uint256",
6588
+ name: "amount",
6589
+ type: "uint256"
6590
+ },
6591
+ {
6592
+ components: [
6593
+ {
6594
+ internalType: "uint8",
6595
+ name: "parents",
6596
+ type: "uint8"
6597
+ },
6598
+ {
6599
+ internalType: "bytes[]",
6600
+ name: "interior",
6601
+ type: "bytes[]"
6602
+ }
6603
+ ],
6604
+ internalType: "struct Xtokens.Multilocation",
6605
+ name: "destination",
6606
+ type: "tuple"
6607
+ },
6608
+ {
6609
+ internalType: "uint64",
6610
+ name: "weight",
6611
+ type: "uint64"
6612
+ }
6613
+ ],
6614
+ name: "transfer",
6615
+ outputs: [
6616
+ ],
6617
+ stateMutability: "nonpayable",
6618
+ type: "function"
6619
+ },
6620
+ {
6621
+ inputs: [
6622
+ {
6623
+ components: [
6624
+ {
6625
+ internalType: "address",
6626
+ name: "currencyAddress",
6627
+ type: "address"
6628
+ },
6629
+ {
6630
+ internalType: "uint256",
6631
+ name: "amount",
6632
+ type: "uint256"
6633
+ }
6634
+ ],
6635
+ internalType: "struct Xtokens.Currency[]",
6636
+ name: "currencies",
6637
+ type: "tuple[]"
6638
+ },
6639
+ {
6640
+ internalType: "uint32",
6641
+ name: "feeItem",
6642
+ type: "uint32"
6643
+ },
6644
+ {
6645
+ components: [
6646
+ {
6647
+ internalType: "uint8",
6648
+ name: "parents",
6649
+ type: "uint8"
6650
+ },
6651
+ {
6652
+ internalType: "bytes[]",
6653
+ name: "interior",
6654
+ type: "bytes[]"
6655
+ }
6656
+ ],
6657
+ internalType: "struct Xtokens.Multilocation",
6658
+ name: "destination",
6659
+ type: "tuple"
6660
+ },
6661
+ {
6662
+ internalType: "uint64",
6663
+ name: "weight",
6664
+ type: "uint64"
6665
+ }
6666
+ ],
6667
+ name: "transferMultiCurrencies",
6668
+ outputs: [
6669
+ ],
6670
+ stateMutability: "nonpayable",
6671
+ type: "function"
6672
+ }
6673
+ ];
6674
+
6675
+ // Inspired by Moonbeam XCM-SDK
6676
+ // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/utils/src/format/asset.ts#L1
6677
+ var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
6678
+ if (id.startsWith('0x')) {
6679
+ return id;
5770
6680
  }
5771
- return getNodeConfig(node).paraId;
6681
+ if (!(/^\d{38,39}$/.test(id) || /^\d{4}$/.test(id))) {
6682
+ throw new Error("Asset id: ".concat(id, " must be a string and have either 4 digits or 38-39 digits"));
6683
+ }
6684
+ return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
5772
6685
  };
5773
6686
 
5774
6687
  // Partially inspired by Moonbeam XCM-SDK
@@ -6224,7 +7137,7 @@ var validateCurrency = function validateCurrency(currency, feeAsset) {
6224
7137
  }
6225
7138
  };
6226
7139
  var validateDestination = function validateDestination(origin, destination) {
6227
- if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination)) {
7140
+ if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
6228
7141
  throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
6229
7142
  }
6230
7143
  if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration' && origin !== 'BifrostPolkadot') {
@@ -6353,7 +7266,7 @@ var validateDestinationAddress = function validateDestinationAddress(address, de
6353
7266
 
6354
7267
  var send = /*#__PURE__*/function () {
6355
7268
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
6356
- var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, overriddenAsset, resolvedAsset, originNode;
7269
+ var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, isLocalTransfer, overriddenAsset, resolvedAsset, originNode;
6357
7270
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6358
7271
  while (1) switch (_context.prev = _context.next) {
6359
7272
  case 0:
@@ -6362,12 +7275,6 @@ var send = /*#__PURE__*/function () {
6362
7275
  validateDestination(origin, destination);
6363
7276
  validateDestinationAddress(address, destination);
6364
7277
  if (senderAddress) validateAddress(senderAddress, origin, false);
6365
- if (!(sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination))) {
6366
- _context.next = 7;
6367
- break;
6368
- }
6369
- throw new Error('Relay chain to relay chain transfers are not supported.');
6370
- case 7:
6371
7278
  isBridge = isBridgeTransfer(origin, destination);
6372
7279
  assetCheckEnabled = determineAssetCheckEnabled(origin, currency);
6373
7280
  validateAssetSpecifiers(assetCheckEnabled, currency);
@@ -6375,21 +7282,46 @@ var send = /*#__PURE__*/function () {
6375
7282
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
6376
7283
  validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
6377
7284
  if (!sdkCommon.isRelayChain(origin)) {
6378
- _context.next = 19;
7285
+ _context.next = 24;
6379
7286
  break;
6380
7287
  }
6381
7288
  if (!(destination === 'Ethereum')) {
6382
- _context.next = 16;
7289
+ _context.next = 14;
6383
7290
  break;
6384
7291
  }
6385
7292
  throw new Error('Transfers from relay chain to Ethereum are not supported.');
6386
- case 16:
7293
+ case 14:
6387
7294
  if (asset) {
6388
- _context.next = 18;
7295
+ _context.next = 16;
6389
7296
  break;
6390
7297
  }
6391
7298
  throw new Error('Asset is required for relay chain to relay chain transfers.');
6392
- case 18:
7299
+ case 16:
7300
+ isLocalTransfer = origin === destination;
7301
+ if (!isLocalTransfer) {
7302
+ _context.next = 23;
7303
+ break;
7304
+ }
7305
+ if (!sdkCommon.isTMultiLocation(address)) {
7306
+ _context.next = 20;
7307
+ break;
7308
+ }
7309
+ throw new InvalidAddressError('Multi-Location address is not supported for local transfers.');
7310
+ case 20:
7311
+ _context.next = 22;
7312
+ return api.init(origin);
7313
+ case 22:
7314
+ return _context.abrupt("return", api.callTxMethod({
7315
+ module: 'Balances',
7316
+ section: 'transfer_keep_alive',
7317
+ parameters: {
7318
+ dest: {
7319
+ Id: address
7320
+ },
7321
+ value: 'multiasset' in currency ? 0n : BigInt(currency.amount)
7322
+ }
7323
+ }));
7324
+ case 23:
6393
7325
  return _context.abrupt("return", transferRelayToPara({
6394
7326
  api: api,
6395
7327
  origin: origin,
@@ -6403,11 +7335,11 @@ var send = /*#__PURE__*/function () {
6403
7335
  pallet: pallet,
6404
7336
  method: method
6405
7337
  }));
6406
- case 19:
7338
+ case 24:
6407
7339
  overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset);
6408
- _context.next = 22;
7340
+ _context.next = 27;
6409
7341
  return api.init(origin);
6410
- case 22:
7342
+ case 27:
6411
7343
  // In case asset check is disabled, we create asset object from currency symbol
6412
7344
  resolvedAsset = asset !== null && asset !== void 0 ? asset : {
6413
7345
  symbol: 'symbol' in currency ? currency.symbol : undefined
@@ -6428,7 +7360,7 @@ var send = /*#__PURE__*/function () {
6428
7360
  pallet: pallet,
6429
7361
  method: method
6430
7362
  }));
6431
- case 25:
7363
+ case 30:
6432
7364
  case "end":
6433
7365
  return _context.stop();
6434
7366
  }
@@ -6682,6 +7614,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
6682
7614
  key: "build",
6683
7615
  value: (function () {
6684
7616
  var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
7617
+ var _this$_options, from, to;
6685
7618
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6686
7619
  while (1) switch (_context2.prev = _context2.next) {
6687
7620
  case 0:
@@ -6691,16 +7624,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
6691
7624
  }
6692
7625
  throw new Error('Transaction manager contains batched items. Use buildBatch() to process them.');
6693
7626
  case 2:
6694
- if (!(!sdkCommon.isTMultiLocation(this._options.to) && sdkCommon.isRelayChain(this._options.from) && sdkCommon.isRelayChain(this._options.to))) {
6695
- _context2.next = 4;
7627
+ _this$_options = this._options, from = _this$_options.from, to = _this$_options.to;
7628
+ if (!(!sdkCommon.isTMultiLocation(to) && sdkCommon.isRelayChain(from) && sdkCommon.isRelayChain(to) && from !== to)) {
7629
+ _context2.next = 5;
6696
7630
  break;
6697
7631
  }
6698
7632
  throw new Error('Transfers between relay chains are not yet supported.');
6699
- case 4:
7633
+ case 5:
6700
7634
  return _context2.abrupt("return", send(_objectSpread2({
6701
7635
  api: this.api
6702
7636
  }, this._options)));
6703
- case 5:
7637
+ case 6:
6704
7638
  case "end":
6705
7639
  return _context2.stop();
6706
7640
  }
@@ -7545,6 +8479,7 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
7545
8479
  exports.AssetClaimBuilder = AssetClaimBuilder;
7546
8480
  exports.BridgeHaltedError = BridgeHaltedError;
7547
8481
  exports.Builder = Builder;
8482
+ exports.DryRunFailedError = DryRunFailedError;
7548
8483
  exports.ETHEREUM_JUNCTION = ETHEREUM_JUNCTION;
7549
8484
  exports.ETH_CHAIN_ID = ETH_CHAIN_ID;
7550
8485
  exports.GeneralBuilder = GeneralBuilder;