@paraspell/sdk 12.8.9 → 12.9.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 +5 -5
- package/dist/index.mjs +122 -73
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
|
|
30
30
|
### Install dependencies
|
|
31
31
|
|
|
32
|
-
ParaSpell XCM SDK is the 🥇 in the ecosystem to support
|
|
32
|
+
ParaSpell XCM SDK is the 🥇 in the ecosystem to support **PolkadotJS**, **Dedot** and **PolkadotAPI**.
|
|
33
33
|
|
|
34
|
-
**This version of SDK uses PolkadotAPI** if you wish to use **PolkadotJS** version please reffer to [following package](https://github.com/paraspell/xcm-tools/tree/main/packages/sdk-pjs).
|
|
34
|
+
**This version of SDK uses PolkadotAPI** if you wish to use **PolkadotJS** version please reffer to [following package](https://github.com/paraspell/xcm-tools/tree/main/packages/sdk-pjs) or **Dedot** please reffer to [following package](https://github.com/paraspell/xcm-tools/tree/main/packages/sdk-dedot).
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
#Polkadot API peer dependencies
|
|
39
|
-
|
|
39
|
+
npm install | pnpm add | yarn add polkadot-api
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
### Install SDK
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
|
|
45
|
+
npm install | pnpm add | yarn add @paraspell/sdk
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
### Install Swap extension
|
|
@@ -55,7 +55,7 @@ If you plan to do Swap XCMs you can install Swap package which allows you to do
|
|
|
55
55
|
> - ⚠️ **XCM Router has been migrated to the PAPI library.** If you used XCM Router prior to migration, replace the legacy Polkadot.js (PJS) injector with the PAPI signer and install the newly required peer dependency. Follow the setup guide for more information.
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
|
|
58
|
+
npm install | pnpm add | yarn add @paraspell/swap
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Importing package to your project
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache,
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, DEFAULT_TTL_MS, resolveChainApi, isExternalChain, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$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 { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
4
4
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
@@ -285,6 +285,83 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
289
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
290
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
291
|
+
var getLocationTokenId = function getLocationTokenId(location, chain) {
|
|
292
|
+
if (location.interior.type === 'Here') {
|
|
293
|
+
// native token
|
|
294
|
+
return getNativeAssetSymbol(chain);
|
|
295
|
+
}
|
|
296
|
+
var foreignAssets = getOtherAssets(chain);
|
|
297
|
+
if (location.interior.type === 'X2') {
|
|
298
|
+
if (location.interior.value[0].type === 'PalletInstance' && location.interior.value[0].value === 50 && location.interior.value[1].type === 'GeneralIndex') {
|
|
299
|
+
var _foreignAssets$find$a, _foreignAssets$find;
|
|
300
|
+
var assetId = location.interior.value[1].value;
|
|
301
|
+
return (_foreignAssets$find$a = (_foreignAssets$find = foreignAssets.find(function (asset) {
|
|
302
|
+
return asset.assetId === String(assetId);
|
|
303
|
+
})) === null || _foreignAssets$find === void 0 ? void 0 : _foreignAssets$find.assetId) !== null && _foreignAssets$find$a !== void 0 ? _foreignAssets$find$a : null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var computeOriginFee = function computeOriginFee(dryRun, chain, executionFee) {
|
|
310
|
+
var isFeeAsset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
311
|
+
// Extract delivery fees from emitted events
|
|
312
|
+
var deliveryFees = [];
|
|
313
|
+
var assetConversionFee = 0n;
|
|
314
|
+
var _iterator = _createForOfIteratorHelper(dryRun.value.emitted_events),
|
|
315
|
+
_step;
|
|
316
|
+
try {
|
|
317
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
318
|
+
var _e$value, _e$value2;
|
|
319
|
+
var e = _step.value;
|
|
320
|
+
var isXcmEvent = e.type === 'XcmPallet' || e.type === 'PolkadotXcm' || e.type === 'CumulusXcm';
|
|
321
|
+
var isFeesPaid = e.value.type === 'FeesPaid';
|
|
322
|
+
if (isXcmEvent && isFeesPaid && e.value.value.fees) {
|
|
323
|
+
var _iterator2 = _createForOfIteratorHelper(e.value.value.fees),
|
|
324
|
+
_step2;
|
|
325
|
+
try {
|
|
326
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
327
|
+
var feeItem = _step2.value;
|
|
328
|
+
if (feeItem.fun.type === 'NonFungible') continue;
|
|
329
|
+
var plancks = feeItem.fun.value;
|
|
330
|
+
var tokenSymbol = getLocationTokenId(feeItem.id, chain);
|
|
331
|
+
if (!tokenSymbol || !plancks) continue;
|
|
332
|
+
deliveryFees.push({
|
|
333
|
+
plancks: plancks,
|
|
334
|
+
tokenSymbol: tokenSymbol
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
} catch (err) {
|
|
338
|
+
_iterator2.e(err);
|
|
339
|
+
} finally {
|
|
340
|
+
_iterator2.f();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (isFeeAsset && e.type === 'AssetConversion' && ((_e$value = e.value) === null || _e$value === void 0 ? void 0 : _e$value.type) === 'SwapCreditExecuted' && (_e$value2 = e.value) !== null && _e$value2 !== void 0 && _e$value2.value && e.value.value.amount_in !== undefined && e.value.value.amount_in !== null) {
|
|
344
|
+
assetConversionFee += e.value.value.amount_in;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
} catch (err) {
|
|
348
|
+
_iterator.e(err);
|
|
349
|
+
} finally {
|
|
350
|
+
_iterator.f();
|
|
351
|
+
}
|
|
352
|
+
if (isFeeAsset && assetConversionFee > 0n) {
|
|
353
|
+
return assetConversionFee;
|
|
354
|
+
} else {
|
|
355
|
+
var nativeAssetSymbol = getNativeAssetSymbol(chain);
|
|
356
|
+
var totalDeliveryFees = deliveryFees.filter(function (df) {
|
|
357
|
+
return df.tokenSymbol === nativeAssetSymbol;
|
|
358
|
+
}).reduce(function (acc, df) {
|
|
359
|
+
return acc + df.plancks;
|
|
360
|
+
}, 0n);
|
|
361
|
+
return totalDeliveryFees + executionFee;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
288
365
|
var signEcdsa = function signEcdsa(input, privateKey) {
|
|
289
366
|
var signature = secp256k1.sign(keccak_256(input), privateKey, {
|
|
290
367
|
prehash: false,
|
|
@@ -332,10 +409,6 @@ var deriveAddress = function deriveAddress(sender) {
|
|
|
332
409
|
};
|
|
333
410
|
|
|
334
411
|
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'Pendulum'];
|
|
335
|
-
// Cache settings
|
|
336
|
-
var DEFAULT_TTL_MS = 60000; // 1 minute
|
|
337
|
-
var MAX_CLIENTS = 100;
|
|
338
|
-
var EXTENSION_MS = 5 * 60000; // 5 minutes
|
|
339
412
|
|
|
340
413
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
341
414
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
@@ -644,8 +717,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
644
717
|
key: "init",
|
|
645
718
|
value: function () {
|
|
646
719
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain) {
|
|
720
|
+
var _this = this;
|
|
647
721
|
var clientTtlMs,
|
|
648
|
-
apiConfig,
|
|
649
722
|
_args = arguments;
|
|
650
723
|
return _regenerator().w(function (_context2) {
|
|
651
724
|
while (1) switch (_context2.n) {
|
|
@@ -659,19 +732,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
659
732
|
case 1:
|
|
660
733
|
this._ttlMs = clientTtlMs;
|
|
661
734
|
this._chain = chain;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
throw new MissingChainApiError(chain);
|
|
735
|
+
_context2.n = 2;
|
|
736
|
+
return resolveChainApi(this._config, chain, function (wsUrl, c) {
|
|
737
|
+
return _this.createApiInstance(wsUrl, c);
|
|
738
|
+
});
|
|
668
739
|
case 2:
|
|
669
|
-
_context2.n = 3;
|
|
670
|
-
return this.resolveApi(apiConfig, chain);
|
|
671
|
-
case 3:
|
|
672
740
|
this.api = _context2.v;
|
|
673
741
|
this.initialized = true;
|
|
674
|
-
case
|
|
742
|
+
case 3:
|
|
675
743
|
return _context2.a(2);
|
|
676
744
|
}
|
|
677
745
|
}, _callee2, this);
|
|
@@ -681,27 +749,6 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
681
749
|
}
|
|
682
750
|
return init;
|
|
683
751
|
}()
|
|
684
|
-
}, {
|
|
685
|
-
key: "getApiConfigForChain",
|
|
686
|
-
value: function getApiConfigForChain(chain) {
|
|
687
|
-
if (isConfig(this._config)) {
|
|
688
|
-
var _this$_config$apiOver;
|
|
689
|
-
return (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[chain];
|
|
690
|
-
}
|
|
691
|
-
return this._config;
|
|
692
|
-
}
|
|
693
|
-
}, {
|
|
694
|
-
key: "resolveApi",
|
|
695
|
-
value: function resolveApi(apiConfig, chain) {
|
|
696
|
-
if (!apiConfig) {
|
|
697
|
-
var wsUrl = getChainProviders(chain);
|
|
698
|
-
return this.createApiInstance(wsUrl, chain);
|
|
699
|
-
}
|
|
700
|
-
if (typeof apiConfig === 'string' || apiConfig instanceof Array) {
|
|
701
|
-
return this.createApiInstance(apiConfig, chain);
|
|
702
|
-
}
|
|
703
|
-
return Promise.resolve(apiConfig);
|
|
704
|
-
}
|
|
705
752
|
}, {
|
|
706
753
|
key: "createApiInstance",
|
|
707
754
|
value: function createApiInstance(wsUrl, chain) {
|
|
@@ -781,14 +828,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
781
828
|
value: function callBatchMethod(calls, mode) {
|
|
782
829
|
var method = mode === BatchMode.BATCH_ALL ? 'batch_all' : 'batch';
|
|
783
830
|
return this.api.getUnsafeApi().tx.Utility[method]({
|
|
784
|
-
calls: calls.map(function (
|
|
785
|
-
|
|
831
|
+
calls: calls.map(function (_ref9) {
|
|
832
|
+
var decodedCall = _ref9.decodedCall;
|
|
833
|
+
return decodedCall;
|
|
786
834
|
})
|
|
787
835
|
});
|
|
788
836
|
}
|
|
789
837
|
}, {
|
|
790
838
|
key: "callDispatchAsMethod",
|
|
791
|
-
value: function callDispatchAsMethod(
|
|
839
|
+
value: function callDispatchAsMethod(_ref0, address) {
|
|
840
|
+
var decodedCall = _ref0.decodedCall;
|
|
792
841
|
var origin = {
|
|
793
842
|
type: 'system',
|
|
794
843
|
value: {
|
|
@@ -798,7 +847,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
798
847
|
};
|
|
799
848
|
return this.api.getUnsafeApi().tx.Utility.dispatch_as({
|
|
800
849
|
as_origin: origin,
|
|
801
|
-
call:
|
|
850
|
+
call: decodedCall
|
|
802
851
|
});
|
|
803
852
|
}
|
|
804
853
|
}, {
|
|
@@ -1010,9 +1059,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1010
1059
|
}()
|
|
1011
1060
|
}, {
|
|
1012
1061
|
key: "resolveDefaultFeeAsset",
|
|
1013
|
-
value: function resolveDefaultFeeAsset(
|
|
1014
|
-
var chain =
|
|
1015
|
-
feeAsset =
|
|
1062
|
+
value: function resolveDefaultFeeAsset(_ref1) {
|
|
1063
|
+
var chain = _ref1.chain,
|
|
1064
|
+
feeAsset = _ref1.feeAsset;
|
|
1016
1065
|
return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
|
|
1017
1066
|
}
|
|
1018
1067
|
}, {
|
|
@@ -1064,13 +1113,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1064
1113
|
key: "getDryRunCall",
|
|
1065
1114
|
value: function () {
|
|
1066
1115
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
|
|
1067
|
-
var
|
|
1068
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3;
|
|
1116
|
+
var _this2 = this;
|
|
1117
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3;
|
|
1069
1118
|
return _regenerator().w(function (_context10) {
|
|
1070
1119
|
while (1) switch (_context10.n) {
|
|
1071
1120
|
case 0:
|
|
1072
1121
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1073
|
-
|
|
1122
|
+
_getAssetsObject = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject.supportsDryRunApi;
|
|
1074
1123
|
if (supportsDryRunApi) {
|
|
1075
1124
|
_context10.n = 1;
|
|
1076
1125
|
break;
|
|
@@ -1103,8 +1152,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1103
1152
|
case 4:
|
|
1104
1153
|
resolvedTx = _t2;
|
|
1105
1154
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1106
|
-
var
|
|
1107
|
-
var
|
|
1155
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(includeVersion) {
|
|
1156
|
+
var _this2$api$getUnsafeA;
|
|
1108
1157
|
var callArgs, versionNum;
|
|
1109
1158
|
return _regenerator().w(function (_context1) {
|
|
1110
1159
|
while (1) switch (_context1.n) {
|
|
@@ -1114,12 +1163,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1114
1163
|
versionNum = Number(version.charAt(1));
|
|
1115
1164
|
callArgs.push(versionNum);
|
|
1116
1165
|
}
|
|
1117
|
-
return _context1.a(2, (
|
|
1166
|
+
return _context1.a(2, (_this2$api$getUnsafeA = _this2.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this2$api$getUnsafeA, callArgs));
|
|
1118
1167
|
}
|
|
1119
1168
|
}, _callee1);
|
|
1120
1169
|
}));
|
|
1121
1170
|
return function performDryRunCall(_x18) {
|
|
1122
|
-
return
|
|
1171
|
+
return _ref10.apply(this, arguments);
|
|
1123
1172
|
};
|
|
1124
1173
|
}();
|
|
1125
1174
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
@@ -1151,7 +1200,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1151
1200
|
return result;
|
|
1152
1201
|
};
|
|
1153
1202
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1154
|
-
var _obj$value,
|
|
1203
|
+
var _obj$value, _ref11, _result$value6;
|
|
1155
1204
|
var obj = findFailureObjectFromResult(result);
|
|
1156
1205
|
if (obj !== null && obj !== void 0 && obj.type && obj !== null && obj !== void 0 && (_obj$value = obj.value) !== null && _obj$value !== void 0 && (_obj$value = _obj$value.error) !== null && _obj$value !== void 0 && _obj$value.type) {
|
|
1157
1206
|
return {
|
|
@@ -1165,7 +1214,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1165
1214
|
};
|
|
1166
1215
|
}
|
|
1167
1216
|
return {
|
|
1168
|
-
failureReason: JSON.stringify((
|
|
1217
|
+
failureReason: JSON.stringify((_ref11 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref11 !== void 0 ? _ref11 : 'Unknown error structure', replaceBigInt)
|
|
1169
1218
|
};
|
|
1170
1219
|
};
|
|
1171
1220
|
failureOutputReason = {
|
|
@@ -1268,7 +1317,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1268
1317
|
case 16:
|
|
1269
1318
|
_yield$this$getPaymen = _context10.v;
|
|
1270
1319
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1271
|
-
fee =
|
|
1320
|
+
fee = computeOriginFee(result, chain, executionFee, !!feeAsset);
|
|
1272
1321
|
return _context10.a(2, Promise.resolve({
|
|
1273
1322
|
success: true,
|
|
1274
1323
|
fee: fee,
|
|
@@ -1391,7 +1440,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1391
1440
|
key: "getXcmPaymentApiFee",
|
|
1392
1441
|
value: function () {
|
|
1393
1442
|
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset, version) {
|
|
1394
|
-
var
|
|
1443
|
+
var _this3 = this,
|
|
1395
1444
|
_execFeeRes$value;
|
|
1396
1445
|
var transformXcm,
|
|
1397
1446
|
overridenWeight,
|
|
@@ -1413,13 +1462,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1413
1462
|
overridenWeight = _args13.length > 6 ? _args13[6] : undefined;
|
|
1414
1463
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1415
1464
|
queryWeight = /*#__PURE__*/function () {
|
|
1416
|
-
var
|
|
1465
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1417
1466
|
var weightRes;
|
|
1418
1467
|
return _regenerator().w(function (_context13) {
|
|
1419
1468
|
while (1) switch (_context13.n) {
|
|
1420
1469
|
case 0:
|
|
1421
1470
|
_context13.n = 1;
|
|
1422
|
-
return
|
|
1471
|
+
return _this3.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1423
1472
|
case 1:
|
|
1424
1473
|
weightRes = _context13.v;
|
|
1425
1474
|
return _context13.a(2, weightRes.value);
|
|
@@ -1427,7 +1476,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1427
1476
|
}, _callee13);
|
|
1428
1477
|
}));
|
|
1429
1478
|
return function queryWeight() {
|
|
1430
|
-
return
|
|
1479
|
+
return _ref12.apply(this, arguments);
|
|
1431
1480
|
};
|
|
1432
1481
|
}();
|
|
1433
1482
|
if (!overridenWeight) {
|
|
@@ -1531,14 +1580,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1531
1580
|
}, {
|
|
1532
1581
|
key: "getDryRunXcm",
|
|
1533
1582
|
value: function () {
|
|
1534
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(
|
|
1535
|
-
var
|
|
1536
|
-
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1583
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref13) {
|
|
1584
|
+
var _ref14, _processAssetsDeposit, _ref15, _ref16, _ref17, _ref18, _ref19;
|
|
1585
|
+
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1537
1586
|
return _regenerator().w(function (_context16) {
|
|
1538
1587
|
while (1) switch (_context16.n) {
|
|
1539
1588
|
case 0:
|
|
1540
|
-
originLocation =
|
|
1541
|
-
|
|
1589
|
+
originLocation = _ref13.originLocation, xcm = _ref13.xcm, chain = _ref13.chain, origin = _ref13.origin, asset = _ref13.asset, feeAsset = _ref13.feeAsset, originFee = _ref13.originFee, amount = _ref13.amount, version = _ref13.version;
|
|
1590
|
+
_getAssetsObject2 = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject2.supportsDryRunApi;
|
|
1542
1591
|
if (supportsDryRunApi) {
|
|
1543
1592
|
_context16.n = 1;
|
|
1544
1593
|
break;
|
|
@@ -1594,15 +1643,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1594
1643
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1595
1644
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1596
1645
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1597
|
-
feeAssetFeeEvent = (
|
|
1646
|
+
feeAssetFeeEvent = (_ref14 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1598
1647
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1599
|
-
}) : undefined) !== null &&
|
|
1648
|
+
}) : undefined) !== null && _ref14 !== void 0 ? _ref14 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1600
1649
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1601
1650
|
}) : undefined;
|
|
1602
1651
|
processedAssetsAmount = chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount, 'Assets', 'Deposited', true) : (_processAssetsDeposit = processAssetsDepositedEvents(emitted, amount, 'Balances', 'Minted', false)) !== null && _processAssetsDeposit !== void 0 ? _processAssetsDeposit : processAssetsDepositedEvents(emitted, amount, 'Balances', 'Issued', false);
|
|
1603
|
-
feeEvent = (
|
|
1652
|
+
feeEvent = (_ref15 = (_ref16 = (_ref17 = (_ref18 = (_ref19 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent : chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1604
1653
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1605
|
-
}) : undefined) !== null &&
|
|
1654
|
+
}) : undefined) !== null && _ref19 !== void 0 ? _ref19 : processedAssetsAmount !== undefined ? {
|
|
1606
1655
|
type: 'Assets',
|
|
1607
1656
|
value: {
|
|
1608
1657
|
type: 'Deposited',
|
|
@@ -1610,17 +1659,17 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1610
1659
|
amount: processedAssetsAmount
|
|
1611
1660
|
}
|
|
1612
1661
|
}
|
|
1613
|
-
} : undefined) !== null &&
|
|
1662
|
+
} : undefined) !== null && _ref18 !== void 0 ? _ref18 : origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1614
1663
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1615
|
-
}) : undefined) !== null &&
|
|
1664
|
+
}) : undefined) !== null && _ref17 !== void 0 ? _ref17 :
|
|
1616
1665
|
// Prefer to Minted event
|
|
1617
1666
|
reversedEvents.find(function (event) {
|
|
1618
1667
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1619
|
-
})) !== null &&
|
|
1668
|
+
})) !== null && _ref16 !== void 0 ? _ref16 :
|
|
1620
1669
|
// Fallback an Issued event
|
|
1621
1670
|
reversedEvents.find(function (event) {
|
|
1622
1671
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1623
|
-
})) !== null &&
|
|
1672
|
+
})) !== null && _ref15 !== void 0 ? _ref15 : reversedEvents.find(function (event) {
|
|
1624
1673
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1625
1674
|
});
|
|
1626
1675
|
if (feeEvent) {
|
|
@@ -1688,11 +1737,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1688
1737
|
}, {
|
|
1689
1738
|
key: "disconnect",
|
|
1690
1739
|
value: function disconnect() {
|
|
1691
|
-
var _this$_config$
|
|
1740
|
+
var _this$_config$apiOver;
|
|
1692
1741
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1693
1742
|
if (!this.initialized) return Promise.resolve();
|
|
1694
1743
|
if (!force && !this.disconnectAllowed) return Promise.resolve();
|
|
1695
|
-
var api = isConfig(this._config) ? (_this$_config$
|
|
1744
|
+
var api = isConfig(this._config) ? (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[this._chain] : this._config;
|
|
1696
1745
|
// Own client provided, destroy only if force true
|
|
1697
1746
|
if (force && _typeof(api) === 'object') {
|
|
1698
1747
|
this.api.destroy();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.1",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@polkadot-labs/hdkd": "^0.0.26",
|
|
29
29
|
"@polkadot-labs/hdkd-helpers": "^0.0.27",
|
|
30
30
|
"viem": "^2.47.1",
|
|
31
|
-
"@paraspell/sdk-core": "12.
|
|
31
|
+
"@paraspell/sdk-core": "12.9.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"polkadot-api": ">= 1.23.3 < 2"
|