@paraspell/sdk-pjs 12.0.4 → 12.0.5
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 +16 -16
- package/dist/index.mjs +207 -146
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ For full documentation on XCM Transfers head over to [official documentation](ht
|
|
|
86
86
|
|
|
87
87
|
```ts
|
|
88
88
|
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
89
|
-
.from(
|
|
89
|
+
.from(TSubstrateChain)
|
|
90
90
|
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
|
|
91
91
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
92
92
|
.address(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
|
|
@@ -157,7 +157,7 @@ await builder.disconnect()
|
|
|
157
157
|
|
|
158
158
|
```ts
|
|
159
159
|
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
160
|
-
.from(
|
|
160
|
+
.from(TSubstrateChain)
|
|
161
161
|
.to(TRelaychain) // Kusama | Polkadot | Westend | Paseo
|
|
162
162
|
.currency({symbol: 'DOT', amount: amount /*Use "ALL" to transfer everything*/})
|
|
163
163
|
.address(address | Location object)
|
|
@@ -191,7 +191,7 @@ await builder.disconnect()
|
|
|
191
191
|
|
|
192
192
|
```ts
|
|
193
193
|
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
194
|
-
.from(
|
|
194
|
+
.from(TSubstrateChain)
|
|
195
195
|
.to(TChain) //Has to be the same as the origin (from)
|
|
196
196
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
197
197
|
.address(address)
|
|
@@ -223,13 +223,13 @@ await builder.disconnect()
|
|
|
223
223
|
|
|
224
224
|
```ts
|
|
225
225
|
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
226
|
-
.from(
|
|
226
|
+
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
227
227
|
.to(TChain2) //Any compatible Parachain
|
|
228
228
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
229
229
|
.address(address | Location object)
|
|
230
230
|
.addToBatch()
|
|
231
231
|
|
|
232
|
-
.from(
|
|
232
|
+
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
233
233
|
.to(TChain3) //Any compatible Parachain
|
|
234
234
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
235
235
|
.address(address | Location object)
|
|
@@ -249,7 +249,7 @@ await builder.disconnect()
|
|
|
249
249
|
```ts
|
|
250
250
|
//Claim XCM trapped assets from the selected chain
|
|
251
251
|
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
252
|
-
.
|
|
252
|
+
.claimfrom(TSubstrateChain)
|
|
253
253
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..]
|
|
254
254
|
)
|
|
255
255
|
.address(address | Location object)
|
|
@@ -265,7 +265,7 @@ await builder.disconnect()
|
|
|
265
265
|
```ts
|
|
266
266
|
//Builder pattern
|
|
267
267
|
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
268
|
-
.from(
|
|
268
|
+
.from(TSubstrateChain)
|
|
269
269
|
.to(TChain)
|
|
270
270
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
271
271
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
@@ -284,7 +284,7 @@ const result = hasDryRunSupport(chain)
|
|
|
284
284
|
```ts
|
|
285
285
|
//Builder pattern
|
|
286
286
|
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
287
|
-
.from(
|
|
287
|
+
.from(TSubstrateChain)
|
|
288
288
|
.to(TChain)
|
|
289
289
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
290
290
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
@@ -305,7 +305,7 @@ const builder = await Builder({
|
|
|
305
305
|
//ChainName: ...
|
|
306
306
|
}
|
|
307
307
|
})
|
|
308
|
-
.from(
|
|
308
|
+
.from(TSubstrateChain)
|
|
309
309
|
.to(TChain)
|
|
310
310
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}])
|
|
311
311
|
.address(address)
|
|
@@ -323,7 +323,7 @@ For full documentation with output examples of XCM Fee queries, head to [officia
|
|
|
323
323
|
#### XCM Transfer info
|
|
324
324
|
```ts
|
|
325
325
|
const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
326
|
-
.from(
|
|
326
|
+
.from(TSubstrateChain)
|
|
327
327
|
.to(TChain)
|
|
328
328
|
.currency(CURRENCY_SPEC)
|
|
329
329
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -335,7 +335,7 @@ const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
335
335
|
#### Transferable amount
|
|
336
336
|
```ts
|
|
337
337
|
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
338
|
-
.from(
|
|
338
|
+
.from(TSubstrateChain)
|
|
339
339
|
.to(TChain)
|
|
340
340
|
.currency(CURRENCY_SPEC)
|
|
341
341
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -347,7 +347,7 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
347
347
|
#### Minimal transferable amount
|
|
348
348
|
```ts
|
|
349
349
|
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
350
|
-
.from(
|
|
350
|
+
.from(TSubstrateChain)
|
|
351
351
|
.to(TChain)
|
|
352
352
|
.currency(CURRENCY_SPEC)
|
|
353
353
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -359,7 +359,7 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
359
359
|
#### Receivable amount
|
|
360
360
|
```ts
|
|
361
361
|
const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
362
|
-
.from(
|
|
362
|
+
.from(TSubstrateChain)
|
|
363
363
|
.to(TChain)
|
|
364
364
|
.currency(CURRENCY_SPEC)
|
|
365
365
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -371,7 +371,7 @@ const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url
|
|
|
371
371
|
#### Verify ED on destination
|
|
372
372
|
```ts
|
|
373
373
|
const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
374
|
-
.from(
|
|
374
|
+
.from(TSubstrateChain)
|
|
375
375
|
.to(TChain)
|
|
376
376
|
.currency(CURRENCY_SPEC)
|
|
377
377
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -384,7 +384,7 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
384
384
|
|
|
385
385
|
```ts
|
|
386
386
|
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
387
|
-
.from(
|
|
387
|
+
.from(TSubstrateChain)
|
|
388
388
|
.to(TChain)
|
|
389
389
|
.currency(CURRENCY_SPEC)
|
|
390
390
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
@@ -397,7 +397,7 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
397
397
|
|
|
398
398
|
```ts
|
|
399
399
|
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
400
|
-
.from(
|
|
400
|
+
.from(TSubstrateChain)
|
|
401
401
|
.to(TChain)
|
|
402
402
|
.currency(CURRENCY_SPEC)
|
|
403
403
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isConfig, BatchMode, MissingChainApiError, getChainProviders, UnsupportedOperationError,
|
|
1
|
+
import { isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
@@ -580,19 +580,72 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
580
580
|
}
|
|
581
581
|
return createApiForChain;
|
|
582
582
|
}()
|
|
583
|
+
}, {
|
|
584
|
+
key: "resolveDefaultFeeAsset",
|
|
585
|
+
value: function resolveDefaultFeeAsset(_ref2) {
|
|
586
|
+
var chain = _ref2.chain,
|
|
587
|
+
feeAsset = _ref2.feeAsset;
|
|
588
|
+
return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
|
|
589
|
+
}
|
|
590
|
+
}, {
|
|
591
|
+
key: "resolveFeeAsset",
|
|
592
|
+
value: function () {
|
|
593
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(options) {
|
|
594
|
+
var chain, address, response, assetId;
|
|
595
|
+
return _regenerator().w(function (_context9) {
|
|
596
|
+
while (1) switch (_context9.n) {
|
|
597
|
+
case 0:
|
|
598
|
+
chain = options.chain, address = options.address;
|
|
599
|
+
if (chain.startsWith('Hydration')) {
|
|
600
|
+
_context9.n = 1;
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
return _context9.a(2, {
|
|
604
|
+
isCustomAsset: false,
|
|
605
|
+
asset: this.resolveDefaultFeeAsset(options)
|
|
606
|
+
});
|
|
607
|
+
case 1:
|
|
608
|
+
_context9.n = 2;
|
|
609
|
+
return this.api.query.multiTransactionPayment.accountCurrencyMap(address);
|
|
610
|
+
case 2:
|
|
611
|
+
response = _context9.v;
|
|
612
|
+
assetId = response.toJSON();
|
|
613
|
+
if (!(assetId === null)) {
|
|
614
|
+
_context9.n = 3;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
return _context9.a(2, {
|
|
618
|
+
isCustomAsset: false,
|
|
619
|
+
asset: this.resolveDefaultFeeAsset(options)
|
|
620
|
+
});
|
|
621
|
+
case 3:
|
|
622
|
+
return _context9.a(2, {
|
|
623
|
+
isCustomAsset: true,
|
|
624
|
+
asset: findAssetInfoOrThrow(chain, {
|
|
625
|
+
id: assetId
|
|
626
|
+
}, null)
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}, _callee9, this);
|
|
630
|
+
}));
|
|
631
|
+
function resolveFeeAsset(_x15) {
|
|
632
|
+
return _resolveFeeAsset.apply(this, arguments);
|
|
633
|
+
}
|
|
634
|
+
return resolveFeeAsset;
|
|
635
|
+
}()
|
|
583
636
|
}, {
|
|
584
637
|
key: "getDryRunCall",
|
|
585
638
|
value: function () {
|
|
586
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
639
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
|
|
587
640
|
var _this = this;
|
|
588
|
-
var tx, address, feeAsset, chain, destination, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx,
|
|
589
|
-
return _regenerator().w(function (
|
|
590
|
-
while (1) switch (
|
|
641
|
+
var tx, address, feeAsset, chain, destination, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, nativeAsset, hasLocation, destParaId, xcmFee, executionFee, fee, _t, _t2, _t3;
|
|
642
|
+
return _regenerator().w(function (_context1) {
|
|
643
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
591
644
|
case 0:
|
|
592
645
|
tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
|
|
593
646
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
594
647
|
if (supportsDryRunApi) {
|
|
595
|
-
|
|
648
|
+
_context1.n = 1;
|
|
596
649
|
break;
|
|
597
650
|
}
|
|
598
651
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
@@ -608,34 +661,37 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
608
661
|
}
|
|
609
662
|
};
|
|
610
663
|
if (!useRootOrigin) {
|
|
611
|
-
|
|
664
|
+
_context1.n = 3;
|
|
612
665
|
break;
|
|
613
666
|
}
|
|
614
|
-
|
|
667
|
+
_context1.n = 2;
|
|
615
668
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
616
669
|
api: this
|
|
617
670
|
}), bypassOptions);
|
|
618
671
|
case 2:
|
|
619
|
-
_t =
|
|
620
|
-
|
|
672
|
+
_t = _context1.v;
|
|
673
|
+
_context1.n = 4;
|
|
621
674
|
break;
|
|
622
675
|
case 3:
|
|
623
676
|
_t = tx;
|
|
624
677
|
case 4:
|
|
625
678
|
resolvedTx = _t;
|
|
626
|
-
|
|
679
|
+
_context1.n = 5;
|
|
680
|
+
return this.resolveFeeAsset(options);
|
|
681
|
+
case 5:
|
|
682
|
+
resolvedFeeAsset = _context1.v;
|
|
627
683
|
performDryRunCall = /*#__PURE__*/function () {
|
|
628
|
-
var
|
|
684
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
|
|
629
685
|
var _this$api$call$dryRun;
|
|
630
|
-
return _regenerator().w(function (
|
|
631
|
-
while (1) switch (
|
|
686
|
+
return _regenerator().w(function (_context0) {
|
|
687
|
+
while (1) switch (_context0.n) {
|
|
632
688
|
case 0:
|
|
633
|
-
return
|
|
689
|
+
return _context0.a(2, (_this$api$call$dryRun = _this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [DEFAULT_XCM_VERSION] : []))));
|
|
634
690
|
}
|
|
635
|
-
},
|
|
691
|
+
}, _callee0);
|
|
636
692
|
}));
|
|
637
|
-
return function performDryRunCall(
|
|
638
|
-
return
|
|
693
|
+
return function performDryRunCall(_x17) {
|
|
694
|
+
return _ref3.apply(this, arguments);
|
|
639
695
|
};
|
|
640
696
|
}();
|
|
641
697
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(resultHuman) {
|
|
@@ -643,7 +699,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
643
699
|
return Boolean((resultHuman === null || resultHuman === void 0 ? void 0 : resultHuman.Ok) && ((_resultHuman$Ok$execu = resultHuman.Ok.executionResult) === null || _resultHuman$Ok$execu === void 0 ? void 0 : _resultHuman$Ok$execu.Ok));
|
|
644
700
|
};
|
|
645
701
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(resultHuman, resultJson) {
|
|
646
|
-
var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok,
|
|
702
|
+
var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok, _ref4;
|
|
647
703
|
var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok = resultHuman.Ok) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.executionResult) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.Err) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.error) === null || _resultHuman$Ok === void 0 ? void 0 : _resultHuman$Ok.Module;
|
|
648
704
|
if (modErrHuman) {
|
|
649
705
|
return resolveModuleError(chain, modErrHuman);
|
|
@@ -664,7 +720,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
664
720
|
};
|
|
665
721
|
}
|
|
666
722
|
return {
|
|
667
|
-
failureReason: JSON.stringify((
|
|
723
|
+
failureReason: JSON.stringify((_ref4 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref4 !== void 0 ? _ref4 : 'Unknown error')
|
|
668
724
|
};
|
|
669
725
|
}; // Attempt 1: WITHOUT version
|
|
670
726
|
isSuccess = false;
|
|
@@ -672,11 +728,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
672
728
|
failureReason: ''
|
|
673
729
|
};
|
|
674
730
|
shouldRetryWithVersion = false;
|
|
675
|
-
|
|
676
|
-
|
|
731
|
+
_context1.p = 6;
|
|
732
|
+
_context1.n = 7;
|
|
677
733
|
return performDryRunCall(false);
|
|
678
|
-
case
|
|
679
|
-
response =
|
|
734
|
+
case 7:
|
|
735
|
+
response = _context1.v;
|
|
680
736
|
resultHuman = response.toHuman();
|
|
681
737
|
resultJson = response.toJSON();
|
|
682
738
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
@@ -686,66 +742,66 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
686
742
|
shouldRetryWithVersion = true;
|
|
687
743
|
}
|
|
688
744
|
}
|
|
689
|
-
|
|
745
|
+
_context1.n = 10;
|
|
690
746
|
break;
|
|
691
|
-
case
|
|
692
|
-
|
|
693
|
-
_t2 =
|
|
747
|
+
case 8:
|
|
748
|
+
_context1.p = 8;
|
|
749
|
+
_t2 = _context1.v;
|
|
694
750
|
msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
695
751
|
if (!msg.includes('Expected 3 arguments')) {
|
|
696
|
-
|
|
752
|
+
_context1.n = 9;
|
|
697
753
|
break;
|
|
698
754
|
}
|
|
699
755
|
shouldRetryWithVersion = true;
|
|
700
|
-
|
|
756
|
+
_context1.n = 10;
|
|
701
757
|
break;
|
|
702
|
-
case
|
|
703
|
-
return
|
|
758
|
+
case 9:
|
|
759
|
+
return _context1.a(2, {
|
|
704
760
|
success: false,
|
|
705
761
|
failureReason: msg,
|
|
706
|
-
asset:
|
|
762
|
+
asset: resolvedFeeAsset.asset
|
|
707
763
|
});
|
|
708
|
-
case
|
|
764
|
+
case 10:
|
|
709
765
|
if (!shouldRetryWithVersion) {
|
|
710
|
-
|
|
766
|
+
_context1.n = 14;
|
|
711
767
|
break;
|
|
712
768
|
}
|
|
713
|
-
|
|
714
|
-
|
|
769
|
+
_context1.p = 11;
|
|
770
|
+
_context1.n = 12;
|
|
715
771
|
return performDryRunCall(true);
|
|
716
|
-
case
|
|
717
|
-
response =
|
|
772
|
+
case 12:
|
|
773
|
+
response = _context1.v;
|
|
718
774
|
resultHuman = response.toHuman();
|
|
719
775
|
resultJson = response.toJSON();
|
|
720
776
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
721
777
|
if (!isSuccess) {
|
|
722
778
|
failureErr = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
723
779
|
}
|
|
724
|
-
|
|
780
|
+
_context1.n = 14;
|
|
725
781
|
break;
|
|
726
|
-
case
|
|
727
|
-
|
|
728
|
-
_t3 =
|
|
782
|
+
case 13:
|
|
783
|
+
_context1.p = 13;
|
|
784
|
+
_t3 = _context1.v;
|
|
729
785
|
_msg = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
730
786
|
failureErr = failureErr || _msg;
|
|
731
|
-
return
|
|
787
|
+
return _context1.a(2, {
|
|
732
788
|
success: false,
|
|
733
789
|
failureReason: failureErr.failureReason,
|
|
734
790
|
failureSubReason: failureErr.failureSubReason,
|
|
735
|
-
asset:
|
|
791
|
+
asset: resolvedFeeAsset.asset
|
|
736
792
|
});
|
|
737
|
-
case
|
|
793
|
+
case 14:
|
|
738
794
|
if (isSuccess) {
|
|
739
|
-
|
|
795
|
+
_context1.n = 15;
|
|
740
796
|
break;
|
|
741
797
|
}
|
|
742
|
-
return
|
|
798
|
+
return _context1.a(2, {
|
|
743
799
|
success: false,
|
|
744
800
|
failureReason: failureErr.failureReason || 'Unknown error',
|
|
745
801
|
failureSubReason: failureErr.failureSubReason,
|
|
746
|
-
asset:
|
|
802
|
+
asset: resolvedFeeAsset.asset
|
|
747
803
|
});
|
|
748
|
-
case
|
|
804
|
+
case 15:
|
|
749
805
|
forwardedXcms = resultJson.ok.forwardedXcms.length > 0 ? resultJson.ok.forwardedXcms[0] : [];
|
|
750
806
|
actualWeight = resultJson.ok.executionResult.ok.actualWeight;
|
|
751
807
|
weight = actualWeight ? {
|
|
@@ -754,47 +810,52 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
754
810
|
} : undefined;
|
|
755
811
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
756
812
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
757
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
758
|
-
return i.here === null ? 0 : (
|
|
813
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref5) {
|
|
814
|
+
return i.here === null ? 0 : (_ref5 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref5 === void 0 ? void 0 : _ref5.parachain;
|
|
759
815
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
760
|
-
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum'))) {
|
|
761
|
-
|
|
816
|
+
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
817
|
+
_context1.n = 18;
|
|
762
818
|
break;
|
|
763
819
|
}
|
|
764
|
-
|
|
820
|
+
_context1.n = 16;
|
|
765
821
|
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
766
|
-
case
|
|
767
|
-
xcmFee =
|
|
822
|
+
case 16:
|
|
823
|
+
xcmFee = _context1.v;
|
|
768
824
|
if (!(typeof xcmFee === 'bigint')) {
|
|
769
|
-
|
|
825
|
+
_context1.n = 17;
|
|
770
826
|
break;
|
|
771
827
|
}
|
|
772
|
-
return
|
|
828
|
+
return _context1.a(2, Promise.resolve({
|
|
773
829
|
success: true,
|
|
774
830
|
fee: xcmFee,
|
|
775
|
-
asset:
|
|
831
|
+
asset: resolvedFeeAsset.asset,
|
|
776
832
|
weight: weight,
|
|
777
833
|
forwardedXcms: forwardedXcms,
|
|
778
834
|
destParaId: destParaId
|
|
779
835
|
}));
|
|
780
|
-
case 16:
|
|
781
|
-
_context0.n = 17;
|
|
782
|
-
return this.calculateTransactionFee(tx, address);
|
|
783
836
|
case 17:
|
|
784
|
-
|
|
837
|
+
resolvedFeeAsset = {
|
|
838
|
+
isCustomAsset: false,
|
|
839
|
+
asset: this.resolveDefaultFeeAsset(options)
|
|
840
|
+
};
|
|
841
|
+
case 18:
|
|
842
|
+
_context1.n = 19;
|
|
843
|
+
return this.calculateTransactionFee(tx, address);
|
|
844
|
+
case 19:
|
|
845
|
+
executionFee = _context1.v;
|
|
785
846
|
fee = computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
786
|
-
return
|
|
847
|
+
return _context1.a(2, {
|
|
787
848
|
success: true,
|
|
788
849
|
fee: fee,
|
|
789
|
-
asset:
|
|
850
|
+
asset: resolvedFeeAsset.asset,
|
|
790
851
|
weight: weight,
|
|
791
852
|
forwardedXcms: forwardedXcms,
|
|
792
853
|
destParaId: destParaId
|
|
793
854
|
});
|
|
794
855
|
}
|
|
795
|
-
},
|
|
856
|
+
}, _callee1, this, [[11, 13], [6, 8]]);
|
|
796
857
|
}));
|
|
797
|
-
function getDryRunCall(
|
|
858
|
+
function getDryRunCall(_x16) {
|
|
798
859
|
return _getDryRunCall.apply(this, arguments);
|
|
799
860
|
}
|
|
800
861
|
return getDryRunCall;
|
|
@@ -802,68 +863,68 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
802
863
|
}, {
|
|
803
864
|
key: "getXcmPaymentApiFee",
|
|
804
865
|
value: function () {
|
|
805
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
806
|
-
var
|
|
866
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, localXcm, forwardedXcm, asset) {
|
|
867
|
+
var _ref6, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref7, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
|
|
807
868
|
var weight, assetLocalizedLoc, feeResult, execFeeRes, execFee, deliveryFeeRes, deliveryFeeResJson, deliveryFeeResolved, nativeAsset, deliveryFee, res, _t4;
|
|
808
|
-
return _regenerator().w(function (
|
|
809
|
-
while (1) switch (
|
|
869
|
+
return _regenerator().w(function (_context10) {
|
|
870
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
810
871
|
case 0:
|
|
811
|
-
|
|
872
|
+
_context10.n = 1;
|
|
812
873
|
return this.getXcmWeight(localXcm);
|
|
813
874
|
case 1:
|
|
814
|
-
weight =
|
|
875
|
+
weight = _context10.v;
|
|
815
876
|
assertHasLocation(asset);
|
|
816
877
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
817
|
-
|
|
878
|
+
_context10.n = 2;
|
|
818
879
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc, Version.V4));
|
|
819
880
|
case 2:
|
|
820
|
-
feeResult =
|
|
881
|
+
feeResult = _context10.v;
|
|
821
882
|
execFeeRes = feeResult.toJSON();
|
|
822
883
|
execFee = BigInt(execFeeRes.ok);
|
|
823
884
|
if (!(forwardedXcm.length > 0)) {
|
|
824
|
-
|
|
885
|
+
_context10.n = 4;
|
|
825
886
|
break;
|
|
826
887
|
}
|
|
827
|
-
|
|
888
|
+
_context10.n = 3;
|
|
828
889
|
return this.api.call.xcmPaymentApi.queryDeliveryFees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
829
890
|
case 3:
|
|
830
|
-
_t4 =
|
|
831
|
-
|
|
891
|
+
_t4 = _context10.v;
|
|
892
|
+
_context10.n = 5;
|
|
832
893
|
break;
|
|
833
894
|
case 4:
|
|
834
895
|
_t4 = undefined;
|
|
835
896
|
case 5:
|
|
836
897
|
deliveryFeeRes = _t4;
|
|
837
898
|
deliveryFeeResJson = deliveryFeeRes === null || deliveryFeeRes === void 0 ? void 0 : deliveryFeeRes.toJSON();
|
|
838
|
-
deliveryFeeResolved = deliveryFeeRes && ((
|
|
899
|
+
deliveryFeeResolved = deliveryFeeRes && ((_ref6 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref6 === void 0 ? void 0 : _ref6.length) > 0 ? BigInt((_ref7 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref7 === void 0 || (_ref7 = _ref7[0]) === null || _ref7 === void 0 || (_ref7 = _ref7.fun) === null || _ref7 === void 0 ? void 0 : _ref7.fungible) : 0n;
|
|
839
900
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
840
901
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
841
|
-
|
|
902
|
+
_context10.n = 6;
|
|
842
903
|
break;
|
|
843
904
|
}
|
|
844
905
|
deliveryFee = deliveryFeeResolved;
|
|
845
|
-
|
|
906
|
+
_context10.n = 9;
|
|
846
907
|
break;
|
|
847
908
|
case 6:
|
|
848
|
-
|
|
909
|
+
_context10.p = 6;
|
|
849
910
|
assertHasLocation(nativeAsset);
|
|
850
|
-
|
|
911
|
+
_context10.n = 7;
|
|
851
912
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
852
913
|
case 7:
|
|
853
|
-
res =
|
|
914
|
+
res = _context10.v;
|
|
854
915
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
855
|
-
|
|
916
|
+
_context10.n = 9;
|
|
856
917
|
break;
|
|
857
918
|
case 8:
|
|
858
|
-
|
|
859
|
-
|
|
919
|
+
_context10.p = 8;
|
|
920
|
+
_context10.v;
|
|
860
921
|
deliveryFee = 0n;
|
|
861
922
|
case 9:
|
|
862
|
-
return
|
|
923
|
+
return _context10.a(2, execFee + deliveryFee);
|
|
863
924
|
}
|
|
864
|
-
},
|
|
925
|
+
}, _callee10, this, [[6, 8]]);
|
|
865
926
|
}));
|
|
866
|
-
function getXcmPaymentApiFee(
|
|
927
|
+
function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
|
|
867
928
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
868
929
|
}
|
|
869
930
|
return getXcmPaymentApiFee;
|
|
@@ -871,21 +932,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
871
932
|
}, {
|
|
872
933
|
key: "getXcmWeight",
|
|
873
934
|
value: function () {
|
|
874
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
935
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(xcm) {
|
|
875
936
|
var result, resultJson;
|
|
876
|
-
return _regenerator().w(function (
|
|
877
|
-
while (1) switch (
|
|
937
|
+
return _regenerator().w(function (_context11) {
|
|
938
|
+
while (1) switch (_context11.n) {
|
|
878
939
|
case 0:
|
|
879
|
-
|
|
940
|
+
_context11.n = 1;
|
|
880
941
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
881
942
|
case 1:
|
|
882
|
-
result =
|
|
943
|
+
result = _context11.v;
|
|
883
944
|
resultJson = result.toJSON();
|
|
884
|
-
return
|
|
945
|
+
return _context11.a(2, resultJson.ok);
|
|
885
946
|
}
|
|
886
|
-
},
|
|
947
|
+
}, _callee11, this);
|
|
887
948
|
}));
|
|
888
|
-
function getXcmWeight(
|
|
949
|
+
function getXcmWeight(_x22) {
|
|
889
950
|
return _getXcmWeight.apply(this, arguments);
|
|
890
951
|
}
|
|
891
952
|
return getXcmWeight;
|
|
@@ -893,34 +954,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
893
954
|
}, {
|
|
894
955
|
key: "getDryRunXcm",
|
|
895
956
|
value: function () {
|
|
896
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
897
|
-
var
|
|
957
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(_ref8) {
|
|
958
|
+
var _ref0, _ref1, _ref10;
|
|
898
959
|
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
|
|
899
|
-
return _regenerator().w(function (
|
|
900
|
-
while (1) switch (
|
|
960
|
+
return _regenerator().w(function (_context12) {
|
|
961
|
+
while (1) switch (_context12.n) {
|
|
901
962
|
case 0:
|
|
902
|
-
originLocation =
|
|
963
|
+
originLocation = _ref8.originLocation, xcm = _ref8.xcm, asset = _ref8.asset, chain = _ref8.chain, origin = _ref8.origin;
|
|
903
964
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
904
965
|
if (supportsDryRunApi) {
|
|
905
|
-
|
|
966
|
+
_context12.n = 1;
|
|
906
967
|
break;
|
|
907
968
|
}
|
|
908
969
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
909
970
|
case 1:
|
|
910
|
-
|
|
971
|
+
_context12.n = 2;
|
|
911
972
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
912
973
|
case 2:
|
|
913
|
-
response =
|
|
974
|
+
response = _context12.v;
|
|
914
975
|
result = response.toHuman();
|
|
915
976
|
resultJson = response.toJSON();
|
|
916
977
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
917
978
|
if (isSuccess) {
|
|
918
|
-
|
|
979
|
+
_context12.n = 3;
|
|
919
980
|
break;
|
|
920
981
|
}
|
|
921
982
|
error = result.Ok.executionResult.Incomplete.error;
|
|
922
983
|
failureReason = typeof error === 'string' ? error : error.error;
|
|
923
|
-
return
|
|
984
|
+
return _context12.a(2, {
|
|
924
985
|
success: false,
|
|
925
986
|
failureReason: failureReason,
|
|
926
987
|
asset: asset
|
|
@@ -932,22 +993,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
932
993
|
refTime: BigInt(actualWeight.refTime),
|
|
933
994
|
proofSize: BigInt(actualWeight.proofSize)
|
|
934
995
|
} : undefined;
|
|
935
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
936
|
-
return i.Here ? 0 : (
|
|
996
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref9) {
|
|
997
|
+
return i.Here ? 0 : (_ref9 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref9 === void 0 ? void 0 : _ref9.parachain;
|
|
937
998
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
938
999
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
939
|
-
|
|
1000
|
+
_context12.n = 5;
|
|
940
1001
|
break;
|
|
941
1002
|
}
|
|
942
|
-
|
|
1003
|
+
_context12.n = 4;
|
|
943
1004
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
944
1005
|
case 4:
|
|
945
|
-
_fee =
|
|
1006
|
+
_fee = _context12.v;
|
|
946
1007
|
if (!(typeof _fee === 'bigint')) {
|
|
947
|
-
|
|
1008
|
+
_context12.n = 5;
|
|
948
1009
|
break;
|
|
949
1010
|
}
|
|
950
|
-
return
|
|
1011
|
+
return _context12.a(2, {
|
|
951
1012
|
success: true,
|
|
952
1013
|
fee: _fee,
|
|
953
1014
|
asset: asset,
|
|
@@ -959,24 +1020,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
959
1020
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
960
1021
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
961
1022
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
962
|
-
feeEvent = (
|
|
1023
|
+
feeEvent = (_ref0 = (_ref1 = (_ref10 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
963
1024
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
964
|
-
}) : undefined) !== null &&
|
|
1025
|
+
}) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
|
|
965
1026
|
// Prefer an Issued event
|
|
966
1027
|
reversedEvents.find(function (event) {
|
|
967
1028
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
968
|
-
})) !== null &&
|
|
1029
|
+
})) !== null && _ref1 !== void 0 ? _ref1 :
|
|
969
1030
|
// Fallback to Minted event
|
|
970
1031
|
reversedEvents.find(function (event) {
|
|
971
1032
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
972
|
-
})) !== null &&
|
|
1033
|
+
})) !== null && _ref0 !== void 0 ? _ref0 : reversedEvents.find(function (event) {
|
|
973
1034
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
974
1035
|
});
|
|
975
1036
|
if (feeEvent) {
|
|
976
|
-
|
|
1037
|
+
_context12.n = 6;
|
|
977
1038
|
break;
|
|
978
1039
|
}
|
|
979
|
-
return
|
|
1040
|
+
return _context12.a(2, Promise.resolve({
|
|
980
1041
|
success: false,
|
|
981
1042
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
982
1043
|
asset: asset
|
|
@@ -984,7 +1045,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
984
1045
|
case 6:
|
|
985
1046
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
986
1047
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
987
|
-
return
|
|
1048
|
+
return _context12.a(2, {
|
|
988
1049
|
success: true,
|
|
989
1050
|
fee: fee,
|
|
990
1051
|
asset: asset,
|
|
@@ -993,9 +1054,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
993
1054
|
destParaId: destParaId
|
|
994
1055
|
});
|
|
995
1056
|
}
|
|
996
|
-
},
|
|
1057
|
+
}, _callee12, this);
|
|
997
1058
|
}));
|
|
998
|
-
function getDryRunXcm(
|
|
1059
|
+
function getDryRunXcm(_x23) {
|
|
999
1060
|
return _getDryRunXcm.apply(this, arguments);
|
|
1000
1061
|
}
|
|
1001
1062
|
return getDryRunXcm;
|
|
@@ -1003,18 +1064,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1003
1064
|
}, {
|
|
1004
1065
|
key: "getBridgeStatus",
|
|
1005
1066
|
value: function () {
|
|
1006
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1067
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1007
1068
|
var outboundOperatingMode;
|
|
1008
|
-
return _regenerator().w(function (
|
|
1009
|
-
while (1) switch (
|
|
1069
|
+
return _regenerator().w(function (_context13) {
|
|
1070
|
+
while (1) switch (_context13.n) {
|
|
1010
1071
|
case 0:
|
|
1011
|
-
|
|
1072
|
+
_context13.n = 1;
|
|
1012
1073
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1013
1074
|
case 1:
|
|
1014
|
-
outboundOperatingMode =
|
|
1015
|
-
return
|
|
1075
|
+
outboundOperatingMode = _context13.v;
|
|
1076
|
+
return _context13.a(2, outboundOperatingMode.toPrimitive());
|
|
1016
1077
|
}
|
|
1017
|
-
},
|
|
1078
|
+
}, _callee13, this);
|
|
1018
1079
|
}));
|
|
1019
1080
|
function getBridgeStatus() {
|
|
1020
1081
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1034,38 +1095,38 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1034
1095
|
}, {
|
|
1035
1096
|
key: "disconnect",
|
|
1036
1097
|
value: function () {
|
|
1037
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1098
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1038
1099
|
var _this$_config$apiOver2;
|
|
1039
1100
|
var force,
|
|
1040
1101
|
api,
|
|
1041
|
-
|
|
1042
|
-
return _regenerator().w(function (
|
|
1043
|
-
while (1) switch (
|
|
1102
|
+
_args14 = arguments;
|
|
1103
|
+
return _regenerator().w(function (_context14) {
|
|
1104
|
+
while (1) switch (_context14.n) {
|
|
1044
1105
|
case 0:
|
|
1045
|
-
force =
|
|
1106
|
+
force = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : false;
|
|
1046
1107
|
if (this.initialized) {
|
|
1047
|
-
|
|
1108
|
+
_context14.n = 1;
|
|
1048
1109
|
break;
|
|
1049
1110
|
}
|
|
1050
|
-
return
|
|
1111
|
+
return _context14.a(2, Promise.resolve());
|
|
1051
1112
|
case 1:
|
|
1052
1113
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1053
|
-
|
|
1114
|
+
_context14.n = 2;
|
|
1054
1115
|
break;
|
|
1055
1116
|
}
|
|
1056
|
-
return
|
|
1117
|
+
return _context14.a(2);
|
|
1057
1118
|
case 2:
|
|
1058
1119
|
api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._chain] : this._config; // Disconnect api only if it was created automatically
|
|
1059
1120
|
if (!(force || typeof api === 'string' || api === undefined)) {
|
|
1060
|
-
|
|
1121
|
+
_context14.n = 3;
|
|
1061
1122
|
break;
|
|
1062
1123
|
}
|
|
1063
|
-
|
|
1124
|
+
_context14.n = 3;
|
|
1064
1125
|
return this.api.disconnect();
|
|
1065
1126
|
case 3:
|
|
1066
|
-
return
|
|
1127
|
+
return _context14.a(2);
|
|
1067
1128
|
}
|
|
1068
|
-
},
|
|
1129
|
+
}, _callee14, this);
|
|
1069
1130
|
}));
|
|
1070
1131
|
function disconnect() {
|
|
1071
1132
|
return _disconnect.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.5",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@snowbridge/contract-types": "0.2.17",
|
|
28
28
|
"ethers": "^6.15.0",
|
|
29
29
|
"viem": "^2.40.3",
|
|
30
|
-
"@paraspell/sdk-core": "12.0.
|
|
30
|
+
"@paraspell/sdk-core": "12.0.5"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 16.0 < 17",
|