@paraspell/sdk-pjs 13.5.0 → 13.6.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/README.md CHANGED
@@ -173,6 +173,74 @@ await builder.disconnect()
173
173
  */
174
174
  ```
175
175
 
176
+ #### Adding chain and/or assets
177
+ SDK features ability to add custom chain and/or custom assets simply by adding its config to the Builder.
178
+
179
+ ```ts
180
+ const tx = await Builder({
181
+ // Adding custom chain
182
+ customChains: {
183
+ MyChain: {
184
+ paraId: 4242,
185
+ ecosystem: 'Polkadot',
186
+ xcmVersion: Version.V5,
187
+ providers: [{ name: 'Primary', endpoint: 'wss://rpc.mychain.example/ws' }],
188
+ // Everything below is optional — auto-fetched from runtime `system.properties` when omitted
189
+ nativeAssetSymbol: 'MYC',
190
+ nativeAssetDecimals: 12,
191
+ ss58Prefix: 42,
192
+ pallets: {
193
+ nativeAssets: "Balances”,
194
+ otherAssets: "Assets",
195
+ }
196
+ assets: [
197
+ {
198
+ symbol: 'USDC',
199
+ decimals: 6,
200
+ location: {
201
+ parents: 1,
202
+ interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
203
+ GeneralIndex: 1337 }] }
204
+ },
205
+ assetId: '1337'
206
+ }
207
+ ]
208
+ }
209
+ },
210
+
211
+ // Adding assets to existing chains
212
+ customAssets: {
213
+ AssetHubPolkadot: [
214
+ {
215
+ symbol: 'MYNEWUSD',
216
+ decimals: 6,
217
+ assetId: '9999',
218
+ location: {
219
+ parents: 0,
220
+ interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
221
+ }
222
+ },
223
+ {
224
+ // Replace an existing registry asset that shares the same location
225
+ symbol: 'USDT',
226
+ decimals: 6,
227
+ assetId: '1984',
228
+ location: {
229
+ parents: 0,
230
+ interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
231
+ },
232
+ forceOverride: true
233
+ }
234
+ ]
235
+ }
236
+ })
237
+ .from('MyChain') // custom chain name — TS-autocompletes
238
+ .to('AssetHubPolkadot') // could be any of the existing or also the new ones added
239
+ .currency({ symbol: 'USDC', amount: amount })
240
+ .recipient(address)
241
+ .build()
242
+ ```
243
+
176
244
  #### Local transfers
177
245
 
178
246
  ```ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _paraspell_sdk_core from '@paraspell/sdk-core';
2
- import { WithApi, TChain, TCurrencyInputWithAmount, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions } from '@paraspell/sdk-core';
2
+ import { WithApi, TChain, TCurrencyInputWithAmount, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TCustomChainFrom, TTransferBaseOptions } 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';
@@ -171,14 +171,14 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
171
171
  /**
172
172
  * Creates a new Builder instance.
173
173
  *
174
- * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
174
+ * @param options - Either an existing API instance, a WS URL, or a config object.
175
175
  * @returns A new Builder instance.
176
176
  */
177
- declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object>;
178
- type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T>;
177
+ declare const Builder: <const TOpts extends TBuilderOptions<TApiOrUrl<TPjsApi>>>(options?: TOpts) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object, TCustomChainFrom<TOpts>>;
178
+ type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object, TCustomChain extends string = never> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T, TCustomChain>;
179
179
  /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
180
180
  declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
181
- api: _paraspell_sdk_core.PolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner>;
181
+ api: _paraspell_sdk_core.PolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, never>;
182
182
  provider: AbstractProvider | undefined;
183
183
  }>;
184
184
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProvidersImpl, isSenderSigner, PolkadotApi, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
4
4
  import { u8aConcat, compactToU8a, u8aEq, isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
@@ -698,6 +698,33 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
698
698
  var methodFormatted = snakeToCamel(method);
699
699
  return Promise.resolve(((_this$api$tx$palletFo = this.api.tx[palletFormatted]) === null || _this$api$tx$palletFo === void 0 ? void 0 : _this$api$tx$palletFo[methodFormatted]) !== undefined);
700
700
  }
701
+ }, {
702
+ key: "hasRuntimeApi",
703
+ value: function hasRuntimeApi(runtimeApi) {
704
+ return Promise.resolve(this.api.call[lowercaseFirstLetter(runtimeApi)] !== undefined);
705
+ }
706
+ }, {
707
+ key: "fetchPalletList",
708
+ value: function fetchPalletList() {
709
+ var _this2 = this;
710
+ var entries = this.api.runtimeMetadata.asLatest.pallets.map(function (p) {
711
+ var name = p.name.toString();
712
+ return {
713
+ name: name,
714
+ index: p.index.toNumber(),
715
+ hasExtrinsics: _this2.api.tx[lowercaseFirstLetter(name)] !== undefined
716
+ };
717
+ });
718
+ return Promise.resolve(entries);
719
+ }
720
+ }, {
721
+ key: "isEvmChain",
722
+ value: function isEvmChain() {
723
+ var _types$, _path$includes;
724
+ var types = this.api.runtimeMetadata.asLatest.lookup.types;
725
+ var path = (_types$ = types[0]) === null || _types$ === void 0 ? void 0 : _types$.type.path.toJSON();
726
+ return Promise.resolve((_path$includes = path === null || path === void 0 ? void 0 : path.includes('AccountId20')) !== null && _path$includes !== void 0 ? _path$includes : false);
727
+ }
701
728
  }, {
702
729
  key: "getFromRpc",
703
730
  value: function () {
@@ -814,7 +841,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
814
841
  key: "getDryRunCall",
815
842
  value: function () {
816
843
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
817
- var _this2 = this;
844
+ var _this3 = this;
818
845
  var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
819
846
  return _regenerator().w(function (_context0) {
820
847
  while (1) switch (_context0.p = _context0.n) {
@@ -858,13 +885,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
858
885
  resolvedFeeAsset = _context0.v;
859
886
  performDryRunCall = /*#__PURE__*/function () {
860
887
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(includeVersion) {
861
- var _this2$api$call$dryRu;
888
+ var _this3$api$call$dryRu;
862
889
  var versionNum;
863
890
  return _regenerator().w(function (_context9) {
864
891
  while (1) switch (_context9.n) {
865
892
  case 0:
866
893
  versionNum = Number(version.charAt(1));
867
- return _context9.a(2, (_this2$api$call$dryRu = _this2.api.call.dryRunApi).dryRunCall.apply(_this2$api$call$dryRu, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
894
+ return _context9.a(2, (_this3$api$call$dryRu = _this3.api.call.dryRunApi).dryRunCall.apply(_this3$api$call$dryRu, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
868
895
  }
869
896
  }, _callee9);
870
897
  }));
@@ -1425,6 +1452,32 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1425
1452
  }
1426
1453
  return getBridgeStatus;
1427
1454
  }()
1455
+ }, {
1456
+ key: "getSystemProperties",
1457
+ value: function () {
1458
+ var _getSystemProperties = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1459
+ var _props$ss58Format, _props$tokenSymbol, _props$tokenDecimals;
1460
+ var props;
1461
+ return _regenerator().w(function (_context15) {
1462
+ while (1) switch (_context15.n) {
1463
+ case 0:
1464
+ _context15.n = 1;
1465
+ return this.api.rpc.system.properties();
1466
+ case 1:
1467
+ props = _context15.v.toPrimitive();
1468
+ return _context15.a(2, {
1469
+ ss58Format: (_props$ss58Format = props.ss58Format) !== null && _props$ss58Format !== void 0 ? _props$ss58Format : undefined,
1470
+ tokenSymbol: (_props$tokenSymbol = props.tokenSymbol) === null || _props$tokenSymbol === void 0 ? void 0 : _props$tokenSymbol[0],
1471
+ tokenDecimals: (_props$tokenDecimals = props.tokenDecimals) === null || _props$tokenDecimals === void 0 ? void 0 : _props$tokenDecimals[0]
1472
+ });
1473
+ }
1474
+ }, _callee15, this);
1475
+ }));
1476
+ function getSystemProperties() {
1477
+ return _getSystemProperties.apply(this, arguments);
1478
+ }
1479
+ return getSystemProperties;
1480
+ }()
1428
1481
  }, {
1429
1482
  key: "disconnect",
1430
1483
  value: function disconnect() {
@@ -1442,7 +1495,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1442
1495
  if (force) {
1443
1496
  void this.api.disconnect();
1444
1497
  } else {
1445
- var key = api === undefined ? getChainProviders(this._chain) : api;
1498
+ var key = api === undefined ? getChainProvidersImpl(this._chain, this._customCtx) : api;
1446
1499
  releaseClient(key);
1447
1500
  }
1448
1501
  }
@@ -1469,33 +1522,33 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1469
1522
  }, {
1470
1523
  key: "signAndSubmit",
1471
1524
  value: function () {
1472
- var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
1525
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
1473
1526
  var hash, _t8;
1474
- return _regenerator().w(function (_context15) {
1475
- while (1) switch (_context15.n) {
1527
+ return _regenerator().w(function (_context16) {
1528
+ while (1) switch (_context16.n) {
1476
1529
  case 0:
1477
1530
  if (!isSenderSigner(sender)) {
1478
- _context15.n = 2;
1531
+ _context16.n = 2;
1479
1532
  break;
1480
1533
  }
1481
- _context15.n = 1;
1534
+ _context16.n = 1;
1482
1535
  return tx.signAndSend(sender.address, {
1483
1536
  signer: sender.signer
1484
1537
  });
1485
1538
  case 1:
1486
- _t8 = _context15.v;
1487
- _context15.n = 4;
1539
+ _t8 = _context16.v;
1540
+ _context16.n = 4;
1488
1541
  break;
1489
1542
  case 2:
1490
- _context15.n = 3;
1543
+ _context16.n = 3;
1491
1544
  return tx.signAndSend(createKeyringPair(sender));
1492
1545
  case 3:
1493
- _t8 = _context15.v;
1546
+ _t8 = _context16.v;
1494
1547
  case 4:
1495
1548
  hash = _t8;
1496
- return _context15.a(2, hash.toHex());
1549
+ return _context16.a(2, hash.toHex());
1497
1550
  }
1498
- }, _callee15);
1551
+ }, _callee16);
1499
1552
  }));
1500
1553
  function signAndSubmit(_x28, _x29) {
1501
1554
  return _signAndSubmit.apply(this, arguments);
@@ -1505,27 +1558,27 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1505
1558
  }, {
1506
1559
  key: "signAndSubmitFinalized",
1507
1560
  value: function () {
1508
- var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
1509
- var _this3 = this;
1510
- return _regenerator().w(function (_context16) {
1511
- while (1) switch (_context16.n) {
1561
+ var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, sender) {
1562
+ var _this4 = this;
1563
+ return _regenerator().w(function (_context17) {
1564
+ while (1) switch (_context17.n) {
1512
1565
  case 0:
1513
1566
  if (!isSenderSigner(sender)) {
1514
- _context16.n = 2;
1567
+ _context17.n = 2;
1515
1568
  break;
1516
1569
  }
1517
- _context16.n = 1;
1570
+ _context17.n = 1;
1518
1571
  return tx.signAsync(sender.address, {
1519
1572
  signer: sender.signer
1520
1573
  });
1521
1574
  case 1:
1522
- _context16.n = 3;
1575
+ _context17.n = 3;
1523
1576
  break;
1524
1577
  case 2:
1525
- _context16.n = 3;
1578
+ _context17.n = 3;
1526
1579
  return tx.signAsync(createKeyringPair(sender));
1527
1580
  case 3:
1528
- return _context16.a(2, new Promise(function (resolve, reject) {
1581
+ return _context17.a(2, new Promise(function (resolve, reject) {
1529
1582
  tx.send(function (_ref14) {
1530
1583
  var status = _ref14.status,
1531
1584
  dispatchError = _ref14.dispatchError,
@@ -1533,7 +1586,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1533
1586
  if (status.isFinalized) {
1534
1587
  if (dispatchError !== undefined) {
1535
1588
  if (dispatchError.isModule) {
1536
- var decoded = _this3.api.registry.findMetaError(dispatchError.asModule);
1589
+ var decoded = _this4.api.registry.findMetaError(dispatchError.asModule);
1537
1590
  var docs = decoded.docs,
1538
1591
  name = decoded.name,
1539
1592
  section = decoded.section;
@@ -1550,7 +1603,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1550
1603
  });
1551
1604
  }));
1552
1605
  }
1553
- }, _callee16);
1606
+ }, _callee17);
1554
1607
  }));
1555
1608
  function signAndSubmitFinalized(_x30, _x31) {
1556
1609
  return _signAndSubmitFinalized.apply(this, arguments);
@@ -2019,11 +2072,11 @@ var EvmBuilder$1 = function EvmBuilder(api, provider) {
2019
2072
  /**
2020
2073
  * Creates a new Builder instance.
2021
2074
  *
2022
- * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
2075
+ * @param options - Either an existing API instance, a WS URL, or a config object.
2023
2076
  * @returns A new Builder instance.
2024
2077
  */
2025
- var Builder = function Builder(api) {
2026
- var pjsApi = new PolkadotJsApi(api);
2078
+ var Builder = function Builder(options) {
2079
+ var pjsApi = new PolkadotJsApi(options);
2027
2080
  return Builder$1(pjsApi);
2028
2081
  };
2029
2082
  /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "13.5.0",
3
+ "version": "13.6.0",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,14 +22,14 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@snowbridge/api": "^1.0.13",
26
- "@snowbridge/base-types": "^1.0.13",
27
- "@snowbridge/contract-types": "^1.0.13",
28
- "@snowbridge/provider-ethers": "^1.0.13",
29
- "@snowbridge/registry": "^1.0.13",
25
+ "@snowbridge/api": "^1.1.6",
26
+ "@snowbridge/base-types": "^1.1.6",
27
+ "@snowbridge/contract-types": "^1.1.6",
28
+ "@snowbridge/provider-ethers": "^1.1.6",
29
+ "@snowbridge/registry": "^1.1.6",
30
30
  "ethers": "^6.16.0",
31
- "viem": "^2.48.4",
32
- "@paraspell/sdk-core": "13.5.0"
31
+ "viem": "^2.51.3",
32
+ "@paraspell/sdk-core": "13.6.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@polkadot/api": ">= 16.0 < 17",
@@ -39,16 +39,16 @@
39
39
  "@polkadot/util-crypto": ">= 14"
40
40
  },
41
41
  "devDependencies": {
42
- "@babel/plugin-syntax-import-attributes": "^7.28.6",
43
- "@babel/preset-env": "^7.29.2",
42
+ "@babel/plugin-syntax-import-attributes": "^7.29.7",
43
+ "@babel/preset-env": "^7.29.7",
44
44
  "@codecov/rollup-plugin": "^2.0.1",
45
45
  "@rollup/plugin-babel": "^7.0.0",
46
46
  "@rollup/plugin-json": "^6.1.0",
47
47
  "@rollup/plugin-typescript": "^12.3.0",
48
- "@vitest/coverage-v8": "^4.1.5",
49
- "axios": "^1.15.2",
48
+ "@vitest/coverage-v8": "^4.1.7",
49
+ "axios": "^1.16.1",
50
50
  "dotenv": "^17.4.2",
51
- "rollup": "^4.60.2",
51
+ "rollup": "^4.60.4",
52
52
  "rollup-plugin-dts": "^6.4.1",
53
53
  "tslib": "^2.8.1"
54
54
  },