@paraspell/evm 14.1.0-rc.1 → 14.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ declare const buildEvmTransfer: <TApi, TRes, TSigner, TCustomChain extends strin
5
5
 
6
6
  declare const executeEvmTransfer: <TApi, TRes, TSigner, TCustomChain extends string = never>(options: TEvmTransferOptions<TApi, TRes, TSigner, TCustomChain>) => Promise<string>;
7
7
 
8
- declare const EVM_ORIGIN_CHAINS: readonly ["Moonbeam", "Moonriver", "Darwinia"];
8
+ declare const EVM_ORIGIN_CHAINS: readonly ["Darwinia"];
9
9
 
10
10
  export { EVM_ORIGIN_CHAINS, buildEvmTransfer, executeEvmTransfer };
package/dist/index.mjs CHANGED
@@ -1,15 +1,7 @@
1
- import { UnsupportedOperationError, assertHasId, assertEvmAddress, getAssetsObject, getParaId, findAssetInfoOrThrow, abstractDecimals, getNativeAssetSymbol, InvalidCurrencyError, formatAssetIdToERC20, parseUnits, getParaEthTransferFees, pickCompatibleXcmVersion, createCustomXcmOnDest, createAsset, generateMessageId, TX_CLIENT_TIMEOUT_MS, BridgeHaltedError, getBridgeStatus, MissingParameterError, NumberFormatError, registerEvmExtension } from '@paraspell/sdk-core';
1
+ import { UnsupportedOperationError, assertHasId, assertEvmAddress, getAssetsObject, getParaId, findAssetInfoOrThrow, abstractDecimals, getNativeAssetSymbol, InvalidCurrencyError, formatAssetIdToERC20, MissingParameterError, registerEvmExtension } from '@paraspell/sdk-core';
2
2
  import { encodeFunctionData, maxUint64 } from 'viem';
3
- import { darwinia, moonriver, moonbeam } from 'viem/chains';
3
+ import { darwinia } from 'viem/chains';
4
4
 
5
- function _arrayLikeToArray(r, a) {
6
- (null == a || a > r.length) && (a = r.length);
7
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
- return n;
9
- }
10
- function _arrayWithHoles(r) {
11
- if (Array.isArray(r)) return r;
12
- }
13
5
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
14
6
  try {
15
7
  var i = n[a](c),
@@ -43,33 +35,6 @@ function _defineProperty(e, r, t) {
43
35
  writable: true
44
36
  }) : e[r] = t, e;
45
37
  }
46
- function _iterableToArrayLimit(r, l) {
47
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
48
- if (null != t) {
49
- var e,
50
- n,
51
- i,
52
- u,
53
- a = [],
54
- f = true,
55
- o = false;
56
- try {
57
- if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
58
- } catch (r) {
59
- o = true, n = r;
60
- } finally {
61
- try {
62
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
63
- } finally {
64
- if (o) throw n;
65
- }
66
- }
67
- return a;
68
- }
69
- }
70
- function _nonIterableRest() {
71
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
72
- }
73
38
  function ownKeys(e, r) {
74
39
  var t = Object.keys(e);
75
40
  if (Object.getOwnPropertySymbols) {
@@ -199,9 +164,6 @@ function _regeneratorDefine(e, r, n, t) {
199
164
  }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
200
165
  }, _regeneratorDefine(e, r, n, t);
201
166
  }
202
- function _slicedToArray(r, e) {
203
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
204
- }
205
167
  function _toPrimitive(t, r) {
206
168
  if ("object" != typeof t || !t) return t;
207
169
  var e = t[Symbol.toPrimitive];
@@ -216,17 +178,8 @@ function _toPropertyKey(t) {
216
178
  var i = _toPrimitive(t, "string");
217
179
  return "symbol" == typeof i ? i : i + "";
218
180
  }
219
- function _unsupportedIterableToArray(r, a) {
220
- if (r) {
221
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
222
- var t = {}.toString.call(r).slice(8, -1);
223
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
224
- }
225
- }
226
181
 
227
182
  var EVM_VIEM_CHAIN_BY_ORIGIN = {
228
- Moonbeam: moonbeam,
229
- Moonriver: moonriver,
230
183
  Darwinia: darwinia
231
184
  };
232
185
  var getViemChain = function getViemChain(chain) {
@@ -237,7 +190,7 @@ var getViemChain = function getViemChain(chain) {
237
190
  return viemChain;
238
191
  };
239
192
 
240
- var abi$2 = [
193
+ var abi$1 = [
241
194
  {
242
195
  inputs: [
243
196
  {
@@ -334,7 +287,7 @@ var abi$2 = [
334
287
  }
335
288
  ];
336
289
 
337
- var abi$1 = [{
290
+ var abi = [{
338
291
  inputs: [{
339
292
  internalType: 'address',
340
293
  name: 'recipient_',
@@ -353,12 +306,12 @@ var abi$1 = [{
353
306
  stateMutability: 'nonpayable',
354
307
  type: 'function'
355
308
  }];
356
- var buildMoonbeamLocal = function buildMoonbeamLocal(from, assetInfo, recipient) {
309
+ var buildEvmLocal = function buildEvmLocal(from, assetInfo, recipient) {
357
310
  assertHasId(assetInfo);
358
311
  assertEvmAddress(recipient);
359
312
  assertEvmAddress(assetInfo.assetId);
360
313
  var data = encodeFunctionData({
361
- abi: abi$1,
314
+ abi: abi,
362
315
  functionName: 'transfer',
363
316
  args: [recipient, assetInfo.amount]
364
317
  });
@@ -385,7 +338,7 @@ var getDestinationLocation = function getDestinationLocation(api, address, desti
385
338
 
386
339
  var CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000804';
387
340
  var NATIVE_ASSET_ID = '0x0000000000000000000000000000000000000802';
388
- var buildMoonbeamEvm = function buildMoonbeamEvm(options) {
341
+ var buildXTokensEvm = function buildXTokensEvm(options) {
389
342
  var api = options.api,
390
343
  from = options.from,
391
344
  to = options.to,
@@ -397,7 +350,7 @@ var buildMoonbeamEvm = function buildMoonbeamEvm(options) {
397
350
  var foundAsset = findAssetInfoOrThrow(from, currency, to);
398
351
  var amount = abstractDecimals(currency.amount, foundAsset.decimals, api);
399
352
  if (from === to) {
400
- return buildMoonbeamLocal(from, _objectSpread2(_objectSpread2({}, foundAsset), {}, {
353
+ return buildEvmLocal(from, _objectSpread2(_objectSpread2({}, foundAsset), {}, {
401
354
  amount: amount
402
355
  }), recipient);
403
356
  }
@@ -412,21 +365,8 @@ var buildMoonbeamEvm = function buildMoonbeamEvm(options) {
412
365
  }
413
366
  var destLocation = getDestinationLocation(api, recipient, to);
414
367
  var weight = maxUint64;
415
- var multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
416
- var useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
417
- var usdtAsset = findAssetInfoOrThrow(from, {
418
- symbol: 'xcUSDT'
419
- }, to);
420
- assertHasId(usdtAsset);
421
- var usdtAmount = parseUnits('0.2', usdtAsset.decimals);
422
- var data = useMultiAssets ? encodeFunctionData({
423
- abi: abi$2,
424
- functionName: 'transferMultiCurrencies',
425
- args: [[[asset, amount.toString()], [formatAssetIdToERC20(usdtAsset.assetId), usdtAmount.toString()]], 1,
426
- // index of the fee asset
427
- destLocation, weight]
428
- }) : encodeFunctionData({
429
- abi: abi$2,
368
+ var data = encodeFunctionData({
369
+ abi: abi$1,
430
370
  functionName: 'transfer',
431
371
  args: [asset, amount.toString(), destLocation, weight]
432
372
  });
@@ -439,215 +379,16 @@ var buildMoonbeamEvm = function buildMoonbeamEvm(options) {
439
379
  };
440
380
  };
441
381
 
442
- var abi = [
443
- {
444
- inputs: [
445
- {
446
- components: [
447
- {
448
- internalType: "uint8",
449
- name: "parents",
450
- type: "uint8"
451
- },
452
- {
453
- internalType: "bytes[]",
454
- name: "interior",
455
- type: "bytes[]"
456
- }
457
- ],
458
- internalType: "struct XCM.Location",
459
- name: "dest",
460
- type: "tuple"
461
- },
462
- {
463
- components: [
464
- {
465
- internalType: "address",
466
- name: "asset",
467
- type: "address"
468
- },
469
- {
470
- internalType: "uint256",
471
- name: "amount",
472
- type: "uint256"
473
- }
474
- ],
475
- internalType: "struct XCM.AssetAddressInfo[]",
476
- name: "assets",
477
- type: "tuple[]"
478
- },
479
- {
480
- internalType: "enum XCM.TransferType",
481
- name: "assetsTransferType",
482
- type: "uint8"
483
- },
484
- {
485
- internalType: "uint8",
486
- name: "remoteFeesIdIndex",
487
- type: "uint8"
488
- },
489
- {
490
- internalType: "enum XCM.TransferType",
491
- name: "feesTransferType",
492
- type: "uint8"
493
- },
494
- {
495
- internalType: "bytes",
496
- name: "customXcmOnDest",
497
- type: "bytes"
498
- }
499
- ],
500
- name: "transferAssetsUsingTypeAndThenAddress",
501
- outputs: [
502
- ],
503
- stateMutability: "nonpayable",
504
- type: "function"
505
- }
506
- ];
507
-
508
- // https://github.com/moonbeam-foundation/moonbeam/blob/b2b1bde7ced13aad4bd2928effc415c521fd48cb/runtime/moonbeam/src/precompiles.rs#L281
509
- var xcmInterfacePrecompile = '0x000000000000000000000000000000000000081A';
510
- var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
511
- var buildMoonbeamToEth = /*#__PURE__*/function () {
512
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(from, options) {
513
- var api, to, sender, recipient, ahAddress, currency, bridgeStatus, foundAsset, amount, ethAsset, messageId, version, customXcm, customXcmOnDest, assetHubApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, numberToHex32, data;
514
- return _regenerator().w(function (_context) {
515
- while (1) switch (_context.n) {
516
- case 0:
517
- api = options.api, to = options.to, sender = options.sender, recipient = options.recipient, ahAddress = options.ahAddress, currency = options.currency;
518
- if (ahAddress) {
519
- _context.n = 1;
520
- break;
521
- }
522
- throw new MissingParameterError('ahAddress');
523
- case 1:
524
- _context.n = 2;
525
- return getBridgeStatus(api.clone());
526
- case 2:
527
- bridgeStatus = _context.v;
528
- if (!(bridgeStatus !== 'Normal')) {
529
- _context.n = 3;
530
- break;
531
- }
532
- throw new BridgeHaltedError();
533
- case 3:
534
- if (!Array.isArray(currency)) {
535
- _context.n = 4;
536
- break;
537
- }
538
- throw new UnsupportedOperationError('Multi-assets are not yet supported for EVM transfers');
539
- case 4:
540
- foundAsset = findAssetInfoOrThrow(from, currency, to);
541
- amount = abstractDecimals(currency.amount, foundAsset.decimals, api);
542
- ethAsset = findAssetInfoOrThrow('Ethereum', {
543
- symbol: foundAsset.symbol
544
- });
545
- assertHasId(ethAsset);
546
- _context.n = 5;
547
- return api.init(from, TX_CLIENT_TIMEOUT_MS);
548
- case 5:
549
- _context.n = 6;
550
- return generateMessageId(api, sender, getParaId(from), ethAsset.assetId, recipient, amount);
551
- case 6:
552
- messageId = _context.v;
553
- version = pickCompatibleXcmVersion(api, from, to);
554
- customXcm = createCustomXcmOnDest({
555
- api: api,
556
- chain: from,
557
- destination: to,
558
- recipient: recipient,
559
- scenario: 'ParaToPara',
560
- sender: sender,
561
- ahAddress: ahAddress,
562
- assetInfo: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
563
- amount: amount
564
- }),
565
- currency: currency,
566
- asset: createAsset(version, amount, ethAsset.location),
567
- beneficiaryLocation: {},
568
- version: version
569
- }, from, messageId, ethAsset);
570
- _context.n = 7;
571
- return api.objectToHex(customXcm, 'XcmVersionedXcm', version);
572
- case 7:
573
- customXcmOnDest = _context.v;
574
- _context.n = 8;
575
- return api.createApiForChain('AssetHubPolkadot');
576
- case 8:
577
- assetHubApi = _context.v;
578
- _context.n = 9;
579
- return getParaEthTransferFees(assetHubApi);
580
- case 9:
581
- _yield$getParaEthTran = _context.v;
582
- _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
583
- bridgeFee = _yield$getParaEthTran2[0];
584
- executionFee = _yield$getParaEthTran2[1];
585
- transferFee = (bridgeFee + executionFee).toString();
586
- numberToHex32 = function numberToHex32(num) {
587
- if (typeof num !== 'number' || isNaN(num)) {
588
- throw new NumberFormatError('Input must be a valid number');
589
- }
590
- return "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
591
- };
592
- data = encodeFunctionData({
593
- abi: abi,
594
- functionName: 'transferAssetsUsingTypeAndThenAddress',
595
- args: [
596
- // (1, X1(Parachain(1000)))
597
- [1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
598
- // Assets including fee and the ERC20 asset, with fee first
599
- [[XCDOT, transferFee], [ethAsset.assetId, amount.toString()]],
600
- // 2 == DestinationReserve
601
- 2,
602
- // index of the fee asset
603
- 0,
604
- // TransferType for fee asset (DestinationReserve)
605
- 2, customXcmOnDest]
606
- });
607
- return _context.a(2, {
608
- type: 'eip1559',
609
- chainId: getViemChain(from).id,
610
- to: xcmInterfacePrecompile,
611
- data: data,
612
- value: 0n
613
- });
614
- }
615
- }, _callee);
616
- }));
617
- return function buildMoonbeamToEth(_x, _x2) {
618
- return _ref.apply(this, arguments);
619
- };
620
- }();
621
-
622
- var buildEvmTransfer = /*#__PURE__*/function () {
623
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
624
- var from, to;
625
- return _regenerator().w(function (_context) {
626
- while (1) switch (_context.n) {
627
- case 0:
628
- from = options.from, to = options.to;
629
- if (!(from === 'Moonbeam' && to === 'Ethereum')) {
630
- _context.n = 1;
631
- break;
632
- }
633
- return _context.a(2, buildMoonbeamToEth(from, options));
634
- case 1:
635
- if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
636
- _context.n = 2;
637
- break;
638
- }
639
- return _context.a(2, buildMoonbeamEvm(options));
640
- case 2:
641
- throw new UnsupportedOperationError("EVM transfer from '".concat(from, "' to '").concat(to, "' is not supported by @paraspell/evm."));
642
- case 3:
643
- return _context.a(2);
644
- }
645
- }, _callee);
646
- }));
647
- return function buildEvmTransfer(_x) {
648
- return _ref.apply(this, arguments);
649
- };
650
- }();
382
+ var buildEvmTransfer = function buildEvmTransfer(options) {
383
+ var from = options.from,
384
+ to = options.to;
385
+ if (from === 'Darwinia') {
386
+ return Promise.resolve().then(function () {
387
+ return buildXTokensEvm(options);
388
+ });
389
+ }
390
+ return Promise.reject(new UnsupportedOperationError("EVM transfer from '".concat(from, "' to '").concat(to, "' is not supported by @paraspell/evm.")));
391
+ };
651
392
 
652
393
  var executeEvmTransfer = /*#__PURE__*/function () {
653
394
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
@@ -686,6 +427,6 @@ registerEvmExtension({
686
427
  executeTransfer: executeEvmTransfer,
687
428
  buildTransfer: buildEvmTransfer
688
429
  });
689
- var EVM_ORIGIN_CHAINS = ['Moonbeam', 'Moonriver', 'Darwinia'];
430
+ var EVM_ORIGIN_CHAINS = ['Darwinia'];
690
431
 
691
432
  export { EVM_ORIGIN_CHAINS, buildEvmTransfer, executeEvmTransfer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/evm",
3
- "version": "14.1.0-rc.1",
3
+ "version": "14.1.1",
4
4
  "description": "Optional EVM extension for @paraspell/sdk enabling interaction with EVM-compatible chains.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,8 +24,8 @@
24
24
  "keywords": [],
25
25
  "author": "",
26
26
  "dependencies": {
27
- "viem": "^2.53.1",
28
- "@paraspell/sdk-core": "14.1.0-rc.1"
27
+ "viem": "^2.55.10",
28
+ "@paraspell/sdk-core": "14.1.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/plugin-syntax-import-attributes": "^7.29.7",
@@ -34,9 +34,9 @@
34
34
  "@rollup/plugin-babel": "^7.1.0",
35
35
  "@rollup/plugin-json": "^6.1.0",
36
36
  "@rollup/plugin-typescript": "^12.3.0",
37
- "@vitest/coverage-v8": "^4.1.9",
37
+ "@vitest/coverage-v8": "^4.1.10",
38
38
  "dotenv": "^17.4.2",
39
- "rollup": "^4.62.2",
39
+ "rollup": "^4.62.3",
40
40
  "rollup-plugin-dts": "^6.4.1"
41
41
  },
42
42
  "scripts": {