@paraspell/sdk-pjs 10.2.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +40 -12
- package/dist/index.d.ts +37 -8
- package/dist/index.mjs +40 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -409,6 +409,15 @@ function _toPropertyKey(t) {
|
|
|
409
409
|
var i = _toPrimitive(t, "string");
|
|
410
410
|
return "symbol" == typeof i ? i : i + "";
|
|
411
411
|
}
|
|
412
|
+
function _typeof(o) {
|
|
413
|
+
"@babel/helpers - typeof";
|
|
414
|
+
|
|
415
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
416
|
+
return typeof o;
|
|
417
|
+
} : function (o) {
|
|
418
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
419
|
+
}, _typeof(o);
|
|
420
|
+
}
|
|
412
421
|
function _unsupportedIterableToArray(r, a) {
|
|
413
422
|
if (r) {
|
|
414
423
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -1197,6 +1206,9 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1197
1206
|
};
|
|
1198
1207
|
}();
|
|
1199
1208
|
};
|
|
1209
|
+
var isEthersSigner = function isEthersSigner(signer) {
|
|
1210
|
+
return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
|
|
1211
|
+
};
|
|
1200
1212
|
|
|
1201
1213
|
/**
|
|
1202
1214
|
* Retrieves the native balance for a given account on a specified node.
|
|
@@ -1403,7 +1415,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
|
1403
1415
|
}
|
|
1404
1416
|
throw new sdkCore.InvalidParameterError('provider parameter is required for Snowbridge transfers.');
|
|
1405
1417
|
case 7:
|
|
1406
|
-
if (
|
|
1418
|
+
if (isEthersSigner(signer)) {
|
|
1407
1419
|
_context.next = 9;
|
|
1408
1420
|
break;
|
|
1409
1421
|
}
|
|
@@ -1699,31 +1711,47 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
1699
1711
|
key: "build",
|
|
1700
1712
|
value: (function () {
|
|
1701
1713
|
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1702
|
-
var _this$_options, from, to, address, _yield$transferEthToP, response;
|
|
1714
|
+
var _this$_options, from, to, address, signer, _yield$transferEthToP, response;
|
|
1703
1715
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1704
1716
|
while (1) switch (_context.prev = _context.next) {
|
|
1705
1717
|
case 0:
|
|
1706
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
1718
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address, signer = _this$_options.signer;
|
|
1707
1719
|
sdkCore.validateAddress(address, to);
|
|
1708
1720
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1709
|
-
_context.next =
|
|
1721
|
+
_context.next = 6;
|
|
1710
1722
|
break;
|
|
1711
1723
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1724
|
+
if (!isEthersSigner(signer)) {
|
|
1725
|
+
_context.next = 5;
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
throw new sdkCore.InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1729
|
+
case 5:
|
|
1730
|
+
return _context.abrupt("return", sdkCore.transferMoonbeamToEth(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1731
|
+
signer: signer
|
|
1732
|
+
})));
|
|
1733
|
+
case 6:
|
|
1714
1734
|
if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
|
|
1715
|
-
_context.next =
|
|
1735
|
+
_context.next = 12;
|
|
1716
1736
|
break;
|
|
1717
1737
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1738
|
+
if (!isEthersSigner(signer)) {
|
|
1739
|
+
_context.next = 9;
|
|
1740
|
+
break;
|
|
1741
|
+
}
|
|
1742
|
+
throw new sdkCore.InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1743
|
+
case 9:
|
|
1744
|
+
return _context.abrupt("return", sdkCore.transferMoonbeamEvm(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1745
|
+
signer: signer
|
|
1746
|
+
})));
|
|
1747
|
+
case 12:
|
|
1748
|
+
_context.next = 14;
|
|
1721
1749
|
return transferEthToPolkadot$1(this._options);
|
|
1722
|
-
case
|
|
1750
|
+
case 14:
|
|
1723
1751
|
_yield$transferEthToP = _context.sent;
|
|
1724
1752
|
response = _yield$transferEthToP.response;
|
|
1725
1753
|
return _context.abrupt("return", response.hash);
|
|
1726
|
-
case
|
|
1754
|
+
case 17:
|
|
1727
1755
|
case "end":
|
|
1728
1756
|
return _context.stop();
|
|
1729
1757
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import { TApiOrUrl, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, TNodeDotKsmWithRelayChains,
|
|
2
|
+
import { TApiOrUrl, WithApi, TEvmNodeFrom, TNodeWithRelayChains, TCurrencyInputWithAmount, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, TNodeDotKsmWithRelayChains, GeneralBuilder as GeneralBuilder$1, TSendBaseOptions } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as _polkadot_api from '@polkadot/api';
|
|
5
5
|
import { ApiPromise } from '@polkadot/api';
|
|
6
6
|
import { SubmittableExtrinsic } from '@polkadot/api/types';
|
|
7
|
-
import { TEvmNodeFrom } from '@paraspell/sdk-core/src';
|
|
8
7
|
import * as ethers from 'ethers';
|
|
9
8
|
import { Signer, AbstractProvider } from 'ethers';
|
|
10
9
|
import { WalletClient } from 'viem';
|
|
10
|
+
import { TEvmNodeFrom as TEvmNodeFrom$1 } from '@paraspell/sdk-core/src';
|
|
11
11
|
import * as _snowbridge_api_dist_toPolkadot_v2 from '@snowbridge/api/dist/toPolkadot_v2';
|
|
12
12
|
|
|
13
13
|
type TPjsApi = ApiPromise;
|
|
14
14
|
type TPjsApiOrUrl = TApiOrUrl<TPjsApi>;
|
|
15
15
|
type Extrinsic = SubmittableExtrinsic<'promise'>;
|
|
16
|
+
type TEvmBuilderOptionsBase = {
|
|
17
|
+
/**
|
|
18
|
+
* The source node. Can be either 'Ethereum', 'Moonbeam', 'Moonriver', or 'Darwinia'.
|
|
19
|
+
*/
|
|
20
|
+
from: TEvmNodeFrom;
|
|
21
|
+
/**
|
|
22
|
+
* The destination node on Polkadot network.
|
|
23
|
+
*/
|
|
24
|
+
to: TNodeWithRelayChains;
|
|
25
|
+
/**
|
|
26
|
+
* The currency to transfer. Symbol or ID.
|
|
27
|
+
*/
|
|
28
|
+
currency: TCurrencyInputWithAmount;
|
|
29
|
+
/**
|
|
30
|
+
* The Polkadot destination address.
|
|
31
|
+
*/
|
|
32
|
+
address: string;
|
|
33
|
+
/**
|
|
34
|
+
* The AssetHub address
|
|
35
|
+
*/
|
|
36
|
+
ahAddress?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The Ethereum signer.
|
|
39
|
+
*/
|
|
40
|
+
signer: Signer | WalletClient;
|
|
41
|
+
};
|
|
42
|
+
type TPjsEvmBuilderOptions<TApi, TRes> = WithApi<TEvmBuilderOptionsBase, TApi, TRes> & {
|
|
43
|
+
provider?: AbstractProvider;
|
|
44
|
+
};
|
|
16
45
|
|
|
17
46
|
/**
|
|
18
47
|
* Retrieves the native balance for a given account on a specified node.
|
|
@@ -115,11 +144,11 @@ declare const convertSs58: (address: string, node: TNodeDotKsmWithRelayChains) =
|
|
|
115
144
|
/**
|
|
116
145
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
117
146
|
*/
|
|
118
|
-
declare class EvmBuilderCore<TApi, TRes, T extends Partial<
|
|
147
|
+
declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions<TApi, TRes>> = object> {
|
|
119
148
|
protected readonly _options: T;
|
|
120
149
|
constructor(options: T);
|
|
121
|
-
from(node: TEvmNodeFrom): EvmBuilderCore<TApi, TRes, T & {
|
|
122
|
-
from: TEvmNodeFrom;
|
|
150
|
+
from(node: TEvmNodeFrom$1): EvmBuilderCore<TApi, TRes, T & {
|
|
151
|
+
from: TEvmNodeFrom$1;
|
|
123
152
|
}>;
|
|
124
153
|
/**
|
|
125
154
|
* Specifies the destination node on Polkadot.
|
|
@@ -171,7 +200,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
171
200
|
*
|
|
172
201
|
* @throws Error if any required parameters are missing.
|
|
173
202
|
*/
|
|
174
|
-
build(this: EvmBuilderCore<TApi, TRes,
|
|
203
|
+
build(this: EvmBuilderCore<TApi, TRes, TPjsEvmBuilderOptions<TApi, TRes>>): Promise<string>;
|
|
175
204
|
}
|
|
176
205
|
|
|
177
206
|
/**
|
|
@@ -213,7 +242,7 @@ declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrinsic
|
|
|
213
242
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<Extrinsic> & {
|
|
214
243
|
api?: TPjsApiOrUrl;
|
|
215
244
|
}) => Promise<_paraspell_sdk_core.TDryRunNodeResult>;
|
|
216
|
-
declare const transferEthToPolkadot: (options: Omit<
|
|
245
|
+
declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic>, "api">) => Promise<{
|
|
217
246
|
response: ethers.TransactionResponse;
|
|
218
247
|
messageReceipt: _snowbridge_api_dist_toPolkadot_v2.MessageReceipt;
|
|
219
248
|
}>;
|
|
@@ -249,4 +278,4 @@ declare namespace transfer {
|
|
|
249
278
|
declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<_polkadot_api.ApiPromise>;
|
|
250
279
|
|
|
251
280
|
export { Builder, EvmBuilder, approveToken, assets, claimAssets, convertSs58, createApiInstanceForNode, depositToken, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, send, transferEthToPolkadot, transfer as xcmPallet };
|
|
252
|
-
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsApiOrUrl };
|
|
281
|
+
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsApiOrUrl, TPjsEvmBuilderOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, InvalidParameterError, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, InvalidCurrencyError,
|
|
1
|
+
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, InvalidParameterError, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, InvalidCurrencyError, isOverrideMultiLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { u32 } from '@polkadot/types';
|
|
@@ -408,6 +408,15 @@ function _toPropertyKey(t) {
|
|
|
408
408
|
var i = _toPrimitive(t, "string");
|
|
409
409
|
return "symbol" == typeof i ? i : i + "";
|
|
410
410
|
}
|
|
411
|
+
function _typeof(o) {
|
|
412
|
+
"@babel/helpers - typeof";
|
|
413
|
+
|
|
414
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
415
|
+
return typeof o;
|
|
416
|
+
} : function (o) {
|
|
417
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
418
|
+
}, _typeof(o);
|
|
419
|
+
}
|
|
411
420
|
function _unsupportedIterableToArray(r, a) {
|
|
412
421
|
if (r) {
|
|
413
422
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -1196,6 +1205,9 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1196
1205
|
};
|
|
1197
1206
|
}();
|
|
1198
1207
|
};
|
|
1208
|
+
var isEthersSigner = function isEthersSigner(signer) {
|
|
1209
|
+
return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
|
|
1210
|
+
};
|
|
1199
1211
|
|
|
1200
1212
|
/**
|
|
1201
1213
|
* Retrieves the native balance for a given account on a specified node.
|
|
@@ -1698,31 +1710,47 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
1698
1710
|
key: "build",
|
|
1699
1711
|
value: (function () {
|
|
1700
1712
|
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1701
|
-
var _this$_options, from, to, address, _yield$transferEthToP, response;
|
|
1713
|
+
var _this$_options, from, to, address, signer, _yield$transferEthToP, response;
|
|
1702
1714
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1703
1715
|
while (1) switch (_context.prev = _context.next) {
|
|
1704
1716
|
case 0:
|
|
1705
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
1717
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address, signer = _this$_options.signer;
|
|
1706
1718
|
validateAddress(address, to);
|
|
1707
1719
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1708
|
-
_context.next =
|
|
1720
|
+
_context.next = 6;
|
|
1709
1721
|
break;
|
|
1710
1722
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1723
|
+
if (!isEthersSigner(signer)) {
|
|
1724
|
+
_context.next = 5;
|
|
1725
|
+
break;
|
|
1726
|
+
}
|
|
1727
|
+
throw new InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1728
|
+
case 5:
|
|
1729
|
+
return _context.abrupt("return", transferMoonbeamToEth(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1730
|
+
signer: signer
|
|
1731
|
+
})));
|
|
1732
|
+
case 6:
|
|
1713
1733
|
if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
|
|
1714
|
-
_context.next =
|
|
1734
|
+
_context.next = 12;
|
|
1715
1735
|
break;
|
|
1716
1736
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1737
|
+
if (!isEthersSigner(signer)) {
|
|
1738
|
+
_context.next = 9;
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
throw new InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1742
|
+
case 9:
|
|
1743
|
+
return _context.abrupt("return", transferMoonbeamEvm(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1744
|
+
signer: signer
|
|
1745
|
+
})));
|
|
1746
|
+
case 12:
|
|
1747
|
+
_context.next = 14;
|
|
1720
1748
|
return transferEthToPolkadot$1(this._options);
|
|
1721
|
-
case
|
|
1749
|
+
case 14:
|
|
1722
1750
|
_yield$transferEthToP = _context.sent;
|
|
1723
1751
|
response = _yield$transferEthToP.response;
|
|
1724
1752
|
return _context.abrupt("return", response.hash);
|
|
1725
|
-
case
|
|
1753
|
+
case 17:
|
|
1726
1754
|
case "end":
|
|
1727
1755
|
return _context.stop();
|
|
1728
1756
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@snowbridge/contract-types": "0.1.50",
|
|
28
28
|
"ethers": "^6.13.7",
|
|
29
29
|
"viem": "^2.28.1",
|
|
30
|
-
"@paraspell/sdk-core": "10.
|
|
30
|
+
"@paraspell/sdk-core": "10.3.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 15.0 < 16",
|