@paraspell/sdk 11.1.1 → 11.2.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/dist/index.cjs +84 -25
- package/dist/index.mjs +86 -27
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -372,6 +372,16 @@ var _transform = function transform(obj) {
|
|
|
372
372
|
if (keys.length === 1) {
|
|
373
373
|
var key = keys[0];
|
|
374
374
|
var value = obj[key];
|
|
375
|
+
if (key === 'items' && Array.isArray(value)) {
|
|
376
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
377
|
+
return {
|
|
378
|
+
items: value.map(function (item) {
|
|
379
|
+
return item.map(function (i) {
|
|
380
|
+
return polkadotApi.Binary.fromHex(i);
|
|
381
|
+
});
|
|
382
|
+
})
|
|
383
|
+
};
|
|
384
|
+
}
|
|
375
385
|
if (key === 'AccountId32') {
|
|
376
386
|
return {
|
|
377
387
|
type: key,
|
|
@@ -497,11 +507,13 @@ var _transform = function transform(obj) {
|
|
|
497
507
|
newObj[k] = undefined;
|
|
498
508
|
continue;
|
|
499
509
|
}
|
|
500
|
-
if ((k === 'dest' || k === 'target') && typeof v === 'string') {
|
|
510
|
+
if ((k === 'dest' || k === 'who' || k === 'target') && typeof v === 'string') {
|
|
501
511
|
newObj[k] = v;
|
|
502
512
|
continue;
|
|
503
513
|
}
|
|
504
|
-
if (typeof v === 'string' &&
|
|
514
|
+
if (typeof v === 'string' && viem.isAddress(v)) {
|
|
515
|
+
newObj[k] = v;
|
|
516
|
+
} else if (typeof v === 'string' && v.startsWith('0x')) {
|
|
505
517
|
newObj[k] = polkadotApi.FixedSizeBinary.fromHex(v);
|
|
506
518
|
} else if (typeof v === 'string') {
|
|
507
519
|
newObj[k] = {
|
|
@@ -938,6 +950,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
938
950
|
})
|
|
939
951
|
});
|
|
940
952
|
}
|
|
953
|
+
}, {
|
|
954
|
+
key: "callDispatchAsMethod",
|
|
955
|
+
value: function callDispatchAsMethod(call, address) {
|
|
956
|
+
var origin = {
|
|
957
|
+
type: 'system',
|
|
958
|
+
value: {
|
|
959
|
+
type: 'Signed',
|
|
960
|
+
value: address
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
return this.api.getUnsafeApi().tx.Utility.dispatch_as({
|
|
964
|
+
as_origin: origin,
|
|
965
|
+
call: call.decodedCall
|
|
966
|
+
});
|
|
967
|
+
}
|
|
941
968
|
}, {
|
|
942
969
|
key: "objectToHex",
|
|
943
970
|
value: function () {
|
|
@@ -1041,6 +1068,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1041
1068
|
}
|
|
1042
1069
|
return quoteAhPrice;
|
|
1043
1070
|
}()
|
|
1071
|
+
}, {
|
|
1072
|
+
key: "getEvmStorage",
|
|
1073
|
+
value: function getEvmStorage(contract, slot) {
|
|
1074
|
+
return this.api.getUnsafeApi().query.EVM.AccountStorages.getKey(polkadotApi.FixedSizeBinary.fromHex(contract), polkadotApi.FixedSizeBinary.fromHex(slot));
|
|
1075
|
+
}
|
|
1044
1076
|
}, {
|
|
1045
1077
|
key: "getBalanceNative",
|
|
1046
1078
|
value: function () {
|
|
@@ -1314,11 +1346,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1314
1346
|
value: function () {
|
|
1315
1347
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref6) {
|
|
1316
1348
|
var _this = this;
|
|
1317
|
-
var tx, address, chain, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee;
|
|
1349
|
+
var tx, address, chain, asset, feeAsset, _ref6$useRootOrigin, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee, _t3;
|
|
1318
1350
|
return _regenerator().w(function (_context19) {
|
|
1319
1351
|
while (1) switch (_context19.n) {
|
|
1320
1352
|
case 0:
|
|
1321
|
-
tx = _ref6.tx, address = _ref6.address, chain = _ref6.chain, feeAsset = _ref6.feeAsset;
|
|
1353
|
+
tx = _ref6.tx, address = _ref6.address, chain = _ref6.chain, asset = _ref6.asset, feeAsset = _ref6.feeAsset, _ref6$useRootOrigin = _ref6.useRootOrigin, useRootOrigin = _ref6$useRootOrigin === void 0 ? false : _ref6$useRootOrigin;
|
|
1322
1354
|
supportsDryRunApi = sdkCore.getAssetsObject(chain).supportsDryRunApi;
|
|
1323
1355
|
if (supportsDryRunApi) {
|
|
1324
1356
|
_context19.n = 1;
|
|
@@ -1329,11 +1361,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1329
1361
|
DEFAULT_XCM_VERSION = 3;
|
|
1330
1362
|
basePayload = {
|
|
1331
1363
|
type: 'system',
|
|
1332
|
-
value: {
|
|
1364
|
+
value: useRootOrigin ? {
|
|
1365
|
+
type: 'Root'
|
|
1366
|
+
} : {
|
|
1333
1367
|
type: 'Signed',
|
|
1334
1368
|
value: address
|
|
1335
1369
|
}
|
|
1336
1370
|
};
|
|
1371
|
+
if (!useRootOrigin) {
|
|
1372
|
+
_context19.n = 3;
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
_context19.n = 2;
|
|
1376
|
+
return sdkCore.wrapTxBypass(this, chain, asset, feeAsset, address, tx);
|
|
1377
|
+
case 2:
|
|
1378
|
+
_t3 = _context19.v;
|
|
1379
|
+
_context19.n = 4;
|
|
1380
|
+
break;
|
|
1381
|
+
case 3:
|
|
1382
|
+
_t3 = tx;
|
|
1383
|
+
case 4:
|
|
1384
|
+
resolvedTx = _t3;
|
|
1337
1385
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1338
1386
|
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(includeVersion) {
|
|
1339
1387
|
var _this$api$getUnsafeAp;
|
|
@@ -1341,7 +1389,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1341
1389
|
return _regenerator().w(function (_context18) {
|
|
1342
1390
|
while (1) switch (_context18.n) {
|
|
1343
1391
|
case 0:
|
|
1344
|
-
callArgs = [basePayload,
|
|
1392
|
+
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1345
1393
|
if (includeVersion) {
|
|
1346
1394
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1347
1395
|
}
|
|
@@ -1355,7 +1403,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1355
1403
|
}();
|
|
1356
1404
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
1357
1405
|
var _result$value;
|
|
1358
|
-
|
|
1406
|
+
var errorInEvents = findFailingEvent(result);
|
|
1407
|
+
return (result === null || result === void 0 ? void 0 : result.success) && ((_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.execution_result) === null || _result$value === void 0 ? void 0 : _result$value.success) && !errorInEvents;
|
|
1359
1408
|
};
|
|
1360
1409
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1361
1410
|
var _result$value2, _executionResultValue, _executionResultValue2, _result$value3, _ref8, _result$value4;
|
|
@@ -1369,27 +1418,31 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1369
1418
|
if (result !== null && result !== void 0 && (_result$value3 = result.value) !== null && _result$value3 !== void 0 && _result$value3.type) {
|
|
1370
1419
|
return String(result.value.type);
|
|
1371
1420
|
}
|
|
1372
|
-
|
|
1421
|
+
var erroredEvent = findFailingEvent(result);
|
|
1422
|
+
if (erroredEvent) {
|
|
1423
|
+
return erroredEvent.value.value.result.value.value.value.type;
|
|
1424
|
+
}
|
|
1425
|
+
return JSON.stringify((_ref8 = (_result$value4 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value4 !== void 0 ? _result$value4 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure', sdkCore.replaceBigInt);
|
|
1373
1426
|
};
|
|
1374
1427
|
failureOutputReason = '';
|
|
1375
|
-
_context19.n =
|
|
1428
|
+
_context19.n = 5;
|
|
1376
1429
|
return performDryRunCall(false);
|
|
1377
|
-
case
|
|
1430
|
+
case 5:
|
|
1378
1431
|
result = _context19.v;
|
|
1379
1432
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1380
1433
|
if (isSuccess) {
|
|
1381
|
-
_context19.n =
|
|
1434
|
+
_context19.n = 7;
|
|
1382
1435
|
break;
|
|
1383
1436
|
}
|
|
1384
1437
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1385
1438
|
failureOutputReason = initialFailureReason;
|
|
1386
1439
|
if (!(initialFailureReason === 'VersionedConversionFailed')) {
|
|
1387
|
-
_context19.n =
|
|
1440
|
+
_context19.n = 7;
|
|
1388
1441
|
break;
|
|
1389
1442
|
}
|
|
1390
|
-
_context19.n =
|
|
1443
|
+
_context19.n = 6;
|
|
1391
1444
|
return performDryRunCall(true);
|
|
1392
|
-
case
|
|
1445
|
+
case 6:
|
|
1393
1446
|
result = _context19.v;
|
|
1394
1447
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1395
1448
|
if (!isSuccess) {
|
|
@@ -1397,16 +1450,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1397
1450
|
} else {
|
|
1398
1451
|
failureOutputReason = '';
|
|
1399
1452
|
}
|
|
1400
|
-
case
|
|
1453
|
+
case 7:
|
|
1401
1454
|
if (isSuccess) {
|
|
1402
|
-
_context19.n =
|
|
1455
|
+
_context19.n = 8;
|
|
1403
1456
|
break;
|
|
1404
1457
|
}
|
|
1405
1458
|
return _context19.a(2, Promise.resolve({
|
|
1406
1459
|
success: false,
|
|
1407
1460
|
failureReason: failureOutputReason
|
|
1408
1461
|
}));
|
|
1409
|
-
case
|
|
1462
|
+
case 8:
|
|
1410
1463
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1411
1464
|
weight = actualWeight ? {
|
|
1412
1465
|
refTime: actualWeight.ref_time,
|
|
@@ -1414,24 +1467,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1414
1467
|
} : undefined;
|
|
1415
1468
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1416
1469
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1417
|
-
_context19.n =
|
|
1418
|
-
return this.calculateTransactionFee(
|
|
1419
|
-
case
|
|
1470
|
+
_context19.n = 9;
|
|
1471
|
+
return this.calculateTransactionFee(resolvedTx, address);
|
|
1472
|
+
case 9:
|
|
1420
1473
|
executionFee = _context19.v;
|
|
1421
1474
|
nativeAsset = sdkCore.findAssetInfo(chain, {
|
|
1422
1475
|
symbol: sdkCore.Native(sdkCore.getNativeAssetSymbol(chain))
|
|
1423
1476
|
}, null);
|
|
1424
1477
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
1425
1478
|
if (!(sdkCore.hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && nativeAsset && chain !== 'AssetHubPolkadot' && chain !== 'Kusama')) {
|
|
1426
|
-
_context19.n =
|
|
1479
|
+
_context19.n = 11;
|
|
1427
1480
|
break;
|
|
1428
1481
|
}
|
|
1429
|
-
_context19.n =
|
|
1482
|
+
_context19.n = 10;
|
|
1430
1483
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1431
|
-
case
|
|
1484
|
+
case 10:
|
|
1432
1485
|
xcmFee = _context19.v;
|
|
1433
1486
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1434
|
-
_context19.n =
|
|
1487
|
+
_context19.n = 11;
|
|
1435
1488
|
break;
|
|
1436
1489
|
}
|
|
1437
1490
|
return _context19.a(2, Promise.resolve({
|
|
@@ -1441,7 +1494,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1441
1494
|
forwardedXcms: forwardedXcms,
|
|
1442
1495
|
destParaId: destParaId
|
|
1443
1496
|
}));
|
|
1444
|
-
case
|
|
1497
|
+
case 11:
|
|
1445
1498
|
fee = sdkCore.computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1446
1499
|
return _context19.a(2, Promise.resolve({
|
|
1447
1500
|
success: true,
|
|
@@ -1729,6 +1782,12 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1729
1782
|
};
|
|
1730
1783
|
}();
|
|
1731
1784
|
};
|
|
1785
|
+
var findFailingEvent = function findFailingEvent(result) {
|
|
1786
|
+
var _result$value;
|
|
1787
|
+
return (_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.emitted_events) === null || _result$value === void 0 ? void 0 : _result$value.find(function (event) {
|
|
1788
|
+
return event.type === 'Utility' && event.value.type === 'DispatchedAs' && event.value.value.result.success === false;
|
|
1789
|
+
});
|
|
1790
|
+
};
|
|
1732
1791
|
|
|
1733
1792
|
/**
|
|
1734
1793
|
* Retrieves the native balance for a given account on a specified chain.
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { InvalidParameterError, isConfig, BatchMode, getChainProviders, MissingChainApiError, ChainNotSupportedError, createChainClient as createChainClient$1, Parents, Version, getChain, isForeignAsset, assertHasId, computeFeeFromDryRun, findAssetInfo, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, getAssetsObject, assertHasLocation, localizeLocation, isRelayChain, padFeeBy, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { InvalidParameterError, isConfig, BatchMode, getChainProviders, MissingChainApiError, ChainNotSupportedError, createChainClient as createChainClient$1, Parents, Version, getChain, isForeignAsset, assertHasId, computeFeeFromDryRun, findAssetInfo, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, wrapTxBypass, assertHasLocation, localizeLocation, isRelayChain, padFeeBy, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$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';
|
|
5
|
-
import { FixedSizeBinary, getSs58AddressInfo,
|
|
5
|
+
import { Binary, FixedSizeBinary, getSs58AddressInfo, AccountId, createClient } from 'polkadot-api';
|
|
6
6
|
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
|
|
7
7
|
import { isAddress } from 'viem';
|
|
8
8
|
|
|
@@ -371,6 +371,16 @@ var _transform = function transform(obj) {
|
|
|
371
371
|
if (keys.length === 1) {
|
|
372
372
|
var key = keys[0];
|
|
373
373
|
var value = obj[key];
|
|
374
|
+
if (key === 'items' && Array.isArray(value)) {
|
|
375
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
376
|
+
return {
|
|
377
|
+
items: value.map(function (item) {
|
|
378
|
+
return item.map(function (i) {
|
|
379
|
+
return Binary.fromHex(i);
|
|
380
|
+
});
|
|
381
|
+
})
|
|
382
|
+
};
|
|
383
|
+
}
|
|
374
384
|
if (key === 'AccountId32') {
|
|
375
385
|
return {
|
|
376
386
|
type: key,
|
|
@@ -496,11 +506,13 @@ var _transform = function transform(obj) {
|
|
|
496
506
|
newObj[k] = undefined;
|
|
497
507
|
continue;
|
|
498
508
|
}
|
|
499
|
-
if ((k === 'dest' || k === 'target') && typeof v === 'string') {
|
|
509
|
+
if ((k === 'dest' || k === 'who' || k === 'target') && typeof v === 'string') {
|
|
500
510
|
newObj[k] = v;
|
|
501
511
|
continue;
|
|
502
512
|
}
|
|
503
|
-
if (typeof v === 'string' && v
|
|
513
|
+
if (typeof v === 'string' && isAddress(v)) {
|
|
514
|
+
newObj[k] = v;
|
|
515
|
+
} else if (typeof v === 'string' && v.startsWith('0x')) {
|
|
504
516
|
newObj[k] = FixedSizeBinary.fromHex(v);
|
|
505
517
|
} else if (typeof v === 'string') {
|
|
506
518
|
newObj[k] = {
|
|
@@ -937,6 +949,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
937
949
|
})
|
|
938
950
|
});
|
|
939
951
|
}
|
|
952
|
+
}, {
|
|
953
|
+
key: "callDispatchAsMethod",
|
|
954
|
+
value: function callDispatchAsMethod(call, address) {
|
|
955
|
+
var origin = {
|
|
956
|
+
type: 'system',
|
|
957
|
+
value: {
|
|
958
|
+
type: 'Signed',
|
|
959
|
+
value: address
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
return this.api.getUnsafeApi().tx.Utility.dispatch_as({
|
|
963
|
+
as_origin: origin,
|
|
964
|
+
call: call.decodedCall
|
|
965
|
+
});
|
|
966
|
+
}
|
|
940
967
|
}, {
|
|
941
968
|
key: "objectToHex",
|
|
942
969
|
value: function () {
|
|
@@ -1040,6 +1067,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1040
1067
|
}
|
|
1041
1068
|
return quoteAhPrice;
|
|
1042
1069
|
}()
|
|
1070
|
+
}, {
|
|
1071
|
+
key: "getEvmStorage",
|
|
1072
|
+
value: function getEvmStorage(contract, slot) {
|
|
1073
|
+
return this.api.getUnsafeApi().query.EVM.AccountStorages.getKey(FixedSizeBinary.fromHex(contract), FixedSizeBinary.fromHex(slot));
|
|
1074
|
+
}
|
|
1043
1075
|
}, {
|
|
1044
1076
|
key: "getBalanceNative",
|
|
1045
1077
|
value: function () {
|
|
@@ -1313,11 +1345,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1313
1345
|
value: function () {
|
|
1314
1346
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref6) {
|
|
1315
1347
|
var _this = this;
|
|
1316
|
-
var tx, address, chain, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee;
|
|
1348
|
+
var tx, address, chain, asset, feeAsset, _ref6$useRootOrigin, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee, _t3;
|
|
1317
1349
|
return _regenerator().w(function (_context19) {
|
|
1318
1350
|
while (1) switch (_context19.n) {
|
|
1319
1351
|
case 0:
|
|
1320
|
-
tx = _ref6.tx, address = _ref6.address, chain = _ref6.chain, feeAsset = _ref6.feeAsset;
|
|
1352
|
+
tx = _ref6.tx, address = _ref6.address, chain = _ref6.chain, asset = _ref6.asset, feeAsset = _ref6.feeAsset, _ref6$useRootOrigin = _ref6.useRootOrigin, useRootOrigin = _ref6$useRootOrigin === void 0 ? false : _ref6$useRootOrigin;
|
|
1321
1353
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1322
1354
|
if (supportsDryRunApi) {
|
|
1323
1355
|
_context19.n = 1;
|
|
@@ -1328,11 +1360,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1328
1360
|
DEFAULT_XCM_VERSION = 3;
|
|
1329
1361
|
basePayload = {
|
|
1330
1362
|
type: 'system',
|
|
1331
|
-
value: {
|
|
1363
|
+
value: useRootOrigin ? {
|
|
1364
|
+
type: 'Root'
|
|
1365
|
+
} : {
|
|
1332
1366
|
type: 'Signed',
|
|
1333
1367
|
value: address
|
|
1334
1368
|
}
|
|
1335
1369
|
};
|
|
1370
|
+
if (!useRootOrigin) {
|
|
1371
|
+
_context19.n = 3;
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
_context19.n = 2;
|
|
1375
|
+
return wrapTxBypass(this, chain, asset, feeAsset, address, tx);
|
|
1376
|
+
case 2:
|
|
1377
|
+
_t3 = _context19.v;
|
|
1378
|
+
_context19.n = 4;
|
|
1379
|
+
break;
|
|
1380
|
+
case 3:
|
|
1381
|
+
_t3 = tx;
|
|
1382
|
+
case 4:
|
|
1383
|
+
resolvedTx = _t3;
|
|
1336
1384
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1337
1385
|
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(includeVersion) {
|
|
1338
1386
|
var _this$api$getUnsafeAp;
|
|
@@ -1340,7 +1388,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1340
1388
|
return _regenerator().w(function (_context18) {
|
|
1341
1389
|
while (1) switch (_context18.n) {
|
|
1342
1390
|
case 0:
|
|
1343
|
-
callArgs = [basePayload,
|
|
1391
|
+
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1344
1392
|
if (includeVersion) {
|
|
1345
1393
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1346
1394
|
}
|
|
@@ -1354,7 +1402,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1354
1402
|
}();
|
|
1355
1403
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
1356
1404
|
var _result$value;
|
|
1357
|
-
|
|
1405
|
+
var errorInEvents = findFailingEvent(result);
|
|
1406
|
+
return (result === null || result === void 0 ? void 0 : result.success) && ((_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.execution_result) === null || _result$value === void 0 ? void 0 : _result$value.success) && !errorInEvents;
|
|
1358
1407
|
};
|
|
1359
1408
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1360
1409
|
var _result$value2, _executionResultValue, _executionResultValue2, _result$value3, _ref8, _result$value4;
|
|
@@ -1368,27 +1417,31 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1368
1417
|
if (result !== null && result !== void 0 && (_result$value3 = result.value) !== null && _result$value3 !== void 0 && _result$value3.type) {
|
|
1369
1418
|
return String(result.value.type);
|
|
1370
1419
|
}
|
|
1371
|
-
|
|
1420
|
+
var erroredEvent = findFailingEvent(result);
|
|
1421
|
+
if (erroredEvent) {
|
|
1422
|
+
return erroredEvent.value.value.result.value.value.value.type;
|
|
1423
|
+
}
|
|
1424
|
+
return JSON.stringify((_ref8 = (_result$value4 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value4 !== void 0 ? _result$value4 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure', replaceBigInt);
|
|
1372
1425
|
};
|
|
1373
1426
|
failureOutputReason = '';
|
|
1374
|
-
_context19.n =
|
|
1427
|
+
_context19.n = 5;
|
|
1375
1428
|
return performDryRunCall(false);
|
|
1376
|
-
case
|
|
1429
|
+
case 5:
|
|
1377
1430
|
result = _context19.v;
|
|
1378
1431
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1379
1432
|
if (isSuccess) {
|
|
1380
|
-
_context19.n =
|
|
1433
|
+
_context19.n = 7;
|
|
1381
1434
|
break;
|
|
1382
1435
|
}
|
|
1383
1436
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1384
1437
|
failureOutputReason = initialFailureReason;
|
|
1385
1438
|
if (!(initialFailureReason === 'VersionedConversionFailed')) {
|
|
1386
|
-
_context19.n =
|
|
1439
|
+
_context19.n = 7;
|
|
1387
1440
|
break;
|
|
1388
1441
|
}
|
|
1389
|
-
_context19.n =
|
|
1442
|
+
_context19.n = 6;
|
|
1390
1443
|
return performDryRunCall(true);
|
|
1391
|
-
case
|
|
1444
|
+
case 6:
|
|
1392
1445
|
result = _context19.v;
|
|
1393
1446
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1394
1447
|
if (!isSuccess) {
|
|
@@ -1396,16 +1449,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1396
1449
|
} else {
|
|
1397
1450
|
failureOutputReason = '';
|
|
1398
1451
|
}
|
|
1399
|
-
case
|
|
1452
|
+
case 7:
|
|
1400
1453
|
if (isSuccess) {
|
|
1401
|
-
_context19.n =
|
|
1454
|
+
_context19.n = 8;
|
|
1402
1455
|
break;
|
|
1403
1456
|
}
|
|
1404
1457
|
return _context19.a(2, Promise.resolve({
|
|
1405
1458
|
success: false,
|
|
1406
1459
|
failureReason: failureOutputReason
|
|
1407
1460
|
}));
|
|
1408
|
-
case
|
|
1461
|
+
case 8:
|
|
1409
1462
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1410
1463
|
weight = actualWeight ? {
|
|
1411
1464
|
refTime: actualWeight.ref_time,
|
|
@@ -1413,24 +1466,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1413
1466
|
} : undefined;
|
|
1414
1467
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1415
1468
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1416
|
-
_context19.n =
|
|
1417
|
-
return this.calculateTransactionFee(
|
|
1418
|
-
case
|
|
1469
|
+
_context19.n = 9;
|
|
1470
|
+
return this.calculateTransactionFee(resolvedTx, address);
|
|
1471
|
+
case 9:
|
|
1419
1472
|
executionFee = _context19.v;
|
|
1420
1473
|
nativeAsset = findAssetInfo(chain, {
|
|
1421
1474
|
symbol: Native(getNativeAssetSymbol(chain))
|
|
1422
1475
|
}, null);
|
|
1423
1476
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
1424
1477
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && nativeAsset && chain !== 'AssetHubPolkadot' && chain !== 'Kusama')) {
|
|
1425
|
-
_context19.n =
|
|
1478
|
+
_context19.n = 11;
|
|
1426
1479
|
break;
|
|
1427
1480
|
}
|
|
1428
|
-
_context19.n =
|
|
1481
|
+
_context19.n = 10;
|
|
1429
1482
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1430
|
-
case
|
|
1483
|
+
case 10:
|
|
1431
1484
|
xcmFee = _context19.v;
|
|
1432
1485
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1433
|
-
_context19.n =
|
|
1486
|
+
_context19.n = 11;
|
|
1434
1487
|
break;
|
|
1435
1488
|
}
|
|
1436
1489
|
return _context19.a(2, Promise.resolve({
|
|
@@ -1440,7 +1493,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1440
1493
|
forwardedXcms: forwardedXcms,
|
|
1441
1494
|
destParaId: destParaId
|
|
1442
1495
|
}));
|
|
1443
|
-
case
|
|
1496
|
+
case 11:
|
|
1444
1497
|
fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1445
1498
|
return _context19.a(2, Promise.resolve({
|
|
1446
1499
|
success: true,
|
|
@@ -1728,6 +1781,12 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1728
1781
|
};
|
|
1729
1782
|
}();
|
|
1730
1783
|
};
|
|
1784
|
+
var findFailingEvent = function findFailingEvent(result) {
|
|
1785
|
+
var _result$value;
|
|
1786
|
+
return (_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.emitted_events) === null || _result$value === void 0 ? void 0 : _result$value.find(function (event) {
|
|
1787
|
+
return event.type === 'Utility' && event.value.type === 'DispatchedAs' && event.value.value.result.success === false;
|
|
1788
|
+
});
|
|
1789
|
+
};
|
|
1731
1790
|
|
|
1732
1791
|
/**
|
|
1733
1792
|
* Retrieves the native balance for a given account on a specified chain.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@noble/hashes": "^1.8.0",
|
|
27
27
|
"viem": "^2.33.2",
|
|
28
|
-
"@paraspell/sdk-core": "11.
|
|
28
|
+
"@paraspell/sdk-core": "11.2.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"polkadot-api": ">= 1.15.2 < 2"
|