@paraspell/sdk-dedot 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 +2 -2
package/README.md
CHANGED
|
@@ -197,9 +197,9 @@ const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..]
|
|
|
197
197
|
.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.
|
|
198
198
|
.swap({
|
|
199
199
|
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*/}
|
|
200
|
-
// exchange: ['
|
|
200
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
201
201
|
// slippage: 1, - Optional - 1 by default
|
|
202
|
-
//
|
|
202
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
203
203
|
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
204
204
|
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
205
205
|
})
|
|
@@ -220,7 +220,15 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
220
220
|
.from(TSubstrateChain)
|
|
221
221
|
.to(TChain)
|
|
222
222
|
.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*/}]})
|
|
223
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency
|
|
223
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.
|
|
224
|
+
.swap({
|
|
225
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
226
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
227
|
+
// slippage: 1, - Optional - 1 by default
|
|
228
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
229
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
230
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
231
|
+
})*/
|
|
224
232
|
.recipient(ADDRESS)
|
|
225
233
|
.sender(address | {address, DEDOT_Signer})
|
|
226
234
|
.dryRun()
|
|
@@ -269,23 +277,6 @@ const tx = await builder.buildBatch({
|
|
|
269
277
|
await builder.disconnect()
|
|
270
278
|
```
|
|
271
279
|
|
|
272
|
-
#### Asset claim:
|
|
273
|
-
|
|
274
|
-
```ts
|
|
275
|
-
//Claim XCM trapped assets from the selected chain
|
|
276
|
-
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
277
|
-
.claimfrom(TSubstrateChain)
|
|
278
|
-
.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}, ..]
|
|
279
|
-
)
|
|
280
|
-
.recipient(address | Location object)
|
|
281
|
-
/*.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.*/
|
|
282
|
-
|
|
283
|
-
const tx = await builder.build()
|
|
284
|
-
|
|
285
|
-
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
286
|
-
await builder.disconnect()
|
|
287
|
-
```
|
|
288
|
-
|
|
289
280
|
### Localhost test setup
|
|
290
281
|
|
|
291
282
|
```ts
|
|
@@ -323,7 +314,15 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
323
314
|
.from(TSubstrateChain)
|
|
324
315
|
.to(TChain)
|
|
325
316
|
.currency(CURRENCY_SPEC)
|
|
326
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
317
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
318
|
+
.swap({
|
|
319
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
320
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
321
|
+
// slippage: 1, - Optional - 1 by default
|
|
322
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
323
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
324
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
325
|
+
})*/
|
|
327
326
|
.recipient(RECIPIENT_ADDRESS)
|
|
328
327
|
.sender(address | {address, DEDOT_Signer})
|
|
329
328
|
.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.
|
|
@@ -360,7 +359,15 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
360
359
|
.from(TSubstrateChain)
|
|
361
360
|
.to(TChain)
|
|
362
361
|
.currency(CURRENCY_SPEC)
|
|
363
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
362
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
363
|
+
.swap({
|
|
364
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
365
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
366
|
+
// slippage: 1, - Optional - 1 by default
|
|
367
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
368
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
369
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
370
|
+
})*/
|
|
364
371
|
.recipient(RECIPIENT_ADDRESS)
|
|
365
372
|
.sender(address | {address, DEDOT_Signer})
|
|
366
373
|
.getTransferableAmount()
|
|
@@ -372,7 +379,15 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
372
379
|
.from(TSubstrateChain)
|
|
373
380
|
.to(TChain)
|
|
374
381
|
.currency(CURRENCY_SPEC)
|
|
375
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
382
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
383
|
+
.swap({
|
|
384
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
385
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
386
|
+
// slippage: 1, - Optional - 1 by default
|
|
387
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
388
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
389
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
390
|
+
})*/
|
|
376
391
|
.recipient(RECIPIENT_ADDRESS)
|
|
377
392
|
.sender(address | {address, DEDOT_Signer})
|
|
378
393
|
.getMinTransferableAmount()
|
|
@@ -402,6 +417,26 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
402
417
|
.verifyEdOnDestination()
|
|
403
418
|
```
|
|
404
419
|
|
|
420
|
+
#### Get best amount out
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
424
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
425
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
426
|
+
.currency(CURRENCY_SPEC)
|
|
427
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
428
|
+
.sender(SENDER_ADDRESS)
|
|
429
|
+
.swap({
|
|
430
|
+
currencyTo: CURRENCY_SPEC,
|
|
431
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
432
|
+
// slippage: 1, - Optional - 1 by default
|
|
433
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
434
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
435
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
436
|
+
})
|
|
437
|
+
.getBestAmountOut();
|
|
438
|
+
```
|
|
439
|
+
|
|
405
440
|
#### Asset balance
|
|
406
441
|
```ts
|
|
407
442
|
import { getBalance } from "@paraspell/sdk-dedot";
|
|
@@ -509,6 +544,52 @@ getOtherAssetsPallets(chain: TChain)
|
|
|
509
544
|
console.log(SUPPORTED_PALLETS)
|
|
510
545
|
```
|
|
511
546
|
|
|
547
|
+
### Import chains as types
|
|
548
|
+
There are 6 options for types you can choose based on your prefference
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
// Import all exchange chains (Swap)
|
|
552
|
+
import type { TExchangeChain } from "@paraspell/sdk-dedot"
|
|
553
|
+
|
|
554
|
+
// Import all Parachains
|
|
555
|
+
import type { TParachain } from "@paraspell/sdk-dedot"
|
|
556
|
+
|
|
557
|
+
// Import all Relay chains
|
|
558
|
+
import type { TRelaychain } from "@paraspell/sdk-dedot"
|
|
559
|
+
|
|
560
|
+
// Import all Substrate chains (Parachains + Relays)
|
|
561
|
+
import type { TSubstrateChain } from "@paraspell/sdk-dedot"
|
|
562
|
+
|
|
563
|
+
// Import chains outside Polkadot ecosystem (Ethereum)
|
|
564
|
+
import type { TExternalChain } from "@paraspell/sdk-dedot"
|
|
565
|
+
|
|
566
|
+
// Import all chains implemented in ParaSpell
|
|
567
|
+
import type { TChain } from "@paraspell/sdk-dedot"
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Import chains as constant
|
|
571
|
+
There are 6 options for constants you can choose based on your prefference
|
|
572
|
+
|
|
573
|
+
```ts
|
|
574
|
+
// Print all exchange chains (Swap)
|
|
575
|
+
console.log(EXCHANGE_CHAINS)
|
|
576
|
+
|
|
577
|
+
// Print all Parachains
|
|
578
|
+
console.log(PARACHAINS)
|
|
579
|
+
|
|
580
|
+
// Print all Relay chains
|
|
581
|
+
console.log(RELAYCHAINS)
|
|
582
|
+
|
|
583
|
+
// Print all Substrate chains (Parachains + Relays)
|
|
584
|
+
console.log(SUBSTRATE_CHAINS)
|
|
585
|
+
|
|
586
|
+
// Print chains outside Polkadot ecosystem (Ethereum)
|
|
587
|
+
console.log(EXTERNAL_CHAINS)
|
|
588
|
+
|
|
589
|
+
// Print all chains implemented in ParaSpell
|
|
590
|
+
console.log(CHAINS)
|
|
591
|
+
```
|
|
592
|
+
|
|
512
593
|
## 💻 Tests
|
|
513
594
|
- Run compilation using `pnpm compile`
|
|
514
595
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-dedot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Dedot-based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@paraspell/sdk-core": "
|
|
26
|
+
"@paraspell/sdk-core": "13.0.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"dedot": ">= 1.2.0",
|