@paraspell/sdk-pjs 12.10.0-rc.2 → 13.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 +104 -23
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -203,9 +203,9 @@ const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..]
|
|
|
203
203
|
.sender(address | PAPI_SIGNER /*Only in PAPI SDK*/ | {address, PJS_SIGNER} /*Only in PJS SDK*/) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub/Hydration with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
204
204
|
.swap({
|
|
205
205
|
currencyTo: {id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/}
|
|
206
|
-
// exchange: ['
|
|
206
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
207
207
|
// slippage: 1, - Optional - 1 by default
|
|
208
|
-
//
|
|
208
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
209
209
|
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
210
210
|
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
211
211
|
})
|
|
@@ -226,7 +226,15 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
226
226
|
.from(TSubstrateChain)
|
|
227
227
|
.to(TChain)
|
|
228
228
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
229
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency
|
|
229
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.
|
|
230
|
+
.swap({
|
|
231
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
232
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
233
|
+
// slippage: 1, - Optional - 1 by default
|
|
234
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
235
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
236
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
237
|
+
})*/
|
|
230
238
|
.recipient(ADDRESS)
|
|
231
239
|
.sender(address | {address, PJS_Signer})
|
|
232
240
|
.dryRun()
|
|
@@ -275,23 +283,6 @@ const tx = await builder.buildBatch({
|
|
|
275
283
|
await builder.disconnect()
|
|
276
284
|
```
|
|
277
285
|
|
|
278
|
-
#### Asset claim:
|
|
279
|
-
|
|
280
|
-
```ts
|
|
281
|
-
//Claim XCM trapped assets from the selected chain
|
|
282
|
-
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
283
|
-
.claimfrom(TSubstrateChain)
|
|
284
|
-
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..]
|
|
285
|
-
)
|
|
286
|
-
.recipient(address | Location object)
|
|
287
|
-
/*.xcmVersion(Version.V3) Optional parameter, by default chain specific version. XCM Version ENUM if a different XCM version is needed (Supported V3 & V4 & V5). Requires importing Version enum.*/
|
|
288
|
-
|
|
289
|
-
const tx = await builder.build()
|
|
290
|
-
|
|
291
|
-
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
292
|
-
await builder.disconnect()
|
|
293
|
-
```
|
|
294
|
-
|
|
295
286
|
### Localhost test setup
|
|
296
287
|
|
|
297
288
|
```ts
|
|
@@ -329,7 +320,15 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
329
320
|
.from(TSubstrateChain)
|
|
330
321
|
.to(TChain)
|
|
331
322
|
.currency(CURRENCY_SPEC)
|
|
332
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
323
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
324
|
+
.swap({
|
|
325
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
326
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
327
|
+
// slippage: 1, - Optional - 1 by default
|
|
328
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
329
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
330
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
331
|
+
})*/
|
|
333
332
|
.recipient(RECIPIENT_ADDRESS)
|
|
334
333
|
.sender(address | {address, PJS_Signer})
|
|
335
334
|
.getXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of a DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin or Destination chain do not support DryRun out of the box.
|
|
@@ -366,7 +365,15 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
366
365
|
.from(TSubstrateChain)
|
|
367
366
|
.to(TChain)
|
|
368
367
|
.currency(CURRENCY_SPEC)
|
|
369
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
368
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
369
|
+
.swap({
|
|
370
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
371
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
372
|
+
// slippage: 1, - Optional - 1 by default
|
|
373
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
374
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
375
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
376
|
+
})*/
|
|
370
377
|
.recipient(RECIPIENT_ADDRESS)
|
|
371
378
|
.sender(address | {address, PJS_Signer})
|
|
372
379
|
.getTransferableAmount()
|
|
@@ -378,7 +385,15 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
378
385
|
.from(TSubstrateChain)
|
|
379
386
|
.to(TChain)
|
|
380
387
|
.currency(CURRENCY_SPEC)
|
|
381
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
388
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
389
|
+
.swap({
|
|
390
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
391
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
392
|
+
// slippage: 1, - Optional - 1 by default
|
|
393
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
394
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
395
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
396
|
+
})*/
|
|
382
397
|
.recipient(RECIPIENT_ADDRESS)
|
|
383
398
|
.sender(address | {address, PJS_Signer})
|
|
384
399
|
.getMinTransferableAmount()
|
|
@@ -408,6 +423,26 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
408
423
|
.verifyEdOnDestination()
|
|
409
424
|
```
|
|
410
425
|
|
|
426
|
+
#### Get best amount out
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
430
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
431
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
432
|
+
.currency(CURRENCY_SPEC)
|
|
433
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
434
|
+
.sender(SENDER_ADDRESS)
|
|
435
|
+
.swap({
|
|
436
|
+
currencyTo: CURRENCY_SPEC,
|
|
437
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
438
|
+
// slippage: 1, - Optional - 1 by default
|
|
439
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
440
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
441
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
442
|
+
})
|
|
443
|
+
.getBestAmountOut();
|
|
444
|
+
```
|
|
445
|
+
|
|
411
446
|
#### Asset balance
|
|
412
447
|
```ts
|
|
413
448
|
import { getBalance } from "@paraspell/sdk-pjs";
|
|
@@ -515,6 +550,52 @@ getOtherAssetsPallets(chain: TChain)
|
|
|
515
550
|
console.log(SUPPORTED_PALLETS)
|
|
516
551
|
```
|
|
517
552
|
|
|
553
|
+
### Import chains as types
|
|
554
|
+
There are 6 options for types you can choose based on your prefference
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
// Import all exchange chains (Swap)
|
|
558
|
+
import type { TExchangeChain } from "@paraspell/sdk-pjs"
|
|
559
|
+
|
|
560
|
+
// Import all Parachains
|
|
561
|
+
import type { TParachain } from "@paraspell/sdk-pjs"
|
|
562
|
+
|
|
563
|
+
// Import all Relay chains
|
|
564
|
+
import type { TRelaychain } from "@paraspell/sdk-pjs"
|
|
565
|
+
|
|
566
|
+
// Import all Substrate chains (Parachains + Relays)
|
|
567
|
+
import type { TSubstrateChain } from "@paraspell/sdk-pjs"
|
|
568
|
+
|
|
569
|
+
// Import chains outside Polkadot ecosystem (Ethereum)
|
|
570
|
+
import type { TExternalChain } from "@paraspell/sdk-pjs"
|
|
571
|
+
|
|
572
|
+
// Import all chains implemented in ParaSpell
|
|
573
|
+
import type { TChain } from "@paraspell/sdk-pjs"
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Import chains as constant
|
|
577
|
+
There are 6 options for constants you can choose based on your prefference
|
|
578
|
+
|
|
579
|
+
```ts
|
|
580
|
+
// Print all exchange chains (Swap)
|
|
581
|
+
console.log(EXCHANGE_CHAINS)
|
|
582
|
+
|
|
583
|
+
// Print all Parachains
|
|
584
|
+
console.log(PARACHAINS)
|
|
585
|
+
|
|
586
|
+
// Print all Relay chains
|
|
587
|
+
console.log(RELAYCHAINS)
|
|
588
|
+
|
|
589
|
+
// Print all Substrate chains (Parachains + Relays)
|
|
590
|
+
console.log(SUBSTRATE_CHAINS)
|
|
591
|
+
|
|
592
|
+
// Print chains outside Polkadot ecosystem (Ethereum)
|
|
593
|
+
console.log(EXTERNAL_CHAINS)
|
|
594
|
+
|
|
595
|
+
// Print all chains implemented in ParaSpell
|
|
596
|
+
console.log(CHAINS)
|
|
597
|
+
```
|
|
598
|
+
|
|
518
599
|
## 💻 Tests
|
|
519
600
|
- Run compilation using `pnpm compile`
|
|
520
601
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@snowbridge/contract-types": "^0.4.4",
|
|
29
29
|
"@snowbridge/registry": "^0.4.4",
|
|
30
30
|
"ethers": "^6.16.0",
|
|
31
|
-
"viem": "2.47.
|
|
32
|
-
"@paraspell/sdk-core": "
|
|
31
|
+
"viem": "^2.47.6",
|
|
32
|
+
"@paraspell/sdk-core": "13.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@polkadot/api": ">= 16.0 < 17",
|