@paraspell/sdk-pjs 13.6.0 → 13.7.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.
Files changed (3) hide show
  1. package/README.md +71 -68
  2. package/dist/index.mjs +17 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -173,74 +173,6 @@ 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
-
244
176
  #### Local transfers
245
177
 
246
178
  ```ts
@@ -385,6 +317,77 @@ const tx = await builder.buildBatch({
385
317
  await builder.disconnect()
386
318
  ```
387
319
 
320
+ #### Adding chain and/or assets
321
+ SDK features ability to add custom chain and/or custom assets simply by adding its config to the Builder.
322
+
323
+ ```ts
324
+ const tx = await Builder({
325
+ // Adding custom chain
326
+ customChains: {
327
+ MyChain: {
328
+ paraId: 4242,
329
+ ecosystem: 'Polkadot',
330
+ xcmVersion: Version.V5,
331
+ providers: [{ name: 'Primary', endpoint: 'wss://rpc.mychain.example/ws' }],
332
+ // Everything below is optional — auto-fetched from runtime `system.properties` when omitted
333
+ nativeAssetSymbol: 'MYC',
334
+ nativeAssetDecimals: 12,
335
+ ss58Prefix: 42,
336
+ pallets: {
337
+ nativeAssets: "Balances”,
338
+ otherAssets: "Assets",
339
+ }
340
+ assets: [
341
+ {
342
+ symbol: 'USDC',
343
+ decimals: 6,
344
+ existentialDeposit: 0.1,
345
+ location: {
346
+ parents: 1,
347
+ interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
348
+ GeneralIndex: 1337 }] }
349
+ },
350
+ assetId: '1337'
351
+ }
352
+ ]
353
+ }
354
+ },
355
+
356
+ // Adding assets to existing chains
357
+ customAssets: {
358
+ AssetHubPolkadot: [
359
+ {
360
+ symbol: 'MYNEWUSD',
361
+ decimals: 6,
362
+ assetId: '9999',
363
+ existentialDeposit: 0.1,
364
+ location: {
365
+ parents: 0,
366
+ interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
367
+ }
368
+ },
369
+ {
370
+ // Replace an existing registry asset that shares the same location
371
+ symbol: 'USDT',
372
+ decimals: 6,
373
+ assetId: '1984',
374
+ existentialDeposit: 0.1,
375
+ location: {
376
+ parents: 0,
377
+ interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
378
+ },
379
+ forceOverride: true
380
+ }
381
+ ]
382
+ }
383
+ })
384
+ .from('MyChain') // custom chain name — TS-autocompletes
385
+ .to('AssetHubPolkadot') // could be any of the existing or also the new ones added
386
+ .currency({ symbol: 'USDC', amount: amount })
387
+ .recipient(address)
388
+ .build()
389
+ ```
390
+
388
391
  ### Localhost test setup
389
392
 
390
393
  ```ts
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, 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';
1
+ import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrowImpl, getChainProvidersImpl, isSenderSigner, PolkadotApi, findAssetInfoOrThrowImpl, hasXcmPaymentApiSupportImpl, resolveModuleError, hasDryRunSupportImpl, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOfImpl, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, findAssetInfoOrThrow, 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';
@@ -789,7 +789,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
789
789
  value: function resolveDefaultFeeAsset(_ref5) {
790
790
  var chain = _ref5.chain,
791
791
  feeAsset = _ref5.feeAsset;
792
- return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
792
+ return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
793
793
  }
794
794
  }, {
795
795
  key: "resolveFeeAsset",
@@ -825,9 +825,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
825
825
  case 3:
826
826
  return _context8.a(2, {
827
827
  isCustomAsset: true,
828
- asset: findAssetInfoOrThrow(chain, {
828
+ asset: findAssetInfoOrThrowImpl(chain, {
829
829
  id: assetId
830
- })
830
+ }, undefined, this._customCtx)
831
831
  });
832
832
  }
833
833
  }, _callee8, this);
@@ -847,7 +847,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
847
847
  while (1) switch (_context0.p = _context0.n) {
848
848
  case 0:
849
849
  tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
850
- supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
850
+ supportsDryRunApi = hasDryRunSupportImpl(chain, this._customCtx);
851
851
  if (supportsDryRunApi) {
852
852
  _context0.n = 1;
853
853
  break;
@@ -1043,7 +1043,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1043
1043
  destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref8) {
1044
1044
  return i.here === null ? 0 : (_ref8 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref8 === void 0 ? void 0 : _ref8.parachain;
1045
1045
  }(Object.values(forwardedXcms[0])[0].interior);
1046
- if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1046
+ if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1047
1047
  _context0.n = 21;
1048
1048
  break;
1049
1049
  }
@@ -1219,7 +1219,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1219
1219
  case 6:
1220
1220
  deliveryFeeResJson = (_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.toJSON();
1221
1221
  deliveryFeeResolved = deliveryFeeRes && ((_ref9 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref9 === void 0 ? void 0 : _ref9.length) > 0 ? BigInt((_ref0 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref0 === void 0 || (_ref0 = _ref0[0]) === null || _ref0 === void 0 || (_ref0 = _ref0.fun) === null || _ref0 === void 0 ? void 0 : _ref0.fungible) : 0n;
1222
- nativeAsset = findNativeAssetInfoOrThrow(chain);
1222
+ nativeAsset = findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
1223
1223
  if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
1224
1224
  _context10.n = 7;
1225
1225
  break;
@@ -1270,7 +1270,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1270
1270
  return _context11.a(2, undefined);
1271
1271
  case 2:
1272
1272
  ahApi = this.clone();
1273
- assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
1273
+ assetHubChain = "AssetHub".concat(getRelayChainOfImpl(this, chain));
1274
1274
  _context11.n = 3;
1275
1275
  return ahApi.init(assetHubChain);
1276
1276
  case 3:
@@ -1330,7 +1330,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1330
1330
  while (1) switch (_context13.n) {
1331
1331
  case 0:
1332
1332
  originLocation = _ref1.originLocation, xcm = _ref1.xcm, asset = _ref1.asset, chain = _ref1.chain, version = _ref1.version, origin = _ref1.origin;
1333
- supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1333
+ supportsDryRunApi = hasDryRunSupportImpl(chain, this._customCtx);
1334
1334
  if (supportsDryRunApi) {
1335
1335
  _context13.n = 1;
1336
1336
  break;
@@ -1366,7 +1366,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1366
1366
  destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
1367
1367
  return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
1368
1368
  }(Object.values(forwardedXcms[0])[0].interior);
1369
- if (!(hasXcmPaymentApiSupport(chain) && asset)) {
1369
+ if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && asset)) {
1370
1370
  _context13.n = 5;
1371
1371
  break;
1372
1372
  }
@@ -1452,6 +1452,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1452
1452
  }
1453
1453
  return getBridgeStatus;
1454
1454
  }()
1455
+ }, {
1456
+ key: "getConstant",
1457
+ value: function getConstant(pallet, name) {
1458
+ var palletConsts = this.api.consts[lowercaseFirstLetter(pallet)];
1459
+ var value = palletConsts ? palletConsts[lowercaseFirstLetter(name)] : undefined;
1460
+ return Promise.resolve(value !== undefined ? value.toJSON() : undefined);
1461
+ }
1455
1462
  }, {
1456
1463
  key: "getSystemProperties",
1457
1464
  value: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "13.6.0",
3
+ "version": "13.7.0",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  "@snowbridge/registry": "^1.1.6",
30
30
  "ethers": "^6.16.0",
31
31
  "viem": "^2.51.3",
32
- "@paraspell/sdk-core": "13.6.0"
32
+ "@paraspell/sdk-core": "13.7.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@polkadot/api": ">= 16.0 < 17",