@paraspell/sdk-core 8.5.2 → 8.5.3

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
@@ -6103,260 +6103,286 @@ var AssetHubPolkadot$3 = {
6103
6103
  assetId: "1024",
6104
6104
  symbol: "NCTR",
6105
6105
  decimals: 18,
6106
- xcmInterior: [
6107
- {
6108
- Network: "polkadot"
6109
- },
6110
- {
6111
- Parachain: 1000
6112
- },
6113
- {
6114
- PalletInstance: 50
6115
- },
6116
- {
6117
- GeneralIndex: 1024
6118
- }
6119
- ],
6106
+ multiLocation: {
6107
+ parents: 1,
6108
+ interior: {
6109
+ X3: [
6110
+ {
6111
+ Parachain: 1000
6112
+ },
6113
+ {
6114
+ PalletInstance: 50
6115
+ },
6116
+ {
6117
+ GeneralIndex: 1024
6118
+ }
6119
+ ]
6120
+ }
6121
+ },
6120
6122
  existentialDeposit: "100000000"
6121
6123
  },
6122
6124
  {
6123
6125
  assetId: "1337",
6124
6126
  symbol: "USDC",
6125
6127
  decimals: 6,
6126
- xcmInterior: [
6127
- {
6128
- Network: "polkadot"
6129
- },
6130
- {
6131
- Parachain: 1000
6132
- },
6133
- {
6134
- PalletInstance: 50
6135
- },
6136
- {
6137
- GeneralIndex: 1337
6138
- }
6139
- ],
6128
+ multiLocation: {
6129
+ parents: 1,
6130
+ interior: {
6131
+ X3: [
6132
+ {
6133
+ Parachain: 1000
6134
+ },
6135
+ {
6136
+ PalletInstance: 50
6137
+ },
6138
+ {
6139
+ GeneralIndex: 1337
6140
+ }
6141
+ ]
6142
+ }
6143
+ },
6140
6144
  existentialDeposit: "10000"
6141
6145
  },
6142
6146
  {
6143
6147
  assetId: "17",
6144
6148
  symbol: "WIFD",
6145
6149
  decimals: 10,
6146
- xcmInterior: [
6147
- {
6148
- Network: "polkadot"
6149
- },
6150
- {
6151
- Parachain: 1000
6152
- },
6153
- {
6154
- PalletInstance: 50
6155
- },
6156
- {
6157
- GeneralIndex: 17
6158
- }
6159
- ],
6150
+ multiLocation: {
6151
+ parents: 1,
6152
+ interior: {
6153
+ X3: [
6154
+ {
6155
+ Parachain: 1000
6156
+ },
6157
+ {
6158
+ PalletInstance: 50
6159
+ },
6160
+ {
6161
+ GeneralIndex: 17
6162
+ }
6163
+ ]
6164
+ }
6165
+ },
6160
6166
  existentialDeposit: "1"
6161
6167
  },
6162
6168
  {
6163
6169
  assetId: "1984",
6164
6170
  symbol: "USDt",
6165
6171
  decimals: 6,
6166
- xcmInterior: [
6167
- {
6168
- Network: "polkadot"
6169
- },
6170
- {
6171
- Parachain: 1000
6172
- },
6173
- {
6174
- PalletInstance: 50
6175
- },
6176
- {
6177
- GeneralIndex: 1984
6178
- }
6179
- ],
6172
+ multiLocation: {
6173
+ parents: 1,
6174
+ interior: {
6175
+ X3: [
6176
+ {
6177
+ Parachain: 1000
6178
+ },
6179
+ {
6180
+ PalletInstance: 50
6181
+ },
6182
+ {
6183
+ GeneralIndex: 1984
6184
+ }
6185
+ ]
6186
+ }
6187
+ },
6180
6188
  existentialDeposit: "10000"
6181
6189
  },
6182
6190
  {
6183
6191
  assetId: "21",
6184
6192
  symbol: "WBTC",
6185
6193
  decimals: 8,
6186
- xcmInterior: [
6187
- {
6188
- Network: "polkadot"
6189
- },
6190
- {
6191
- Parachain: 1000
6192
- },
6193
- {
6194
- PalletInstance: 50
6195
- },
6196
- {
6197
- GeneralIndex: 21
6198
- }
6199
- ],
6194
+ multiLocation: {
6195
+ parents: 1,
6196
+ interior: {
6197
+ X3: [
6198
+ {
6199
+ Parachain: 1000
6200
+ },
6201
+ {
6202
+ PalletInstance: 50
6203
+ },
6204
+ {
6205
+ GeneralIndex: 21
6206
+ }
6207
+ ]
6208
+ }
6209
+ },
6200
6210
  existentialDeposit: "3000"
6201
6211
  },
6202
6212
  {
6203
6213
  assetId: "22222012",
6204
6214
  symbol: "DAMN",
6205
6215
  decimals: 12,
6206
- xcmInterior: [
6207
- {
6208
- Network: "polkadot"
6209
- },
6210
- {
6211
- Parachain: 1000
6212
- },
6213
- {
6214
- PalletInstance: 50
6215
- },
6216
- {
6217
- GeneralIndex: 22222012
6218
- }
6219
- ],
6216
+ multiLocation: {
6217
+ parents: 1,
6218
+ interior: {
6219
+ X3: [
6220
+ {
6221
+ Parachain: 1000
6222
+ },
6223
+ {
6224
+ PalletInstance: 50
6225
+ },
6226
+ {
6227
+ GeneralIndex: 22222012
6228
+ }
6229
+ ]
6230
+ }
6231
+ },
6220
6232
  existentialDeposit: "1000000000000"
6221
6233
  },
6222
6234
  {
6223
6235
  assetId: "23",
6224
6236
  symbol: "PINK",
6225
6237
  decimals: 10,
6226
- xcmInterior: [
6227
- {
6228
- Network: "polkadot"
6229
- },
6230
- {
6231
- Parachain: 1000
6232
- },
6233
- {
6234
- PalletInstance: 50
6235
- },
6236
- {
6237
- GeneralIndex: 23
6238
- }
6239
- ],
6238
+ multiLocation: {
6239
+ parents: 1,
6240
+ interior: {
6241
+ X3: [
6242
+ {
6243
+ Parachain: 1000
6244
+ },
6245
+ {
6246
+ PalletInstance: 50
6247
+ },
6248
+ {
6249
+ GeneralIndex: 23
6250
+ }
6251
+ ]
6252
+ }
6253
+ },
6240
6254
  existentialDeposit: "1"
6241
6255
  },
6242
6256
  {
6243
6257
  assetId: "30",
6244
6258
  symbol: "DED",
6245
6259
  decimals: 10,
6246
- xcmInterior: [
6247
- {
6248
- Network: "polkadot"
6249
- },
6250
- {
6251
- Parachain: 1000
6252
- },
6253
- {
6254
- PalletInstance: 50
6255
- },
6256
- {
6257
- GeneralIndex: 30
6258
- }
6259
- ],
6260
+ multiLocation: {
6261
+ parents: 1,
6262
+ interior: {
6263
+ X3: [
6264
+ {
6265
+ Parachain: 1000
6266
+ },
6267
+ {
6268
+ PalletInstance: 50
6269
+ },
6270
+ {
6271
+ GeneralIndex: 30
6272
+ }
6273
+ ]
6274
+ }
6275
+ },
6260
6276
  existentialDeposit: "1"
6261
6277
  },
6262
6278
  {
6263
6279
  assetId: "31337",
6264
6280
  symbol: "WUD",
6265
6281
  decimals: 10,
6266
- xcmInterior: [
6267
- {
6268
- Network: "polkadot"
6269
- },
6270
- {
6271
- Parachain: 1000
6272
- },
6273
- {
6274
- PalletInstance: 50
6275
- },
6276
- {
6277
- GeneralIndex: 31337
6278
- }
6279
- ],
6282
+ multiLocation: {
6283
+ parents: 1,
6284
+ interior: {
6285
+ X3: [
6286
+ {
6287
+ Parachain: 1000
6288
+ },
6289
+ {
6290
+ PalletInstance: 50
6291
+ },
6292
+ {
6293
+ GeneralIndex: 31337
6294
+ }
6295
+ ]
6296
+ }
6297
+ },
6280
6298
  existentialDeposit: "10000000"
6281
6299
  },
6282
6300
  {
6283
6301
  assetId: "42069",
6284
6302
  symbol: "STINK",
6285
6303
  decimals: 10,
6286
- xcmInterior: [
6287
- {
6288
- Network: "polkadot"
6289
- },
6290
- {
6291
- Parachain: 1000
6292
- },
6293
- {
6294
- PalletInstance: 50
6295
- },
6296
- {
6297
- GeneralIndex: 42069
6298
- }
6299
- ],
6304
+ multiLocation: {
6305
+ parents: 1,
6306
+ interior: {
6307
+ X3: [
6308
+ {
6309
+ Parachain: 1000
6310
+ },
6311
+ {
6312
+ PalletInstance: 50
6313
+ },
6314
+ {
6315
+ GeneralIndex: 42069
6316
+ }
6317
+ ]
6318
+ }
6319
+ },
6300
6320
  existentialDeposit: "1000000"
6301
6321
  },
6302
6322
  {
6303
6323
  assetId: "50000028",
6304
6324
  symbol: "LOVA",
6305
6325
  decimals: 12,
6306
- xcmInterior: [
6307
- {
6308
- Network: "polkadot"
6309
- },
6310
- {
6311
- Parachain: 1000
6312
- },
6313
- {
6314
- PalletInstance: 50
6315
- },
6316
- {
6317
- GeneralIndex: 50000028
6318
- }
6319
- ],
6326
+ multiLocation: {
6327
+ parents: 1,
6328
+ interior: {
6329
+ X3: [
6330
+ {
6331
+ Parachain: 1000
6332
+ },
6333
+ {
6334
+ PalletInstance: 50
6335
+ },
6336
+ {
6337
+ GeneralIndex: 50000028
6338
+ }
6339
+ ]
6340
+ }
6341
+ },
6320
6342
  existentialDeposit: "1000000000000"
6321
6343
  },
6322
6344
  {
6323
6345
  assetId: "50000069",
6324
6346
  symbol: "LOTY",
6325
6347
  decimals: 12,
6326
- xcmInterior: [
6327
- {
6328
- Network: "polkadot"
6329
- },
6330
- {
6331
- Parachain: 1000
6332
- },
6333
- {
6334
- PalletInstance: 50
6335
- },
6336
- {
6337
- GeneralIndex: 50000069
6338
- }
6339
- ],
6348
+ multiLocation: {
6349
+ parents: 1,
6350
+ interior: {
6351
+ X3: [
6352
+ {
6353
+ Parachain: 1000
6354
+ },
6355
+ {
6356
+ PalletInstance: 50
6357
+ },
6358
+ {
6359
+ GeneralIndex: 50000069
6360
+ }
6361
+ ]
6362
+ }
6363
+ },
6340
6364
  existentialDeposit: "100000000"
6341
6365
  },
6342
6366
  {
6343
6367
  assetId: "555",
6344
6368
  symbol: "GAME",
6345
6369
  decimals: 10,
6346
- xcmInterior: [
6347
- {
6348
- Network: "polkadot"
6349
- },
6350
- {
6351
- Parachain: 1000
6352
- },
6353
- {
6354
- PalletInstance: 50
6355
- },
6356
- {
6357
- GeneralIndex: 555
6358
- }
6359
- ],
6370
+ multiLocation: {
6371
+ parents: 1,
6372
+ interior: {
6373
+ X3: [
6374
+ {
6375
+ Parachain: 1000
6376
+ },
6377
+ {
6378
+ PalletInstance: 50
6379
+ },
6380
+ {
6381
+ GeneralIndex: 555
6382
+ }
6383
+ ]
6384
+ }
6385
+ },
6360
6386
  existentialDeposit: "100000"
6361
6387
  },
6362
6388
  {
@@ -10337,80 +10363,88 @@ var AssetHubKusama$3 = {
10337
10363
  assetId: "16",
10338
10364
  symbol: "ARIS",
10339
10365
  decimals: 8,
10340
- xcmInterior: [
10341
- {
10342
- Network: "kusama"
10343
- },
10344
- {
10345
- Parachain: 1000
10346
- },
10347
- {
10348
- PalletInstance: 50
10349
- },
10350
- {
10351
- GeneralIndex: 16
10352
- }
10353
- ],
10366
+ multiLocation: {
10367
+ parents: 1,
10368
+ interior: {
10369
+ X3: [
10370
+ {
10371
+ Parachain: 1000
10372
+ },
10373
+ {
10374
+ PalletInstance: 50
10375
+ },
10376
+ {
10377
+ GeneralIndex: 16
10378
+ }
10379
+ ]
10380
+ }
10381
+ },
10354
10382
  existentialDeposit: "10000000"
10355
10383
  },
10356
10384
  {
10357
10385
  assetId: "1984",
10358
10386
  symbol: "USDt",
10359
10387
  decimals: 6,
10360
- xcmInterior: [
10361
- {
10362
- Network: "kusama"
10363
- },
10364
- {
10365
- Parachain: 1000
10366
- },
10367
- {
10368
- PalletInstance: 50
10369
- },
10370
- {
10371
- GeneralIndex: 1984
10372
- }
10373
- ],
10388
+ multiLocation: {
10389
+ parents: 1,
10390
+ interior: {
10391
+ X3: [
10392
+ {
10393
+ Parachain: 1000
10394
+ },
10395
+ {
10396
+ PalletInstance: 50
10397
+ },
10398
+ {
10399
+ GeneralIndex: 1984
10400
+ }
10401
+ ]
10402
+ }
10403
+ },
10374
10404
  existentialDeposit: "100"
10375
10405
  },
10376
10406
  {
10377
10407
  assetId: "223",
10378
10408
  symbol: "BILL",
10379
10409
  decimals: 8,
10380
- xcmInterior: [
10381
- {
10382
- Network: "kusama"
10383
- },
10384
- {
10385
- Parachain: 1000
10386
- },
10387
- {
10388
- PalletInstance: 50
10389
- },
10390
- {
10391
- GeneralIndex: 223
10392
- }
10393
- ],
10410
+ multiLocation: {
10411
+ parents: 1,
10412
+ interior: {
10413
+ X3: [
10414
+ {
10415
+ Parachain: 1000
10416
+ },
10417
+ {
10418
+ PalletInstance: 50
10419
+ },
10420
+ {
10421
+ GeneralIndex: 223
10422
+ }
10423
+ ]
10424
+ }
10425
+ },
10394
10426
  existentialDeposit: "10000"
10395
10427
  },
10396
10428
  {
10397
10429
  assetId: "8",
10398
10430
  symbol: "RMRK",
10399
10431
  decimals: 10,
10400
- xcmInterior: [
10401
- {
10402
- Network: "kusama"
10403
- },
10404
- {
10405
- Parachain: 1000
10406
- },
10407
- {
10408
- PalletInstance: 50
10409
- },
10410
- {
10411
- GeneralIndex: 8
10412
- }
10413
- ],
10432
+ multiLocation: {
10433
+ parents: 1,
10434
+ interior: {
10435
+ X3: [
10436
+ {
10437
+ Parachain: 1000
10438
+ },
10439
+ {
10440
+ PalletInstance: 50
10441
+ },
10442
+ {
10443
+ GeneralIndex: 8
10444
+ }
10445
+ ]
10446
+ }
10447
+ },
10414
10448
  existentialDeposit: "10000"
10415
10449
  },
10416
10450
  {
@@ -12776,7 +12810,7 @@ var NODES_WITH_RELAY_CHAINS_DOT_KSM = [].concat(NODE_NAMES_DOT_KSM, ['Polkadot',
12776
12810
  var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm', 'XTransfer', 'XcmPallet'];
12777
12811
 
12778
12812
  var isForeignAsset = function isForeignAsset(asset) {
12779
- return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset || 'xcmInterior' in asset) && !('isNative' in asset);
12813
+ return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
12780
12814
  };
12781
12815
 
12782
12816
  var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
@@ -14578,11 +14612,6 @@ var buildMultiLocation = function buildMultiLocation(_ref) {
14578
14612
  }
14579
14613
  if (assetHubAsset.multiLocation) {
14580
14614
  return assetHubAsset.multiLocation;
14581
- } else if (assetHubAsset.xcmInterior) {
14582
- return {
14583
- parents: exports.Parents.ONE,
14584
- interior: _defineProperty({}, "X".concat(assetHubAsset.xcmInterior.length), assetHubAsset.xcmInterior)
14585
- };
14586
14615
  }
14587
14616
  throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " has no multiLocation"));
14588
14617
  }
@@ -14606,11 +14635,6 @@ var buildMultiLocation = function buildMultiLocation(_ref) {
14606
14635
  }
14607
14636
  if (asset.multiLocation) {
14608
14637
  return asset.multiLocation;
14609
- } else if (asset.xcmInterior) {
14610
- return {
14611
- parents: exports.Parents.ONE,
14612
- interior: _defineProperty({}, "X".concat(asset.xcmInterior.length), asset.xcmInterior)
14613
- };
14614
14638
  } else {
14615
14639
  return createDefaultMultiLocation(asset.assetId);
14616
14640
  }
@@ -14773,18 +14797,21 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
14773
14797
  });
14774
14798
  };
14775
14799
 
14776
- var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
14800
+ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version, messageId) {
14777
14801
  var api = _ref.api,
14778
14802
  address = _ref.address,
14779
14803
  asset = _ref.asset,
14780
14804
  scenario = _ref.scenario,
14781
- ahAddress = _ref.ahAddress;
14805
+ senderAddress = _ref.senderAddress;
14782
14806
  if (!isForeignAsset(asset)) {
14783
14807
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
14784
14808
  }
14785
14809
  if (!asset.multiLocation) {
14786
14810
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
14787
14811
  }
14812
+ if (!senderAddress) {
14813
+ throw new InvalidCurrencyError("Please provide senderAddress");
14814
+ }
14788
14815
  var ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
14789
14816
  if (!ethAsset) {
14790
14817
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
@@ -14795,7 +14822,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
14795
14822
  assets: {
14796
14823
  Wild: 'All'
14797
14824
  },
14798
- beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== undefined ? ahAddress : '', version, undefined))[0]
14825
+ beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', senderAddress, version, undefined))[0]
14799
14826
  }
14800
14827
  }]
14801
14828
  }, {
@@ -14853,11 +14880,39 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
14853
14880
  }
14854
14881
  }
14855
14882
  }
14883
+ }, {
14884
+ SetTopic: messageId
14856
14885
  }]
14857
14886
  }
14887
+ }, {
14888
+ SetTopic: messageId
14858
14889
  }]);
14859
14890
  };
14860
14891
 
14892
+ var generateMessageId = /*#__PURE__*/function () {
14893
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, senderAddress, sourceParaId, tokenAddress, recipientAddress, amount) {
14894
+ var accountNextId, sourceAccountHex, entropy;
14895
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14896
+ while (1) switch (_context.prev = _context.next) {
14897
+ case 0:
14898
+ _context.next = 2;
14899
+ return api.getFromRpc('system', 'accountNextIndex', senderAddress);
14900
+ case 2:
14901
+ accountNextId = _context.sent;
14902
+ sourceAccountHex = api.accountToHex(senderAddress);
14903
+ entropy = new Uint8Array([].concat(_toConsumableArray(api.stringToUint8a(sourceParaId.toString())), _toConsumableArray(api.hexToUint8a(sourceAccountHex)), _toConsumableArray(api.stringToUint8a(accountNextId)), _toConsumableArray(api.hexToUint8a(tokenAddress)), _toConsumableArray(api.stringToUint8a(recipientAddress)), _toConsumableArray(api.stringToUint8a(amount.toString()))));
14904
+ return _context.abrupt("return", api.blake2AsHex(entropy));
14905
+ case 6:
14906
+ case "end":
14907
+ return _context.stop();
14908
+ }
14909
+ }, _callee);
14910
+ }));
14911
+ return function generateMessageId(_x, _x2, _x3, _x4, _x5, _x6) {
14912
+ return _ref.apply(this, arguments);
14913
+ };
14914
+ }();
14915
+
14861
14916
  var supportsXTokens = function supportsXTokens(obj) {
14862
14917
  return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
14863
14918
  };
@@ -14910,11 +14965,11 @@ var ParachainNode = /*#__PURE__*/function () {
14910
14965
  key: "transfer",
14911
14966
  value: function () {
14912
14967
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
14913
- var api, asset, address, destination, paraIdTo, overriddenAsset, version, ahAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
14968
+ var api, asset, address, destination, paraIdTo, overriddenAsset, version, senderAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
14914
14969
  return _regeneratorRuntime().wrap(function _callee$(_context) {
14915
14970
  while (1) switch (_context.prev = _context.next) {
14916
14971
  case 0:
14917
- 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;
14972
+ api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, senderAddress = options.senderAddress, pallet = options.pallet, method = options.method;
14918
14973
  isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
14919
14974
  scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
14920
14975
  paraId = resolveParaId(paraIdTo, destination);
@@ -14985,7 +15040,7 @@ var ParachainNode = /*#__PURE__*/function () {
14985
15040
  paraIdTo: paraId,
14986
15041
  overriddenAsset: overriddenAsset,
14987
15042
  version: version,
14988
- ahAddress: ahAddress,
15043
+ senderAddress: senderAddress,
14989
15044
  pallet: pallet,
14990
15045
  method: method
14991
15046
  }));
@@ -15047,37 +15102,54 @@ var ParachainNode = /*#__PURE__*/function () {
15047
15102
  key: "transferToEthereum",
15048
15103
  value: function () {
15049
15104
  var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
15050
- var api, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, fee, call;
15105
+ var api, asset, scenario, version, destination, address, senderAddress, versionOrDefault, ethMultiAsset, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, fee, ethAsset, messageId, call;
15051
15106
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
15052
15107
  while (1) switch (_context2.prev = _context2.next) {
15053
15108
  case 0:
15054
- api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, ahAddress = input.ahAddress;
15109
+ api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress;
15055
15110
  if (isForeignAsset(asset)) {
15056
15111
  _context2.next = 3;
15057
15112
  break;
15058
15113
  }
15059
15114
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
15060
15115
  case 3:
15061
- if (!(ahAddress === undefined)) {
15116
+ if (!(senderAddress === undefined)) {
15062
15117
  _context2.next = 5;
15063
15118
  break;
15064
15119
  }
15065
- throw new Error('AssetHub address is required for Ethereum transfers');
15120
+ throw new Error('Sender address is required for transfers to Ethereum');
15066
15121
  case 5:
15122
+ if (!isTMultiLocation(address)) {
15123
+ _context2.next = 7;
15124
+ break;
15125
+ }
15126
+ throw new Error('Multi-location address is not supported for Ethereum transfers');
15127
+ case 7:
15067
15128
  versionOrDefault = version !== null && version !== undefined ? version : exports.Version.V4;
15068
15129
  ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, asset.multiLocation))[0][0];
15069
- _context2.next = 9;
15130
+ _context2.next = 11;
15070
15131
  return api.createApiForNode('AssetHubPolkadot');
15071
- case 9:
15132
+ case 11:
15072
15133
  ahApi = _context2.sent;
15073
- _context2.next = 12;
15134
+ _context2.next = 14;
15074
15135
  return getParaEthTransferFees(ahApi);
15075
- case 12:
15136
+ case 14:
15076
15137
  _yield$getParaEthTran = _context2.sent;
15077
15138
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
15078
15139
  bridgeFee = _yield$getParaEthTran2[0];
15079
15140
  executionFee = _yield$getParaEthTran2[1];
15080
15141
  fee = (bridgeFee + executionFee).toString();
15142
+ ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
15143
+ if (!(!ethAsset || !ethAsset.assetId)) {
15144
+ _context2.next = 22;
15145
+ break;
15146
+ }
15147
+ throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
15148
+ case 22:
15149
+ _context2.next = 24;
15150
+ return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
15151
+ case 24:
15152
+ messageId = _context2.sent;
15081
15153
  call = {
15082
15154
  module: 'PolkadotXcm',
15083
15155
  section: 'transfer_assets_using_type_and_then',
@@ -15090,12 +15162,12 @@ var ParachainNode = /*#__PURE__*/function () {
15090
15162
  interior: 'Here'
15091
15163
  }),
15092
15164
  fees_transfer_type: 'DestinationReserve',
15093
- custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
15165
+ custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault, messageId),
15094
15166
  weight_limit: 'Unlimited'
15095
15167
  }
15096
15168
  };
15097
15169
  return _context2.abrupt("return", api.callTxMethod(call));
15098
- case 19:
15170
+ case 27:
15099
15171
  case "end":
15100
15172
  return _context2.stop();
15101
15173
  }
@@ -17364,21 +17436,19 @@ var sanitizeMultiLocation = function sanitizeMultiLocation(multiLocation) {
17364
17436
  return multiLocation.replace(/"(\d+),(\d+)"/g, '"$1$2"');
17365
17437
  };
17366
17438
  var compareMultiLocations = function compareMultiLocations(input, asset) {
17367
- var _asset$multiLocation, _asset$xcmInterior;
17439
+ var _asset$multiLocation;
17368
17440
  var sanitizedInput = sanitizeMultiLocation(input);
17369
17441
  var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
17370
- var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
17371
17442
  var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
17372
- var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
17373
17443
  return (
17374
17444
  // Compare sanitized input with sanitized asset values
17375
- sanitizedInput === sanitizedAssetMLStr || sanitizedInput === sanitizedAssetMLInteriorStr ||
17445
+ sanitizedInput === sanitizedAssetMLStr ||
17376
17446
  // Compare original input with sanitized asset values
17377
- input === sanitizedAssetMLStr || input === sanitizedAssetMLInteriorStr ||
17447
+ input === sanitizedAssetMLStr ||
17378
17448
  // Compare original input with original asset values
17379
- input === assetMLStr || input === assetMLInteriorStr ||
17449
+ input === assetMLStr ||
17380
17450
  // Compare sanitized input with original asset values
17381
- sanitizedInput === assetMLStr || sanitizedInput === assetMLInteriorStr
17451
+ sanitizedInput === assetMLStr
17382
17452
  );
17383
17453
  };
17384
17454
 
@@ -17387,10 +17457,6 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
17387
17457
  return foreignAssets.find(function (asset) {
17388
17458
  return compareMultiLocations(multiLocation, asset);
17389
17459
  });
17390
- } else if (Array.isArray(multiLocation)) {
17391
- return foreignAssets.find(function (asset) {
17392
- return _deepEqual(asset.xcmInterior, multiLocation);
17393
- });
17394
17460
  } else {
17395
17461
  return foreignAssets.find(function (asset) {
17396
17462
  return _deepEqual(asset.multiLocation, multiLocation);
@@ -17401,7 +17467,7 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
17401
17467
  var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
17402
17468
  var ethAssets = getOtherAssets('Ethereum');
17403
17469
  return assets.filter(function (asset) {
17404
- var assetMultiLoc = asset.multiLocation || asset.xcmInterior;
17470
+ var assetMultiLoc = asset.multiLocation;
17405
17471
  if (!assetMultiLoc) return false;
17406
17472
  return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
17407
17473
  });
@@ -17456,18 +17522,6 @@ var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
17456
17522
  if (asset.multiLocation) {
17457
17523
  return asset.multiLocation;
17458
17524
  }
17459
- if (asset.xcmInterior) {
17460
- var _asset$xcmInterior$sl = asset.xcmInterior.slice(-2),
17461
- _asset$xcmInterior$sl2 = _slicedToArray(_asset$xcmInterior$sl, 2),
17462
- secondLast = _asset$xcmInterior$sl2[0],
17463
- last = _asset$xcmInterior$sl2[1];
17464
- return {
17465
- parents: exports.Parents.ZERO,
17466
- interior: {
17467
- X2: [secondLast, last]
17468
- }
17469
- };
17470
- }
17471
17525
  return null;
17472
17526
  };
17473
17527
 
@@ -19141,9 +19195,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
19141
19195
  */
19142
19196
  }, {
19143
19197
  key: "address",
19144
- value: function address(_address, ahAddress) {
19198
+ value: function address(_address, senderAddress) {
19145
19199
  this._address = _address;
19146
- this._ahAddress = ahAddress;
19200
+ this._senderAddress = senderAddress;
19147
19201
  return this;
19148
19202
  }
19149
19203
  /**
@@ -19182,7 +19236,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
19182
19236
  destination: this._to,
19183
19237
  paraIdTo: this._paraIdTo,
19184
19238
  version: this._version,
19185
- ahAddress: this._ahAddress,
19239
+ senderAddress: this._senderAddress,
19186
19240
  pallet: this._pallet,
19187
19241
  method: this._method
19188
19242
  };
@@ -19327,16 +19381,16 @@ var Builder = function Builder(api) {
19327
19381
  var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
19328
19382
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
19329
19383
  var _getExistentialDeposi;
19330
- var api, account, accountDestination, ahAccount, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
19384
+ var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
19331
19385
  return _regeneratorRuntime().wrap(function _callee$(_context) {
19332
19386
  while (1) switch (_context.prev = _context.next) {
19333
19387
  case 0:
19334
- 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;
19388
+ 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;
19335
19389
  _context.next = 3;
19336
19390
  return api.init(origin);
19337
19391
  case 3:
19338
19392
  _context.next = 5;
19339
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination, ahAccount).build();
19393
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination, account).build();
19340
19394
  case 5:
19341
19395
  tx = _context.sent;
19342
19396
  _context.next = 8;
@@ -19757,6 +19811,75 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
19757
19811
  return supportedAssets;
19758
19812
  };
19759
19813
 
19814
+ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
19815
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
19816
+ var api, node, address, currency, ed, edBN, balance, originalAmount, fee, amountWithoutFee;
19817
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19818
+ while (1) switch (_context.prev = _context.next) {
19819
+ case 0:
19820
+ api = _ref.api, node = _ref.node, address = _ref.address, currency = _ref.currency;
19821
+ validateAddress(address, node);
19822
+ ed = getExistentialDeposit(node, currency);
19823
+ if (!(ed === null)) {
19824
+ _context.next = 5;
19825
+ break;
19826
+ }
19827
+ throw new Error("Cannot get existential deposit for currency ".concat(JSON.stringify(currency)));
19828
+ case 5:
19829
+ edBN = BigInt(ed);
19830
+ _context.next = 8;
19831
+ return getAssetBalanceInternal({
19832
+ address: address,
19833
+ node: node,
19834
+ api: api,
19835
+ currency: currency
19836
+ });
19837
+ case 8:
19838
+ balance = _context.sent;
19839
+ originalAmount = BigInt(currency.amount);
19840
+ fee = originalAmount / BigInt(100);
19841
+ amountWithoutFee = originalAmount - fee;
19842
+ return _context.abrupt("return", balance + amountWithoutFee - edBN > 0);
19843
+ case 13:
19844
+ case "end":
19845
+ return _context.stop();
19846
+ }
19847
+ }, _callee);
19848
+ }));
19849
+ return function verifyEdOnDestinationInternal(_x) {
19850
+ return _ref2.apply(this, arguments);
19851
+ };
19852
+ }();
19853
+
19854
+ var verifyEdOnDestination = /*#__PURE__*/function () {
19855
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
19856
+ var api;
19857
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19858
+ while (1) switch (_context.prev = _context.next) {
19859
+ case 0:
19860
+ api = options.api;
19861
+ _context.prev = 1;
19862
+ _context.next = 4;
19863
+ return verifyEdOnDestinationInternal(options);
19864
+ case 4:
19865
+ return _context.abrupt("return", _context.sent);
19866
+ case 5:
19867
+ _context.prev = 5;
19868
+ _context.next = 8;
19869
+ return api.disconnect();
19870
+ case 8:
19871
+ return _context.finish(5);
19872
+ case 9:
19873
+ case "end":
19874
+ return _context.stop();
19875
+ }
19876
+ }, _callee, null, [[1,, 5, 9]]);
19877
+ }));
19878
+ return function verifyEdOnDestination(_x) {
19879
+ return _ref.apply(this, arguments);
19880
+ };
19881
+ }();
19882
+
19760
19883
  var isPrimitive = function isPrimitive(obj) {
19761
19884
  return obj !== Object(obj);
19762
19885
  };
@@ -20217,47 +20340,42 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
20217
20340
 
20218
20341
  var send = /*#__PURE__*/function () {
20219
20342
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
20220
- var api, origin, currency, address, destination, paraIdTo, version, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, overriddenAsset, resolvedAsset, originNode;
20343
+ var api, origin, currency, address, destination, paraIdTo, version, senderAddress, pallet, method, isBridge, assetCheckEnabled, asset, overriddenAsset, resolvedAsset, originNode;
20221
20344
  return _regeneratorRuntime().wrap(function _callee$(_context) {
20222
20345
  while (1) switch (_context.prev = _context.next) {
20223
20346
  case 0:
20224
- api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, version = options.version, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
20347
+ api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, pallet = options.pallet, method = options.method;
20225
20348
  validateCurrency(currency);
20226
20349
  validateDestination(origin, destination);
20227
20350
  validateDestinationAddress(address, destination);
20228
- if (!(ahAddress && ethers.ethers.isAddress(ahAddress))) {
20229
- _context.next = 6;
20230
- break;
20231
- }
20232
- throw new Error('AssetHub address needs to be in Substrate format');
20233
- case 6:
20351
+ if (senderAddress) validateAddress(senderAddress, origin, false);
20234
20352
  if (!(isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination))) {
20235
- _context.next = 8;
20353
+ _context.next = 7;
20236
20354
  break;
20237
20355
  }
20238
20356
  throw new Error('Relay chain to relay chain transfers are not supported.');
20239
- case 8:
20357
+ case 7:
20240
20358
  isBridge = isBridgeTransfer(origin, destination);
20241
20359
  assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
20242
20360
  validateAssetSpecifiers(assetCheckEnabled, currency);
20243
20361
  asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
20244
20362
  validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
20245
20363
  if (!isRelayChain(origin)) {
20246
- _context.next = 19;
20364
+ _context.next = 18;
20247
20365
  break;
20248
20366
  }
20249
20367
  if (!(destination === 'Ethereum')) {
20250
- _context.next = 16;
20368
+ _context.next = 15;
20251
20369
  break;
20252
20370
  }
20253
20371
  throw new Error('Transfers from relay chain to Ethereum are not supported.');
20254
- case 16:
20372
+ case 15:
20255
20373
  if (asset) {
20256
- _context.next = 18;
20374
+ _context.next = 17;
20257
20375
  break;
20258
20376
  }
20259
20377
  throw new Error('Asset is required for relay chain to relay chain transfers.');
20260
- case 18:
20378
+ case 17:
20261
20379
  return _context.abrupt("return", transferRelayToPara({
20262
20380
  api: api,
20263
20381
  origin: origin,
@@ -20271,11 +20389,11 @@ var send = /*#__PURE__*/function () {
20271
20389
  pallet: pallet,
20272
20390
  method: method
20273
20391
  }));
20274
- case 19:
20392
+ case 18:
20275
20393
  overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled);
20276
- _context.next = 22;
20394
+ _context.next = 21;
20277
20395
  return api.init(origin);
20278
- case 22:
20396
+ case 21:
20279
20397
  // In case asset check is disabled, we create asset object from currency symbol
20280
20398
  resolvedAsset = asset !== null && asset !== undefined ? asset : {
20281
20399
  symbol: 'symbol' in currency ? currency.symbol : undefined
@@ -20291,11 +20409,11 @@ var send = /*#__PURE__*/function () {
20291
20409
  paraIdTo: paraIdTo,
20292
20410
  overriddenAsset: overriddenAsset,
20293
20411
  version: version,
20294
- ahAddress: ahAddress,
20412
+ senderAddress: senderAddress,
20295
20413
  pallet: pallet,
20296
20414
  method: method
20297
20415
  }));
20298
- case 25:
20416
+ case 24:
20299
20417
  case "end":
20300
20418
  return _context.stop();
20301
20419
  }
@@ -20370,7 +20488,7 @@ var getDestinationMultilocation = function getDestinationMultilocation(api, addr
20370
20488
  return [1, paraId ? ["0x0000000".concat(paraId.toString(16)), acc] : [acc]];
20371
20489
  };
20372
20490
 
20373
- var abi = [
20491
+ var abi$1 = [
20374
20492
  {
20375
20493
  inputs: [
20376
20494
  {
@@ -20491,8 +20609,8 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
20491
20609
  }
20492
20610
  throw new Error('Override multilocation is not supported for Evm transfers');
20493
20611
  case 5:
20494
- contract = isEthersSigner(signer) ? new ethers.Contract(CONTRACT_ADDRESS, abi, signer) : viem.getContract({
20495
- abi: abi,
20612
+ contract = isEthersSigner(signer) ? new ethers.Contract(CONTRACT_ADDRESS, abi$1, signer) : viem.getContract({
20613
+ abi: abi$1,
20496
20614
  address: CONTRACT_ADDRESS,
20497
20615
  client: {
20498
20616
  "public": viem.createPublicClient({
@@ -20570,6 +20688,72 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
20570
20688
  };
20571
20689
  }();
20572
20690
 
20691
+ var abi = [
20692
+ {
20693
+ inputs: [
20694
+ {
20695
+ components: [
20696
+ {
20697
+ internalType: "uint8",
20698
+ name: "parents",
20699
+ type: "uint8"
20700
+ },
20701
+ {
20702
+ internalType: "bytes[]",
20703
+ name: "interior",
20704
+ type: "bytes[]"
20705
+ }
20706
+ ],
20707
+ internalType: "struct XCM.Location",
20708
+ name: "dest",
20709
+ type: "tuple"
20710
+ },
20711
+ {
20712
+ components: [
20713
+ {
20714
+ internalType: "address",
20715
+ name: "asset",
20716
+ type: "address"
20717
+ },
20718
+ {
20719
+ internalType: "uint256",
20720
+ name: "amount",
20721
+ type: "uint256"
20722
+ }
20723
+ ],
20724
+ internalType: "struct XCM.AssetAddressInfo[]",
20725
+ name: "assets",
20726
+ type: "tuple[]"
20727
+ },
20728
+ {
20729
+ internalType: "enum XCM.TransferType",
20730
+ name: "assetsTransferType",
20731
+ type: "uint8"
20732
+ },
20733
+ {
20734
+ internalType: "uint8",
20735
+ name: "remoteFeesIdIndex",
20736
+ type: "uint8"
20737
+ },
20738
+ {
20739
+ internalType: "enum XCM.TransferType",
20740
+ name: "feesTransferType",
20741
+ type: "uint8"
20742
+ },
20743
+ {
20744
+ internalType: "bytes",
20745
+ name: "customXcmOnDest",
20746
+ type: "bytes"
20747
+ }
20748
+ ],
20749
+ name: "transferAssetsUsingTypeAndThenAddress",
20750
+ outputs: [
20751
+ ],
20752
+ stateMutability: "nonpayable",
20753
+ type: "function"
20754
+ }
20755
+ ];
20756
+
20573
20757
  var getParaEthTransferFees = /*#__PURE__*/function () {
20574
20758
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
20575
20759
  var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, transferAssethubExecutionFee, finalBridgeFee, finalAssethubExecutionFee;
@@ -20578,7 +20762,7 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
20578
20762
  case 0:
20579
20763
  DEFAULT_FEE = 2750872500000n;
20580
20764
  _context.next = 3;
20581
- return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
20765
+ return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
20582
20766
  case 3:
20583
20767
  feeStorageItem = _context.sent;
20584
20768
  leFeeHex = feeStorageItem.replace('0x', '');
@@ -20605,6 +20789,160 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
20605
20789
  };
20606
20790
  }();
20607
20791
 
20792
+ // https://github.com/moonbeam-foundation/moonbeam/blob/b2b1bde7ced13aad4bd2928effc415c521fd48cb/runtime/moonbeam/src/precompiles.rs#L281
20793
+ var xcmInterfacePrecompile = '0x000000000000000000000000000000000000081A';
20794
+ var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
20795
+ var transferMoonbeamToEth = /*#__PURE__*/function () {
20796
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
20797
+ var _signer$account;
20798
+ var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, senderAddress, messageId, customXcm, customXcmOnDest, assetHubApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, createTx, numberToHex32, tx;
20799
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
20800
+ while (1) switch (_context.prev = _context.next) {
20801
+ case 0:
20802
+ api = _ref.api, from = _ref.from, to = _ref.to, signer = _ref.signer, address = _ref.address, ahAddress = _ref.ahAddress, currency = _ref.currency;
20803
+ if (ahAddress) {
20804
+ _context.next = 3;
20805
+ break;
20806
+ }
20807
+ throw new Error('AssetHub address is required');
20808
+ case 3:
20809
+ if (!('multiasset' in currency)) {
20810
+ _context.next = 5;
20811
+ break;
20812
+ }
20813
+ throw new Error('Multiassets syntax is not supported for Evm transfers');
20814
+ case 5:
20815
+ if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
20816
+ _context.next = 7;
20817
+ break;
20818
+ }
20819
+ throw new Error('Override multilocation is not supported for Evm transfers');
20820
+ case 7:
20821
+ foundAsset = getAssetBySymbolOrId(from, currency, to);
20822
+ if (!(foundAsset === null)) {
20823
+ _context.next = 10;
20824
+ break;
20825
+ }
20826
+ throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
20827
+ case 10:
20828
+ if (!(!isForeignAsset(foundAsset) || !foundAsset.multiLocation)) {
20829
+ _context.next = 12;
20830
+ break;
20831
+ }
20832
+ throw new InvalidCurrencyError('Currency must be a foreign asset with valid multi-location');
20833
+ case 12:
20834
+ ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), foundAsset.multiLocation);
20835
+ if (!(!ethAsset || !ethAsset.assetId)) {
20836
+ _context.next = 15;
20837
+ break;
20838
+ }
20839
+ throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
20840
+ case 15:
20841
+ contract = isEthersSigner(signer) ? new ethers.Contract(xcmInterfacePrecompile, abi, signer) : viem.getContract({
20842
+ abi: abi,
20843
+ address: xcmInterfacePrecompile,
20844
+ client: {
20845
+ "public": viem.createPublicClient({
20846
+ chain: signer.chain,
20847
+ transport: viem.http()
20848
+ }),
20849
+ wallet: signer
20850
+ }
20851
+ });
20852
+ if (!isEthersSigner(signer)) {
20853
+ _context.next = 22;
20854
+ break;
20855
+ }
20856
+ _context.next = 19;
20857
+ return signer.getAddress();
20858
+ case 19:
20859
+ _context.t0 = _context.sent;
20860
+ _context.next = 23;
20861
+ break;
20862
+ case 22:
20863
+ _context.t0 = (_signer$account = signer.account) === null || _signer$account === undefined ? undefined : _signer$account.address;
20864
+ case 23:
20865
+ senderAddress = _context.t0;
20866
+ if (senderAddress) {
20867
+ _context.next = 26;
20868
+ break;
20869
+ }
20870
+ throw new Error('Unable to get sender address');
20871
+ case 26:
20872
+ _context.next = 28;
20873
+ return api.init(from);
20874
+ case 28:
20875
+ _context.next = 30;
20876
+ return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
20877
+ case 30:
20878
+ messageId = _context.sent;
20879
+ customXcm = createCustomXcmOnDest({
20880
+ api: api,
20881
+ destination: to,
20882
+ address: address,
20883
+ scenario: 'ParaToPara',
20884
+ senderAddress: senderAddress,
20885
+ asset: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
20886
+ amount: currency.amount
20887
+ }),
20888
+ header: {},
20889
+ currencySelection: {},
20890
+ addressSelection: {}
20891
+ }, exports.Version.V4, messageId);
20892
+ _context.next = 34;
20893
+ return api.objectToHex(customXcm, 'XcmVersionedXcm');
20894
+ case 34:
20895
+ customXcmOnDest = _context.sent;
20896
+ _context.next = 37;
20897
+ return api.createApiForNode('AssetHubPolkadot');
20898
+ case 37:
20899
+ assetHubApi = _context.sent;
20900
+ _context.next = 40;
20901
+ return getParaEthTransferFees(assetHubApi);
20902
+ case 40:
20903
+ _yield$getParaEthTran = _context.sent;
20904
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
20905
+ bridgeFee = _yield$getParaEthTran2[0];
20906
+ executionFee = _yield$getParaEthTran2[1];
20907
+ transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
20908
+ // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
20909
+ createTx = function createTx(func, args) {
20910
+ if (isEthersContract(contract)) {
20911
+ return contract[func].apply(contract, _toConsumableArray(args));
20912
+ }
20913
+ return contract.write[func](args);
20914
+ };
20915
+ numberToHex32 = function numberToHex32(num) {
20916
+ return typeof num !== 'number' || isNaN(num) ? function () {
20917
+ throw new Error('Input must be a valid number');
20918
+ }() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
20919
+ }; // Execute the custom XCM message with the precompile
20920
+ _context.next = 49;
20921
+ return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
20922
+ // This represents (1,X1(Parachain(1000)))
20923
+ [1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
20924
+ // Assets including fee and the ERC20 asset, with fee be the first
20925
+ [[XCDOT, transferFee], [ethAsset.assetId, currency.amount.toString()]],
20926
+ // The TransferType corresponding to asset being sent, 2 represents `DestinationReserve`
20927
+ 2,
20928
+ // index for the fee
20929
+ 0,
20930
+ // The TransferType corresponding to fee asset
20931
+ 2, customXcmOnDest]);
20932
+ case 49:
20933
+ tx = _context.sent;
20934
+ return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
20935
+ case 51:
20936
+ case "end":
20937
+ return _context.stop();
20938
+ }
20939
+ }, _callee);
20940
+ }));
20941
+ return function transferMoonbeamToEth(_x) {
20942
+ return _ref2.apply(this, arguments);
20943
+ };
20944
+ }();
20945
+
20608
20946
  exports.Builder = Builder;
20609
20947
  exports.DuplicateAssetError = DuplicateAssetError;
20610
20948
  exports.DuplicateAssetIdError = DuplicateAssetIdError;
@@ -20676,6 +21014,8 @@ exports.getTNode = getTNode;
20676
21014
  exports.getTransferInfo = getTransferInfo;
20677
21015
  exports.getTransferableAmount = getTransferableAmount;
20678
21016
  exports.hasSupportForAsset = hasSupportForAsset;
21017
+ exports.isEthersContract = isEthersContract;
21018
+ exports.isEthersSigner = isEthersSigner;
20679
21019
  exports.isForeignAsset = isForeignAsset;
20680
21020
  exports.isNodeEvm = isNodeEvm;
20681
21021
  exports.isOverrideMultiLocationSpecifier = isOverrideMultiLocationSpecifier;
@@ -20686,5 +21026,7 @@ exports.resolveModuleError = resolveModuleError;
20686
21026
  exports.resolveParaId = resolveParaId;
20687
21027
  exports.send = send;
20688
21028
  exports.transferMoonbeamEvm = transferMoonbeamEvm;
21029
+ exports.transferMoonbeamToEth = transferMoonbeamToEth;
20689
21030
  exports.transferRelayToPara = transferRelayToPara;
20690
21031
  exports.validateAddress = validateAddress;
21032
+ exports.verifyEdOnDestination = verifyEdOnDestination;