@paraspell/sdk 8.16.0 → 9.1.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 +74 -75
- package/dist/index.cjs +3 -4
- package/dist/index.mjs +3 -4
- package/package.json +2 -2
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
280
|
-
await
|
|
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
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
294
|
-
await
|
|
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
|
-
|
|
298
|
-
|
|
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
|
-
|
|
336
|
+
### Existential deposit queries
|
|
337
|
+
```ts
|
|
338
|
+
import { getExistentialDeposit } from "@paraspell/sdk";
|
|
308
339
|
|
|
309
|
-
//
|
|
310
|
-
|
|
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,45 +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
|
-
### Convert SS58 address
|
|
386
|
-
```ts
|
|
387
|
-
import { convertSs58 } from "@paraspell/sdk";
|
|
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";
|
|
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
414
|
## 💻 Tests
|
|
416
415
|
- Run compilation using `pnpm compile`
|
|
417
416
|
|
package/dist/index.cjs
CHANGED
|
@@ -1437,7 +1437,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1437
1437
|
value: function () {
|
|
1438
1438
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
1439
1439
|
var _this$api$getUnsafeAp;
|
|
1440
|
-
var tx, address, node, supportsDryRunApi,
|
|
1440
|
+
var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1441
1441
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1442
1442
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1443
1443
|
case 0:
|
|
@@ -1449,8 +1449,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
1451
1451
|
case 4:
|
|
1452
|
-
|
|
1453
|
-
isBifrost = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama';
|
|
1452
|
+
needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama';
|
|
1454
1453
|
DEFAULT_XCM_VERSION = 3;
|
|
1455
1454
|
_context17.next = 8;
|
|
1456
1455
|
return (_this$api$getUnsafeAp = this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, [{
|
|
@@ -1459,7 +1458,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1459
1458
|
type: 'Signed',
|
|
1460
1459
|
value: address
|
|
1461
1460
|
}
|
|
1462
|
-
}, tx.decodedCall].concat(_toConsumableArray(
|
|
1461
|
+
}, tx.decodedCall].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
|
|
1463
1462
|
case 8:
|
|
1464
1463
|
result = _context17.sent;
|
|
1465
1464
|
isSuccess = result.success && result.value.execution_result.success;
|
package/dist/index.mjs
CHANGED
|
@@ -1436,7 +1436,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1436
1436
|
value: function () {
|
|
1437
1437
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
1438
1438
|
var _this$api$getUnsafeAp;
|
|
1439
|
-
var tx, address, node, supportsDryRunApi,
|
|
1439
|
+
var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1440
1440
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1441
1441
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1442
1442
|
case 0:
|
|
@@ -1448,8 +1448,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1448
1448
|
}
|
|
1449
1449
|
throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
1450
1450
|
case 4:
|
|
1451
|
-
|
|
1452
|
-
isBifrost = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama';
|
|
1451
|
+
needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama';
|
|
1453
1452
|
DEFAULT_XCM_VERSION = 3;
|
|
1454
1453
|
_context17.next = 8;
|
|
1455
1454
|
return (_this$api$getUnsafeAp = this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, [{
|
|
@@ -1458,7 +1457,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1458
1457
|
type: 'Signed',
|
|
1459
1458
|
value: address
|
|
1460
1459
|
}
|
|
1461
|
-
}, tx.decodedCall].concat(_toConsumableArray(
|
|
1460
|
+
}, tx.decodedCall].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
|
|
1462
1461
|
case 8:
|
|
1463
1462
|
result = _context17.sent;
|
|
1464
1463
|
isSuccess = result.success && result.value.execution_result.success;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.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": "
|
|
30
|
+
"@paraspell/sdk-core": "9.1.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"polkadot-api": ">= 1.10.2 < 2"
|