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