@paraspell/sdk 9.2.2 → 10.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 +113 -66
- package/dist/index.cjs +27 -34
- package/dist/index.d.ts +12 -38
- package/dist/index.mjs +28 -30
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -48,13 +48,13 @@ pnpm | npm install || yarn add @paraspell/sdk
|
|
|
48
48
|
### Importing package to your project
|
|
49
49
|
|
|
50
50
|
Builder pattern:
|
|
51
|
-
```
|
|
51
|
+
```ts
|
|
52
52
|
// Polkadot API version
|
|
53
53
|
import { Builder } from '@paraspell/sdk'
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Other patterns:
|
|
57
|
-
```
|
|
57
|
+
```ts
|
|
58
58
|
// ESM
|
|
59
59
|
import * as paraspell from '@paraspell/sdk'
|
|
60
60
|
|
|
@@ -63,29 +63,26 @@ const paraspell = require('@paraspell/sdk')
|
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
Interaction with further asset symbol abstraction:
|
|
66
|
-
```
|
|
66
|
+
```ts
|
|
67
67
|
import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk'; //Only needed when advanced asset symbol selection is used.
|
|
68
68
|
```
|
|
69
69
|
## Implementation
|
|
70
70
|
|
|
71
71
|
```
|
|
72
72
|
NOTES:
|
|
73
|
-
-
|
|
74
|
-
- You can now query foreign asset minimal deposits also.
|
|
75
|
-
- Since v8, amount moved closer to currency selection and specifying from and to parameters is no longer optional to save code.
|
|
76
|
-
- More information on v8 major breaking change: https://github.com/paraspell/xcm-tools/pull/554
|
|
77
|
-
- XCM SDK Now supports API Failsafe - If one endpoint doesn't work it automatically switches to the next one.
|
|
78
|
-
- Builder now allows you to directly disconnect API.
|
|
73
|
+
- Local transfers are now available for every currency and every chain. To try them, simply use same origin and destination parameters.
|
|
79
74
|
```
|
|
80
75
|
|
|
81
76
|
```
|
|
82
77
|
Latest news:
|
|
83
|
-
-
|
|
78
|
+
- Transfer info queries are now all in Builder pattern and don't require any imports other than builder.
|
|
84
79
|
```
|
|
85
80
|
|
|
86
|
-
###
|
|
81
|
+
### Sending XCM:
|
|
87
82
|
|
|
88
|
-
|
|
83
|
+
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html).
|
|
84
|
+
|
|
85
|
+
#### Transfer assets from Parachain to Parachain
|
|
89
86
|
```ts
|
|
90
87
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
91
88
|
.from(NODE)
|
|
@@ -120,7 +117,7 @@ const tx = await builder.build()
|
|
|
120
117
|
await builder.disconnect()
|
|
121
118
|
*/
|
|
122
119
|
```
|
|
123
|
-
|
|
120
|
+
#### Transfer assets from the Relay chain to Parachain
|
|
124
121
|
```ts
|
|
125
122
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
126
123
|
.from(RELAY_NODE) //Kusama or Polkadot
|
|
@@ -152,7 +149,7 @@ const tx = await builder.build()
|
|
|
152
149
|
await builder.disconnect()
|
|
153
150
|
*/
|
|
154
151
|
```
|
|
155
|
-
|
|
152
|
+
#### Transfer assets from Parachain to Relay chain
|
|
156
153
|
```ts
|
|
157
154
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
158
155
|
.from(NODE)
|
|
@@ -185,7 +182,7 @@ await builder.disconnect()
|
|
|
185
182
|
*/
|
|
186
183
|
```
|
|
187
184
|
|
|
188
|
-
|
|
185
|
+
#### Local transfers
|
|
189
186
|
```ts
|
|
190
187
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
191
188
|
.from(NODE)
|
|
@@ -216,9 +213,8 @@ await builder.disconnect()
|
|
|
216
213
|
*/
|
|
217
214
|
```
|
|
218
215
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
```js
|
|
216
|
+
#### Batch calls
|
|
217
|
+
```ts
|
|
222
218
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
223
219
|
.from(NODE) //Ensure, that origin node is the same in all batched XCM Calls.
|
|
224
220
|
.to(NODE_2) //Any compatible Parachain
|
|
@@ -241,7 +237,7 @@ const tx = await builder.buildBatch({
|
|
|
241
237
|
await builder.disconnect()
|
|
242
238
|
```
|
|
243
239
|
|
|
244
|
-
|
|
240
|
+
#### Asset claim:
|
|
245
241
|
```ts
|
|
246
242
|
//Claim XCM trapped assets from the selected chain
|
|
247
243
|
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
@@ -256,13 +252,14 @@ const tx = await builder.build()
|
|
|
256
252
|
await builder.disconnect()
|
|
257
253
|
```
|
|
258
254
|
|
|
259
|
-
|
|
255
|
+
#### Dry run your XCM Calls:
|
|
260
256
|
```ts
|
|
261
257
|
//Builder pattern
|
|
262
258
|
const result = await Builder(API /*optional*/)
|
|
263
259
|
.from(NODE)
|
|
264
260
|
.to(NODE_2)
|
|
265
261
|
.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}})
|
|
262
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
266
263
|
.address(ADDRESS)
|
|
267
264
|
.senderAddress(SENDER_ADDRESS)
|
|
268
265
|
.dryRun()
|
|
@@ -273,67 +270,112 @@ import { hasDryRunSupport } from "@paraspell/sdk-pjs";
|
|
|
273
270
|
const result = hasDryRunSupport(node)
|
|
274
271
|
```
|
|
275
272
|
|
|
276
|
-
### XCM Fee
|
|
277
|
-
Following queries allow you to query fee from both Origin and Destination of the XCM Message. You can get accurate result from DryRun query(Requires token balance) or less accurate from Payment info query (Doesn't require token balance).
|
|
273
|
+
### XCM Fee queries
|
|
278
274
|
|
|
279
|
-
|
|
280
|
-
The query is designed to retrieve you XCM fee at any cost, but fallbacking to Payment info if DryRun query fails or is not supported by either origin or destination. This query requires user to have token balance (Token that they are sending and origin native asset to pay for execution fees on origin).
|
|
275
|
+
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmUtils.html).
|
|
281
276
|
|
|
277
|
+
#### XCM Transfer info
|
|
278
|
+
```ts
|
|
279
|
+
const info = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
280
|
+
.from(ORIGIN_CHAIN)
|
|
281
|
+
.to(DESTINATION_CHAIN)
|
|
282
|
+
.currency(CURRENCY)
|
|
283
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
284
|
+
.address(RECIPIENT_ADDRESS)
|
|
285
|
+
.senderAddress(SENDER_ADDRESS)
|
|
286
|
+
.getTransferInfo()
|
|
282
287
|
```
|
|
283
|
-
|
|
288
|
+
|
|
289
|
+
#### Transferable amount
|
|
290
|
+
```ts
|
|
291
|
+
const transferable = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
292
|
+
.from(ORIGIN_CHAIN)
|
|
293
|
+
.to(DESTINATION_CHAIN)
|
|
294
|
+
.currency(CURRENCY)
|
|
295
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
296
|
+
.address(RECIPIENT_ADDRESS)
|
|
297
|
+
.senderAddress(SENDER_ADDRESS)
|
|
298
|
+
.getTransferableAmount()
|
|
284
299
|
```
|
|
285
300
|
|
|
301
|
+
#### Verify ED on destination
|
|
286
302
|
```ts
|
|
287
|
-
const
|
|
303
|
+
const ed = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
288
304
|
.from(ORIGIN_CHAIN)
|
|
289
305
|
.to(DESTINATION_CHAIN)
|
|
290
306
|
.currency(CURRENCY)
|
|
307
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
291
308
|
.address(RECIPIENT_ADDRESS)
|
|
292
309
|
.senderAddress(SENDER_ADDRESS)
|
|
293
|
-
.
|
|
310
|
+
.verifyEdOnDestination()
|
|
294
311
|
```
|
|
295
312
|
|
|
296
|
-
####
|
|
297
|
-
This query is designed to retrieve you approximate fee and doesn't require any token balance.
|
|
313
|
+
#### XCM Fee (Origin and Dest.)
|
|
298
314
|
|
|
299
|
-
|
|
300
|
-
|
|
315
|
+
##### More accurate query using DryRun
|
|
316
|
+
```ts
|
|
317
|
+
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
318
|
+
.from(ORIGIN_CHAIN)
|
|
319
|
+
.to(DESTINATION_CHAIN)
|
|
320
|
+
.currency(CURRENCY)
|
|
321
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
322
|
+
.address(RECIPIENT_ADDRESS)
|
|
323
|
+
.senderAddress(SENDER_ADDRESS)
|
|
324
|
+
.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.
|
|
301
325
|
```
|
|
302
326
|
|
|
327
|
+
##### Less accurate query using Payment info
|
|
303
328
|
```ts
|
|
304
329
|
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
305
330
|
.from(ORIGIN_CHAIN)
|
|
306
331
|
.to(DESTINATION_CHAIN)
|
|
307
332
|
.currency(CURRENCY)
|
|
308
333
|
.address(RECIPIENT_ADDRESS)
|
|
309
|
-
.senderAddress(SENDER_ADDRESS)
|
|
334
|
+
.senderAddress(SENDER_ADDRESS)
|
|
310
335
|
.getXcmFeeEstimate()
|
|
311
336
|
```
|
|
312
337
|
|
|
313
|
-
|
|
314
|
-
```ts
|
|
315
|
-
import { getAssetBalance, getTransferInfo, getOriginFeeDetails, getTransferableAmount, getParaEthTransferFees, verifyEdOnDestination } from "@paraspell/sdk";
|
|
338
|
+
#### XCM Fee (Origin only)
|
|
316
339
|
|
|
317
|
-
|
|
318
|
-
|
|
340
|
+
##### More accurate query using DryRun
|
|
341
|
+
```ts
|
|
342
|
+
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
343
|
+
.from(ORIGIN_CHAIN)
|
|
344
|
+
.to(DESTINATION_CHAIN)
|
|
345
|
+
.currency(CURRENCY)
|
|
346
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
347
|
+
.address(RECIPIENT_ADDRESS)
|
|
348
|
+
.senderAddress(SENDER_ADDRESS)
|
|
349
|
+
.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.
|
|
350
|
+
```
|
|
319
351
|
|
|
320
|
-
|
|
321
|
-
|
|
352
|
+
##### Less accurate query using Payment info
|
|
353
|
+
```ts
|
|
354
|
+
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
355
|
+
.from(ORIGIN_CHAIN)
|
|
356
|
+
.to(DESTINATION_CHAIN)
|
|
357
|
+
.currency(CURRENCY)
|
|
358
|
+
.address(RECIPIENT_ADDRESS)
|
|
359
|
+
.senderAddress(SENDER_ADDRESS)
|
|
360
|
+
.getOriginXcmFeeEstimate()
|
|
361
|
+
```
|
|
322
362
|
|
|
323
|
-
|
|
324
|
-
|
|
363
|
+
#### Asset balance
|
|
364
|
+
```ts
|
|
365
|
+
import { getAssetBalance } from "@paraspell/sdk";
|
|
325
366
|
|
|
326
|
-
//
|
|
327
|
-
await
|
|
367
|
+
//Retrieves the asset balance for a given account on a specified node (You do not need to specify if it is native or foreign).
|
|
368
|
+
const balance = 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 */});
|
|
369
|
+
```
|
|
328
370
|
|
|
329
|
-
|
|
330
|
-
|
|
371
|
+
#### Ethereum bridge fees
|
|
372
|
+
```ts
|
|
373
|
+
import { getParaEthTransferFees } from "@paraspell/sdk";
|
|
331
374
|
|
|
332
|
-
|
|
333
|
-
await verifyEdOnDestination(node, currency: {symbol: || id: || multilocation: .. ,amount: 100000n}, address)
|
|
375
|
+
const fees = await getParaEthTransferFees(/*api - optional (Can also be WS port string or array o WS ports. Must be AssetHubPolkadot WS!)*/)
|
|
334
376
|
```
|
|
335
377
|
|
|
336
|
-
|
|
378
|
+
#### Existential deposit queries
|
|
337
379
|
```ts
|
|
338
380
|
import { getExistentialDeposit } from "@paraspell/sdk";
|
|
339
381
|
|
|
@@ -342,7 +384,7 @@ import { getExistentialDeposit } from "@paraspell/sdk";
|
|
|
342
384
|
const ed = getExistentialDeposit(node, currency?)
|
|
343
385
|
```
|
|
344
386
|
|
|
345
|
-
|
|
387
|
+
#### Convert SS58 address
|
|
346
388
|
```ts
|
|
347
389
|
import { convertSs58 } from "@paraspell/sdk";
|
|
348
390
|
|
|
@@ -351,61 +393,66 @@ let result = convertSs58(address, node) // returns converted address in string
|
|
|
351
393
|
|
|
352
394
|
### Asset queries:
|
|
353
395
|
|
|
396
|
+
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
397
|
+
|
|
354
398
|
```ts
|
|
355
399
|
import { getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTNode, getAssetMultiLocation, NODE_NAMES } from '@paraspell/sdk'
|
|
356
400
|
|
|
357
401
|
// Retrieve Fee asset queries (Assets accepted as XCM Fee on specific node)
|
|
358
|
-
getFeeAssets(
|
|
402
|
+
getFeeAssets(NODE)
|
|
403
|
+
|
|
404
|
+
// Get multilocation for asset id or symbol on specific chain
|
|
405
|
+
getAssetMultiLocation(NODE, { symbol: symbol } | { id: assetId })
|
|
359
406
|
|
|
360
407
|
// Retrieve assets object from assets.json for particular node including information about native and foreign assets
|
|
361
|
-
getAssetsObject(
|
|
408
|
+
getAssetsObject(NODE)
|
|
362
409
|
|
|
363
410
|
// Retrieve foreign assetId for a particular node and asset symbol
|
|
364
|
-
getAssetId(
|
|
411
|
+
getAssetId(NODE, ASSET_SYMBOL)
|
|
365
412
|
|
|
366
413
|
// Retrieve the symbol of the relay chain for a particular node. Either "DOT" or "KSM"
|
|
367
|
-
getRelayChainSymbol(
|
|
414
|
+
getRelayChainSymbol(NODE)
|
|
368
415
|
|
|
369
416
|
// Retrieve string array of native assets symbols for particular node
|
|
370
|
-
getNativeAssets(
|
|
417
|
+
getNativeAssets(NODE)
|
|
371
418
|
|
|
372
419
|
// Retrieve object array of foreign assets for a particular node. Each object has a symbol and assetId property
|
|
373
|
-
getOtherAssets(
|
|
420
|
+
getOtherAssets(NODE)
|
|
374
421
|
|
|
375
422
|
// Retrieve string array of all assets symbols. (native and foreign assets are merged into a single array)
|
|
376
|
-
getAllAssetsSymbols(
|
|
423
|
+
getAllAssetsSymbols(NODE)
|
|
377
424
|
|
|
378
425
|
// Check if a node supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
379
|
-
hasSupportForAsset(
|
|
426
|
+
hasSupportForAsset(NODE, ASSET_SYMBOL)
|
|
380
427
|
|
|
381
428
|
// Get decimals for specific asset
|
|
382
|
-
getAssetDecimals(
|
|
429
|
+
getAssetDecimals(NODE, ASSET_SYMBOL)
|
|
383
430
|
|
|
384
431
|
// Get specific node id
|
|
385
|
-
getParaId(
|
|
432
|
+
getParaId(NODE)
|
|
386
433
|
|
|
387
434
|
// Get specific TNode from nodeID
|
|
388
|
-
getTNode(
|
|
435
|
+
getTNode(paraID: number, ecosystem: 'polkadot' || 'kusama' || 'ethereum') //When Ethereum ecosystem is selected please fill nodeID as 1 to select Ethereum.
|
|
389
436
|
|
|
390
437
|
// Import all compatible nodes as constant
|
|
391
438
|
NODE_NAMES
|
|
392
|
-
|
|
393
|
-
// Get multilocation for asset id or symbol on specific chain
|
|
394
|
-
getAssetMultiLocation(chainFrom, { symbol: symbol } | { id: assetId })
|
|
395
439
|
```
|
|
396
440
|
|
|
397
441
|
### Parachain XCM Pallet queries
|
|
442
|
+
|
|
443
|
+
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/NodePallets.html).
|
|
444
|
+
|
|
398
445
|
```ts
|
|
399
446
|
import { getDefaultPallet, getSupportedPallets, getPalletIndex SUPPORTED_PALLETS } from '@paraspell/sdk';
|
|
400
447
|
|
|
401
448
|
//Retrieve default pallet for specific Parachain
|
|
402
|
-
getDefaultPallet(
|
|
449
|
+
getDefaultPallet(NODE)
|
|
403
450
|
|
|
404
451
|
// Returns an array of supported pallets for a specific Parachain
|
|
405
|
-
getSupportedPallets(
|
|
452
|
+
getSupportedPallets(NODE)
|
|
406
453
|
|
|
407
454
|
//Returns index of XCM Pallet used by Parachain
|
|
408
|
-
getPalletIndex(
|
|
455
|
+
getPalletIndex(NODE)
|
|
409
456
|
|
|
410
457
|
// Print all pallets that are currently supported
|
|
411
458
|
console.log(SUPPORTED_PALLETS)
|
package/dist/index.cjs
CHANGED
|
@@ -1437,11 +1437,11 @@ 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, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1440
|
+
var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, 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:
|
|
1444
|
-
tx = _ref6.tx, address = _ref6.address, node = _ref6.node;
|
|
1444
|
+
tx = _ref6.tx, address = _ref6.address, node = _ref6.node, isFeeAsset = _ref6.isFeeAsset;
|
|
1445
1445
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1446
1446
|
if (supportsDryRunApi) {
|
|
1447
1447
|
_context17.next = 4;
|
|
@@ -1477,7 +1477,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1477
1477
|
return this.calculateTransactionFee(tx, address);
|
|
1478
1478
|
case 16:
|
|
1479
1479
|
executionFee = _context17.sent;
|
|
1480
|
-
fee = sdkCore.computeFeeFromDryRun(result, node, executionFee);
|
|
1480
|
+
fee = sdkCore.computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
|
|
1481
1481
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1482
1482
|
weight = actualWeight ? {
|
|
1483
1483
|
refTime: actualWeight.ref_time,
|
|
@@ -1507,12 +1507,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1507
1507
|
key: "getDryRunXcm",
|
|
1508
1508
|
value: function () {
|
|
1509
1509
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref9) {
|
|
1510
|
-
var _ref0, _ref1, _ref10;
|
|
1511
|
-
var originLocation, xcm, node, origin, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1510
|
+
var _ref0, _ref1, _ref10, _ref11;
|
|
1511
|
+
var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1512
1512
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1513
1513
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1514
1514
|
case 0:
|
|
1515
|
-
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin;
|
|
1515
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1516
1516
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1517
1517
|
if (supportsDryRunApi) {
|
|
1518
1518
|
_context18.next = 4;
|
|
@@ -1539,7 +1539,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1539
1539
|
emitted = result.value.emitted_events; // We want to look for the last event
|
|
1540
1540
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1541
1541
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1542
|
-
|
|
1542
|
+
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && sdkCore.isAssetEqual(feeAsset, asset);
|
|
1543
|
+
feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1544
|
+
return event.type === 'ForeignAssets' && event.value.type === 'Issued';
|
|
1545
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1543
1546
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1544
1547
|
}) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1545
1548
|
// Prefer an Issued event
|
|
@@ -1553,15 +1556,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1553
1556
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1554
1557
|
});
|
|
1555
1558
|
if (feeEvent) {
|
|
1556
|
-
_context18.next =
|
|
1559
|
+
_context18.next = 19;
|
|
1557
1560
|
break;
|
|
1558
1561
|
}
|
|
1559
1562
|
return _context18.abrupt("return", Promise.resolve({
|
|
1560
1563
|
success: false,
|
|
1561
1564
|
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
1562
1565
|
}));
|
|
1563
|
-
case
|
|
1566
|
+
case 19:
|
|
1564
1567
|
fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
|
|
1568
|
+
if (isFeeAsset && feeEvent.type === 'ForeignAssets' && feeEvent.value.type === 'Issued') {
|
|
1569
|
+
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1570
|
+
}
|
|
1565
1571
|
actualWeight = result.value.execution_result.value.used;
|
|
1566
1572
|
weight = actualWeight ? {
|
|
1567
1573
|
refTime: actualWeight.ref_time,
|
|
@@ -1576,7 +1582,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1576
1582
|
forwardedXcms: forwardedXcms,
|
|
1577
1583
|
destParaId: destParaId
|
|
1578
1584
|
}));
|
|
1579
|
-
case
|
|
1585
|
+
case 26:
|
|
1580
1586
|
case "end":
|
|
1581
1587
|
return _context18.stop();
|
|
1582
1588
|
}
|
|
@@ -1686,12 +1692,6 @@ var getBalanceNative = createPapiApiCall(sdkCore.getBalanceNative);
|
|
|
1686
1692
|
* @returns The balance of the foreign asset as a bigint, or null if not found.
|
|
1687
1693
|
*/
|
|
1688
1694
|
var getBalanceForeign = createPapiApiCall(sdkCore.getBalanceForeign);
|
|
1689
|
-
/**
|
|
1690
|
-
* Retrieves detailed transfer information for a cross-chain transfer.
|
|
1691
|
-
*
|
|
1692
|
-
* @returns A Promise that resolves to the transfer information.
|
|
1693
|
-
*/
|
|
1694
|
-
var getTransferInfo = createPapiApiCall(sdkCore.getTransferInfo);
|
|
1695
1695
|
/**
|
|
1696
1696
|
* Retrieves the asset balance for a given account on a specified node.
|
|
1697
1697
|
*
|
|
@@ -1704,11 +1704,14 @@ var getAssetBalance = createPapiApiCall(sdkCore.getAssetBalance);
|
|
|
1704
1704
|
* @returns An extrinsic representing the claim transaction.
|
|
1705
1705
|
*/
|
|
1706
1706
|
var claimAssets = createPapiApiCall(sdkCore.claimAssets);
|
|
1707
|
+
/**
|
|
1708
|
+
* @deprecated This function is deprecated and will be removed in a future version.
|
|
1709
|
+
* Please use `builder.getOriginXcmFee()` or `builder.getOriginXcmFeeEstimate()` instead,
|
|
1710
|
+
* where `builder` is an instance of `Builder()`.
|
|
1711
|
+
* For more details, please refer to the documentation:
|
|
1712
|
+
* {@link https://paraspell.github.io/docs/sdk/xcmPallet.html#xcm-fee-origin-and-dest}
|
|
1713
|
+
*/
|
|
1707
1714
|
var getOriginFeeDetails = createPapiApiCall(sdkCore.getOriginFeeDetails);
|
|
1708
|
-
var getMaxNativeTransferableAmount = createPapiApiCall(sdkCore.getMaxNativeTransferableAmount);
|
|
1709
|
-
var getMaxForeignTransferableAmount = createPapiApiCall(sdkCore.getMaxForeignTransferableAmount);
|
|
1710
|
-
var getTransferableAmount = createPapiApiCall(sdkCore.getTransferableAmount);
|
|
1711
|
-
var verifyEdOnDestination = createPapiApiCall(sdkCore.verifyEdOnDestination);
|
|
1712
1715
|
|
|
1713
1716
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1714
1717
|
__proto__: null,
|
|
@@ -1727,8 +1730,6 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1727
1730
|
getBalanceForeign: getBalanceForeign,
|
|
1728
1731
|
getBalanceNative: getBalanceNative,
|
|
1729
1732
|
getExistentialDeposit: sdkCore.getExistentialDeposit,
|
|
1730
|
-
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
1731
|
-
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
1732
1733
|
getNativeAssetSymbol: sdkCore.getNativeAssetSymbol,
|
|
1733
1734
|
getNativeAssets: sdkCore.getNativeAssets,
|
|
1734
1735
|
getOriginFeeDetails: getOriginFeeDetails,
|
|
@@ -1736,11 +1737,8 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1736
1737
|
getRelayChainSymbol: sdkCore.getRelayChainSymbol,
|
|
1737
1738
|
getSupportedAssets: sdkCore.getSupportedAssets,
|
|
1738
1739
|
getTNode: sdkCore.getTNode,
|
|
1739
|
-
getTransferInfo: getTransferInfo,
|
|
1740
|
-
getTransferableAmount: getTransferableAmount,
|
|
1741
1740
|
hasSupportForAsset: sdkCore.hasSupportForAsset,
|
|
1742
|
-
isNodeEvm: sdkCore.isNodeEvm
|
|
1743
|
-
verifyEdOnDestination: verifyEdOnDestination
|
|
1741
|
+
isNodeEvm: sdkCore.isNodeEvm
|
|
1744
1742
|
});
|
|
1745
1743
|
|
|
1746
1744
|
var convertSs58 = function convertSs58(address, node) {
|
|
@@ -1943,14 +1941,14 @@ var getBridgeStatus = /*#__PURE__*/function () {
|
|
|
1943
1941
|
return _ref2.apply(this, arguments);
|
|
1944
1942
|
};
|
|
1945
1943
|
}();
|
|
1946
|
-
var
|
|
1944
|
+
var getOriginXcmFee = createPapiApiCall(sdkCore.getOriginXcmFee);
|
|
1947
1945
|
|
|
1948
1946
|
var transfer = /*#__PURE__*/Object.freeze({
|
|
1949
1947
|
__proto__: null,
|
|
1950
1948
|
dryRun: dryRun,
|
|
1951
1949
|
dryRunOrigin: dryRunOrigin,
|
|
1952
1950
|
getBridgeStatus: getBridgeStatus,
|
|
1953
|
-
|
|
1951
|
+
getOriginXcmFee: getOriginXcmFee,
|
|
1954
1952
|
getParaEthTransferFees: getParaEthTransferFees,
|
|
1955
1953
|
send: send
|
|
1956
1954
|
});
|
|
@@ -1967,15 +1965,10 @@ exports.getAssetBalance = getAssetBalance;
|
|
|
1967
1965
|
exports.getBalanceForeign = getBalanceForeign;
|
|
1968
1966
|
exports.getBalanceNative = getBalanceNative;
|
|
1969
1967
|
exports.getBridgeStatus = getBridgeStatus;
|
|
1970
|
-
exports.getFeeForOriginNode = getFeeForOriginNode;
|
|
1971
|
-
exports.getMaxForeignTransferableAmount = getMaxForeignTransferableAmount;
|
|
1972
|
-
exports.getMaxNativeTransferableAmount = getMaxNativeTransferableAmount;
|
|
1973
1968
|
exports.getOriginFeeDetails = getOriginFeeDetails;
|
|
1969
|
+
exports.getOriginXcmFee = getOriginXcmFee;
|
|
1974
1970
|
exports.getParaEthTransferFees = getParaEthTransferFees;
|
|
1975
|
-
exports.getTransferInfo = getTransferInfo;
|
|
1976
|
-
exports.getTransferableAmount = getTransferableAmount;
|
|
1977
1971
|
exports.send = send;
|
|
1978
|
-
exports.verifyEdOnDestination = verifyEdOnDestination;
|
|
1979
1972
|
exports.xcmPallet = transfer;
|
|
1980
1973
|
Object.keys(sdkCore).forEach(function (k) {
|
|
1981
1974
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/dist/index.d.ts
CHANGED
|
@@ -28,14 +28,6 @@ declare const getBalanceNative: (options: _paraspell_sdk_core.TGetBalanceNativeO
|
|
|
28
28
|
declare const getBalanceForeign: (options: _paraspell_sdk_core.TGetBalanceForeignOptionsBase & {
|
|
29
29
|
api?: TPapiApiOrUrl;
|
|
30
30
|
}) => Promise<bigint>;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves detailed transfer information for a cross-chain transfer.
|
|
33
|
-
*
|
|
34
|
-
* @returns A Promise that resolves to the transfer information.
|
|
35
|
-
*/
|
|
36
|
-
declare const getTransferInfo: (options: _paraspell_sdk_core.TGetTransferInfoOptionsBase & {
|
|
37
|
-
api?: TPapiApiOrUrl;
|
|
38
|
-
}) => Promise<_paraspell_sdk_core.TTransferInfo>;
|
|
39
31
|
/**
|
|
40
32
|
* Retrieves the asset balance for a given account on a specified node.
|
|
41
33
|
*
|
|
@@ -52,21 +44,16 @@ declare const getAssetBalance: (options: _paraspell_sdk_core.TGetAssetBalanceOpt
|
|
|
52
44
|
declare const claimAssets: (options: _paraspell_sdk_core.TAssetClaimOptionsBase & {
|
|
53
45
|
api?: TPapiApiOrUrl;
|
|
54
46
|
}) => Promise<TPapiTransaction>;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated This function is deprecated and will be removed in a future version.
|
|
49
|
+
* Please use `builder.getOriginXcmFee()` or `builder.getOriginXcmFeeEstimate()` instead,
|
|
50
|
+
* where `builder` is an instance of `Builder()`.
|
|
51
|
+
* For more details, please refer to the documentation:
|
|
52
|
+
* {@link https://paraspell.github.io/docs/sdk/xcmPallet.html#xcm-fee-origin-and-dest}
|
|
53
|
+
*/
|
|
55
54
|
declare const getOriginFeeDetails: (options: _paraspell_sdk_core.TGetOriginFeeDetailsOptionsBase & {
|
|
56
55
|
api?: TPapiApiOrUrl;
|
|
57
56
|
}) => Promise<_paraspell_sdk_core.TOriginFeeDetails>;
|
|
58
|
-
declare const getMaxNativeTransferableAmount: (options: _paraspell_sdk_core.TGetMaxNativeTransferableAmountOptionsBase & {
|
|
59
|
-
api?: TPapiApiOrUrl;
|
|
60
|
-
}) => Promise<bigint>;
|
|
61
|
-
declare const getMaxForeignTransferableAmount: (options: _paraspell_sdk_core.TGetMaxForeignTransferableAmountOptionsBase & {
|
|
62
|
-
api?: TPapiApiOrUrl;
|
|
63
|
-
}) => Promise<bigint>;
|
|
64
|
-
declare const getTransferableAmount: (options: _paraspell_sdk_core.TGetTransferableAmountOptionsBase & {
|
|
65
|
-
api?: TPapiApiOrUrl;
|
|
66
|
-
}) => Promise<bigint>;
|
|
67
|
-
declare const verifyEdOnDestination: (options: _paraspell_sdk_core.TVerifyEdOnDestinationOptionsBase & {
|
|
68
|
-
api?: TPapiApiOrUrl;
|
|
69
|
-
}) => Promise<boolean>;
|
|
70
57
|
|
|
71
58
|
declare const assets_Foreign: typeof Foreign;
|
|
72
59
|
declare const assets_ForeignAbstract: typeof ForeignAbstract;
|
|
@@ -83,8 +70,6 @@ declare const assets_getAssetsObject: typeof getAssetsObject;
|
|
|
83
70
|
declare const assets_getBalanceForeign: typeof getBalanceForeign;
|
|
84
71
|
declare const assets_getBalanceNative: typeof getBalanceNative;
|
|
85
72
|
declare const assets_getExistentialDeposit: typeof getExistentialDeposit;
|
|
86
|
-
declare const assets_getMaxForeignTransferableAmount: typeof getMaxForeignTransferableAmount;
|
|
87
|
-
declare const assets_getMaxNativeTransferableAmount: typeof getMaxNativeTransferableAmount;
|
|
88
73
|
declare const assets_getNativeAssetSymbol: typeof getNativeAssetSymbol;
|
|
89
74
|
declare const assets_getNativeAssets: typeof getNativeAssets;
|
|
90
75
|
declare const assets_getOriginFeeDetails: typeof getOriginFeeDetails;
|
|
@@ -92,11 +77,8 @@ declare const assets_getOtherAssets: typeof getOtherAssets;
|
|
|
92
77
|
declare const assets_getRelayChainSymbol: typeof getRelayChainSymbol;
|
|
93
78
|
declare const assets_getSupportedAssets: typeof getSupportedAssets;
|
|
94
79
|
declare const assets_getTNode: typeof getTNode;
|
|
95
|
-
declare const assets_getTransferInfo: typeof getTransferInfo;
|
|
96
|
-
declare const assets_getTransferableAmount: typeof getTransferableAmount;
|
|
97
80
|
declare const assets_hasSupportForAsset: typeof hasSupportForAsset;
|
|
98
81
|
declare const assets_isNodeEvm: typeof isNodeEvm;
|
|
99
|
-
declare const assets_verifyEdOnDestination: typeof verifyEdOnDestination;
|
|
100
82
|
declare namespace assets {
|
|
101
83
|
export {
|
|
102
84
|
assets_Foreign as Foreign,
|
|
@@ -114,8 +96,6 @@ declare namespace assets {
|
|
|
114
96
|
assets_getBalanceForeign as getBalanceForeign,
|
|
115
97
|
assets_getBalanceNative as getBalanceNative,
|
|
116
98
|
assets_getExistentialDeposit as getExistentialDeposit,
|
|
117
|
-
assets_getMaxForeignTransferableAmount as getMaxForeignTransferableAmount,
|
|
118
|
-
assets_getMaxNativeTransferableAmount as getMaxNativeTransferableAmount,
|
|
119
99
|
assets_getNativeAssetSymbol as getNativeAssetSymbol,
|
|
120
100
|
assets_getNativeAssets as getNativeAssets,
|
|
121
101
|
assets_getOriginFeeDetails as getOriginFeeDetails,
|
|
@@ -123,11 +103,8 @@ declare namespace assets {
|
|
|
123
103
|
assets_getRelayChainSymbol as getRelayChainSymbol,
|
|
124
104
|
assets_getSupportedAssets as getSupportedAssets,
|
|
125
105
|
assets_getTNode as getTNode,
|
|
126
|
-
assets_getTransferInfo as getTransferInfo,
|
|
127
|
-
assets_getTransferableAmount as getTransferableAmount,
|
|
128
106
|
assets_hasSupportForAsset as hasSupportForAsset,
|
|
129
107
|
assets_isNodeEvm as isNodeEvm,
|
|
130
|
-
assets_verifyEdOnDestination as verifyEdOnDestination,
|
|
131
108
|
};
|
|
132
109
|
}
|
|
133
110
|
|
|
@@ -226,12 +203,9 @@ declare const getParaEthTransferFees: (ahApi?: TPapiApiOrUrl) => Promise<[bigint
|
|
|
226
203
|
* Gets the Ethereum bridge status.
|
|
227
204
|
*/
|
|
228
205
|
declare const getBridgeStatus: (ahApi?: TPapiApiOrUrl) => Promise<_paraspell_sdk_core.TBridgeStatus>;
|
|
229
|
-
declare const
|
|
206
|
+
declare const getOriginXcmFee: (options: _paraspell_sdk_core.TGetOriginXcmFeeBaseOptions<TPapiTransaction> & {
|
|
230
207
|
api?: TPapiApiOrUrl;
|
|
231
|
-
}) => Promise<{
|
|
232
|
-
fee?: bigint;
|
|
233
|
-
feeType?: _paraspell_sdk_core.TFeeType;
|
|
234
|
-
dryRunError?: string;
|
|
208
|
+
}) => Promise<_paraspell_sdk_core.TXcmFeeDetail & {
|
|
235
209
|
forwardedXcms?: any;
|
|
236
210
|
destParaId?: number;
|
|
237
211
|
}>;
|
|
@@ -239,7 +213,7 @@ declare const getFeeForOriginNode: (options: _paraspell_sdk_core.TGetFeeForOrigi
|
|
|
239
213
|
declare const transfer_dryRun: typeof dryRun;
|
|
240
214
|
declare const transfer_dryRunOrigin: typeof dryRunOrigin;
|
|
241
215
|
declare const transfer_getBridgeStatus: typeof getBridgeStatus;
|
|
242
|
-
declare const
|
|
216
|
+
declare const transfer_getOriginXcmFee: typeof getOriginXcmFee;
|
|
243
217
|
declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
|
|
244
218
|
declare const transfer_send: typeof send;
|
|
245
219
|
declare namespace transfer {
|
|
@@ -247,7 +221,7 @@ declare namespace transfer {
|
|
|
247
221
|
transfer_dryRun as dryRun,
|
|
248
222
|
transfer_dryRunOrigin as dryRunOrigin,
|
|
249
223
|
transfer_getBridgeStatus as getBridgeStatus,
|
|
250
|
-
|
|
224
|
+
transfer_getOriginXcmFee as getOriginXcmFee,
|
|
251
225
|
transfer_getParaEthTransferFees as getParaEthTransferFees,
|
|
252
226
|
transfer_send as send,
|
|
253
227
|
};
|
|
@@ -255,5 +229,5 @@ declare namespace transfer {
|
|
|
255
229
|
|
|
256
230
|
declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<polkadot_api.PolkadotClient>;
|
|
257
231
|
|
|
258
|
-
export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus,
|
|
232
|
+
export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, send, transfer as xcmPallet };
|
|
259
233
|
export type { GeneralBuilder, TEvmNodeFromPapi, TPapiApi, TPapiApiOrUrl, TPapiTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1,
|
|
1
|
+
import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { blake2b } from '@noble/hashes/blake2';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
@@ -1436,11 +1436,11 @@ 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, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1439
|
+
var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, 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:
|
|
1443
|
-
tx = _ref6.tx, address = _ref6.address, node = _ref6.node;
|
|
1443
|
+
tx = _ref6.tx, address = _ref6.address, node = _ref6.node, isFeeAsset = _ref6.isFeeAsset;
|
|
1444
1444
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1445
1445
|
if (supportsDryRunApi) {
|
|
1446
1446
|
_context17.next = 4;
|
|
@@ -1476,7 +1476,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1476
1476
|
return this.calculateTransactionFee(tx, address);
|
|
1477
1477
|
case 16:
|
|
1478
1478
|
executionFee = _context17.sent;
|
|
1479
|
-
fee = computeFeeFromDryRun(result, node, executionFee);
|
|
1479
|
+
fee = computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
|
|
1480
1480
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1481
1481
|
weight = actualWeight ? {
|
|
1482
1482
|
refTime: actualWeight.ref_time,
|
|
@@ -1506,12 +1506,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1506
1506
|
key: "getDryRunXcm",
|
|
1507
1507
|
value: function () {
|
|
1508
1508
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref9) {
|
|
1509
|
-
var _ref0, _ref1, _ref10;
|
|
1510
|
-
var originLocation, xcm, node, origin, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1509
|
+
var _ref0, _ref1, _ref10, _ref11;
|
|
1510
|
+
var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeEvent, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1511
1511
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1512
1512
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1513
1513
|
case 0:
|
|
1514
|
-
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin;
|
|
1514
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1515
1515
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1516
1516
|
if (supportsDryRunApi) {
|
|
1517
1517
|
_context18.next = 4;
|
|
@@ -1538,7 +1538,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1538
1538
|
emitted = result.value.emitted_events; // We want to look for the last event
|
|
1539
1539
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1540
1540
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1541
|
-
|
|
1541
|
+
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && isAssetEqual(feeAsset, asset);
|
|
1542
|
+
feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1543
|
+
return event.type === 'ForeignAssets' && event.value.type === 'Issued';
|
|
1544
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1542
1545
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1543
1546
|
}) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1544
1547
|
// Prefer an Issued event
|
|
@@ -1552,15 +1555,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1552
1555
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1553
1556
|
});
|
|
1554
1557
|
if (feeEvent) {
|
|
1555
|
-
_context18.next =
|
|
1558
|
+
_context18.next = 19;
|
|
1556
1559
|
break;
|
|
1557
1560
|
}
|
|
1558
1561
|
return _context18.abrupt("return", Promise.resolve({
|
|
1559
1562
|
success: false,
|
|
1560
1563
|
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
1561
1564
|
}));
|
|
1562
|
-
case
|
|
1565
|
+
case 19:
|
|
1563
1566
|
fee = feeEvent.type === 'AssetConversion' ? feeEvent.value.value.amount_in : feeEvent.value.value.amount;
|
|
1567
|
+
if (isFeeAsset && feeEvent.type === 'ForeignAssets' && feeEvent.value.type === 'Issued') {
|
|
1568
|
+
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1569
|
+
}
|
|
1564
1570
|
actualWeight = result.value.execution_result.value.used;
|
|
1565
1571
|
weight = actualWeight ? {
|
|
1566
1572
|
refTime: actualWeight.ref_time,
|
|
@@ -1575,7 +1581,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1575
1581
|
forwardedXcms: forwardedXcms,
|
|
1576
1582
|
destParaId: destParaId
|
|
1577
1583
|
}));
|
|
1578
|
-
case
|
|
1584
|
+
case 26:
|
|
1579
1585
|
case "end":
|
|
1580
1586
|
return _context18.stop();
|
|
1581
1587
|
}
|
|
@@ -1685,12 +1691,6 @@ var getBalanceNative = createPapiApiCall(getBalanceNative$1);
|
|
|
1685
1691
|
* @returns The balance of the foreign asset as a bigint, or null if not found.
|
|
1686
1692
|
*/
|
|
1687
1693
|
var getBalanceForeign = createPapiApiCall(getBalanceForeign$1);
|
|
1688
|
-
/**
|
|
1689
|
-
* Retrieves detailed transfer information for a cross-chain transfer.
|
|
1690
|
-
*
|
|
1691
|
-
* @returns A Promise that resolves to the transfer information.
|
|
1692
|
-
*/
|
|
1693
|
-
var getTransferInfo = createPapiApiCall(getTransferInfo$1);
|
|
1694
1694
|
/**
|
|
1695
1695
|
* Retrieves the asset balance for a given account on a specified node.
|
|
1696
1696
|
*
|
|
@@ -1703,11 +1703,14 @@ var getAssetBalance = createPapiApiCall(getAssetBalance$1);
|
|
|
1703
1703
|
* @returns An extrinsic representing the claim transaction.
|
|
1704
1704
|
*/
|
|
1705
1705
|
var claimAssets = createPapiApiCall(claimAssets$1);
|
|
1706
|
+
/**
|
|
1707
|
+
* @deprecated This function is deprecated and will be removed in a future version.
|
|
1708
|
+
* Please use `builder.getOriginXcmFee()` or `builder.getOriginXcmFeeEstimate()` instead,
|
|
1709
|
+
* where `builder` is an instance of `Builder()`.
|
|
1710
|
+
* For more details, please refer to the documentation:
|
|
1711
|
+
* {@link https://paraspell.github.io/docs/sdk/xcmPallet.html#xcm-fee-origin-and-dest}
|
|
1712
|
+
*/
|
|
1706
1713
|
var getOriginFeeDetails = createPapiApiCall(getOriginFeeDetails$1);
|
|
1707
|
-
var getMaxNativeTransferableAmount = createPapiApiCall(getMaxNativeTransferableAmount$1);
|
|
1708
|
-
var getMaxForeignTransferableAmount = createPapiApiCall(getMaxForeignTransferableAmount$1);
|
|
1709
|
-
var getTransferableAmount = createPapiApiCall(getTransferableAmount$1);
|
|
1710
|
-
var verifyEdOnDestination = createPapiApiCall(verifyEdOnDestination$1);
|
|
1711
1714
|
|
|
1712
1715
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1713
1716
|
__proto__: null,
|
|
@@ -1726,8 +1729,6 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1726
1729
|
getBalanceForeign: getBalanceForeign,
|
|
1727
1730
|
getBalanceNative: getBalanceNative,
|
|
1728
1731
|
getExistentialDeposit: getExistentialDeposit,
|
|
1729
|
-
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
1730
|
-
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
1731
1732
|
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
1732
1733
|
getNativeAssets: getNativeAssets,
|
|
1733
1734
|
getOriginFeeDetails: getOriginFeeDetails,
|
|
@@ -1735,11 +1736,8 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1735
1736
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
1736
1737
|
getSupportedAssets: getSupportedAssets,
|
|
1737
1738
|
getTNode: getTNode,
|
|
1738
|
-
getTransferInfo: getTransferInfo,
|
|
1739
|
-
getTransferableAmount: getTransferableAmount,
|
|
1740
1739
|
hasSupportForAsset: hasSupportForAsset,
|
|
1741
|
-
isNodeEvm: isNodeEvm
|
|
1742
|
-
verifyEdOnDestination: verifyEdOnDestination
|
|
1740
|
+
isNodeEvm: isNodeEvm
|
|
1743
1741
|
});
|
|
1744
1742
|
|
|
1745
1743
|
var convertSs58 = function convertSs58(address, node) {
|
|
@@ -1942,16 +1940,16 @@ var getBridgeStatus = /*#__PURE__*/function () {
|
|
|
1942
1940
|
return _ref2.apply(this, arguments);
|
|
1943
1941
|
};
|
|
1944
1942
|
}();
|
|
1945
|
-
var
|
|
1943
|
+
var getOriginXcmFee = createPapiApiCall(getOriginXcmFee$1);
|
|
1946
1944
|
|
|
1947
1945
|
var transfer = /*#__PURE__*/Object.freeze({
|
|
1948
1946
|
__proto__: null,
|
|
1949
1947
|
dryRun: dryRun,
|
|
1950
1948
|
dryRunOrigin: dryRunOrigin,
|
|
1951
1949
|
getBridgeStatus: getBridgeStatus,
|
|
1952
|
-
|
|
1950
|
+
getOriginXcmFee: getOriginXcmFee,
|
|
1953
1951
|
getParaEthTransferFees: getParaEthTransferFees,
|
|
1954
1952
|
send: send
|
|
1955
1953
|
});
|
|
1956
1954
|
|
|
1957
|
-
export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus,
|
|
1955
|
+
export { Builder, EvmBuilder, assets, claimAssets, convertSs58, createApiInstanceForNode, dryRun, dryRunOrigin, getAssetBalance, getBalanceForeign, getBalanceNative, getBridgeStatus, getOriginFeeDetails, getOriginXcmFee, getParaEthTransferFees, send, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1",
|
|
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": "10.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"polkadot-api": ">= 1.10.2 < 2"
|