@paraspell/sdk 8.6.0 → 8.6.2
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 +77 -93
- package/dist/index.d.ts +48 -51
- package/dist/index.mjs +79 -94
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var sdkCore = require('@paraspell/sdk-core');
|
|
4
|
-
var polkadotSdkCompat = require('polkadot-api/polkadot-sdk-compat');
|
|
5
|
-
var polkadotApi = require('polkadot-api');
|
|
6
4
|
var blake2b = require('@noble/hashes/blake2b');
|
|
7
5
|
var utils = require('@noble/hashes/utils');
|
|
6
|
+
var polkadotApi = require('polkadot-api');
|
|
7
|
+
var polkadotSdkCompat = require('polkadot-api/polkadot-sdk-compat');
|
|
8
8
|
|
|
9
9
|
function _arrayLikeToArray(r, a) {
|
|
10
10
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1235,20 +1235,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1235
1235
|
}();
|
|
1236
1236
|
|
|
1237
1237
|
var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
1238
|
-
var
|
|
1239
|
-
return sdkCore.createApiInstanceForNode(
|
|
1238
|
+
var papiApi = new PapiApi();
|
|
1239
|
+
return sdkCore.createApiInstanceForNode(papiApi, node);
|
|
1240
1240
|
};
|
|
1241
1241
|
var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
1242
1242
|
return /*#__PURE__*/function () {
|
|
1243
1243
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
1244
|
-
var
|
|
1244
|
+
var papiApi, optionsWithApi;
|
|
1245
1245
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1246
1246
|
while (1) switch (_context.prev = _context.next) {
|
|
1247
1247
|
case 0:
|
|
1248
|
-
|
|
1249
|
-
|
|
1248
|
+
papiApi = new PapiApi();
|
|
1249
|
+
papiApi.setApi(options.api);
|
|
1250
1250
|
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1251
|
-
api:
|
|
1251
|
+
api: papiApi
|
|
1252
1252
|
});
|
|
1253
1253
|
return _context.abrupt("return", apiCall(optionsWithApi));
|
|
1254
1254
|
case 4:
|
|
@@ -1263,43 +1263,6 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1263
1263
|
}();
|
|
1264
1264
|
};
|
|
1265
1265
|
|
|
1266
|
-
/**
|
|
1267
|
-
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
1268
|
-
* @param options - The transfer options.
|
|
1269
|
-
* @returns An extrinsic to be signed and sent.
|
|
1270
|
-
*/
|
|
1271
|
-
var send = createPapiApiCall(sdkCore.send);
|
|
1272
|
-
var getDryRun = createPapiApiCall(sdkCore.getDryRun);
|
|
1273
|
-
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
1274
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
1275
|
-
var papiApi;
|
|
1276
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1277
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1278
|
-
case 0:
|
|
1279
|
-
papiApi = new PapiApi();
|
|
1280
|
-
papiApi.setApi(ahApi);
|
|
1281
|
-
_context.next = 4;
|
|
1282
|
-
return papiApi.init('AssetHubPolkadot');
|
|
1283
|
-
case 4:
|
|
1284
|
-
return _context.abrupt("return", sdkCore.getParaEthTransferFees(papiApi));
|
|
1285
|
-
case 5:
|
|
1286
|
-
case "end":
|
|
1287
|
-
return _context.stop();
|
|
1288
|
-
}
|
|
1289
|
-
}, _callee);
|
|
1290
|
-
}));
|
|
1291
|
-
return function getParaEthTransferFees(_x) {
|
|
1292
|
-
return _ref.apply(this, arguments);
|
|
1293
|
-
};
|
|
1294
|
-
}();
|
|
1295
|
-
|
|
1296
|
-
var transfer = /*#__PURE__*/Object.freeze({
|
|
1297
|
-
__proto__: null,
|
|
1298
|
-
getDryRun: getDryRun,
|
|
1299
|
-
getParaEthTransferFees: getParaEthTransferFees,
|
|
1300
|
-
send: send
|
|
1301
|
-
});
|
|
1302
|
-
|
|
1303
1266
|
/**
|
|
1304
1267
|
* Retrieves the native balance for a given account on a specified node.
|
|
1305
1268
|
*
|
|
@@ -1372,17 +1335,17 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1372
1335
|
/**
|
|
1373
1336
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
1374
1337
|
*/
|
|
1375
|
-
var
|
|
1376
|
-
function
|
|
1377
|
-
_classCallCheck(this,
|
|
1378
|
-
this._options =
|
|
1379
|
-
this._options.api = api;
|
|
1338
|
+
var EvmBuilderCore = /*#__PURE__*/function () {
|
|
1339
|
+
function EvmBuilderCore(options) {
|
|
1340
|
+
_classCallCheck(this, EvmBuilderCore);
|
|
1341
|
+
this._options = options;
|
|
1380
1342
|
}
|
|
1381
|
-
return _createClass(
|
|
1343
|
+
return _createClass(EvmBuilderCore, [{
|
|
1382
1344
|
key: "from",
|
|
1383
1345
|
value: function from(node) {
|
|
1384
|
-
this._options
|
|
1385
|
-
|
|
1346
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1347
|
+
from: node
|
|
1348
|
+
}));
|
|
1386
1349
|
}
|
|
1387
1350
|
/**
|
|
1388
1351
|
* Specifies the destination node on Polkadot.
|
|
@@ -1393,8 +1356,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1393
1356
|
}, {
|
|
1394
1357
|
key: "to",
|
|
1395
1358
|
value: function to(node) {
|
|
1396
|
-
this._options
|
|
1397
|
-
|
|
1359
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1360
|
+
to: node
|
|
1361
|
+
}));
|
|
1398
1362
|
}
|
|
1399
1363
|
/**
|
|
1400
1364
|
* Specifies the currency to transfer.
|
|
@@ -1405,8 +1369,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1405
1369
|
}, {
|
|
1406
1370
|
key: "currency",
|
|
1407
1371
|
value: function currency(_currency) {
|
|
1408
|
-
this._options
|
|
1409
|
-
|
|
1372
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1373
|
+
currency: _currency
|
|
1374
|
+
}));
|
|
1410
1375
|
}
|
|
1411
1376
|
/**
|
|
1412
1377
|
* Specifies the recipient address on Polkadot.
|
|
@@ -1417,9 +1382,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1417
1382
|
}, {
|
|
1418
1383
|
key: "address",
|
|
1419
1384
|
value: function address(_address, ahAddress) {
|
|
1420
|
-
this._options
|
|
1421
|
-
|
|
1422
|
-
|
|
1385
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1386
|
+
address: _address,
|
|
1387
|
+
ahAddress: ahAddress
|
|
1388
|
+
}));
|
|
1423
1389
|
}
|
|
1424
1390
|
/**
|
|
1425
1391
|
* Specifies the signer for the Ethereum transaction.
|
|
@@ -1430,8 +1396,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1430
1396
|
}, {
|
|
1431
1397
|
key: "signer",
|
|
1432
1398
|
value: function signer(_signer) {
|
|
1433
|
-
this._options
|
|
1434
|
-
|
|
1399
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1400
|
+
signer: _signer
|
|
1401
|
+
}));
|
|
1435
1402
|
}
|
|
1436
1403
|
/**
|
|
1437
1404
|
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
@@ -1442,40 +1409,20 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1442
1409
|
key: "build",
|
|
1443
1410
|
value: (function () {
|
|
1444
1411
|
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1445
|
-
var
|
|
1412
|
+
var _this$_options, from, to, address;
|
|
1446
1413
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1447
1414
|
while (1) switch (_context.prev = _context.next) {
|
|
1448
1415
|
case 0:
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
_context.next = 9;
|
|
1454
|
-
break;
|
|
1455
|
-
}
|
|
1456
|
-
param = _requiredParams[_i];
|
|
1457
|
-
if (!(this._options[param] === undefined)) {
|
|
1458
|
-
_context.next = 6;
|
|
1459
|
-
break;
|
|
1460
|
-
}
|
|
1461
|
-
throw new Error("Builder object is missing parameter: ".concat(param));
|
|
1462
|
-
case 6:
|
|
1463
|
-
_i++;
|
|
1464
|
-
_context.next = 2;
|
|
1465
|
-
break;
|
|
1466
|
-
case 9:
|
|
1467
|
-
sdkCore.validateAddress(this._options.address, this._options.to);
|
|
1468
|
-
if (!(this._options.from === 'Moonbeam' && this._options.to === 'Ethereum')) {
|
|
1469
|
-
_context.next = 12;
|
|
1416
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
1417
|
+
sdkCore.validateAddress(address, to);
|
|
1418
|
+
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1419
|
+
_context.next = 4;
|
|
1470
1420
|
break;
|
|
1471
1421
|
}
|
|
1472
1422
|
return _context.abrupt("return", sdkCore.transferMoonbeamToEth(this._options));
|
|
1473
|
-
case
|
|
1474
|
-
_context.
|
|
1475
|
-
|
|
1476
|
-
case 14:
|
|
1477
|
-
return _context.abrupt("return", _context.sent);
|
|
1478
|
-
case 15:
|
|
1423
|
+
case 4:
|
|
1424
|
+
return _context.abrupt("return", sdkCore.transferMoonbeamEvm(this._options));
|
|
1425
|
+
case 5:
|
|
1479
1426
|
case "end":
|
|
1480
1427
|
return _context.stop();
|
|
1481
1428
|
}
|
|
@@ -1495,7 +1442,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1495
1442
|
* @returns An instance of EvmBuilder class
|
|
1496
1443
|
*/
|
|
1497
1444
|
var EvmBuilder$1 = function EvmBuilder(api) {
|
|
1498
|
-
return new
|
|
1445
|
+
return new EvmBuilderCore({
|
|
1446
|
+
api: api
|
|
1447
|
+
});
|
|
1499
1448
|
};
|
|
1500
1449
|
|
|
1501
1450
|
/**
|
|
@@ -1509,15 +1458,50 @@ var Builder = function Builder(api) {
|
|
|
1509
1458
|
papiApi.setApi(api);
|
|
1510
1459
|
return sdkCore.Builder(papiApi);
|
|
1511
1460
|
};
|
|
1512
|
-
var GeneralBuilder = sdkCore.GeneralBuilder;
|
|
1513
1461
|
var EvmBuilder = function EvmBuilder() {
|
|
1514
1462
|
var papiApi = new PapiApi();
|
|
1515
1463
|
return EvmBuilder$1(papiApi);
|
|
1516
1464
|
};
|
|
1517
1465
|
|
|
1466
|
+
/**
|
|
1467
|
+
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
1468
|
+
* @param options - The transfer options.
|
|
1469
|
+
* @returns An extrinsic to be signed and sent.
|
|
1470
|
+
*/
|
|
1471
|
+
var send = createPapiApiCall(sdkCore.send);
|
|
1472
|
+
var getDryRun = createPapiApiCall(sdkCore.getDryRun);
|
|
1473
|
+
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
1474
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
1475
|
+
var papiApi;
|
|
1476
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1477
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1478
|
+
case 0:
|
|
1479
|
+
papiApi = new PapiApi();
|
|
1480
|
+
papiApi.setApi(ahApi);
|
|
1481
|
+
_context.next = 4;
|
|
1482
|
+
return papiApi.init('AssetHubPolkadot');
|
|
1483
|
+
case 4:
|
|
1484
|
+
return _context.abrupt("return", sdkCore.getParaEthTransferFees(papiApi));
|
|
1485
|
+
case 5:
|
|
1486
|
+
case "end":
|
|
1487
|
+
return _context.stop();
|
|
1488
|
+
}
|
|
1489
|
+
}, _callee);
|
|
1490
|
+
}));
|
|
1491
|
+
return function getParaEthTransferFees(_x) {
|
|
1492
|
+
return _ref.apply(this, arguments);
|
|
1493
|
+
};
|
|
1494
|
+
}();
|
|
1495
|
+
|
|
1496
|
+
var transfer = /*#__PURE__*/Object.freeze({
|
|
1497
|
+
__proto__: null,
|
|
1498
|
+
getDryRun: getDryRun,
|
|
1499
|
+
getParaEthTransferFees: getParaEthTransferFees,
|
|
1500
|
+
send: send
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1518
1503
|
exports.Builder = Builder;
|
|
1519
1504
|
exports.EvmBuilder = EvmBuilder;
|
|
1520
|
-
exports.GeneralBuilder = GeneralBuilder;
|
|
1521
1505
|
exports.assets = assets;
|
|
1522
1506
|
exports.claimAssets = claimAssets;
|
|
1523
1507
|
exports.createApiInstanceForNode = createApiInstanceForNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import { TApiOrUrl, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm,
|
|
2
|
+
import { TApiOrUrl, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, TEvmBuilderOptions, TNodeWithRelayChains, TCurrencyInputWithAmount, GeneralBuilder as GeneralBuilder$1, TSendBaseOptions, TNodeDotKsmWithRelayChains } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
|
+
import { TEvmNodeFrom } from '@paraspell/sdk-core/src';
|
|
4
5
|
import * as polkadot_api from 'polkadot-api';
|
|
5
6
|
import { PolkadotClient, UnsafeTransaction } from 'polkadot-api';
|
|
6
7
|
import { Signer } from 'ethers';
|
|
@@ -9,29 +10,7 @@ import { WalletClient } from 'viem';
|
|
|
9
10
|
type TPapiApi = PolkadotClient;
|
|
10
11
|
type TPapiApiOrUrl = TApiOrUrl<PolkadotClient>;
|
|
11
12
|
type TPapiTransaction = UnsafeTransaction<any, string, string, any>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
15
|
-
* @param options - The transfer options.
|
|
16
|
-
* @returns An extrinsic to be signed and sent.
|
|
17
|
-
*/
|
|
18
|
-
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions & {
|
|
19
|
-
origin: _paraspell_sdk_core.TNodeDotKsmWithRelayChains;
|
|
20
|
-
currency: _paraspell_sdk_core.TCurrencyInputWithAmount;
|
|
21
|
-
} & {
|
|
22
|
-
api?: TPapiApiOrUrl;
|
|
23
|
-
}) => Promise<TPapiTransaction>;
|
|
24
|
-
declare const getDryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<TPapiTransaction> & {
|
|
25
|
-
api?: TPapiApiOrUrl;
|
|
26
|
-
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
27
|
-
declare const getParaEthTransferFees: (ahApi?: TPapiApiOrUrl) => Promise<[bigint, bigint]>;
|
|
28
|
-
|
|
29
|
-
declare const transfer_getDryRun: typeof getDryRun;
|
|
30
|
-
declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
|
|
31
|
-
declare const transfer_send: typeof send;
|
|
32
|
-
declare namespace transfer {
|
|
33
|
-
export { transfer_getDryRun as getDryRun, transfer_getParaEthTransferFees as getParaEthTransferFees, transfer_send as send };
|
|
34
|
-
}
|
|
13
|
+
type TEvmNodeFromPapi = Extract<TEvmNodeFrom, 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
|
|
35
14
|
|
|
36
15
|
/**
|
|
37
16
|
* Retrieves the native balance for a given account on a specified node.
|
|
@@ -70,12 +49,7 @@ declare const getAssetBalance: (options: _paraspell_sdk_core.TGetAssetBalanceOpt
|
|
|
70
49
|
*
|
|
71
50
|
* @returns An extrinsic representing the claim transaction.
|
|
72
51
|
*/
|
|
73
|
-
declare const claimAssets: (options: {
|
|
74
|
-
node: _paraspell_sdk_core.TNodeWithRelayChains;
|
|
75
|
-
multiAssets: _paraspell_sdk_core.TMultiAsset[];
|
|
76
|
-
address: _paraspell_sdk_core.TAddress;
|
|
77
|
-
version?: _paraspell_sdk_core.TVersionClaimAssets;
|
|
78
|
-
} & {
|
|
52
|
+
declare const claimAssets: (options: _paraspell_sdk_core.TAssetClaimOptionsBase & {
|
|
79
53
|
api?: TPapiApiOrUrl;
|
|
80
54
|
}) => Promise<TPapiTransaction>;
|
|
81
55
|
declare const getOriginFeeDetails: (options: _paraspell_sdk_core.TGetOriginFeeDetailsOptionsBase & {
|
|
@@ -130,44 +104,54 @@ declare namespace assets {
|
|
|
130
104
|
/**
|
|
131
105
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
132
106
|
*/
|
|
133
|
-
declare class
|
|
134
|
-
_options:
|
|
135
|
-
constructor(
|
|
136
|
-
from(node:
|
|
107
|
+
declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TApi, TRes>> = object> {
|
|
108
|
+
protected readonly _options: T;
|
|
109
|
+
constructor(options: T);
|
|
110
|
+
from(node: TEvmNodeFromPapi): EvmBuilderCore<TApi, TRes, T & {
|
|
111
|
+
from: TEvmNodeFromPapi;
|
|
112
|
+
}>;
|
|
137
113
|
/**
|
|
138
114
|
* Specifies the destination node on Polkadot.
|
|
139
115
|
*
|
|
140
116
|
* @param node - The Polkadot node to which the transfer will be made.
|
|
141
117
|
* @returns An instance of EvmBuilder
|
|
142
118
|
*/
|
|
143
|
-
to(node: TNodeWithRelayChains):
|
|
119
|
+
to(node: TNodeWithRelayChains): EvmBuilderCore<TApi, TRes, T & {
|
|
120
|
+
to: TNodeWithRelayChains;
|
|
121
|
+
}>;
|
|
144
122
|
/**
|
|
145
123
|
* Specifies the currency to transfer.
|
|
146
124
|
*
|
|
147
125
|
* @param currency - The currency to be transferred.
|
|
148
126
|
* @returns An instance of EvmBuilder
|
|
149
127
|
*/
|
|
150
|
-
currency(currency: TCurrencyInputWithAmount):
|
|
128
|
+
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, T & {
|
|
129
|
+
currency: TCurrencyInputWithAmount;
|
|
130
|
+
}>;
|
|
151
131
|
/**
|
|
152
132
|
* Specifies the recipient address on Polkadot.
|
|
153
133
|
*
|
|
154
134
|
* @param address - The Polkadot address to receive the transfer.
|
|
155
135
|
* @returns An instance of EvmBuilder
|
|
156
136
|
*/
|
|
157
|
-
address(address: string, ahAddress?: string):
|
|
137
|
+
address(address: string, ahAddress?: string): EvmBuilderCore<TApi, TRes, T & {
|
|
138
|
+
address: string;
|
|
139
|
+
}>;
|
|
158
140
|
/**
|
|
159
141
|
* Specifies the signer for the Ethereum transaction.
|
|
160
142
|
*
|
|
161
143
|
* @param signer - The Ethereum signer to authorize the transfer.
|
|
162
144
|
* @returns An instance of EvmBuilder
|
|
163
145
|
*/
|
|
164
|
-
signer(signer: Signer | WalletClient):
|
|
146
|
+
signer(signer: Signer | WalletClient): EvmBuilderCore<TApi, TRes, T & {
|
|
147
|
+
signer: Signer | WalletClient;
|
|
148
|
+
}>;
|
|
165
149
|
/**
|
|
166
150
|
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
167
151
|
*
|
|
168
152
|
* @throws Error if any required parameters are missing.
|
|
169
153
|
*/
|
|
170
|
-
build(): Promise<string>;
|
|
154
|
+
build(this: EvmBuilderCore<TApi, TRes, TEvmBuilderOptions<TApi, TRes>>): Promise<string>;
|
|
171
155
|
}
|
|
172
156
|
|
|
173
157
|
/**
|
|
@@ -176,19 +160,32 @@ declare class EvmBuilderClass<TApi, TRes> {
|
|
|
176
160
|
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
177
161
|
* @returns A new Builder instance.
|
|
178
162
|
*/
|
|
179
|
-
declare const Builder: (api?: TPapiApiOrUrl) =>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
isEmpty(): boolean;
|
|
185
|
-
buildBatch(api: _paraspell_sdk_core.IPolkadotApi<polkadot_api.PolkadotClient, TPapiTransaction>, from: _paraspell_sdk_core.TNodeDotKsmWithRelayChains, options?: _paraspell_sdk_core.TBatchOptions): Promise<TPapiTransaction>;
|
|
186
|
-
}, api: _paraspell_sdk_core.IPolkadotApi<polkadot_api.PolkadotClient, TPapiTransaction>, from?: _paraspell_sdk_core.TNodeDotKsmWithRelayChains): GeneralBuilder$1<polkadot_api.PolkadotClient, TPapiTransaction>;
|
|
187
|
-
};
|
|
188
|
-
declare const EvmBuilder: () => EvmBuilderClass<polkadot_api.PolkadotClient, TPapiTransaction>;
|
|
163
|
+
declare const Builder: (api?: TPapiApiOrUrl) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, object>;
|
|
164
|
+
type GeneralBuilder<T extends Partial<TSendBaseOptions> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, T>;
|
|
165
|
+
declare const EvmBuilder: () => EvmBuilderCore<unknown, unknown, {
|
|
166
|
+
api: _paraspell_sdk_core.IPolkadotApi<PolkadotClient, TPapiTransaction>;
|
|
167
|
+
}>;
|
|
189
168
|
|
|
190
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
171
|
+
* @param options - The transfer options.
|
|
172
|
+
* @returns An extrinsic to be signed and sent.
|
|
173
|
+
*/
|
|
174
|
+
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions & {
|
|
175
|
+
api?: TPapiApiOrUrl;
|
|
176
|
+
}) => Promise<TPapiTransaction>;
|
|
177
|
+
declare const getDryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<TPapiTransaction> & {
|
|
178
|
+
api?: TPapiApiOrUrl;
|
|
179
|
+
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
180
|
+
declare const getParaEthTransferFees: (ahApi?: TPapiApiOrUrl) => Promise<[bigint, bigint]>;
|
|
181
|
+
|
|
182
|
+
declare const transfer_getDryRun: typeof getDryRun;
|
|
183
|
+
declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
|
|
184
|
+
declare const transfer_send: typeof send;
|
|
185
|
+
declare namespace transfer {
|
|
186
|
+
export { transfer_getDryRun as getDryRun, transfer_getParaEthTransferFees as getParaEthTransferFees, transfer_send as send };
|
|
187
|
+
}
|
|
191
188
|
|
|
192
189
|
declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<polkadot_api.PolkadotClient>;
|
|
193
190
|
|
|
194
|
-
export { Builder, EvmBuilder, GeneralBuilder, type
|
|
191
|
+
export { Builder, EvmBuilder, type GeneralBuilder, type TEvmNodeFromPapi, type TPapiApi, type TPapiApiOrUrl, type TPapiTransaction, assets, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject,
|
|
1
|
+
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, verifyEdOnDestination as verifyEdOnDestination$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, send as send$1, getDryRun as getDryRun$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
|
-
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
|
|
4
|
-
import { FixedSizeBinary, Binary, createClient, AccountId } from 'polkadot-api';
|
|
5
3
|
import { blake2b } from '@noble/hashes/blake2b';
|
|
6
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
5
|
+
import { FixedSizeBinary, Binary, createClient, AccountId } from 'polkadot-api';
|
|
6
|
+
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
|
|
7
7
|
|
|
8
8
|
function _arrayLikeToArray(r, a) {
|
|
9
9
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1234,20 +1234,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1234
1234
|
}();
|
|
1235
1235
|
|
|
1236
1236
|
var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
1237
|
-
var
|
|
1238
|
-
return createApiInstanceForNode$1(
|
|
1237
|
+
var papiApi = new PapiApi();
|
|
1238
|
+
return createApiInstanceForNode$1(papiApi, node);
|
|
1239
1239
|
};
|
|
1240
1240
|
var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
1241
1241
|
return /*#__PURE__*/function () {
|
|
1242
1242
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
1243
|
-
var
|
|
1243
|
+
var papiApi, optionsWithApi;
|
|
1244
1244
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1245
1245
|
while (1) switch (_context.prev = _context.next) {
|
|
1246
1246
|
case 0:
|
|
1247
|
-
|
|
1248
|
-
|
|
1247
|
+
papiApi = new PapiApi();
|
|
1248
|
+
papiApi.setApi(options.api);
|
|
1249
1249
|
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1250
|
-
api:
|
|
1250
|
+
api: papiApi
|
|
1251
1251
|
});
|
|
1252
1252
|
return _context.abrupt("return", apiCall(optionsWithApi));
|
|
1253
1253
|
case 4:
|
|
@@ -1262,43 +1262,6 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1262
1262
|
}();
|
|
1263
1263
|
};
|
|
1264
1264
|
|
|
1265
|
-
/**
|
|
1266
|
-
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
1267
|
-
* @param options - The transfer options.
|
|
1268
|
-
* @returns An extrinsic to be signed and sent.
|
|
1269
|
-
*/
|
|
1270
|
-
var send = createPapiApiCall(send$1);
|
|
1271
|
-
var getDryRun = createPapiApiCall(getDryRun$1);
|
|
1272
|
-
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
1273
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
1274
|
-
var papiApi;
|
|
1275
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1276
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1277
|
-
case 0:
|
|
1278
|
-
papiApi = new PapiApi();
|
|
1279
|
-
papiApi.setApi(ahApi);
|
|
1280
|
-
_context.next = 4;
|
|
1281
|
-
return papiApi.init('AssetHubPolkadot');
|
|
1282
|
-
case 4:
|
|
1283
|
-
return _context.abrupt("return", getParaEthTransferFees$1(papiApi));
|
|
1284
|
-
case 5:
|
|
1285
|
-
case "end":
|
|
1286
|
-
return _context.stop();
|
|
1287
|
-
}
|
|
1288
|
-
}, _callee);
|
|
1289
|
-
}));
|
|
1290
|
-
return function getParaEthTransferFees(_x) {
|
|
1291
|
-
return _ref.apply(this, arguments);
|
|
1292
|
-
};
|
|
1293
|
-
}();
|
|
1294
|
-
|
|
1295
|
-
var transfer = /*#__PURE__*/Object.freeze({
|
|
1296
|
-
__proto__: null,
|
|
1297
|
-
getDryRun: getDryRun,
|
|
1298
|
-
getParaEthTransferFees: getParaEthTransferFees,
|
|
1299
|
-
send: send
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
1265
|
/**
|
|
1303
1266
|
* Retrieves the native balance for a given account on a specified node.
|
|
1304
1267
|
*
|
|
@@ -1371,17 +1334,17 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1371
1334
|
/**
|
|
1372
1335
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
1373
1336
|
*/
|
|
1374
|
-
var
|
|
1375
|
-
function
|
|
1376
|
-
_classCallCheck(this,
|
|
1377
|
-
this._options =
|
|
1378
|
-
this._options.api = api;
|
|
1337
|
+
var EvmBuilderCore = /*#__PURE__*/function () {
|
|
1338
|
+
function EvmBuilderCore(options) {
|
|
1339
|
+
_classCallCheck(this, EvmBuilderCore);
|
|
1340
|
+
this._options = options;
|
|
1379
1341
|
}
|
|
1380
|
-
return _createClass(
|
|
1342
|
+
return _createClass(EvmBuilderCore, [{
|
|
1381
1343
|
key: "from",
|
|
1382
1344
|
value: function from(node) {
|
|
1383
|
-
this._options
|
|
1384
|
-
|
|
1345
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1346
|
+
from: node
|
|
1347
|
+
}));
|
|
1385
1348
|
}
|
|
1386
1349
|
/**
|
|
1387
1350
|
* Specifies the destination node on Polkadot.
|
|
@@ -1392,8 +1355,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1392
1355
|
}, {
|
|
1393
1356
|
key: "to",
|
|
1394
1357
|
value: function to(node) {
|
|
1395
|
-
this._options
|
|
1396
|
-
|
|
1358
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1359
|
+
to: node
|
|
1360
|
+
}));
|
|
1397
1361
|
}
|
|
1398
1362
|
/**
|
|
1399
1363
|
* Specifies the currency to transfer.
|
|
@@ -1404,8 +1368,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1404
1368
|
}, {
|
|
1405
1369
|
key: "currency",
|
|
1406
1370
|
value: function currency(_currency) {
|
|
1407
|
-
this._options
|
|
1408
|
-
|
|
1371
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1372
|
+
currency: _currency
|
|
1373
|
+
}));
|
|
1409
1374
|
}
|
|
1410
1375
|
/**
|
|
1411
1376
|
* Specifies the recipient address on Polkadot.
|
|
@@ -1416,9 +1381,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1416
1381
|
}, {
|
|
1417
1382
|
key: "address",
|
|
1418
1383
|
value: function address(_address, ahAddress) {
|
|
1419
|
-
this._options
|
|
1420
|
-
|
|
1421
|
-
|
|
1384
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1385
|
+
address: _address,
|
|
1386
|
+
ahAddress: ahAddress
|
|
1387
|
+
}));
|
|
1422
1388
|
}
|
|
1423
1389
|
/**
|
|
1424
1390
|
* Specifies the signer for the Ethereum transaction.
|
|
@@ -1429,8 +1395,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1429
1395
|
}, {
|
|
1430
1396
|
key: "signer",
|
|
1431
1397
|
value: function signer(_signer) {
|
|
1432
|
-
this._options
|
|
1433
|
-
|
|
1398
|
+
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1399
|
+
signer: _signer
|
|
1400
|
+
}));
|
|
1434
1401
|
}
|
|
1435
1402
|
/**
|
|
1436
1403
|
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
@@ -1441,40 +1408,20 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1441
1408
|
key: "build",
|
|
1442
1409
|
value: (function () {
|
|
1443
1410
|
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1444
|
-
var
|
|
1411
|
+
var _this$_options, from, to, address;
|
|
1445
1412
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1446
1413
|
while (1) switch (_context.prev = _context.next) {
|
|
1447
1414
|
case 0:
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
_context.next = 9;
|
|
1453
|
-
break;
|
|
1454
|
-
}
|
|
1455
|
-
param = _requiredParams[_i];
|
|
1456
|
-
if (!(this._options[param] === undefined)) {
|
|
1457
|
-
_context.next = 6;
|
|
1458
|
-
break;
|
|
1459
|
-
}
|
|
1460
|
-
throw new Error("Builder object is missing parameter: ".concat(param));
|
|
1461
|
-
case 6:
|
|
1462
|
-
_i++;
|
|
1463
|
-
_context.next = 2;
|
|
1464
|
-
break;
|
|
1465
|
-
case 9:
|
|
1466
|
-
validateAddress(this._options.address, this._options.to);
|
|
1467
|
-
if (!(this._options.from === 'Moonbeam' && this._options.to === 'Ethereum')) {
|
|
1468
|
-
_context.next = 12;
|
|
1415
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
1416
|
+
validateAddress(address, to);
|
|
1417
|
+
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1418
|
+
_context.next = 4;
|
|
1469
1419
|
break;
|
|
1470
1420
|
}
|
|
1471
1421
|
return _context.abrupt("return", transferMoonbeamToEth(this._options));
|
|
1472
|
-
case
|
|
1473
|
-
_context.
|
|
1474
|
-
|
|
1475
|
-
case 14:
|
|
1476
|
-
return _context.abrupt("return", _context.sent);
|
|
1477
|
-
case 15:
|
|
1422
|
+
case 4:
|
|
1423
|
+
return _context.abrupt("return", transferMoonbeamEvm(this._options));
|
|
1424
|
+
case 5:
|
|
1478
1425
|
case "end":
|
|
1479
1426
|
return _context.stop();
|
|
1480
1427
|
}
|
|
@@ -1494,7 +1441,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1494
1441
|
* @returns An instance of EvmBuilder class
|
|
1495
1442
|
*/
|
|
1496
1443
|
var EvmBuilder$1 = function EvmBuilder(api) {
|
|
1497
|
-
return new
|
|
1444
|
+
return new EvmBuilderCore({
|
|
1445
|
+
api: api
|
|
1446
|
+
});
|
|
1498
1447
|
};
|
|
1499
1448
|
|
|
1500
1449
|
/**
|
|
@@ -1508,10 +1457,46 @@ var Builder = function Builder(api) {
|
|
|
1508
1457
|
papiApi.setApi(api);
|
|
1509
1458
|
return Builder$1(papiApi);
|
|
1510
1459
|
};
|
|
1511
|
-
var GeneralBuilder = GeneralBuilder$1;
|
|
1512
1460
|
var EvmBuilder = function EvmBuilder() {
|
|
1513
1461
|
var papiApi = new PapiApi();
|
|
1514
1462
|
return EvmBuilder$1(papiApi);
|
|
1515
1463
|
};
|
|
1516
1464
|
|
|
1517
|
-
|
|
1465
|
+
/**
|
|
1466
|
+
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
1467
|
+
* @param options - The transfer options.
|
|
1468
|
+
* @returns An extrinsic to be signed and sent.
|
|
1469
|
+
*/
|
|
1470
|
+
var send = createPapiApiCall(send$1);
|
|
1471
|
+
var getDryRun = createPapiApiCall(getDryRun$1);
|
|
1472
|
+
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
1473
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
1474
|
+
var papiApi;
|
|
1475
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1476
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1477
|
+
case 0:
|
|
1478
|
+
papiApi = new PapiApi();
|
|
1479
|
+
papiApi.setApi(ahApi);
|
|
1480
|
+
_context.next = 4;
|
|
1481
|
+
return papiApi.init('AssetHubPolkadot');
|
|
1482
|
+
case 4:
|
|
1483
|
+
return _context.abrupt("return", getParaEthTransferFees$1(papiApi));
|
|
1484
|
+
case 5:
|
|
1485
|
+
case "end":
|
|
1486
|
+
return _context.stop();
|
|
1487
|
+
}
|
|
1488
|
+
}, _callee);
|
|
1489
|
+
}));
|
|
1490
|
+
return function getParaEthTransferFees(_x) {
|
|
1491
|
+
return _ref.apply(this, arguments);
|
|
1492
|
+
};
|
|
1493
|
+
}();
|
|
1494
|
+
|
|
1495
|
+
var transfer = /*#__PURE__*/Object.freeze({
|
|
1496
|
+
__proto__: null,
|
|
1497
|
+
getDryRun: getDryRun,
|
|
1498
|
+
getParaEthTransferFees: getParaEthTransferFees,
|
|
1499
|
+
send: send
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
export { Builder, EvmBuilder, assets, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.2",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"ethers": "^6.13.5",
|
|
27
27
|
"viem": "^2.23.5",
|
|
28
28
|
"@noble/hashes": "^1.7.1",
|
|
29
|
-
"@paraspell/sdk-core": "8.6.
|
|
29
|
+
"@paraspell/sdk-core": "8.6.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"polkadot-api": ">= 1.9.3 < 2"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@scure/bip32": "^1.6.2",
|
|
45
45
|
"@scure/bip39": "^1.5.4",
|
|
46
46
|
"@vitest/coverage-v8": "^3.0.7",
|
|
47
|
-
"axios": "^1.8.
|
|
47
|
+
"axios": "^1.8.2",
|
|
48
48
|
"dotenv": "^16.4.7",
|
|
49
49
|
"prettier": "^3.5.2",
|
|
50
50
|
"rollup": "^4.34.8",
|