@paraspell/evm 13.4.0 → 13.5.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.d.ts +5 -2
- package/dist/index.mjs +175 -189
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { TEvmTransferOptions } from '@paraspell/sdk-core';
|
|
1
|
+
import { TBuildEvmTransferOptions, TEvmTransferOptions } from '@paraspell/sdk-core';
|
|
2
|
+
import { TransactionSerializableEIP1559 } from 'viem';
|
|
3
|
+
|
|
4
|
+
declare const buildEvmTransfer: <TApi, TRes, TSigner>(options: TBuildEvmTransferOptions<TApi, TRes, TSigner>) => Promise<TransactionSerializableEIP1559>;
|
|
2
5
|
|
|
3
6
|
declare const executeEvmTransfer: <TApi, TRes, TSigner>(options: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
|
|
4
7
|
|
|
5
8
|
declare const EVM_ORIGIN_CHAINS: readonly ["Moonbeam", "Moonriver", "Darwinia"];
|
|
6
9
|
|
|
7
|
-
export { EVM_ORIGIN_CHAINS, executeEvmTransfer };
|
|
10
|
+
export { EVM_ORIGIN_CHAINS, buildEvmTransfer, executeEvmTransfer };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { UnsupportedOperationError, assertHasId, assertEvmAddress, getAssetsObject, getParaId, isOverrideLocationSpecifier, findAssetInfoOrThrow, abstractDecimals, getNativeAssetSymbol, InvalidCurrencyError, formatAssetIdToERC20, parseUnits, getParaEthTransferFees, pickCompatibleXcmVersion, createCustomXcmOnDest, createAsset, generateMessageId, TX_CLIENT_TIMEOUT_MS, BridgeHaltedError, getBridgeStatus, MissingParameterError, NumberFormatError, registerEvmExtension } from '@paraspell/sdk-core';
|
|
2
|
+
import { encodeFunctionData, maxUint64 } from 'viem';
|
|
3
|
+
import { darwinia, moonriver, moonbeam } from 'viem/chains';
|
|
3
4
|
|
|
4
5
|
function _arrayLikeToArray(r, a) {
|
|
5
6
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -223,6 +224,19 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
var EVM_VIEM_CHAIN_BY_ORIGIN = {
|
|
228
|
+
Moonbeam: moonbeam,
|
|
229
|
+
Moonriver: moonriver,
|
|
230
|
+
Darwinia: darwinia
|
|
231
|
+
};
|
|
232
|
+
var getViemChain = function getViemChain(chain) {
|
|
233
|
+
var viemChain = EVM_VIEM_CHAIN_BY_ORIGIN[chain];
|
|
234
|
+
if (!viemChain) {
|
|
235
|
+
throw new UnsupportedOperationError("No viem chain registered for '".concat(chain, "'."));
|
|
236
|
+
}
|
|
237
|
+
return viemChain;
|
|
238
|
+
};
|
|
239
|
+
|
|
226
240
|
var abi$2 = [
|
|
227
241
|
{
|
|
228
242
|
inputs: [
|
|
@@ -320,19 +334,6 @@ var abi$2 = [
|
|
|
320
334
|
}
|
|
321
335
|
];
|
|
322
336
|
|
|
323
|
-
// Partially inspired by Moonbeam XCM-SDK
|
|
324
|
-
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts#L126
|
|
325
|
-
var getDestinationLocation = function getDestinationLocation(api, address, destination) {
|
|
326
|
-
var _getAssetsObject = getAssetsObject(destination),
|
|
327
|
-
isEVM = _getAssetsObject.isEVM;
|
|
328
|
-
var accountType = isEVM ? '03' : '01';
|
|
329
|
-
var addressHex = api.accountToHex(address, false);
|
|
330
|
-
var acc = "0x".concat(accountType).concat(addressHex, "00");
|
|
331
|
-
var _getChainConfig = getChainConfig(destination),
|
|
332
|
-
paraId = _getChainConfig.paraId;
|
|
333
|
-
return [1, paraId ? ["0x0000000".concat(paraId.toString(16)), acc] : [acc]];
|
|
334
|
-
};
|
|
335
|
-
|
|
336
337
|
var abi$1 = [{
|
|
337
338
|
inputs: [{
|
|
338
339
|
internalType: 'address',
|
|
@@ -352,132 +353,94 @@ var abi$1 = [{
|
|
|
352
353
|
stateMutability: 'nonpayable',
|
|
353
354
|
type: 'function'
|
|
354
355
|
}];
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
371
|
-
return _context.a(2, contract.write.transfer([recipient, assetInfo.amount]));
|
|
372
|
-
}
|
|
373
|
-
}, _callee);
|
|
374
|
-
}));
|
|
375
|
-
return function transferMoonbeamLocal(_x, _x2, _x3) {
|
|
376
|
-
return _ref2.apply(this, arguments);
|
|
356
|
+
var buildMoonbeamLocal = function buildMoonbeamLocal(from, assetInfo, recipient) {
|
|
357
|
+
assertHasId(assetInfo);
|
|
358
|
+
assertEvmAddress(recipient);
|
|
359
|
+
assertEvmAddress(assetInfo.assetId);
|
|
360
|
+
var data = encodeFunctionData({
|
|
361
|
+
abi: abi$1,
|
|
362
|
+
functionName: 'transfer',
|
|
363
|
+
args: [recipient, assetInfo.amount]
|
|
364
|
+
});
|
|
365
|
+
return {
|
|
366
|
+
type: 'eip1559',
|
|
367
|
+
chainId: getViemChain(from).id,
|
|
368
|
+
to: assetInfo.assetId,
|
|
369
|
+
data: data,
|
|
370
|
+
value: 0n
|
|
377
371
|
};
|
|
378
|
-
}
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// Partially inspired by Moonbeam XCM-SDK
|
|
375
|
+
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts#L126
|
|
376
|
+
var getDestinationLocation = function getDestinationLocation(api, address, destination) {
|
|
377
|
+
var _getAssetsObject = getAssetsObject(destination),
|
|
378
|
+
isEVM = _getAssetsObject.isEVM;
|
|
379
|
+
var accountType = isEVM ? '03' : '01';
|
|
380
|
+
var addressHex = api.accountToHex(address, false);
|
|
381
|
+
var acc = "0x".concat(accountType).concat(addressHex, "00");
|
|
382
|
+
var paraId = getParaId(destination);
|
|
383
|
+
return [1, paraId ? ["0x0000000".concat(paraId.toString(16)), acc] : [acc]];
|
|
384
|
+
};
|
|
379
385
|
|
|
380
|
-
var U_64_MAX = 18446744073709551615n;
|
|
381
386
|
var CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000804';
|
|
382
387
|
var NATIVE_ASSET_ID = '0x0000000000000000000000000000000000000802';
|
|
383
|
-
|
|
384
|
-
var
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
throw new InvalidCurrencyError('Currency must be a foreign asset with valid assetId');
|
|
439
|
-
case 5:
|
|
440
|
-
asset = formatAssetIdToERC20(foundAsset.assetId);
|
|
441
|
-
case 6:
|
|
442
|
-
destLocation = getDestinationLocation(api, recipient, to);
|
|
443
|
-
weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
|
|
444
|
-
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
|
|
445
|
-
createTx = function createTx(func, args) {
|
|
446
|
-
return contract.write[func](args);
|
|
447
|
-
};
|
|
448
|
-
multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
|
|
449
|
-
useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
|
|
450
|
-
usdtAsset = findAssetInfoOrThrow(from, {
|
|
451
|
-
symbol: 'xcUSDT'
|
|
452
|
-
}, to);
|
|
453
|
-
assertHasId(usdtAsset);
|
|
454
|
-
if (!useMultiAssets) {
|
|
455
|
-
_context.n = 8;
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
_context.n = 7;
|
|
459
|
-
return createTx('transferMultiCurrencies', [[[asset, amount.toString()], [formatAssetIdToERC20((_usdtAsset$assetId = usdtAsset.assetId) !== null && _usdtAsset$assetId !== void 0 ? _usdtAsset$assetId : ''), '200000']], 1,
|
|
460
|
-
// index of the fee asset
|
|
461
|
-
destLocation, weight]);
|
|
462
|
-
case 7:
|
|
463
|
-
_t = _context.v;
|
|
464
|
-
_context.n = 10;
|
|
465
|
-
break;
|
|
466
|
-
case 8:
|
|
467
|
-
_context.n = 9;
|
|
468
|
-
return createTx('transfer', [asset, amount.toString(), destLocation, weight]);
|
|
469
|
-
case 9:
|
|
470
|
-
_t = _context.v;
|
|
471
|
-
case 10:
|
|
472
|
-
tx = _t;
|
|
473
|
-
return _context.a(2, tx);
|
|
474
|
-
}
|
|
475
|
-
}, _callee);
|
|
476
|
-
}));
|
|
477
|
-
return function transferMoonbeamEvm(_x) {
|
|
478
|
-
return _ref.apply(this, arguments);
|
|
388
|
+
var buildMoonbeamEvm = function buildMoonbeamEvm(options) {
|
|
389
|
+
var api = options.api,
|
|
390
|
+
from = options.from,
|
|
391
|
+
to = options.to,
|
|
392
|
+
recipient = options.recipient,
|
|
393
|
+
currency = options.currency;
|
|
394
|
+
if (Array.isArray(currency)) {
|
|
395
|
+
throw new UnsupportedOperationError('Multi-assets are not yet supported for EVM transfers');
|
|
396
|
+
}
|
|
397
|
+
if ('location' in currency && isOverrideLocationSpecifier(currency.location)) {
|
|
398
|
+
throw new UnsupportedOperationError('Override location is not supported for EVM transfers');
|
|
399
|
+
}
|
|
400
|
+
var foundAsset = findAssetInfoOrThrow(from, currency, to);
|
|
401
|
+
var amount = abstractDecimals(currency.amount, foundAsset.decimals, api);
|
|
402
|
+
if (from === to) {
|
|
403
|
+
return buildMoonbeamLocal(from, _objectSpread2(_objectSpread2({}, foundAsset), {}, {
|
|
404
|
+
amount: amount
|
|
405
|
+
}), recipient);
|
|
406
|
+
}
|
|
407
|
+
var asset;
|
|
408
|
+
if (foundAsset.symbol === getNativeAssetSymbol(from)) {
|
|
409
|
+
asset = NATIVE_ASSET_ID;
|
|
410
|
+
} else {
|
|
411
|
+
if (foundAsset.assetId === undefined) {
|
|
412
|
+
throw new InvalidCurrencyError('Currency must be a foreign asset with valid assetId');
|
|
413
|
+
}
|
|
414
|
+
asset = formatAssetIdToERC20(foundAsset.assetId);
|
|
415
|
+
}
|
|
416
|
+
var destLocation = getDestinationLocation(api, recipient, to);
|
|
417
|
+
var weight = maxUint64;
|
|
418
|
+
var multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
|
|
419
|
+
var useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
|
|
420
|
+
var usdtAsset = findAssetInfoOrThrow(from, {
|
|
421
|
+
symbol: 'xcUSDT'
|
|
422
|
+
}, to);
|
|
423
|
+
assertHasId(usdtAsset);
|
|
424
|
+
var usdtAmount = parseUnits('0.2', usdtAsset.decimals);
|
|
425
|
+
var data = useMultiAssets ? encodeFunctionData({
|
|
426
|
+
abi: abi$2,
|
|
427
|
+
functionName: 'transferMultiCurrencies',
|
|
428
|
+
args: [[[asset, amount.toString()], [formatAssetIdToERC20(usdtAsset.assetId), usdtAmount.toString()]], 1,
|
|
429
|
+
// index of the fee asset
|
|
430
|
+
destLocation, weight]
|
|
431
|
+
}) : encodeFunctionData({
|
|
432
|
+
abi: abi$2,
|
|
433
|
+
functionName: 'transfer',
|
|
434
|
+
args: [asset, amount.toString(), destLocation, weight]
|
|
435
|
+
});
|
|
436
|
+
return {
|
|
437
|
+
type: 'eip1559',
|
|
438
|
+
chainId: getViemChain(from).id,
|
|
439
|
+
to: CONTRACT_ADDRESS,
|
|
440
|
+
data: data,
|
|
441
|
+
value: 0n
|
|
479
442
|
};
|
|
480
|
-
}
|
|
443
|
+
};
|
|
481
444
|
|
|
482
445
|
var abi = [
|
|
483
446
|
{
|
|
@@ -548,14 +511,13 @@ var abi = [
|
|
|
548
511
|
// https://github.com/moonbeam-foundation/moonbeam/blob/b2b1bde7ced13aad4bd2928effc415c521fd48cb/runtime/moonbeam/src/precompiles.rs#L281
|
|
549
512
|
var xcmInterfacePrecompile = '0x000000000000000000000000000000000000081A';
|
|
550
513
|
var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
|
|
551
|
-
var
|
|
552
|
-
var
|
|
553
|
-
var
|
|
554
|
-
var api, to, signer, recipient, ahAddress, currency, bridgeStatus, foundAsset, amount, ethAsset, contract, sender, messageId, version, customXcm, customXcmOnDest, assetHubApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, createTx, numberToHex32, tx;
|
|
514
|
+
var buildMoonbeamToEth = /*#__PURE__*/function () {
|
|
515
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(from, options) {
|
|
516
|
+
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;
|
|
555
517
|
return _regenerator().w(function (_context) {
|
|
556
518
|
while (1) switch (_context.n) {
|
|
557
519
|
case 0:
|
|
558
|
-
api =
|
|
520
|
+
api = options.api, to = options.to, sender = options.sender, recipient = options.recipient, ahAddress = options.ahAddress, currency = options.currency;
|
|
559
521
|
if (ahAddress) {
|
|
560
522
|
_context.n = 1;
|
|
561
523
|
break;
|
|
@@ -589,19 +551,6 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
589
551
|
ethAsset = findAssetInfoOrThrow('Ethereum', {
|
|
590
552
|
symbol: foundAsset.symbol
|
|
591
553
|
});
|
|
592
|
-
contract = getContract({
|
|
593
|
-
abi: abi,
|
|
594
|
-
address: xcmInterfacePrecompile,
|
|
595
|
-
client: {
|
|
596
|
-
"public": createPublicClient({
|
|
597
|
-
chain: signer.chain,
|
|
598
|
-
transport: http()
|
|
599
|
-
}),
|
|
600
|
-
wallet: signer
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
sender = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
|
|
604
|
-
assertSender(sender);
|
|
605
554
|
assertHasId(ethAsset);
|
|
606
555
|
_context.n = 6;
|
|
607
556
|
return api.init(from, TX_CLIENT_TIMEOUT_MS);
|
|
@@ -610,7 +559,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
610
559
|
return generateMessageId(api, sender, getParaId(from), ethAsset.assetId, recipient, amount);
|
|
611
560
|
case 7:
|
|
612
561
|
messageId = _context.v;
|
|
613
|
-
version =
|
|
562
|
+
version = pickCompatibleXcmVersion(from, to);
|
|
614
563
|
customXcm = createCustomXcmOnDest({
|
|
615
564
|
api: api,
|
|
616
565
|
chain: from,
|
|
@@ -623,7 +572,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
623
572
|
amount: amount
|
|
624
573
|
}),
|
|
625
574
|
currency: currency,
|
|
626
|
-
asset:
|
|
575
|
+
asset: createAsset(version, amount, ethAsset.location),
|
|
627
576
|
beneficiaryLocation: {},
|
|
628
577
|
version: version
|
|
629
578
|
}, from, messageId, ethAsset);
|
|
@@ -642,58 +591,61 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
642
591
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
643
592
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
644
593
|
executionFee = _yield$getParaEthTran2[1];
|
|
645
|
-
transferFee = (bridgeFee + executionFee).toString();
|
|
646
|
-
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
|
|
647
|
-
createTx = function createTx(func, args) {
|
|
648
|
-
return contract.write[func](args);
|
|
649
|
-
};
|
|
594
|
+
transferFee = (bridgeFee + executionFee).toString();
|
|
650
595
|
numberToHex32 = function numberToHex32(num) {
|
|
651
|
-
|
|
596
|
+
if (typeof num !== 'number' || isNaN(num)) {
|
|
652
597
|
throw new NumberFormatError('Input must be a valid number');
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
598
|
+
}
|
|
599
|
+
return "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
|
|
600
|
+
};
|
|
601
|
+
data = encodeFunctionData({
|
|
602
|
+
abi: abi,
|
|
603
|
+
functionName: 'transferAssetsUsingTypeAndThenAddress',
|
|
604
|
+
args: [
|
|
605
|
+
// (1, X1(Parachain(1000)))
|
|
606
|
+
[1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
|
|
607
|
+
// Assets including fee and the ERC20 asset, with fee first
|
|
608
|
+
[[XCDOT, transferFee], [ethAsset.assetId, amount.toString()]],
|
|
609
|
+
// 2 == DestinationReserve
|
|
610
|
+
2,
|
|
611
|
+
// index of the fee asset
|
|
612
|
+
0,
|
|
613
|
+
// TransferType for fee asset (DestinationReserve)
|
|
614
|
+
2, customXcmOnDest]
|
|
615
|
+
});
|
|
616
|
+
return _context.a(2, {
|
|
617
|
+
type: 'eip1559',
|
|
618
|
+
chainId: getViemChain(from).id,
|
|
619
|
+
to: xcmInterfacePrecompile,
|
|
620
|
+
data: data,
|
|
621
|
+
value: 0n
|
|
622
|
+
});
|
|
670
623
|
}
|
|
671
624
|
}, _callee);
|
|
672
625
|
}));
|
|
673
|
-
return function
|
|
674
|
-
return
|
|
626
|
+
return function buildMoonbeamToEth(_x, _x2) {
|
|
627
|
+
return _ref.apply(this, arguments);
|
|
675
628
|
};
|
|
676
629
|
}();
|
|
677
630
|
|
|
678
|
-
var
|
|
631
|
+
var buildEvmTransfer = /*#__PURE__*/function () {
|
|
679
632
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
680
|
-
var
|
|
633
|
+
var from, to;
|
|
681
634
|
return _regenerator().w(function (_context) {
|
|
682
635
|
while (1) switch (_context.n) {
|
|
683
636
|
case 0:
|
|
684
|
-
|
|
685
|
-
validateAddress(api, recipient, to);
|
|
637
|
+
from = options.from, to = options.to;
|
|
686
638
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
687
639
|
_context.n = 1;
|
|
688
640
|
break;
|
|
689
641
|
}
|
|
690
|
-
return _context.a(2,
|
|
642
|
+
return _context.a(2, buildMoonbeamToEth(from, options));
|
|
691
643
|
case 1:
|
|
692
644
|
if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
|
|
693
645
|
_context.n = 2;
|
|
694
646
|
break;
|
|
695
647
|
}
|
|
696
|
-
return _context.a(2,
|
|
648
|
+
return _context.a(2, buildMoonbeamEvm(options));
|
|
697
649
|
case 2:
|
|
698
650
|
throw new UnsupportedOperationError("EVM transfer from '".concat(from, "' to '").concat(to, "' is not supported by @paraspell/evm."));
|
|
699
651
|
case 3:
|
|
@@ -701,14 +653,48 @@ var executeEvmTransfer = /*#__PURE__*/function () {
|
|
|
701
653
|
}
|
|
702
654
|
}, _callee);
|
|
703
655
|
}));
|
|
656
|
+
return function buildEvmTransfer(_x) {
|
|
657
|
+
return _ref.apply(this, arguments);
|
|
658
|
+
};
|
|
659
|
+
}();
|
|
660
|
+
|
|
661
|
+
var executeEvmTransfer = /*#__PURE__*/function () {
|
|
662
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
663
|
+
var signer, account, sender, tx;
|
|
664
|
+
return _regenerator().w(function (_context) {
|
|
665
|
+
while (1) switch (_context.n) {
|
|
666
|
+
case 0:
|
|
667
|
+
signer = options.signer;
|
|
668
|
+
account = signer.account;
|
|
669
|
+
if (account) {
|
|
670
|
+
_context.n = 1;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
throw new MissingParameterError('signer.account', 'viem WalletClient must have an account configured.');
|
|
674
|
+
case 1:
|
|
675
|
+
sender = account.address;
|
|
676
|
+
_context.n = 2;
|
|
677
|
+
return buildEvmTransfer(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
678
|
+
sender: sender
|
|
679
|
+
}));
|
|
680
|
+
case 2:
|
|
681
|
+
tx = _context.v;
|
|
682
|
+
return _context.a(2, signer.sendTransaction(_objectSpread2(_objectSpread2({}, tx), {}, {
|
|
683
|
+
chain: signer.chain,
|
|
684
|
+
account: account
|
|
685
|
+
})));
|
|
686
|
+
}
|
|
687
|
+
}, _callee);
|
|
688
|
+
}));
|
|
704
689
|
return function executeEvmTransfer(_x) {
|
|
705
690
|
return _ref.apply(this, arguments);
|
|
706
691
|
};
|
|
707
692
|
}();
|
|
708
693
|
|
|
709
694
|
registerEvmExtension({
|
|
710
|
-
|
|
695
|
+
executeTransfer: executeEvmTransfer,
|
|
696
|
+
buildTransfer: buildEvmTransfer
|
|
711
697
|
});
|
|
712
698
|
var EVM_ORIGIN_CHAINS = ['Moonbeam', 'Moonriver', 'Darwinia'];
|
|
713
699
|
|
|
714
|
-
export { EVM_ORIGIN_CHAINS, executeEvmTransfer };
|
|
700
|
+
export { EVM_ORIGIN_CHAINS, buildEvmTransfer, executeEvmTransfer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/evm",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.5.0",
|
|
4
4
|
"description": "Optional EVM extension for @paraspell/sdk enabling interaction with EVM-compatible chains.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"keywords": [],
|
|
25
25
|
"author": "",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"viem": "^2.
|
|
28
|
-
"@paraspell/sdk-core": "13.
|
|
27
|
+
"viem": "^2.48.4",
|
|
28
|
+
"@paraspell/sdk-core": "13.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/plugin-syntax-import-attributes": "^7.28.6",
|
|
32
32
|
"@babel/preset-env": "^7.29.2",
|
|
33
|
-
"@codecov/rollup-plugin": "^
|
|
33
|
+
"@codecov/rollup-plugin": "^2.0.1",
|
|
34
34
|
"@rollup/plugin-babel": "^7.0.0",
|
|
35
35
|
"@rollup/plugin-json": "^6.1.0",
|
|
36
36
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
37
|
-
"@vitest/coverage-v8": "^4.1.
|
|
38
|
-
"dotenv": "^17.
|
|
39
|
-
"rollup": "^4.60.
|
|
37
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
38
|
+
"dotenv": "^17.4.2",
|
|
39
|
+
"rollup": "^4.60.2",
|
|
40
40
|
"rollup-plugin-dts": "^6.4.1",
|
|
41
41
|
"tslib": "^2.8.1"
|
|
42
42
|
},
|