@paraspell/sdk 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
@@ -185,6 +185,37 @@ await builder.disconnect()
185
185
  */
186
186
  ```
187
187
 
188
+ ##### Local transfers
189
+ ```ts
190
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
191
+ .from(NODE)
192
+ .to(NODE) //Has to be same as origin (from)
193
+ .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}})
194
+ .address(address)
195
+
196
+ const tx = await builder.build()
197
+
198
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
199
+ await builder.disconnect()
200
+
201
+ /*
202
+ EXAMPLE:
203
+ const builder = Builder()
204
+ .from('Hydration')
205
+ .to('Hydration')
206
+ .currency({
207
+ symbol: 'DOT',
208
+ amount: '1000000000'
209
+ })
210
+ .address(address)
211
+
212
+ const tx = await builder.build()
213
+
214
+ //Disconnect API after TX
215
+ await builder.disconnect()
216
+ */
217
+ ```
218
+
188
219
  ##### Batch calls
189
220
  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.
190
221
  ```js
@@ -210,6 +241,21 @@ const tx = await builder.buildBatch({
210
241
  await builder.disconnect()
211
242
  ```
212
243
 
244
+ ##### Asset claim:
245
+ ```ts
246
+ //Claim XCM trapped assets from the selected chain
247
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
248
+ .claimFrom(NODE)
249
+ .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
250
+ .account(address | Multilocation object)
251
+ /*.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.*/
252
+
253
+ const tx = await builder.build()
254
+
255
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
256
+ await builder.disconnect()
257
+ ```
258
+
213
259
  ### Dry run your XCM Calls:
214
260
  ```ts
215
261
  //Builder pattern
@@ -264,51 +310,43 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
264
310
  .getXcmFeeEstimate()
265
311
  ```
266
312
 
267
-
268
- ### Asset claim:
313
+ ### XCM Transfer info
269
314
  ```ts
270
- //Claim XCM trapped assets from the selected chain
271
- const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
272
- .claimFrom(NODE)
273
- .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
274
- .account(address | Multilocation object)
275
- /*.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.*/
315
+ import { getAssetBalance, getTransferInfo, getOriginFeeDetails, getTransferableAmount, getParaEthTransferFees, verifyEdOnDestination } from "@paraspell/sdk";
276
316
 
277
- const tx = await builder.build()
317
+ //Get fee information regarding XCM call
318
+ 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 */})
278
319
 
279
- //Make sure to disconnect API after it is no longer used (eg. after transaction)
280
- await builder.disconnect()
281
- ```
320
+ //Retrieves the asset balance for a given account on a specified node. (You do not need to specify if it is native or foreign).
321
+ 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 */});
282
322
 
283
- ### Local transfers
284
- ```ts
285
- const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
286
- .from(NODE)
287
- .to(NODE) //Has to be same as origin (from)
288
- .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}})
289
- .address(address)
323
+ //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.
324
+ await getTransferableAmount({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/});
290
325
 
291
- const tx = await builder.build()
326
+ //Get all the information about XCM transfer
327
+ 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 */})
292
328
 
293
- //Make sure to disconnect API after it is no longer used (eg. after transaction)
294
- await builder.disconnect()
329
+ //Get bridge and execution fee for transfer from Parachain to Ethereum. Returns as an object of 2 values - [bridgeFee, executionFee]
330
+ await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
295
331
 
296
- /*
297
- EXAMPLE:
298
- const builder = Builder()
299
- .from('Hydration')
300
- .to('Hydration')
301
- .currency({
302
- symbol: 'DOT',
303
- amount: '1000000000'
304
- })
305
- .address(address)
332
+ //Verify whether XCM message you wish to send will reach above existential deposit on destination chain.
333
+ await verifyEdOnDestination(node, currency: {symbol: || id: || multilocation: .. ,amount: 100000n}, address)
334
+ ```
306
335
 
307
- const tx = await builder.build()
336
+ ### Existential deposit queries
337
+ ```ts
338
+ import { getExistentialDeposit } from "@paraspell/sdk";
308
339
 
309
- //Disconnect API after TX
310
- await builder.disconnect()
311
- */
340
+ //Currency is an optional parameter. If you wish to query native asset, currency parameter is not necessary.
341
+ //Currency can be either {symbol: assetSymbol}, {id: assetId}, {multilocation: assetMultilocation}.
342
+ const ed = getExistentialDeposit(node, currency?)
343
+ ```
344
+
345
+ ### Convert SS58 address
346
+ ```ts
347
+ import { convertSs58 } from "@paraspell/sdk";
348
+
349
+ let result = convertSs58(address, node) // returns converted address in string
312
350
  ```
313
351
 
314
352
  ### Asset queries:
@@ -373,38 +411,6 @@ getPalletIndex(node: TNode)
373
411
  console.log(SUPPORTED_PALLETS)
374
412
  ```
375
413
 
376
- ### Existential deposit queries
377
- ```ts
378
- import { getExistentialDeposit } from "@paraspell/sdk";
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";
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
414
  ## 💻 Tests
409
415
  - Run compilation using `pnpm compile`
410
416
 
package/dist/index.cjs CHANGED
@@ -1007,6 +1007,15 @@ var PapiApi = /*#__PURE__*/function () {
1007
1007
  var hex = polkadotApi.FixedSizeBinary.fromAccountId32(address).asHex();
1008
1008
  return isPrefixed ? hex : hex.slice(2);
1009
1009
  }
1010
+ }, {
1011
+ key: "accountToUint8a",
1012
+ value: function accountToUint8a(address) {
1013
+ var result = polkadotApi.getSs58AddressInfo(address);
1014
+ if (!result.isValid) {
1015
+ throw new sdkCore.InvalidParameterError("Invalid address: ".concat(address));
1016
+ }
1017
+ return result.publicKey;
1018
+ }
1010
1019
  }, {
1011
1020
  key: "callTxMethod",
1012
1021
  value: function callTxMethod(_ref4) {
@@ -1734,6 +1743,11 @@ var assets = /*#__PURE__*/Object.freeze({
1734
1743
  verifyEdOnDestination: verifyEdOnDestination
1735
1744
  });
1736
1745
 
1746
+ var convertSs58 = function convertSs58(address, node) {
1747
+ var papiApi = new PapiApi();
1748
+ return sdkCore.convertSs58(papiApi, address, node);
1749
+ };
1750
+
1737
1751
  /**
1738
1752
  * Builder class for constructing transfers from Ethereum to Polkadot.
1739
1753
  */
@@ -1943,6 +1957,7 @@ exports.Builder = Builder;
1943
1957
  exports.EvmBuilder = EvmBuilder;
1944
1958
  exports.assets = assets;
1945
1959
  exports.claimAssets = claimAssets;
1960
+ exports.convertSs58 = convertSs58;
1946
1961
  exports.createApiInstanceForNode = createApiInstanceForNode;
1947
1962
  exports.dryRun = dryRun;
1948
1963
  exports.dryRunOrigin = dryRunOrigin;
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 { TEvmNodeFrom } from '@paraspell/sdk-core/src';
5
5
  import * as polkadot_api from 'polkadot-api';
@@ -131,6 +131,8 @@ declare namespace assets {
131
131
  };
132
132
  }
133
133
 
134
+ declare const convertSs58: (address: string, node: TNodeDotKsmWithRelayChains) => string;
135
+
134
136
  /**
135
137
  * Builder class for constructing transfers from Ethereum to Polkadot.
136
138
  */
@@ -242,5 +244,5 @@ declare namespace transfer {
242
244
 
243
245
  declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<polkadot_api.PolkadotClient>;
244
246
 
245
- export { Builder, EvmBuilder, assets, claimAssets, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
247
+ export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
246
248
  export type { GeneralBuilder, TEvmNodeFromPapi, TPapiApi, TPapiApiOrUrl, TPapiTransaction };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { BatchMode, getNodeProviders, 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, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { InvalidParameterError, BatchMode, getNodeProviders, 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, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, 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 { blake2b } from '@noble/hashes/blake2';
4
4
  import { bytesToHex } from '@noble/hashes/utils';
5
5
  import { ethers } from 'ethers';
6
- import { FixedSizeBinary, Binary, AccountId, createClient } from 'polkadot-api';
6
+ import { FixedSizeBinary, getSs58AddressInfo, Binary, AccountId, createClient } from 'polkadot-api';
7
7
  import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
8
8
 
9
9
  function _arrayLikeToArray(r, a) {
@@ -1006,6 +1006,15 @@ var PapiApi = /*#__PURE__*/function () {
1006
1006
  var hex = FixedSizeBinary.fromAccountId32(address).asHex();
1007
1007
  return isPrefixed ? hex : hex.slice(2);
1008
1008
  }
1009
+ }, {
1010
+ key: "accountToUint8a",
1011
+ value: function accountToUint8a(address) {
1012
+ var result = getSs58AddressInfo(address);
1013
+ if (!result.isValid) {
1014
+ throw new InvalidParameterError("Invalid address: ".concat(address));
1015
+ }
1016
+ return result.publicKey;
1017
+ }
1009
1018
  }, {
1010
1019
  key: "callTxMethod",
1011
1020
  value: function callTxMethod(_ref4) {
@@ -1733,6 +1742,11 @@ var assets = /*#__PURE__*/Object.freeze({
1733
1742
  verifyEdOnDestination: verifyEdOnDestination
1734
1743
  });
1735
1744
 
1745
+ var convertSs58 = function convertSs58(address, node) {
1746
+ var papiApi = new PapiApi();
1747
+ return convertSs58$1(papiApi, address, node);
1748
+ };
1749
+
1736
1750
  /**
1737
1751
  * Builder class for constructing transfers from Ethereum to Polkadot.
1738
1752
  */
@@ -1938,4 +1952,4 @@ var transfer = /*#__PURE__*/Object.freeze({
1938
1952
  send: send
1939
1953
  });
1940
1954
 
1941
- export { Builder, EvmBuilder, assets, claimAssets, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
1955
+ export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, 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.15.2",
3
+ "version": "9.0.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "ethers": "^6.13.7",
28
28
  "quick-lru": "^7.0.1",
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": ">= 1.10.2 < 2"