@paraspell/sdk-pjs 8.15.2 → 9.0.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
@@ -181,6 +181,37 @@ await builder.disconnect()
181
181
  */
182
182
  ```
183
183
 
184
+ ##### Local transfers
185
+ ```ts
186
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
187
+ .from(NODE)
188
+ .to(NODE) //Has to be same as origin (from)
189
+ .currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
190
+ .address(address)
191
+
192
+ const tx = await builder.build()
193
+
194
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
195
+ await builder.disconnect()
196
+
197
+ /*
198
+ EXAMPLE:
199
+ const builder = Builder()
200
+ .from('Hydration')
201
+ .to('Hydration')
202
+ .currency({
203
+ symbol: 'DOT',
204
+ amount: '1000000000'
205
+ })
206
+ .address(address)
207
+
208
+ const tx = await builder.build()
209
+
210
+ //Disconnect API after TX
211
+ await builder.disconnect()
212
+ */
213
+ ```
214
+
184
215
  ##### Batch calls
185
216
  You can batch XCM calls and execute multiple XCM calls within one call. All three scenarios (Para->Para, Para->Relay, Relay->Para) can be used and combined.
186
217
  ```js
@@ -206,6 +237,21 @@ const tx = await builder.buildBatch({
206
237
  await builder.disconnect()
207
238
  ```
208
239
 
240
+ ##### Asset claim:
241
+ ```ts
242
+ //Claim XCM trapped assets from the selected chain
243
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
244
+ .claimFrom(NODE)
245
+ .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
246
+ .account(address | Multilocation object)
247
+ /*.xcmVersion(Version.V3) Optional parameter, by default V3. XCM Version ENUM if a different XCM version is needed (Supported V2 & V3). Requires importing Version enum.*/
248
+
249
+ const tx = await builder.build()
250
+
251
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
252
+ await builder.disconnect()
253
+ ```
254
+
209
255
  ### Dry run your XCM Calls:
210
256
  ```ts
211
257
  //Builder pattern
@@ -263,53 +309,44 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
263
309
  .getXcmFeeEstimate()
264
310
  ```
265
311
 
266
-
267
- ### Asset claim:
312
+ ### XCM Transfer info
268
313
  ```ts
269
- //Claim XCM trapped assets from the selected chain
270
- const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
271
- .claimFrom(NODE)
272
- .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
273
- .account(address | Multilocation object)
274
- /*.xcmVersion(Version.V3) Optional parameter, by default V3. XCM Version ENUM if a different XCM version is needed (Supported V2 & V3). Requires importing Version enum.*/
314
+ import { getAssetBalance, getTransferInfo, getOriginFeeDetails, getTransferableAmount, getParaEthTransferFees, verifyEdOnDestination } from "@paraspell/sdk-pjs";
275
315
 
276
- const tx = await builder.build()
316
+ //Get fee information regarding XCM call
317
+ await getOriginFeeDetails({from, to, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, originAddress, destinationAddress, ahAddress /* optional parameter when destination is Ethereum and origin is Parachain other than AssetHub*/, api /* api/ws_url_string optional */, feeMargin /* 10% by default */})
277
318
 
278
- //Make sure to disconnect API after it is no longer used (eg. after transaction)
279
- await builder.disconnect()
280
- ```
319
+ //Retrieves the asset balance for a given account on a specified node. (You do not need to specify if it is native or foreign).
320
+ await getAssetBalance({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, api /* api/ws_url_string optional */});
281
321
 
282
- ### Local transfers
283
- ```ts
284
- const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
285
- .from(NODE)
286
- .to(NODE) //Has to be same as origin (from)
287
- .currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
288
- .address(address)
322
+ //Combines the getMaxNative and getMaxForeign transferable amount functions into one, so you don't have to specify whether you want a native or foreign asset.
323
+ await getTransferableAmount({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/});
289
324
 
290
- const tx = await builder.build()
325
+ //Get all the information about XCM transfer
326
+ await getTransferInfo({from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, api /* api/ws_url_string optional */})
291
327
 
292
- //Make sure to disconnect API after it is no longer used (eg. after transaction)
293
- await builder.disconnect()
328
+ //Get bridge and execution fee for transfer from Parachain to Ethereum. Returns as an object of 2 values - [bridgeFee, executionFee]
329
+ await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
294
330
 
295
- /*
296
- EXAMPLE:
297
- const builder = Builder()
298
- .from('Hydration')
299
- .to('Hydration')
300
- .currency({
301
- symbol: 'DOT',
302
- amount: '1000000000'
303
- })
304
- .address(address)
331
+ //Verify whether XCM message you wish to send will reach above existential deposit on destination chain.
332
+ await verifyEdOnDestination(node, currency: {symbol: || id: || multilocation: .. ,amount: 100000n}, address)
333
+ ```
305
334
 
306
- const tx = await builder.build()
335
+ ### Existential deposit queries
336
+ ```ts
337
+ import { getExistentialDeposit } from "@paraspell/sdk-pjs";
307
338
 
308
- //Disconnect API after TX
309
- await builder.disconnect()
310
- */
339
+ //Currency is an optional parameter. If you wish to query native asset, currency parameter is not necessary.
340
+ //Currency can be either {symbol: assetSymbol}, {id: assetId}, {multilocation: assetMultilocation}.
341
+ const ed = getExistentialDeposit(node, currency?)
311
342
  ```
312
343
 
344
+ ### Convert SS58 address
345
+ ```ts
346
+ import { convertSs58 } from "@paraspell/sdk-pjs";
347
+
348
+ let result = convertSs58(address, node) // returns converted address in string
349
+ ```
313
350
 
314
351
  ### Asset queries:
315
352
 
@@ -373,38 +410,6 @@ getPalletIndex(node: TNode)
373
410
  console.log(SUPPORTED_PALLETS)
374
411
  ```
375
412
 
376
- ### Existential deposit queries
377
- ```ts
378
- import { getExistentialDeposit } from "@paraspell/sdk-pjs";
379
-
380
- //Currency is an optional parameter. If you wish to query native asset, currency parameter is not necessary.
381
- //Currency can be either {symbol: assetSymbol}, {id: assetId}, {multilocation: assetMultilocation}.
382
- const ed = getExistentialDeposit(node, currency?)
383
- ```
384
-
385
- ### XCM Transfer info
386
- ```ts
387
- import { getAssetBalance, getTransferInfo, getOriginFeeDetails, getTransferableAmount, getParaEthTransferFees, verifyEdOnDestination } from "@paraspell/sdk-pjs";
388
-
389
- //Get fee information regarding XCM call
390
- await getOriginFeeDetails({from, to, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, originAddress, destinationAddress, ahAddress /* optional parameter when destination is Ethereum and origin is Parachain other than AssetHub*/, api /* api/ws_url_string optional */, feeMargin /* 10% by default */})
391
-
392
- //Retrieves the asset balance for a given account on a specified node. (You do not need to specify if it is native or foreign).
393
- await getAssetBalance({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, api /* api/ws_url_string optional */});
394
-
395
- //Combines the getMaxNative and getMaxForeign transferable amount functions into one, so you don't have to specify whether you want a native or foreign asset.
396
- await getTransferableAmount({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/});
397
-
398
- //Get all the information about XCM transfer
399
- await getTransferInfo({from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, api /* api/ws_url_string optional */})
400
-
401
- //Get bridge and execution fee for transfer from Parachain to Ethereum. Returns as an object of 2 values - [bridgeFee, executionFee]
402
- await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
403
-
404
- //Verify whether XCM message you wish to send will reach above existential deposit on destination chain.
405
- await verifyEdOnDestination(node, currency: {symbol: || id: || multilocation: .. ,amount: 100000n}, address)
406
- ```
407
-
408
413
  ## 💻 Tests
409
414
  - Run compilation using `pnpm compile`
410
415
 
package/dist/index.cjs CHANGED
@@ -529,6 +529,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
529
529
  var uint8Array = utilCrypto.decodeAddress(address);
530
530
  return util.u8aToHex(uint8Array, -1, isPrefixed);
531
531
  }
532
+ }, {
533
+ key: "accountToUint8a",
534
+ value: function accountToUint8a(address) {
535
+ return utilCrypto.decodeAddress(address);
536
+ }
532
537
  }, {
533
538
  key: "callTxMethod",
534
539
  value: function callTxMethod(_ref) {
@@ -1257,6 +1262,11 @@ var assets = /*#__PURE__*/Object.freeze({
1257
1262
  verifyEdOnDestination: verifyEdOnDestination
1258
1263
  });
1259
1264
 
1265
+ var convertSs58 = function convertSs58(address, node) {
1266
+ var papiApi = new PolkadotJsApi();
1267
+ return sdkCore.convertSs58(papiApi, address, node);
1268
+ };
1269
+
1260
1270
  var approveToken = /*#__PURE__*/function () {
1261
1271
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
1262
1272
  var env, contract, weth9, result, receipt;
@@ -1834,6 +1844,7 @@ exports.EvmBuilder = EvmBuilder;
1834
1844
  exports.approveToken = approveToken;
1835
1845
  exports.assets = assets;
1836
1846
  exports.claimAssets = claimAssets;
1847
+ exports.convertSs58 = convertSs58;
1837
1848
  exports.createApiInstanceForNode = createApiInstanceForNode;
1838
1849
  exports.depositToken = depositToken;
1839
1850
  exports.dryRun = dryRun;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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, TEvmBuilderOptions, TNodeWithRelayChains, TCurrencyInputWithAmount, GeneralBuilder as GeneralBuilder$1, TSendBaseOptions, TNodeDotKsmWithRelayChains } 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, TEvmBuilderOptions, TNodeWithRelayChains, TCurrencyInputWithAmount, 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';
@@ -133,6 +133,8 @@ declare namespace assets {
133
133
  };
134
134
  }
135
135
 
136
+ declare const convertSs58: (address: string, node: TNodeDotKsmWithRelayChains) => string;
137
+
136
138
  /**
137
139
  * Builder class for constructing transfers from Ethereum to Polkadot.
138
140
  */
@@ -269,5 +271,5 @@ declare namespace transfer {
269
271
 
270
272
  declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<_polkadot_api.ApiPromise>;
271
273
 
272
- export { Builder, EvmBuilder, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, verifyEdOnDestination, transfer as xcmPallet };
274
+ export { Builder, EvmBuilder, approveToken, assets, claimAssets, convertSs58, createApiInstanceForNode, depositToken, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, verifyEdOnDestination, transfer as xcmPallet };
273
275
  export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsApiOrUrl };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, 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, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, getParaId, ETH_CHAIN_ID, InvalidCurrencyError, isEthersSigner, isOverrideMultiLocationSpecifier, validateAddress, transferMoonbeamToEth, transferMoonbeamEvm, 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';
1
+ import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, 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, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, InvalidCurrencyError, isEthersSigner, isOverrideMultiLocationSpecifier, validateAddress, transferMoonbeamToEth, transferMoonbeamEvm, 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';
@@ -528,6 +528,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
528
528
  var uint8Array = decodeAddress(address);
529
529
  return u8aToHex(uint8Array, -1, isPrefixed);
530
530
  }
531
+ }, {
532
+ key: "accountToUint8a",
533
+ value: function accountToUint8a(address) {
534
+ return decodeAddress(address);
535
+ }
531
536
  }, {
532
537
  key: "callTxMethod",
533
538
  value: function callTxMethod(_ref) {
@@ -1256,6 +1261,11 @@ var assets = /*#__PURE__*/Object.freeze({
1256
1261
  verifyEdOnDestination: verifyEdOnDestination
1257
1262
  });
1258
1263
 
1264
+ var convertSs58 = function convertSs58(address, node) {
1265
+ var papiApi = new PolkadotJsApi();
1266
+ return convertSs58$1(papiApi, address, node);
1267
+ };
1268
+
1259
1269
  var approveToken = /*#__PURE__*/function () {
1260
1270
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
1261
1271
  var env, contract, weth9, result, receipt;
@@ -1828,4 +1838,4 @@ var transfer = /*#__PURE__*/Object.freeze({
1828
1838
  transferEthToPolkadot: transferEthToPolkadot
1829
1839
  });
1830
1840
 
1831
- export { Builder, EvmBuilder, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, verifyEdOnDestination, transfer as xcmPallet };
1841
+ export { Builder, EvmBuilder, approveToken, assets, claimAssets, convertSs58, createApiInstanceForNode, depositToken, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, verifyEdOnDestination, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "8.15.2",
3
+ "version": "9.0.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": "8.15.2"
30
+ "@paraspell/sdk-core": "9.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@polkadot/api": ">= 15.0 < 16",