@paraspell/sdk-pjs 10.11.10 → 11.0.1
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 +105 -119
- package/dist/index.cjs +96 -106
- package/dist/index.d.ts +28 -28
- package/dist/index.mjs +97 -107
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -72,11 +72,13 @@ NOTES:
|
|
|
72
72
|
- Local transfers are now available for every currency and every chain. To try them, simply use the same origin and destination parameters.
|
|
73
73
|
- Transfer info queries are now all in the Builder pattern and don't require any imports other than the builder.
|
|
74
74
|
- You can now query Ethereum asset balances on Ethereum via balance query
|
|
75
|
+
- The Builder() now accepts an optional configuration object (To enhance localhost experience and testing). This object can contain apiOverrides and a development flag. More information in the "Localhost test setup" section.
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
```
|
|
78
79
|
Latest news:
|
|
79
|
-
-
|
|
80
|
+
- V10 > V11 Migration guide https://paraspell.github.io/docs/migration/v10-to-v11.html
|
|
81
|
+
- Brand new asset decimal abstraction introduced. It can be turned on in Builder config. Will be turned on by default in next major release.
|
|
80
82
|
```
|
|
81
83
|
|
|
82
84
|
### Sending XCM
|
|
@@ -85,20 +87,20 @@ For full documentation with examples on this feature head over to [official docu
|
|
|
85
87
|
|
|
86
88
|
#### Transfer assets from Parachain to Parachain
|
|
87
89
|
```ts
|
|
88
|
-
const builder = Builder(/*
|
|
89
|
-
.from(
|
|
90
|
-
.to(
|
|
91
|
-
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {
|
|
92
|
-
.address(address |
|
|
90
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
91
|
+
.from(CHAIN)
|
|
92
|
+
.to(CHAIN /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
|
|
93
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | {location: Override('Custom Location'), amount: amount} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount}, {currencySelection}, ..])
|
|
94
|
+
.address(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
|
|
93
95
|
.senderAddress(address) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
94
|
-
/*.ahAddress(ahAddress) - OPTIONAL - used when origin is EVM
|
|
95
|
-
.feeAsset({symbol: 'symbol'} || {id: 'id'} || {
|
|
96
|
-
.xcmVersion(Version.
|
|
97
|
-
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some
|
|
96
|
+
/*.ahAddress(ahAddress) - OPTIONAL - used when origin is EVM chain and XCM goes through AssetHub (Multihop transfer where we are unable to convert Key20 to ID32 address eg. origin: Moonbeam & destination: Ethereum (Multihop goes from Moonbeam > AssetHub > BridgeHub > Ethereum)
|
|
97
|
+
.feeAsset({symbol: 'symbol'} || {id: 'id'} || {location: 'location'}) // Optional parameter used when multiasset is provided or when origin is AssetHub - so user can pay in fees different than DOT
|
|
98
|
+
.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
99
|
+
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
98
100
|
|
|
99
101
|
const tx = await builder.build()
|
|
100
102
|
|
|
101
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
103
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
102
104
|
await builder.disconnect()
|
|
103
105
|
|
|
104
106
|
/*
|
|
@@ -118,19 +120,20 @@ const tx = await builder.build()
|
|
|
118
120
|
await builder.disconnect()
|
|
119
121
|
*/
|
|
120
122
|
```
|
|
121
|
-
|
|
123
|
+
|
|
124
|
+
#### Transfer assets from the Relay chain to the Parachain
|
|
122
125
|
```ts
|
|
123
|
-
const builder = Builder(/*
|
|
124
|
-
.from(
|
|
125
|
-
.to(
|
|
126
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
127
|
+
.from(RELAY_CHAIN) // Kusama | Polkadot | Westend | Paseo
|
|
128
|
+
.to(CHAIN/*,customParaId - optional*/ | Location object)
|
|
126
129
|
.currency({symbol: 'DOT', amount: amount})
|
|
127
|
-
.address(address |
|
|
128
|
-
/*.xcmVersion(Version.
|
|
129
|
-
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some
|
|
130
|
+
.address(address | Location object)
|
|
131
|
+
/*.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
132
|
+
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
130
133
|
|
|
131
134
|
const tx = await builder.build()
|
|
132
135
|
|
|
133
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
136
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
134
137
|
await builder.disconnect()
|
|
135
138
|
|
|
136
139
|
/*
|
|
@@ -150,19 +153,20 @@ const tx = await builder.build()
|
|
|
150
153
|
await builder.disconnect()
|
|
151
154
|
*/
|
|
152
155
|
```
|
|
156
|
+
|
|
153
157
|
#### Transfer assets from Parachain to Relay chain
|
|
154
158
|
```ts
|
|
155
|
-
const builder = Builder(/*
|
|
156
|
-
.from(
|
|
157
|
-
.to(
|
|
159
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
160
|
+
.from(CHAIN)
|
|
161
|
+
.to(RELAY_CHAIN) // Kusama | Polkadot | Westend | Paseo
|
|
158
162
|
.currency({symbol: 'DOT', amount: amount})
|
|
159
|
-
.address(address |
|
|
160
|
-
/*.xcmVersion(Version.
|
|
161
|
-
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some
|
|
163
|
+
.address(address | Location object)
|
|
164
|
+
/*.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
165
|
+
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
162
166
|
|
|
163
167
|
const tx = await builder.build()
|
|
164
168
|
|
|
165
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
169
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
166
170
|
await builder.disconnect()
|
|
167
171
|
|
|
168
172
|
/*
|
|
@@ -185,15 +189,15 @@ await builder.disconnect()
|
|
|
185
189
|
|
|
186
190
|
#### Local transfers
|
|
187
191
|
```ts
|
|
188
|
-
const builder = Builder(/*
|
|
189
|
-
.from(
|
|
190
|
-
.to(
|
|
191
|
-
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {
|
|
192
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
193
|
+
.from(CHAIN)
|
|
194
|
+
.to(CHAIN) //Has to be the same as the origin (from)
|
|
195
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | {location: Override('Custom Location'), amount: amount} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount}, {currencySelection}, ..])
|
|
192
196
|
.address(address)
|
|
193
197
|
|
|
194
198
|
const tx = await builder.build()
|
|
195
199
|
|
|
196
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
200
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
197
201
|
await builder.disconnect()
|
|
198
202
|
|
|
199
203
|
/*
|
|
@@ -216,17 +220,17 @@ await builder.disconnect()
|
|
|
216
220
|
|
|
217
221
|
#### Batch calls
|
|
218
222
|
```ts
|
|
219
|
-
const builder = Builder(/*
|
|
220
|
-
.from(
|
|
221
|
-
.to(
|
|
223
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
224
|
+
.from(CHAIN) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
225
|
+
.to(CHAIN_2) //Any compatible Parachain
|
|
222
226
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
223
|
-
.address(address |
|
|
227
|
+
.address(address | Location object)
|
|
224
228
|
.addToBatch()
|
|
225
229
|
|
|
226
|
-
.from(
|
|
227
|
-
.to(
|
|
230
|
+
.from(CHAIN) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
231
|
+
.to(CHAIN_3) //Any compatible Parachain
|
|
228
232
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
229
|
-
.address(address |
|
|
233
|
+
.address(address | Location object)
|
|
230
234
|
.addToBatch()
|
|
231
235
|
|
|
232
236
|
const tx = await builder.buildBatch({
|
|
@@ -234,41 +238,42 @@ const tx = await builder.buildBatch({
|
|
|
234
238
|
mode: BatchMode.BATCH_ALL //or BatchMode.BATCH
|
|
235
239
|
})
|
|
236
240
|
|
|
237
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
241
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
238
242
|
await builder.disconnect()
|
|
239
243
|
```
|
|
240
244
|
|
|
241
245
|
#### Asset claim:
|
|
242
246
|
```ts
|
|
243
247
|
//Claim XCM trapped assets from the selected chain
|
|
244
|
-
const builder = Builder(/*
|
|
245
|
-
.claimFrom(
|
|
246
|
-
.
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
249
|
+
.claimFrom(CHAIN)
|
|
250
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount}, {currencySelection}, ..]
|
|
251
|
+
)
|
|
252
|
+
.address(address | Location object)
|
|
253
|
+
/*.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.*/
|
|
249
254
|
|
|
250
255
|
const tx = await builder.build()
|
|
251
256
|
|
|
252
|
-
//Make sure to disconnect API after it is no longer used (eg
|
|
257
|
+
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
253
258
|
await builder.disconnect()
|
|
254
259
|
```
|
|
255
260
|
|
|
256
261
|
#### Dry run your XCM Calls:
|
|
257
262
|
```ts
|
|
258
263
|
//Builder pattern
|
|
259
|
-
const result = await Builder(
|
|
260
|
-
.from(
|
|
261
|
-
.to(
|
|
262
|
-
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {
|
|
264
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
265
|
+
.from(CHAIN)
|
|
266
|
+
.to(CHAIN_2)
|
|
267
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | {location: Override('Custom Location'), amount: amount} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount}]})
|
|
263
268
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
264
269
|
.address(ADDRESS)
|
|
265
270
|
.senderAddress(SENDER_ADDRESS)
|
|
266
271
|
.dryRun()
|
|
267
272
|
|
|
268
273
|
//Check Parachain for DryRun support - returns true/false
|
|
269
|
-
import { hasDryRunSupport } from "@paraspell/sdk
|
|
274
|
+
import { hasDryRunSupport } from "@paraspell/sdk";
|
|
270
275
|
|
|
271
|
-
const result = hasDryRunSupport(
|
|
276
|
+
const result = hasDryRunSupport(chain)
|
|
272
277
|
```
|
|
273
278
|
|
|
274
279
|
### Localhost test setup
|
|
@@ -278,6 +283,7 @@ SDK offers enhanced localhost support. You can pass an object containing overrid
|
|
|
278
283
|
```ts
|
|
279
284
|
const builder = await Builder({
|
|
280
285
|
development: true, // Optional: Enforces overrides for all chains used
|
|
286
|
+
decimalAbstraction: true //Abstracts decimals, so 1 as input amount equals 10_000_000_000 if selected asset is DOT.
|
|
281
287
|
apiOverrides: {
|
|
282
288
|
Hydration: // "wsEndpointString" | papiClient
|
|
283
289
|
BridgeHubPolkadot: // "wsEndpointString" | papiClient
|
|
@@ -286,7 +292,7 @@ const builder = await Builder({
|
|
|
286
292
|
})
|
|
287
293
|
.from(CHAIN)
|
|
288
294
|
.to(CHAIN)
|
|
289
|
-
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {
|
|
295
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | {location: Override('Custom Location'), amount: amount} | [{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount}])
|
|
290
296
|
.address(address)
|
|
291
297
|
|
|
292
298
|
const tx = await builder.build()
|
|
@@ -297,15 +303,15 @@ await builder.disconnect()
|
|
|
297
303
|
|
|
298
304
|
### XCM Fee queries
|
|
299
305
|
|
|
300
|
-
For full documentation with examples on this feature head
|
|
306
|
+
For full documentation with examples on this feature, head to [official documentation](https://paraspell.github.io/docs/sdk/xcmUtils.html).
|
|
301
307
|
|
|
302
308
|
#### XCM Transfer info
|
|
303
309
|
```ts
|
|
304
|
-
const info = await Builder(/*
|
|
310
|
+
const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
305
311
|
.from(ORIGIN_CHAIN)
|
|
306
312
|
.to(DESTINATION_CHAIN)
|
|
307
313
|
.currency(CURRENCY)
|
|
308
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
314
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
309
315
|
.address(RECIPIENT_ADDRESS)
|
|
310
316
|
.senderAddress(SENDER_ADDRESS)
|
|
311
317
|
.getTransferInfo()
|
|
@@ -313,11 +319,11 @@ const info = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
313
319
|
|
|
314
320
|
#### Transferable amount
|
|
315
321
|
```ts
|
|
316
|
-
const transferable = await Builder(/*
|
|
322
|
+
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
317
323
|
.from(ORIGIN_CHAIN)
|
|
318
324
|
.to(DESTINATION_CHAIN)
|
|
319
325
|
.currency(CURRENCY)
|
|
320
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
326
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
321
327
|
.address(RECIPIENT_ADDRESS)
|
|
322
328
|
.senderAddress(SENDER_ADDRESS)
|
|
323
329
|
.getTransferableAmount()
|
|
@@ -325,11 +331,11 @@ const transferable = await Builder(/*node api/ws_url_string/ws_url_array - optio
|
|
|
325
331
|
|
|
326
332
|
#### Verify ED on destination
|
|
327
333
|
```ts
|
|
328
|
-
const ed = await Builder(/*
|
|
334
|
+
const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
329
335
|
.from(ORIGIN_CHAIN)
|
|
330
336
|
.to(DESTINATION_CHAIN)
|
|
331
337
|
.currency(CURRENCY)
|
|
332
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
338
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
333
339
|
.address(RECIPIENT_ADDRESS)
|
|
334
340
|
.senderAddress(SENDER_ADDRESS)
|
|
335
341
|
.verifyEdOnDestination()
|
|
@@ -339,19 +345,19 @@ const ed = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
339
345
|
|
|
340
346
|
##### More accurate query using DryRun
|
|
341
347
|
```ts
|
|
342
|
-
const fee = await Builder(/*
|
|
348
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
343
349
|
.from(ORIGIN_CHAIN)
|
|
344
350
|
.to(DESTINATION_CHAIN)
|
|
345
351
|
.currency(CURRENCY)
|
|
346
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
352
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
347
353
|
.address(RECIPIENT_ADDRESS)
|
|
348
354
|
.senderAddress(SENDER_ADDRESS)
|
|
349
|
-
.getXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of 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.
|
|
355
|
+
.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.
|
|
350
356
|
```
|
|
351
357
|
|
|
352
358
|
##### Less accurate query using Payment info
|
|
353
359
|
```ts
|
|
354
|
-
const fee = await Builder(/*
|
|
360
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
355
361
|
.from(ORIGIN_CHAIN)
|
|
356
362
|
.to(DESTINATION_CHAIN)
|
|
357
363
|
.currency(CURRENCY)
|
|
@@ -364,19 +370,19 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
364
370
|
|
|
365
371
|
##### More accurate query using DryRun
|
|
366
372
|
```ts
|
|
367
|
-
const fee = await Builder(/*
|
|
373
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
368
374
|
.from(ORIGIN_CHAIN)
|
|
369
375
|
.to(DESTINATION_CHAIN)
|
|
370
376
|
.currency(CURRENCY)
|
|
371
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
377
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
372
378
|
.address(RECIPIENT_ADDRESS)
|
|
373
379
|
.senderAddress(SENDER_ADDRESS)
|
|
374
|
-
.getOriginXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin do not support DryRun out of the box.
|
|
380
|
+
.getOriginXcmFee(/*{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 do not support DryRun out of the box.
|
|
375
381
|
```
|
|
376
382
|
|
|
377
383
|
##### Less accurate query using Payment info
|
|
378
384
|
```ts
|
|
379
|
-
const fee = await Builder(/*
|
|
385
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
380
386
|
.from(ORIGIN_CHAIN)
|
|
381
387
|
.to(DESTINATION_CHAIN)
|
|
382
388
|
.currency(CURRENCY)
|
|
@@ -389,8 +395,8 @@ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
389
395
|
```ts
|
|
390
396
|
import { getAssetBalance } from "@paraspell/sdk-pjs";
|
|
391
397
|
|
|
392
|
-
//Retrieves the asset balance for a given account on a specified
|
|
393
|
-
const balance = await getAssetBalance({address,
|
|
398
|
+
//Retrieves the asset balance for a given account on a specified chain (You do not need to specify if it is native or foreign).
|
|
399
|
+
const balance = await getAssetBalance({address, chain, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {location: AssetLocationString | AssetLocationJson}*/, api /* api/ws_url_string optional */});
|
|
394
400
|
```
|
|
395
401
|
|
|
396
402
|
#### Ethereum bridge fees
|
|
@@ -405,15 +411,15 @@ const fees = await getParaEthTransferFees(/*api - optional (Can also be WS port
|
|
|
405
411
|
import { getExistentialDeposit } from "@paraspell/sdk-pjs";
|
|
406
412
|
|
|
407
413
|
//Currency is an optional parameter. If you wish to query native asset, currency parameter is not necessary.
|
|
408
|
-
//Currency can be either {symbol: assetSymbol}, {id: assetId}, {
|
|
409
|
-
const ed = getExistentialDeposit(
|
|
414
|
+
//Currency can be either {symbol: assetSymbol}, {id: assetId}, {location: assetLocation}.
|
|
415
|
+
const ed = getExistentialDeposit(chain, currency?)
|
|
410
416
|
```
|
|
411
417
|
|
|
412
418
|
#### Convert SS58 address
|
|
413
419
|
```ts
|
|
414
420
|
import { convertSs58 } from "@paraspell/sdk-pjs";
|
|
415
421
|
|
|
416
|
-
let result = convertSs58(address,
|
|
422
|
+
let result = convertSs58(address, chain) // returns converted address in string
|
|
417
423
|
```
|
|
418
424
|
|
|
419
425
|
### Asset queries:
|
|
@@ -421,69 +427,49 @@ let result = convertSs58(address, node) // returns converted address in string
|
|
|
421
427
|
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
422
428
|
|
|
423
429
|
```ts
|
|
424
|
-
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId,
|
|
430
|
+
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, CHAINS } from '@paraspell/sdk-pjs'
|
|
425
431
|
|
|
426
432
|
//Get chains that support the specific asset related to origin
|
|
427
|
-
getSupportedDestinations(
|
|
433
|
+
getSupportedDestinations(CHAIN, CURRENCY)
|
|
428
434
|
|
|
429
|
-
// Retrieve Fee asset queries (Assets accepted as XCM Fee on specific
|
|
430
|
-
getFeeAssets(
|
|
435
|
+
// Retrieve Fee asset queries (Assets accepted as XCM Fee on specific chain)
|
|
436
|
+
getFeeAssets(CHAIN)
|
|
431
437
|
|
|
432
|
-
// Get
|
|
433
|
-
|
|
438
|
+
// Get Location for asset ID or symbol on a specific chain
|
|
439
|
+
getAssetLocation(CHAIN, { symbol: symbol } | { id: assetId })
|
|
434
440
|
|
|
435
|
-
// Retrieve assets object from assets.json for particular
|
|
436
|
-
getAssetsObject(
|
|
441
|
+
// Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
|
|
442
|
+
getAssetsObject(CHAIN)
|
|
437
443
|
|
|
438
|
-
// Retrieve foreign assetId for a particular
|
|
439
|
-
getAssetId(
|
|
444
|
+
// Retrieve foreign assetId for a particular chain and asset symbol
|
|
445
|
+
getAssetId(CHAIN, ASSET_SYMBOL)
|
|
440
446
|
|
|
441
|
-
// Retrieve the symbol of the relay chain for a particular
|
|
442
|
-
getRelayChainSymbol(
|
|
447
|
+
// Retrieve the symbol of the relay chain for a particular chain. Either "DOT" or "KSM"
|
|
448
|
+
getRelayChainSymbol(CHAIN)
|
|
443
449
|
|
|
444
|
-
// Retrieve string array of native assets symbols for particular
|
|
445
|
-
getNativeAssets(
|
|
450
|
+
// Retrieve string array of native assets symbols for a particular chain
|
|
451
|
+
getNativeAssets(CHAIN)
|
|
446
452
|
|
|
447
|
-
// Retrieve object array of foreign assets for a particular
|
|
448
|
-
getOtherAssets(
|
|
453
|
+
// Retrieve object array of foreign assets for a particular chain. Each object has a symbol and an assetId property
|
|
454
|
+
getOtherAssets(CHAIN)
|
|
449
455
|
|
|
450
|
-
// Retrieve string array of all
|
|
451
|
-
getAllAssetsSymbols(
|
|
456
|
+
// Retrieve string array of all asset symbols. (native and foreign assets are merged into a single array)
|
|
457
|
+
getAllAssetsSymbols(CHAIN)
|
|
452
458
|
|
|
453
|
-
// Check if a
|
|
454
|
-
hasSupportForAsset(
|
|
459
|
+
// Check if a chain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
460
|
+
hasSupportForAsset(CHAIN, ASSET_SYMBOL)
|
|
455
461
|
|
|
456
462
|
// Get decimals for specific asset
|
|
457
|
-
getAssetDecimals(
|
|
458
|
-
|
|
459
|
-
// Get specific node id
|
|
460
|
-
getParaId(NODE)
|
|
461
|
-
|
|
462
|
-
// Get specific TNode from nodeID
|
|
463
|
-
getTNode(paraID: number, ecosystem: 'polkadot' || 'kusama' || 'ethereum') //When Ethereum ecosystem is selected please fill nodeID as 1 to select Ethereum.
|
|
464
|
-
|
|
465
|
-
// Import all compatible nodes as constant
|
|
466
|
-
NODE_NAMES
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### Parachain XCM Pallet queries
|
|
470
|
-
|
|
471
|
-
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/NodePallets.html).
|
|
472
|
-
|
|
473
|
-
```ts
|
|
474
|
-
import { getDefaultPallet, getSupportedPallets, getPalletIndex SUPPORTED_PALLETS } from '@paraspell/sdk-pjs';
|
|
475
|
-
|
|
476
|
-
//Retrieve default pallet for specific Parachain
|
|
477
|
-
getDefaultPallet(NODE)
|
|
463
|
+
getAssetDecimals(CHAIN, ASSET_SYMBOL)
|
|
478
464
|
|
|
479
|
-
//
|
|
480
|
-
|
|
465
|
+
// Get specific chain id
|
|
466
|
+
getParaId(CHAIN)
|
|
481
467
|
|
|
482
|
-
//
|
|
483
|
-
|
|
468
|
+
// Get specific TChain from chainID
|
|
469
|
+
getTChain(paraID: number, ecosystem: 'Polkadot' | 'Kusama' | 'Ethereum' | 'Paseo' | 'Westend') //When the Ethereum ecosystem is selected, please fill chainID as 1 to select Ethereum.
|
|
484
470
|
|
|
485
|
-
//
|
|
486
|
-
|
|
471
|
+
// Import all compatible chains as constant
|
|
472
|
+
CHAINS
|
|
487
473
|
```
|
|
488
474
|
|
|
489
475
|
## 💻 Tests
|