@paraspell/sdk-core 8.3.0 → 8.4.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
@@ -2719,7 +2719,7 @@ var Darwinia$3 = {
2719
2719
  relayChainAssetSymbol: "DOT",
2720
2720
  nativeAssetSymbol: "RING",
2721
2721
  isEVM: true,
2722
- supportsDryRunApi: false,
2722
+ supportsDryRunApi: true,
2723
2723
  nativeAssets: [
2724
2724
  {
2725
2725
  symbol: "RING",
@@ -2842,6 +2842,84 @@ var Hydration$3 = {
2842
2842
  existentialDeposit: "10000",
2843
2843
  alias: "USDC1"
2844
2844
  },
2845
+ {
2846
+ assetId: "1000796",
2847
+ symbol: "LDO",
2848
+ decimals: 18,
2849
+ multiLocation: {
2850
+ parents: 2,
2851
+ interior: {
2852
+ X2: [
2853
+ {
2854
+ GlobalConsensus: {
2855
+ Ethereum: {
2856
+ chainId: 1
2857
+ }
2858
+ }
2859
+ },
2860
+ {
2861
+ AccountKey20: {
2862
+ network: null,
2863
+ key: "0x5a98fcbea516cf06857215779fd812ca3bef1b32"
2864
+ }
2865
+ }
2866
+ ]
2867
+ }
2868
+ },
2869
+ existentialDeposit: "5102040816326530"
2870
+ },
2871
+ {
2872
+ assetId: "1000795",
2873
+ symbol: "SKY",
2874
+ decimals: 18,
2875
+ multiLocation: {
2876
+ parents: 2,
2877
+ interior: {
2878
+ X2: [
2879
+ {
2880
+ GlobalConsensus: {
2881
+ Ethereum: {
2882
+ chainId: 1
2883
+ }
2884
+ }
2885
+ },
2886
+ {
2887
+ AccountKey20: {
2888
+ network: null,
2889
+ key: "0x56072c95faa701256059aa122697b133aded9279"
2890
+ }
2891
+ }
2892
+ ]
2893
+ }
2894
+ },
2895
+ existentialDeposit: "211685012701101000"
2896
+ },
2897
+ {
2898
+ assetId: "1000794",
2899
+ symbol: "LINK",
2900
+ decimals: 18,
2901
+ multiLocation: {
2902
+ parents: 2,
2903
+ interior: {
2904
+ X2: [
2905
+ {
2906
+ GlobalConsensus: {
2907
+ Ethereum: {
2908
+ chainId: 1
2909
+ }
2910
+ }
2911
+ },
2912
+ {
2913
+ AccountKey20: {
2914
+ network: null,
2915
+ key: "0x514910771af9ca656af840dff83e8264ecf986ca"
2916
+ }
2917
+ }
2918
+ ]
2919
+ }
2920
+ },
2921
+ existentialDeposit: "436681222707424"
2922
+ },
2845
2923
  {
2846
2924
  assetId: "1000625",
2847
2925
  symbol: "sUSDe",
@@ -2960,6 +3038,32 @@ var Hydration$3 = {
2960
3038
  existentialDeposit: "9910802775024780",
2961
3039
  alias: "sUSDS1"
2962
3040
  },
3041
+ {
3042
+ assetId: "1000809",
3043
+ symbol: "wstETH",
3044
+ decimals: 18,
3045
+ multiLocation: {
3046
+ parents: 2,
3047
+ interior: {
3048
+ X2: [
3049
+ {
3050
+ GlobalConsensus: {
3051
+ Ethereum: {
3052
+ chainId: 1
3053
+ }
3054
+ }
3055
+ },
3056
+ {
3057
+ AccountKey20: {
3058
+ network: null,
3059
+ key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
3060
+ }
3061
+ }
3062
+ ]
3063
+ }
3064
+ },
3065
+ existentialDeposit: "3244646333550"
3066
+ },
2963
3067
  {
2964
3068
  assetId: "1000767",
2965
3069
  symbol: "USDT",
@@ -4001,6 +4105,20 @@ var Hydration$3 = {
4001
4105
  }
4002
4106
  },
4003
4107
  existentialDeposit: "21367521367521400"
4108
+ },
4109
+ {
4110
+ assetId: "3370",
4111
+ symbol: "LAOS",
4112
+ decimals: 18,
4113
+ multiLocation: {
4114
+ parents: 1,
4115
+ interior: {
4116
+ X1: {
4117
+ Parachain: 3370
4118
+ }
4119
+ }
4120
+ },
4121
+ existentialDeposit: "1"
4004
4122
  }
4005
4123
  ]
4006
4124
  };
@@ -4383,12 +4501,12 @@ var Interlay$3 = {
4383
4501
  };
4384
4502
  var Litentry$3 = {
4385
4503
  relayChainAssetSymbol: "DOT",
4386
- nativeAssetSymbol: "LIT",
4504
+ nativeAssetSymbol: "HEI",
4387
4505
  isEVM: false,
4388
4506
  supportsDryRunApi: false,
4389
4507
  nativeAssets: [
4390
4508
  {
4391
- symbol: "LIT",
4509
+ symbol: "HEI",
4392
4510
  decimals: 18,
4393
4511
  existentialDeposit: "100000000000000000"
4394
4512
  }
@@ -4543,6 +4661,28 @@ var Moonbeam$3 = {
4543
4661
  },
4544
4662
  existentialDeposit: "1"
4545
4663
  },
4664
+ {
4665
+ assetId: "66249247788835743307843320271452141931",
4666
+ symbol: "xcvBNC",
4667
+ decimals: 12,
4668
+ multiLocation: {
4669
+ parents: 1,
4670
+ interior: {
4671
+ X2: [
4672
+ {
4673
+ Parachain: 2030
4674
+ },
4675
+ {
4676
+ GeneralKey: {
4677
+ length: 2,
4678
+ data: "0x0101000000000000000000000000000000000000000000000000000000000000"
4679
+ }
4680
+ }
4681
+ ]
4682
+ }
4683
+ },
4684
+ existentialDeposit: "1"
4685
+ },
4546
4686
  {
4547
4687
  assetId: "125699734534028342599692732320197985871",
4548
4688
  symbol: "xcRING",
@@ -10989,12 +11129,13 @@ var Ethereum = {
10989
11129
  {
10990
11130
  GlobalConsensus: {
10991
11131
  Ethereum: {
10992
- chain_id: 1
11132
+ chainId: 1
10993
11133
  }
10994
11134
  }
10995
11135
  },
10996
11136
  {
10997
11137
  AccountKey20: {
11138
+ network: null,
10998
11139
  key: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
10999
11140
  }
11000
11141
  }
@@ -11013,12 +11154,13 @@ var Ethereum = {
11013
11154
  {
11014
11155
  GlobalConsensus: {
11015
11156
  Ethereum: {
11016
- chain_id: 1
11157
+ chainId: 1
11017
11158
  }
11018
11159
  }
11019
11160
  },
11020
11161
  {
11021
11162
  AccountKey20: {
11163
+ network: null,
11022
11164
  key: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
11023
11165
  }
11024
11166
  }
@@ -11037,12 +11179,13 @@ var Ethereum = {
11037
11179
  {
11038
11180
  GlobalConsensus: {
11039
11181
  Ethereum: {
11040
- chain_id: 1
11182
+ chainId: 1
11041
11183
  }
11042
11184
  }
11043
11185
  },
11044
11186
  {
11045
11187
  AccountKey20: {
11188
+ network: null,
11046
11189
  key: "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce"
11047
11190
  }
11048
11191
  }
@@ -11061,12 +11204,13 @@ var Ethereum = {
11061
11204
  {
11062
11205
  GlobalConsensus: {
11063
11206
  Ethereum: {
11064
- chain_id: 1
11207
+ chainId: 1
11065
11208
  }
11066
11209
  }
11067
11210
  },
11068
11211
  {
11069
11212
  AccountKey20: {
11213
+ network: null,
11070
11214
  key: "0x6982508145454ce325ddbe47a25d4ec3d2311933"
11071
11215
  }
11072
11216
  }
@@ -11085,12 +11229,13 @@ var Ethereum = {
11085
11229
  {
11086
11230
  GlobalConsensus: {
11087
11231
  Ethereum: {
11088
- chain_id: 1
11232
+ chainId: 1
11089
11233
  }
11090
11234
  }
11091
11235
  },
11092
11236
  {
11093
11237
  AccountKey20: {
11238
+ network: null,
11094
11239
  key: "0x582d872a1b094fc48f5de31d3b73f2d9be47def1"
11095
11240
  }
11096
11241
  }
@@ -11109,12 +11254,13 @@ var Ethereum = {
11109
11254
  {
11110
11255
  GlobalConsensus: {
11111
11256
  Ethereum: {
11112
- chain_id: 1
11257
+ chainId: 1
11113
11258
  }
11114
11259
  }
11115
11260
  },
11116
11261
  {
11117
11262
  AccountKey20: {
11263
+ network: null,
11118
11264
  key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
11119
11265
  }
11120
11266
  }
@@ -11133,12 +11279,13 @@ var Ethereum = {
11133
11279
  {
11134
11280
  GlobalConsensus: {
11135
11281
  Ethereum: {
11136
- chain_id: 1
11282
+ chainId: 1
11137
11283
  }
11138
11284
  }
11139
11285
  },
11140
11286
  {
11141
11287
  AccountKey20: {
11288
+ network: null,
11142
11289
  key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
11143
11290
  }
11144
11291
  }
@@ -11157,12 +11304,13 @@ var Ethereum = {
11157
11304
  {
11158
11305
  GlobalConsensus: {
11159
11306
  Ethereum: {
11160
- chain_id: 1
11307
+ chainId: 1
11161
11308
  }
11162
11309
  }
11163
11310
  },
11164
11311
  {
11165
11312
  AccountKey20: {
11313
+ network: null,
11166
11314
  key: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
11167
11315
  }
11168
11316
  }
@@ -11181,12 +11329,13 @@ var Ethereum = {
11181
11329
  {
11182
11330
  GlobalConsensus: {
11183
11331
  Ethereum: {
11184
- chain_id: 1
11332
+ chainId: 1
11185
11333
  }
11186
11334
  }
11187
11335
  },
11188
11336
  {
11189
11337
  AccountKey20: {
11338
+ network: null,
11190
11339
  key: "0xdac17f958d2ee523a2206206994597c13d831ec7"
11191
11340
  }
11192
11341
  }
@@ -11205,12 +11354,13 @@ var Ethereum = {
11205
11354
  {
11206
11355
  GlobalConsensus: {
11207
11356
  Ethereum: {
11208
- chain_id: 1
11357
+ chainId: 1
11209
11358
  }
11210
11359
  }
11211
11360
  },
11212
11361
  {
11213
11362
  AccountKey20: {
11363
+ network: null,
11214
11364
  key: "0x6b175474e89094c44da98b954eedeac495271d0f"
11215
11365
  }
11216
11366
  }
@@ -11229,12 +11379,13 @@ var Ethereum = {
11229
11379
  {
11230
11380
  GlobalConsensus: {
11231
11381
  Ethereum: {
11232
- chain_id: 1
11382
+ chainId: 1
11233
11383
  }
11234
11384
  }
11235
11385
  },
11236
11386
  {
11237
11387
  AccountKey20: {
11388
+ network: null,
11238
11389
  key: "0x5d3d01fd6d2ad1169b17918eb4f153c6616288eb"
11239
11390
  }
11240
11391
  }
@@ -11253,12 +11404,13 @@ var Ethereum = {
11253
11404
  {
11254
11405
  GlobalConsensus: {
11255
11406
  Ethereum: {
11256
- chain_id: 1
11407
+ chainId: 1
11257
11408
  }
11258
11409
  }
11259
11410
  },
11260
11411
  {
11261
11412
  AccountKey20: {
11413
+ network: null,
11262
11414
  key: "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9"
11263
11415
  }
11264
11416
  }
@@ -11807,11 +11959,12 @@ exports.PolkadotXcmError = void 0;
11807
11959
  })(exports.PolkadotXcmError || (exports.PolkadotXcmError = {}));
11808
11960
 
11809
11961
  var DEFAULT_FEE_ASSET = 0;
11810
- var ETH_CHAIN_ID = 1n;
11962
+ var ETH_PARA_ID = 1;
11963
+ var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
11811
11964
  var ETHEREUM_JUNCTION = {
11812
11965
  GlobalConsensus: {
11813
11966
  Ethereum: {
11814
- chain_id: ETH_CHAIN_ID
11967
+ chainId: ETH_CHAIN_ID
11815
11968
  }
11816
11969
  }
11817
11970
  };
@@ -13493,6 +13646,9 @@ var getNodeProviders = function getNodeProviders(node) {
13493
13646
  * @returns The parachain ID of the node.
13494
13647
  */
13495
13648
  var getParaId = function getParaId(node) {
13649
+ if (node === 'Ethereum') {
13650
+ return ETH_PARA_ID;
13651
+ }
13496
13652
  return getNodeConfig(node).paraId;
13497
13653
  };
13498
13654
 
@@ -13607,10 +13763,10 @@ var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(relay
13607
13763
  return node;
13608
13764
  };
13609
13765
  var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, node) {
13610
- var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
13766
+ var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
13611
13767
  isDestination: false
13612
13768
  },
13613
- isDestination = _ref7.isDestination;
13769
+ isDestination = _ref8.isDestination;
13614
13770
  if ('multilocation' in currency) {
13615
13771
  throw new InvalidCurrencyError("\n Selected chain doesn't support multilocation you provided. Maybe you meant custom multilocation. If so, you need to use override option. Your selection should look like this: {multilocation: Override(".concat(JSON.stringify(currency.multilocation), ")}."));
13616
13772
  }
@@ -13763,78 +13919,265 @@ var resolveParaId = function resolveParaId(paraId, destination) {
13763
13919
  return paraId !== null && paraId !== undefined ? paraId : getParaId(destination);
13764
13920
  };
13765
13921
 
13766
- var supportsXTokens = function supportsXTokens(obj) {
13767
- return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
13768
- };
13769
- var supportsXTransfer = function supportsXTransfer(obj) {
13770
- return _typeof(obj) === 'object' && obj !== null && 'transferXTransfer' in obj;
13771
- };
13772
- var supportsPolkadotXCM = function supportsPolkadotXCM(obj) {
13773
- return _typeof(obj) === 'object' && obj !== null && 'transferPolkadotXCM' in obj;
13774
- };
13775
- var ParachainNode = /*#__PURE__*/function () {
13776
- function ParachainNode(node, info, type, version) {
13777
- _classCallCheck(this, ParachainNode);
13778
- this._assetCheckEnabled = true;
13779
- this._info = info;
13780
- this._type = type;
13781
- this._node = node;
13782
- this._version = version;
13922
+ var calculateFee = /*#__PURE__*/function () {
13923
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
13924
+ var DEFAULT_FEE, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
13925
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13926
+ while (1) switch (_context.prev = _context.next) {
13927
+ case 0:
13928
+ DEFAULT_FEE = 2750872500000n;
13929
+ _context.next = 3;
13930
+ return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
13931
+ case 3:
13932
+ feeStorageItem = _context.sent;
13933
+ leFeeHex = feeStorageItem.replace('0x', '');
13934
+ _context.next = 7;
13935
+ return ahApi.disconnect();
13936
+ case 7:
13937
+ leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
13938
+ transfer_bridge_fee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
13939
+ transfer_assethub_execution_fee = 2200000000n;
13940
+ return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
13941
+ case 11:
13942
+ case "end":
13943
+ return _context.stop();
13944
+ }
13945
+ }, _callee);
13946
+ }));
13947
+ return function calculateFee(_x) {
13948
+ return _ref.apply(this, arguments);
13949
+ };
13950
+ }();
13951
+
13952
+ var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
13953
+ var isMultiLocation = _typeof(recipientAddress) === 'object';
13954
+ if (isMultiLocation) {
13955
+ return _defineProperty({}, version, recipientAddress);
13783
13956
  }
13784
- return _createClass(ParachainNode, [{
13785
- key: "info",
13786
- get: function get() {
13787
- return this._info;
13788
- }
13789
- }, {
13790
- key: "type",
13791
- get: function get() {
13792
- return this._type;
13793
- }
13794
- }, {
13795
- key: "node",
13796
- get: function get() {
13797
- return this._node;
13798
- }
13799
- }, {
13800
- key: "version",
13801
- get: function get() {
13802
- return this._version;
13803
- }
13804
- }, {
13805
- key: "assetCheckEnabled",
13806
- get: function get() {
13807
- return this._assetCheckEnabled;
13808
- }
13809
- }, {
13810
- key: "canUseXTokens",
13811
- value: function canUseXTokens(_) {
13812
- return true;
13813
- }
13814
- }, {
13815
- key: "transfer",
13816
- value: function () {
13817
- var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
13818
- var api, asset, address, destination, paraIdTo, overriddenAsset, version, ahAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
13819
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13820
- while (1) switch (_context.prev = _context.next) {
13821
- case 0:
13822
- api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
13823
- isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
13824
- scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
13825
- paraId = resolveParaId(paraIdTo, destination);
13826
- if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
13827
- _context.next = 6;
13828
- break;
13829
- }
13830
- throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
13831
- case 6:
13832
- versionOrDefault = version !== null && version !== undefined ? version : this.version;
13833
- if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
13834
- _context.next = 17;
13835
- break;
13836
- }
13837
- isBifrostOrigin = this.node === 'BifrostPolkadot' || this.node === 'BifrostKusama';
13957
+ var isEthAddress = ethers.ethers.isAddress(recipientAddress);
13958
+ if (scenario === 'ParaToRelay') {
13959
+ return _defineProperty({}, version, {
13960
+ parents: pallet === 'XTokens' ? exports.Parents.ONE : exports.Parents.ZERO,
13961
+ interior: createX1Payload(version, {
13962
+ AccountId32: _objectSpread2(_objectSpread2({}, version === exports.Version.V1 && {
13963
+ network: 'any'
13964
+ }), {}, {
13965
+ id: api.createAccountId(recipientAddress)
13966
+ })
13967
+ })
13968
+ });
13969
+ }
13970
+ if (scenario === 'ParaToPara' && pallet === 'XTokens') {
13971
+ return _defineProperty({}, version, {
13972
+ parents: exports.Parents.ONE,
13973
+ interior: {
13974
+ X2: [{
13975
+ Parachain: nodeId
13976
+ }, isEthAddress ? {
13977
+ AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13978
+ network: 'any'
13979
+ }), {}, {
13980
+ key: recipientAddress
13981
+ })
13982
+ } : {
13983
+ AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13984
+ network: 'any'
13985
+ }), {}, {
13986
+ id: api.createAccountId(recipientAddress)
13987
+ })
13988
+ }]
13989
+ }
13990
+ });
13991
+ }
13992
+ if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
13993
+ return _defineProperty({}, version, {
13994
+ parents: exports.Parents.ZERO,
13995
+ interior: createX1Payload(version, isEthAddress ? {
13996
+ AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
13997
+ network: 'any'
13998
+ }), {}, {
13999
+ key: recipientAddress
14000
+ })
14001
+ } : {
14002
+ AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
14003
+ network: 'any'
14004
+ }), {}, {
14005
+ id: api.createAccountId(recipientAddress)
14006
+ })
14007
+ })
14008
+ });
14009
+ }
14010
+ return _defineProperty({}, version, {
14011
+ parents: exports.Parents.ZERO,
14012
+ interior: createX1Payload(version, isEthAddress ? {
14013
+ AccountKey20: {
14014
+ key: recipientAddress
14015
+ }
14016
+ } : {
14017
+ AccountId32: {
14018
+ id: api.createAccountId(recipientAddress)
14019
+ }
14020
+ })
14021
+ });
14022
+ };
14023
+
14024
+ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
14025
+ var api = _ref.api,
14026
+ address = _ref.address,
14027
+ asset = _ref.asset,
14028
+ scenario = _ref.scenario,
14029
+ ahAddress = _ref.ahAddress;
14030
+ if (!isForeignAsset(asset)) {
14031
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
14032
+ }
14033
+ if (!asset.multiLocation) {
14034
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
14035
+ }
14036
+ var ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
14037
+ if (!ethAsset) {
14038
+ throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
14039
+ }
14040
+ return _defineProperty({}, version, [{
14041
+ SetAppendix: [{
14042
+ DepositAsset: {
14043
+ assets: {
14044
+ Wild: 'All'
14045
+ },
14046
+ beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== undefined ? ahAddress : '', version, undefined))[0]
14047
+ }
14048
+ }]
14049
+ }, {
14050
+ InitiateReserveWithdraw: {
14051
+ assets: {
14052
+ Wild: {
14053
+ AllOf: {
14054
+ id: asset.multiLocation,
14055
+ fun: 'Fungible'
14056
+ }
14057
+ }
14058
+ },
14059
+ reserve: {
14060
+ parents: exports.Parents.TWO,
14061
+ interior: {
14062
+ X1: [ETHEREUM_JUNCTION]
14063
+ }
14064
+ },
14065
+ xcm: [{
14066
+ BuyExecution: {
14067
+ fees: {
14068
+ id: {
14069
+ parents: exports.Parents.ZERO,
14070
+ interior: {
14071
+ X1: [{
14072
+ AccountKey20: {
14073
+ network: null,
14074
+ key: ethAsset.assetId
14075
+ }
14076
+ }]
14077
+ }
14078
+ },
14079
+ fun: {
14080
+ Fungible: 1n
14081
+ }
14082
+ },
14083
+ weight_limit: 'Unlimited'
14084
+ }
14085
+ }, {
14086
+ DepositAsset: {
14087
+ assets: {
14088
+ Wild: {
14089
+ AllCounted: 1
14090
+ }
14091
+ },
14092
+ beneficiary: {
14093
+ parents: exports.Parents.ZERO,
14094
+ interior: {
14095
+ X1: [{
14096
+ AccountKey20: {
14097
+ network: null,
14098
+ key: address
14099
+ }
14100
+ }]
14101
+ }
14102
+ }
14103
+ }
14104
+ }]
14105
+ }
14106
+ }]);
14107
+ };
14108
+
14109
+ var supportsXTokens = function supportsXTokens(obj) {
14110
+ return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
14111
+ };
14112
+ var supportsXTransfer = function supportsXTransfer(obj) {
14113
+ return _typeof(obj) === 'object' && obj !== null && 'transferXTransfer' in obj;
14114
+ };
14115
+ var supportsPolkadotXCM = function supportsPolkadotXCM(obj) {
14116
+ return _typeof(obj) === 'object' && obj !== null && 'transferPolkadotXCM' in obj;
14117
+ };
14118
+ var ParachainNode = /*#__PURE__*/function () {
14119
+ function ParachainNode(node, info, type, version) {
14120
+ _classCallCheck(this, ParachainNode);
14121
+ this._assetCheckEnabled = true;
14122
+ this._info = info;
14123
+ this._type = type;
14124
+ this._node = node;
14125
+ this._version = version;
14126
+ }
14127
+ return _createClass(ParachainNode, [{
14128
+ key: "info",
14129
+ get: function get() {
14130
+ return this._info;
14131
+ }
14132
+ }, {
14133
+ key: "type",
14134
+ get: function get() {
14135
+ return this._type;
14136
+ }
14137
+ }, {
14138
+ key: "node",
14139
+ get: function get() {
14140
+ return this._node;
14141
+ }
14142
+ }, {
14143
+ key: "version",
14144
+ get: function get() {
14145
+ return this._version;
14146
+ }
14147
+ }, {
14148
+ key: "assetCheckEnabled",
14149
+ get: function get() {
14150
+ return this._assetCheckEnabled;
14151
+ }
14152
+ }, {
14153
+ key: "canUseXTokens",
14154
+ value: function canUseXTokens(_) {
14155
+ return true;
14156
+ }
14157
+ }, {
14158
+ key: "transfer",
14159
+ value: function () {
14160
+ var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
14161
+ var api, asset, address, destination, paraIdTo, overriddenAsset, version, ahAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
14162
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14163
+ while (1) switch (_context.prev = _context.next) {
14164
+ case 0:
14165
+ api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
14166
+ isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
14167
+ scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
14168
+ paraId = resolveParaId(paraIdTo, destination);
14169
+ if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
14170
+ _context.next = 6;
14171
+ break;
14172
+ }
14173
+ throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
14174
+ case 6:
14175
+ versionOrDefault = version !== null && version !== undefined ? version : this.version;
14176
+ if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
14177
+ _context.next = 17;
14178
+ break;
14179
+ }
14180
+ isBifrostOrigin = this.node === 'BifrostPolkadot' || this.node === 'BifrostKusama';
13838
14181
  isAssetHubDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
13839
14182
  shouldUseMultiasset = isAssetHubDest && !isBifrostOrigin;
13840
14183
  input = {
@@ -13948,6 +14291,65 @@ var ParachainNode = /*#__PURE__*/function () {
13948
14291
  value: function getNativeAssetSymbol$1() {
13949
14292
  return getNativeAssetSymbol(this.node);
13950
14293
  }
14294
+ }, {
14295
+ key: "transferToEthereum",
14296
+ value: function () {
14297
+ var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
14298
+ var api, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, ahApi, fee, call;
14299
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14300
+ while (1) switch (_context2.prev = _context2.next) {
14301
+ case 0:
14302
+ api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, ahAddress = input.ahAddress;
14303
+ if (isForeignAsset(asset)) {
14304
+ _context2.next = 3;
14305
+ break;
14306
+ }
14307
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
14308
+ case 3:
14309
+ if (!(ahAddress === undefined)) {
14310
+ _context2.next = 5;
14311
+ break;
14312
+ }
14313
+ throw new Error('AssetHub address is required for Ethereum transfers');
14314
+ case 5:
14315
+ versionOrDefault = version !== null && version !== undefined ? version : exports.Version.V4;
14316
+ ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, asset.multiLocation))[0][0];
14317
+ _context2.next = 9;
14318
+ return api.createApiForNode('AssetHubPolkadot');
14319
+ case 9:
14320
+ ahApi = _context2.sent;
14321
+ _context2.next = 12;
14322
+ return calculateFee(ahApi);
14323
+ case 12:
14324
+ fee = _context2.sent;
14325
+ call = {
14326
+ module: 'PolkadotXcm',
14327
+ section: 'transfer_assets_using_type_and_then',
14328
+ parameters: {
14329
+ dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
14330
+ assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
14331
+ assets_transfer_type: 'DestinationReserve',
14332
+ remote_fees_id: _defineProperty({}, versionOrDefault, {
14333
+ parents: exports.Parents.ONE,
14334
+ interior: 'Here'
14335
+ }),
14336
+ fees_transfer_type: 'DestinationReserve',
14337
+ custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
14338
+ weight_limit: 'Unlimited'
14339
+ }
14340
+ };
14341
+ return _context2.abrupt("return", api.callTxMethod(call));
14342
+ case 15:
14343
+ case "end":
14344
+ return _context2.stop();
14345
+ }
14346
+ }, _callee2, this);
14347
+ }));
14348
+ function transferToEthereum(_x2) {
14349
+ return _transferToEthereum.apply(this, arguments);
14350
+ }
14351
+ return transferToEthereum;
14352
+ }()
13951
14353
  }]);
13952
14354
  }();
13953
14355
 
@@ -14102,8 +14504,8 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
14102
14504
  }
14103
14505
  // Handles DOT, WETH transfers to AssetHubPolkadot
14104
14506
  }, {
14105
- key: "transferPolkadotXCM",
14106
- value: function transferPolkadotXCM(input) {
14507
+ key: "transferToAssetHub",
14508
+ value: function transferToAssetHub(input) {
14107
14509
  var _getAssetId;
14108
14510
  var overriddenAsset = input.overriddenAsset,
14109
14511
  asset = input.asset;
@@ -14117,11 +14519,21 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
14117
14519
  } : undefined)
14118
14520
  }), 'transfer_assets', 'Unlimited'));
14119
14521
  }
14522
+ }, {
14523
+ key: "transferPolkadotXCM",
14524
+ value: function transferPolkadotXCM(input) {
14525
+ var destination = input.destination;
14526
+ if (destination === 'Ethereum') {
14527
+ return this.transferToEthereum(input);
14528
+ }
14529
+ return this.transferToAssetHub(input);
14530
+ }
14120
14531
  }, {
14121
14532
  key: "canUseXTokens",
14122
14533
  value: function canUseXTokens(_ref) {
14123
14534
  var asset = _ref.asset,
14124
14535
  destination = _ref.destination;
14536
+ if (destination === 'Ethereum') return false;
14125
14537
  return asset.symbol !== 'WETH' && asset.symbol !== 'DOT' || destination !== 'AssetHubPolkadot';
14126
14538
  }
14127
14539
  }]);
@@ -14177,57 +14589,14 @@ var ComposableFinance$1 = /*#__PURE__*/function (_ParachainNode) {
14177
14589
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
14178
14590
  }
14179
14591
  return XTokensTransferImpl.transferXTokens(input, BigInt(asset.assetId));
14180
- }
14181
- }]);
14182
- }(ParachainNode);
14183
-
14184
- var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
14185
- return {
14186
- parents: exports.Parents.TWO,
14187
- interior: {
14188
- X2: [ETHEREUM_JUNCTION, {
14189
- AccountKey20: {
14190
- key: currencyId
14191
- }
14192
- }]
14193
- }
14194
- };
14195
- };
14196
-
14197
- var calculateFee = /*#__PURE__*/function () {
14198
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
14199
- var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
14200
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14201
- while (1) switch (_context.prev = _context.next) {
14202
- case 0:
14203
- DEFAULT_FEE = 2750872500000n;
14204
- _context.next = 3;
14205
- return api.createApiForNode('AssetHubPolkadot');
14206
- case 3:
14207
- ahApi = _context.sent;
14208
- _context.next = 6;
14209
- return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
14210
- case 6:
14211
- feeStorageItem = _context.sent;
14212
- leFeeHex = feeStorageItem.replace('0x', '');
14213
- leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
14214
- transfer_bridge_fee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
14215
- transfer_assethub_execution_fee = 2200000000n;
14216
- return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
14217
- case 12:
14218
- case "end":
14219
- return _context.stop();
14220
- }
14221
- }, _callee);
14222
- }));
14223
- return function calculateFee(_x) {
14224
- return _ref.apply(this, arguments);
14225
- };
14226
- }();
14227
- var createCustomXcmAh = function createCustomXcmAh(_ref2, version) {
14228
- var api = _ref2.api,
14229
- scenario = _ref2.scenario,
14230
- address = _ref2.address;
14592
+ }
14593
+ }]);
14594
+ }(ParachainNode);
14595
+
14596
+ var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
14597
+ var api = _ref.api,
14598
+ scenario = _ref.scenario,
14599
+ address = _ref.address;
14231
14600
  return _defineProperty({}, version, [{
14232
14601
  DepositAsset: {
14233
14602
  assets: {
@@ -14239,84 +14608,6 @@ var createCustomXcmAh = function createCustomXcmAh(_ref2, version) {
14239
14608
  }
14240
14609
  }]);
14241
14610
  };
14242
- var createCustomXcmOnDest = function createCustomXcmOnDest(_ref4, version) {
14243
- var _asset$assetId;
14244
- var api = _ref4.api,
14245
- address = _ref4.address,
14246
- asset = _ref4.asset,
14247
- scenario = _ref4.scenario,
14248
- ahAddress = _ref4.ahAddress;
14249
- if (!isForeignAsset(asset)) {
14250
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
14251
- }
14252
- return _defineProperty({}, version, [{
14253
- SetAppendix: [{
14254
- DepositAsset: {
14255
- assets: {
14256
- Wild: 'All'
14257
- },
14258
- beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== undefined ? ahAddress : '', version, undefined))[0]
14259
- }
14260
- }]
14261
- }, {
14262
- InitiateReserveWithdraw: {
14263
- assets: {
14264
- Wild: {
14265
- AllOf: {
14266
- id: createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== undefined ? _asset$assetId : ''),
14267
- fun: 'Fungible'
14268
- }
14269
- }
14270
- },
14271
- reserve: {
14272
- parents: exports.Parents.TWO,
14273
- interior: {
14274
- X1: [ETHEREUM_JUNCTION]
14275
- }
14276
- },
14277
- xcm: [{
14278
- BuyExecution: {
14279
- fees: {
14280
- id: {
14281
- parents: exports.Parents.ZERO,
14282
- interior: {
14283
- X1: [{
14284
- AccountKey20: {
14285
- network: null,
14286
- key: asset.assetId
14287
- }
14288
- }]
14289
- }
14290
- },
14291
- fun: {
14292
- Fungible: 1n
14293
- }
14294
- },
14295
- weight_limit: 'Unlimited'
14296
- }
14297
- }, {
14298
- DepositAsset: {
14299
- assets: {
14300
- Wild: {
14301
- AllCounted: 1
14302
- }
14303
- },
14304
- beneficiary: {
14305
- parents: exports.Parents.ZERO,
14306
- interior: {
14307
- X1: [{
14308
- AccountKey20: {
14309
- network: null,
14310
- key: address
14311
- }
14312
- }]
14313
- }
14314
- }
14315
- }
14316
- }]
14317
- }
14318
- }]);
14319
- };
14320
14611
  var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
14321
14612
  function Hydration() {
14322
14613
  _classCallCheck(this, Hydration);
@@ -14324,74 +14615,6 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
14324
14615
  }
14325
14616
  _inherits(Hydration, _ParachainNode);
14326
14617
  return _createClass(Hydration, [{
14327
- key: "transferToEthereum",
14328
- value: function () {
14329
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
14330
- var _asset$symbol, _asset$assetId2;
14331
- var api, address, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
14332
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14333
- while (1) switch (_context2.prev = _context2.next) {
14334
- case 0:
14335
- api = input.api, address = input.address, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, ahAddress = input.ahAddress;
14336
- if (ethers.ethers.isAddress(address)) {
14337
- _context2.next = 3;
14338
- break;
14339
- }
14340
- throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
14341
- case 3:
14342
- if (!(((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toUpperCase()) !== 'WETH')) {
14343
- _context2.next = 5;
14344
- break;
14345
- }
14346
- throw new InvalidCurrencyError("Currency ".concat(asset.symbol, " is not supported for Ethereum transfers from Hydration"));
14347
- case 5:
14348
- if (isForeignAsset(asset)) {
14349
- _context2.next = 7;
14350
- break;
14351
- }
14352
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
14353
- case 7:
14354
- if (!(ahAddress === undefined)) {
14355
- _context2.next = 9;
14356
- break;
14357
- }
14358
- throw new Error('AssetHub address is required for Ethereum transfers');
14359
- case 9:
14360
- versionOrDefault = version !== null && version !== undefined ? version : exports.Version.V4;
14361
- ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, createEthereumTokenLocation((_asset$assetId2 = asset.assetId) !== null && _asset$assetId2 !== undefined ? _asset$assetId2 : '')))[0][0];
14362
- _context2.next = 13;
14363
- return calculateFee(api);
14364
- case 13:
14365
- fee = _context2.sent;
14366
- call = {
14367
- module: 'PolkadotXcm',
14368
- section: 'transfer_assets_using_type_and_then',
14369
- parameters: {
14370
- dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
14371
- assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
14372
- assets_transfer_type: 'DestinationReserve',
14373
- remote_fees_id: _defineProperty({}, versionOrDefault, {
14374
- parents: exports.Parents.ONE,
14375
- interior: 'Here'
14376
- }),
14377
- fees_transfer_type: 'DestinationReserve',
14378
- custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
14379
- weight_limit: 'Unlimited'
14380
- }
14381
- };
14382
- return _context2.abrupt("return", api.callTxMethod(call));
14383
- case 16:
14384
- case "end":
14385
- return _context2.stop();
14386
- }
14387
- }, _callee2, this);
14388
- }));
14389
- function transferToEthereum(_x2) {
14390
- return _transferToEthereum.apply(this, arguments);
14391
- }
14392
- return transferToEthereum;
14393
- }()
14394
- }, {
14395
14618
  key: "transferToAssetHub",
14396
14619
  value: function transferToAssetHub(input) {
14397
14620
  var api = input.api,
@@ -14420,30 +14643,30 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
14420
14643
  };
14421
14644
  return api.callTxMethod(call);
14422
14645
  }
14423
- // Handles WETH Ethereum transfers
14646
+ // Handles transfers to Ethereum
14424
14647
  }, {
14425
14648
  key: "transferPolkadotXCM",
14426
14649
  value: function () {
14427
- var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
14650
+ var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
14428
14651
  var destination;
14429
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14430
- while (1) switch (_context3.prev = _context3.next) {
14652
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14653
+ while (1) switch (_context.prev = _context.next) {
14431
14654
  case 0:
14432
14655
  destination = input.destination;
14433
14656
  if (!(destination === 'Ethereum')) {
14434
- _context3.next = 3;
14657
+ _context.next = 3;
14435
14658
  break;
14436
14659
  }
14437
- return _context3.abrupt("return", this.transferToEthereum(input));
14660
+ return _context.abrupt("return", this.transferToEthereum(input));
14438
14661
  case 3:
14439
- return _context3.abrupt("return", this.transferToAssetHub(input));
14662
+ return _context.abrupt("return", this.transferToAssetHub(input));
14440
14663
  case 4:
14441
14664
  case "end":
14442
- return _context3.stop();
14665
+ return _context.stop();
14443
14666
  }
14444
- }, _callee3, this);
14667
+ }, _callee, this);
14445
14668
  }));
14446
- function transferPolkadotXCM(_x3) {
14669
+ function transferPolkadotXCM(_x) {
14447
14670
  return _transferPolkadotXCM.apply(this, arguments);
14448
14671
  }
14449
14672
  return transferPolkadotXCM;
@@ -14462,9 +14685,9 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
14462
14685
  }
14463
14686
  }, {
14464
14687
  key: "canUseXTokens",
14465
- value: function canUseXTokens(_ref6) {
14466
- var destination = _ref6.destination,
14467
- asset = _ref6.asset;
14688
+ value: function canUseXTokens(_ref3) {
14689
+ var destination = _ref3.destination,
14690
+ asset = _ref3.asset;
14468
14691
  return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT');
14469
14692
  }
14470
14693
  }]);
@@ -14924,78 +15147,6 @@ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api
14924
15147
  });
14925
15148
  };
14926
15149
 
14927
- var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
14928
- var isMultiLocation = _typeof(recipientAddress) === 'object';
14929
- if (isMultiLocation) {
14930
- return _defineProperty({}, version, recipientAddress);
14931
- }
14932
- var isEthAddress = ethers.ethers.isAddress(recipientAddress);
14933
- if (scenario === 'ParaToRelay') {
14934
- return _defineProperty({}, version, {
14935
- parents: pallet === 'XTokens' ? exports.Parents.ONE : exports.Parents.ZERO,
14936
- interior: createX1Payload(version, {
14937
- AccountId32: _objectSpread2(_objectSpread2({}, version === exports.Version.V1 && {
14938
- network: 'any'
14939
- }), {}, {
14940
- id: api.createAccountId(recipientAddress)
14941
- })
14942
- })
14943
- });
14944
- }
14945
- if (scenario === 'ParaToPara' && pallet === 'XTokens') {
14946
- return _defineProperty({}, version, {
14947
- parents: exports.Parents.ONE,
14948
- interior: {
14949
- X2: [{
14950
- Parachain: nodeId
14951
- }, isEthAddress ? {
14952
- AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
14953
- network: 'any'
14954
- }), {}, {
14955
- key: recipientAddress
14956
- })
14957
- } : {
14958
- AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
14959
- network: 'any'
14960
- }), {}, {
14961
- id: api.createAccountId(recipientAddress)
14962
- })
14963
- }]
14964
- }
14965
- });
14966
- }
14967
- if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
14968
- return _defineProperty({}, version, {
14969
- parents: exports.Parents.ZERO,
14970
- interior: createX1Payload(version, isEthAddress ? {
14971
- AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
14972
- network: 'any'
14973
- }), {}, {
14974
- key: recipientAddress
14975
- })
14976
- } : {
14977
- AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
14978
- network: 'any'
14979
- }), {}, {
14980
- id: api.createAccountId(recipientAddress)
14981
- })
14982
- })
14983
- });
14984
- }
14985
- return _defineProperty({}, version, {
14986
- parents: exports.Parents.ZERO,
14987
- interior: createX1Payload(version, isEthAddress ? {
14988
- AccountKey20: {
14989
- key: recipientAddress
14990
- }
14991
- } : {
14992
- AccountId32: {
14993
- id: api.createAccountId(recipientAddress)
14994
- }
14995
- })
14996
- });
14997
- };
14998
-
14999
15150
  var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
15000
15151
  var api = _ref.api,
15001
15152
  address = _ref.address,
@@ -15015,26 +15166,27 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
15015
15166
  _classCallCheck(this, AssetHubPolkadot);
15016
15167
  _this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', exports.Version.V3]);
15017
15168
  _this.handleBifrostEthTransfer = function (input) {
15018
- var _asset$assetId;
15019
15169
  var api = input.api,
15020
15170
  scenario = input.scenario,
15021
15171
  version = input.version,
15022
15172
  destination = input.destination,
15023
15173
  asset = input.asset;
15024
15174
  if (!isForeignAsset(asset)) {
15025
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
15175
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
15176
+ }
15177
+ if (!asset.multiLocation) {
15178
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
15026
15179
  }
15027
15180
  var versionOrDefault = version !== null && version !== undefined ? version : _this.version;
15028
- var ethereumTokenLocation = createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== undefined ? _asset$assetId : '');
15029
15181
  var call = {
15030
15182
  module: 'PolkadotXcm',
15031
15183
  section: 'transfer_assets_using_type_and_then',
15032
15184
  parameters: {
15033
15185
  dest: _this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('BifrostPolkadot')),
15034
- assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, ethereumTokenLocation))[0][0]]),
15186
+ assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, asset.multiLocation))[0][0]]),
15035
15187
  assets_transfer_type: 'LocalReserve',
15036
15188
  remote_fees_id: _defineProperty({}, versionOrDefault, {
15037
- Concrete: ethereumTokenLocation
15189
+ Concrete: asset.multiLocation
15038
15190
  }),
15039
15191
  fees_transfer_type: 'LocalReserve',
15040
15192
  custom_xcm_on_dest: createCustomXcmToBifrost(input, versionOrDefault),
@@ -15069,7 +15221,6 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
15069
15221
  }, {
15070
15222
  key: "handleEthBridgeTransfer",
15071
15223
  value: function handleEthBridgeTransfer(input) {
15072
- var _ethAsset$assetId;
15073
15224
  var api = input.api,
15074
15225
  scenario = input.scenario,
15075
15226
  destination = input.destination,
@@ -15079,26 +15230,16 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
15079
15230
  if (!ethers.ethers.isAddress(address)) {
15080
15231
  throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
15081
15232
  }
15082
- var ethAssets = getOtherAssets('Ethereum');
15083
- var ethAsset = ethAssets.find(function (asset) {
15084
- return asset.symbol === asset.symbol;
15085
- });
15086
- if (!ethAsset) {
15087
- throw new InvalidCurrencyError("Currency ".concat(asset.symbol, " is not supported for Ethereum transfers"));
15233
+ if (!isForeignAsset(asset)) {
15234
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
15235
+ }
15236
+ if (!asset.multiLocation) {
15237
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
15088
15238
  }
15089
15239
  var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
15090
15240
  header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, exports.Parents.TWO),
15091
15241
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
15092
- currencySelection: createCurrencySpec(input.asset.amount, exports.Version.V3, exports.Parents.TWO, {
15093
- parents: exports.Parents.TWO,
15094
- interior: {
15095
- X2: [ETHEREUM_JUNCTION, {
15096
- AccountKey20: {
15097
- key: (_ethAsset$assetId = ethAsset.assetId) !== null && _ethAsset$assetId !== undefined ? _ethAsset$assetId : ''
15098
- }
15099
- }]
15100
- }
15101
- })
15242
+ currencySelection: createCurrencySpec(input.asset.amount, exports.Version.V3, exports.Parents.TWO, asset.multiLocation)
15102
15243
  });
15103
15244
  return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited');
15104
15245
  }
@@ -16466,25 +16607,29 @@ var findAssetById = function findAssetById(assets, assetId) {
16466
16607
  var sanitizeMultiLocation = function sanitizeMultiLocation(multiLocation) {
16467
16608
  return multiLocation.replace(/"(\d+),(\d+)"/g, '"$1$2"');
16468
16609
  };
16610
+ var compareMultiLocations = function compareMultiLocations(input, asset) {
16611
+ var _asset$multiLocation, _asset$xcmInterior;
16612
+ var sanitizedInput = sanitizeMultiLocation(input);
16613
+ var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
16614
+ var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
16615
+ var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
16616
+ var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
16617
+ return (
16618
+ // Compare sanitized input with sanitized asset values
16619
+ sanitizedInput === sanitizedAssetMLStr || sanitizedInput === sanitizedAssetMLInteriorStr ||
16620
+ // Compare original input with sanitized asset values
16621
+ input === sanitizedAssetMLStr || input === sanitizedAssetMLInteriorStr ||
16622
+ // Compare original input with original asset values
16623
+ input === assetMLStr || input === assetMLInteriorStr ||
16624
+ // Compare sanitized input with original asset values
16625
+ sanitizedInput === assetMLStr || sanitizedInput === assetMLInteriorStr
16626
+ );
16627
+ };
16628
+
16469
16629
  var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets, multiLocation) {
16470
16630
  if (typeof multiLocation === 'string') {
16471
- var sanitizedInput = sanitizeMultiLocation(multiLocation);
16472
16631
  return foreignAssets.find(function (asset) {
16473
- var _asset$multiLocation, _asset$xcmInterior;
16474
- var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
16475
- var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
16476
- var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
16477
- var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
16478
- return (
16479
- // Compare inputNoCommas with assetNoCommas
16480
- sanitizedInput === sanitizedAssetMLStr || sanitizedInput === sanitizedAssetMLInteriorStr ||
16481
- // Compare inputOriginal with assetNoCommas
16482
- multiLocation === sanitizedAssetMLStr || multiLocation === sanitizedAssetMLInteriorStr ||
16483
- // Compare inputOriginal with assetOriginal
16484
- multiLocation === assetMLStr || multiLocation === assetMLInteriorStr ||
16485
- // Compare inputNoCommas with assetOriginal
16486
- sanitizedInput === assetMLStr || sanitizedInput === assetMLInteriorStr
16487
- );
16632
+ return compareMultiLocations(multiLocation, asset);
16488
16633
  });
16489
16634
  } else if (Array.isArray(multiLocation)) {
16490
16635
  return foreignAssets.find(function (asset) {
@@ -16497,6 +16642,15 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
16497
16642
  }
16498
16643
  };
16499
16644
 
16645
+ var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
16646
+ var ethAssets = getOtherAssets('Ethereum');
16647
+ return assets.filter(function (asset) {
16648
+ var assetMultiLoc = asset.multiLocation || asset.xcmInterior;
16649
+ if (!assetMultiLoc) return false;
16650
+ return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
16651
+ });
16652
+ };
16653
+
16500
16654
  var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency, destination) {
16501
16655
  if ('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) || 'multiasset' in currency) {
16502
16656
  return null;
@@ -16504,21 +16658,37 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency, destina
16504
16658
  var _getAssetsObject = getAssetsObject(node),
16505
16659
  otherAssets = _getAssetsObject.otherAssets,
16506
16660
  nativeAssets = _getAssetsObject.nativeAssets;
16507
- var resolvedOtherAssets = destination === 'Ethereum' ? getOtherAssets('Ethereum') : otherAssets;
16661
+ var isEthereumDestination = destination === 'Ethereum';
16662
+ var getEthereumAssets = function getEthereumAssets() {
16663
+ return getOtherAssets('Ethereum');
16664
+ };
16665
+ var getFilteredEthereumAssets = function getFilteredEthereumAssets() {
16666
+ return filterEthCompatibleAssets(otherAssets);
16667
+ };
16508
16668
  var asset;
16509
16669
  if ('symbol' in currency) {
16510
- asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol);
16670
+ // If destination is Ethereum first try to find Ethereum compatible assets
16671
+ // If not found, search Ethereum assets directly
16672
+ if (isEthereumDestination) {
16673
+ var _findAssetBySymbol;
16674
+ asset = (_findAssetBySymbol = findAssetBySymbol(node, destination, getFilteredEthereumAssets(), nativeAssets, currency.symbol)) !== null && _findAssetBySymbol !== undefined ? _findAssetBySymbol : findAssetBySymbol(node, destination, getEthereumAssets(), nativeAssets, currency.symbol);
16675
+ } else {
16676
+ asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol);
16677
+ }
16511
16678
  } else if ('multilocation' in currency && !isOverrideMultiLocationSpecifier(currency.multilocation)) {
16512
- asset = findAssetByMultiLocation(resolvedOtherAssets, currency.multilocation);
16679
+ var resolvedAssets = isEthereumDestination ? getEthereumAssets() : otherAssets;
16680
+ asset = findAssetByMultiLocation(resolvedAssets, currency.multilocation);
16513
16681
  } else if ('id' in currency) {
16514
- asset = findAssetById(resolvedOtherAssets, currency.id);
16682
+ if (isEthereumDestination) {
16683
+ var _findAssetById;
16684
+ asset = (_findAssetById = findAssetById(getFilteredEthereumAssets(), currency.id)) !== null && _findAssetById !== undefined ? _findAssetById : findAssetById(getEthereumAssets(), currency.id);
16685
+ } else {
16686
+ asset = findAssetById(otherAssets, currency.id);
16687
+ }
16515
16688
  } else {
16516
16689
  throw new Error('Invalid currency input');
16517
16690
  }
16518
- if (asset) {
16519
- return asset;
16520
- }
16521
- return null;
16691
+ return asset !== null && asset !== undefined ? asset : null;
16522
16692
  };
16523
16693
 
16524
16694
  var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
@@ -16718,6 +16888,9 @@ var getTNode = function getTNode(paraId, ecosystem) {
16718
16888
  if (paraId === 0) {
16719
16889
  return ecosystem === 'polkadot' ? 'Polkadot' : 'Kusama';
16720
16890
  }
16891
+ if (paraId === 1) {
16892
+ return 'Ethereum';
16893
+ }
16721
16894
  return (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
16722
16895
  return getNode(nodeName).type === ecosystem && getParaId(nodeName) === paraId;
16723
16896
  })) !== null && _NODE_NAMES_DOT_KSM$f !== undefined ? _NODE_NAMES_DOT_KSM$f : null;
@@ -18397,16 +18570,16 @@ var Builder = function Builder(api) {
18397
18570
  var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
18398
18571
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
18399
18572
  var _getExistentialDeposi;
18400
- var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
18573
+ var api, account, accountDestination, ahAccount, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
18401
18574
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18402
18575
  while (1) switch (_context.prev = _context.next) {
18403
18576
  case 0:
18404
- api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === undefined ? 10 : _ref$feeMarginPercent;
18577
+ api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAccount = _ref.ahAccount, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === undefined ? 10 : _ref$feeMarginPercent;
18405
18578
  _context.next = 3;
18406
18579
  return api.init(origin);
18407
18580
  case 3:
18408
18581
  _context.next = 5;
18409
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).build();
18582
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination, ahAccount).build();
18410
18583
  case 5:
18411
18584
  tx = _context.sent;
18412
18585
  _context.next = 8;
@@ -18795,7 +18968,10 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
18795
18968
  var originAssets = getAssets(origin);
18796
18969
  var destinationAssets = getAssets(destination);
18797
18970
  if (destination === 'Ethereum' || origin === 'Ethereum') {
18798
- return getOtherAssets('Ethereum');
18971
+ var otherAssets = getOtherAssets(origin);
18972
+ var ethereumCompatibleAssets = filterEthCompatibleAssets(otherAssets);
18973
+ var ethereumAssets = getOtherAssets('Ethereum');
18974
+ return [].concat(_toConsumableArray(ethereumCompatibleAssets), _toConsumableArray(ethereumAssets));
18799
18975
  }
18800
18976
  if (origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot') {
18801
18977
  var polkadotAsset = getAssetBySymbolOrId('Polkadot', {
@@ -19137,7 +19313,7 @@ var validateDestination = function validateDestination(origin, destination) {
19137
19313
  if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination)) {
19138
19314
  throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
19139
19315
  }
19140
- if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration') {
19316
+ if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration' && origin !== 'BifrostPolkadot') {
19141
19317
  throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
19142
19318
  }
19143
19319
  var isMultiLocationDestination = _typeof(destination) === 'object';
@@ -19272,33 +19448,39 @@ var send = /*#__PURE__*/function () {
19272
19448
  validateCurrency(currency);
19273
19449
  validateDestination(origin, destination);
19274
19450
  validateDestinationAddress(address, destination);
19275
- if (!(isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination))) {
19451
+ if (!(ahAddress && ethers.ethers.isAddress(ahAddress))) {
19276
19452
  _context.next = 6;
19277
19453
  break;
19278
19454
  }
19279
- throw new Error('Relay chain to relay chain transfers are not supported.');
19455
+ throw new Error('AssetHub address needs to be in Substrate format');
19280
19456
  case 6:
19457
+ if (!(isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination))) {
19458
+ _context.next = 8;
19459
+ break;
19460
+ }
19461
+ throw new Error('Relay chain to relay chain transfers are not supported.');
19462
+ case 8:
19281
19463
  isBridge = isBridgeTransfer(origin, destination);
19282
19464
  assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
19283
19465
  validateAssetSpecifiers(assetCheckEnabled, currency);
19284
19466
  asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
19285
19467
  validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
19286
19468
  if (!isRelayChain(origin)) {
19287
- _context.next = 17;
19469
+ _context.next = 19;
19288
19470
  break;
19289
19471
  }
19290
19472
  if (!(destination === 'Ethereum')) {
19291
- _context.next = 14;
19473
+ _context.next = 16;
19292
19474
  break;
19293
19475
  }
19294
19476
  throw new Error('Transfers from relay chain to Ethereum are not supported.');
19295
- case 14:
19477
+ case 16:
19296
19478
  if (asset) {
19297
- _context.next = 16;
19479
+ _context.next = 18;
19298
19480
  break;
19299
19481
  }
19300
19482
  throw new Error('Asset is required for relay chain to relay chain transfers.');
19301
- case 16:
19483
+ case 18:
19302
19484
  return _context.abrupt("return", transferRelayToPara({
19303
19485
  api: api,
19304
19486
  origin: origin,
@@ -19312,11 +19494,11 @@ var send = /*#__PURE__*/function () {
19312
19494
  pallet: pallet,
19313
19495
  method: method
19314
19496
  }));
19315
- case 17:
19497
+ case 19:
19316
19498
  overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled);
19317
- _context.next = 20;
19499
+ _context.next = 22;
19318
19500
  return api.init(origin);
19319
- case 20:
19501
+ case 22:
19320
19502
  // In case asset check is disabled, we create asset object from currency symbol
19321
19503
  resolvedAsset = asset !== null && asset !== undefined ? asset : {
19322
19504
  symbol: 'symbol' in currency ? currency.symbol : undefined
@@ -19336,7 +19518,7 @@ var send = /*#__PURE__*/function () {
19336
19518
  pallet: pallet,
19337
19519
  method: method
19338
19520
  }));
19339
- case 23:
19521
+ case 25:
19340
19522
  case "end":
19341
19523
  return _context.stop();
19342
19524
  }
@@ -19614,6 +19796,8 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
19614
19796
  exports.Builder = Builder;
19615
19797
  exports.DuplicateAssetError = DuplicateAssetError;
19616
19798
  exports.DuplicateAssetIdError = DuplicateAssetIdError;
19799
+ exports.ETHEREUM_JUNCTION = ETHEREUM_JUNCTION;
19800
+ exports.ETH_CHAIN_ID = ETH_CHAIN_ID;
19617
19801
  exports.Foreign = Foreign;
19618
19802
  exports.ForeignAbstract = ForeignAbstract;
19619
19803
  exports.GeneralBuilder = GeneralBuilder;
@@ -19630,6 +19814,7 @@ exports.NodeNotSupportedError = NodeNotSupportedError;
19630
19814
  exports.Override = Override;
19631
19815
  exports.SUPPORTED_PALLETS = SUPPORTED_PALLETS;
19632
19816
  exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
19817
+ exports.calculateFee = calculateFee;
19633
19818
  exports.claimAssets = claimAssets;
19634
19819
  exports.computeFeeFromDryRun = computeFeeFromDryRun;
19635
19820
  exports.computeFeeFromDryRunPjs = computeFeeFromDryRunPjs;
@@ -19690,3 +19875,4 @@ exports.resolveParaId = resolveParaId;
19690
19875
  exports.send = send;
19691
19876
  exports.transferMoonbeamEvm = transferMoonbeamEvm;
19692
19877
  exports.transferRelayToPara = transferRelayToPara;
19878
+ exports.validateAddress = validateAddress;