@paraspell/sdk-pjs 8.16.0 → 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 +73 -75
- package/package.json +2 -2
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
279
|
-
await
|
|
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
|
-
|
|
283
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
293
|
-
await
|
|
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
|
-
|
|
297
|
-
|
|
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
|
-
|
|
335
|
+
### Existential deposit queries
|
|
336
|
+
```ts
|
|
337
|
+
import { getExistentialDeposit } from "@paraspell/sdk-pjs";
|
|
307
338
|
|
|
308
|
-
//
|
|
309
|
-
|
|
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,45 +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
|
-
### Convert SS58 address
|
|
386
|
-
```ts
|
|
387
|
-
import { convertSs58 } from "@paraspell/sdk-pjs";
|
|
388
|
-
|
|
389
|
-
let result = convertSs58(address, node) // returns converted address in string
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### XCM Transfer info
|
|
393
|
-
```ts
|
|
394
|
-
import { getAssetBalance, getTransferInfo, getOriginFeeDetails, getTransferableAmount, getParaEthTransferFees, verifyEdOnDestination } from "@paraspell/sdk-pjs";
|
|
395
|
-
|
|
396
|
-
//Get fee information regarding XCM call
|
|
397
|
-
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 */})
|
|
398
|
-
|
|
399
|
-
//Retrieves the asset balance for a given account on a specified node. (You do not need to specify if it is native or foreign).
|
|
400
|
-
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 */});
|
|
401
|
-
|
|
402
|
-
//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.
|
|
403
|
-
await getTransferableAmount({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/});
|
|
404
|
-
|
|
405
|
-
//Get all the information about XCM transfer
|
|
406
|
-
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 */})
|
|
407
|
-
|
|
408
|
-
//Get bridge and execution fee for transfer from Parachain to Ethereum. Returns as an object of 2 values - [bridgeFee, executionFee]
|
|
409
|
-
await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
|
|
410
|
-
|
|
411
|
-
//Verify whether XCM message you wish to send will reach above existential deposit on destination chain.
|
|
412
|
-
await verifyEdOnDestination(node, currency: {symbol: || id: || multilocation: .. ,amount: 100000n}, address)
|
|
413
|
-
```
|
|
414
|
-
|
|
415
413
|
## 💻 Tests
|
|
416
414
|
- Run compilation using `pnpm compile`
|
|
417
415
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "
|
|
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": "
|
|
30
|
+
"@paraspell/sdk-core": "9.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 15.0 < 16",
|