@paraspell/sdk-core 11.8.1 → 11.8.2
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 +105 -76
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +105 -76
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -4372,95 +4372,125 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
|
4372
4372
|
};
|
|
4373
4373
|
};
|
|
4374
4374
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4375
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4375
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
4376
4376
|
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, tx, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4377
|
-
return _regenerator().w(function (
|
|
4378
|
-
while (1) switch (
|
|
4377
|
+
return _regenerator().w(function (_context3) {
|
|
4378
|
+
while (1) switch (_context3.n) {
|
|
4379
4379
|
case 0:
|
|
4380
4380
|
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
4381
4381
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4382
4382
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4383
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4384
|
-
var
|
|
4385
|
-
return _regenerator().w(function (
|
|
4386
|
-
while (1) switch (
|
|
4383
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
4384
|
+
var attempt, _t2;
|
|
4385
|
+
return _regenerator().w(function (_context2) {
|
|
4386
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
4387
4387
|
case 0:
|
|
4388
4388
|
if (!(destination === 'Ethereum')) {
|
|
4389
|
-
|
|
4389
|
+
_context2.n = 1;
|
|
4390
4390
|
break;
|
|
4391
4391
|
}
|
|
4392
|
-
return
|
|
4392
|
+
return _context2.a(2, 0n);
|
|
4393
4393
|
case 1:
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4394
|
+
attempt = /*#__PURE__*/function () {
|
|
4395
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
|
|
4396
|
+
var assetInfo, _t;
|
|
4397
|
+
return _regenerator().w(function (_context) {
|
|
4398
|
+
while (1) switch (_context.p = _context.n) {
|
|
4399
|
+
case 0:
|
|
4400
|
+
assetInfo = assets.findAssetInfoOrThrow(chain, curr, destination);
|
|
4401
|
+
if (!assetInfo.location) {
|
|
4402
|
+
_context.n = 6;
|
|
4403
|
+
break;
|
|
4404
|
+
}
|
|
4405
|
+
_context.p = 1;
|
|
4406
|
+
_context.n = 2;
|
|
4407
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4408
|
+
destination: destination
|
|
4409
|
+
}), {
|
|
4410
|
+
location: assetInfo.location,
|
|
4411
|
+
amount: amt
|
|
4412
|
+
});
|
|
4413
|
+
case 2:
|
|
4414
|
+
return _context.a(2, _context.v);
|
|
4415
|
+
case 3:
|
|
4416
|
+
_context.p = 3;
|
|
4417
|
+
_t = _context.v;
|
|
4418
|
+
if (!(_t instanceof assets.InvalidCurrencyError)) {
|
|
4419
|
+
_context.n = 5;
|
|
4420
|
+
break;
|
|
4421
|
+
}
|
|
4422
|
+
_context.n = 4;
|
|
4423
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4424
|
+
destination: destination
|
|
4425
|
+
}), {
|
|
4426
|
+
symbol: assetInfo.symbol,
|
|
4427
|
+
amount: amt
|
|
4428
|
+
});
|
|
4429
|
+
case 4:
|
|
4430
|
+
return _context.a(2, _context.v);
|
|
4431
|
+
case 5:
|
|
4432
|
+
throw _t;
|
|
4433
|
+
case 6:
|
|
4434
|
+
_context.n = 7;
|
|
4435
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4436
|
+
destination: destination
|
|
4437
|
+
}), {
|
|
4438
|
+
symbol: assetInfo.symbol,
|
|
4439
|
+
amount: amt
|
|
4440
|
+
});
|
|
4441
|
+
case 7:
|
|
4442
|
+
return _context.a(2, _context.v);
|
|
4443
|
+
}
|
|
4444
|
+
}, _callee, null, [[1, 3]]);
|
|
4445
|
+
}));
|
|
4446
|
+
return function attempt(_x2, _x3, _x4) {
|
|
4447
|
+
return _ref3.apply(this, arguments);
|
|
4448
|
+
};
|
|
4449
|
+
}();
|
|
4450
|
+
_context2.p = 2;
|
|
4451
|
+
_context2.n = 3;
|
|
4452
|
+
return attempt(origin, currency, currency.amount);
|
|
4408
4453
|
case 3:
|
|
4409
|
-
return
|
|
4454
|
+
return _context2.a(2, _context2.v);
|
|
4410
4455
|
case 4:
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
if (!(
|
|
4414
|
-
|
|
4456
|
+
_context2.p = 4;
|
|
4457
|
+
_t2 = _context2.v;
|
|
4458
|
+
if (!(!(_t2 instanceof assets.InvalidCurrencyError) || !swapConfig)) {
|
|
4459
|
+
_context2.n = 5;
|
|
4415
4460
|
break;
|
|
4416
4461
|
}
|
|
4417
|
-
|
|
4418
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4419
|
-
destination: destination
|
|
4420
|
-
}), {
|
|
4421
|
-
symbol: originAsset.symbol,
|
|
4422
|
-
amount: amount
|
|
4423
|
-
});
|
|
4462
|
+
throw _t2;
|
|
4424
4463
|
case 5:
|
|
4425
|
-
|
|
4464
|
+
_context2.n = 6;
|
|
4465
|
+
return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
|
|
4426
4466
|
case 6:
|
|
4427
|
-
|
|
4428
|
-
case 7:
|
|
4429
|
-
_context.n = 8;
|
|
4430
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4431
|
-
destination: destination
|
|
4432
|
-
}), {
|
|
4433
|
-
symbol: originAsset.symbol,
|
|
4434
|
-
amount: amount
|
|
4435
|
-
});
|
|
4436
|
-
case 8:
|
|
4437
|
-
return _context.a(2, _context.v);
|
|
4467
|
+
return _context2.a(2, _context2.v);
|
|
4438
4468
|
}
|
|
4439
|
-
},
|
|
4469
|
+
}, _callee2, null, [[2, 4]]);
|
|
4440
4470
|
}));
|
|
4441
4471
|
return function calcPaymentInfoFee() {
|
|
4442
4472
|
return _ref2.apply(this, arguments);
|
|
4443
4473
|
};
|
|
4444
4474
|
}();
|
|
4445
4475
|
if (!(!assets.hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
4446
|
-
|
|
4476
|
+
_context3.n = 3;
|
|
4447
4477
|
break;
|
|
4448
4478
|
}
|
|
4449
|
-
|
|
4479
|
+
_context3.n = 1;
|
|
4450
4480
|
return calcPaymentInfoFee();
|
|
4451
4481
|
case 1:
|
|
4452
|
-
_fee =
|
|
4453
|
-
|
|
4482
|
+
_fee = _context3.v;
|
|
4483
|
+
_context3.n = 2;
|
|
4454
4484
|
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
|
|
4455
4485
|
case 2:
|
|
4456
|
-
sufficient =
|
|
4457
|
-
return
|
|
4486
|
+
sufficient = _context3.v;
|
|
4487
|
+
return _context3.a(2, {
|
|
4458
4488
|
fee: _fee,
|
|
4459
4489
|
feeType: 'paymentInfo',
|
|
4460
4490
|
sufficient: !assets.hasDryRunSupport(destination) ? sufficient : false
|
|
4461
4491
|
});
|
|
4462
4492
|
case 3:
|
|
4463
|
-
|
|
4493
|
+
_context3.n = 4;
|
|
4464
4494
|
return api.getDryRunXcm({
|
|
4465
4495
|
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), sdkCommon.Version.V4),
|
|
4466
4496
|
tx: tx,
|
|
@@ -4473,24 +4503,24 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4473
4503
|
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
4474
4504
|
});
|
|
4475
4505
|
case 4:
|
|
4476
|
-
dryRunResult =
|
|
4506
|
+
dryRunResult = _context3.v;
|
|
4477
4507
|
if (dryRunResult.success) {
|
|
4478
|
-
|
|
4508
|
+
_context3.n = 7;
|
|
4479
4509
|
break;
|
|
4480
4510
|
}
|
|
4481
4511
|
if (!disableFallback) {
|
|
4482
|
-
|
|
4512
|
+
_context3.n = 5;
|
|
4483
4513
|
break;
|
|
4484
4514
|
}
|
|
4485
|
-
return
|
|
4515
|
+
return _context3.a(2, {
|
|
4486
4516
|
dryRunError: dryRunResult.failureReason
|
|
4487
4517
|
});
|
|
4488
4518
|
case 5:
|
|
4489
|
-
|
|
4519
|
+
_context3.n = 6;
|
|
4490
4520
|
return calcPaymentInfoFee();
|
|
4491
4521
|
case 6:
|
|
4492
|
-
_fee2 =
|
|
4493
|
-
return
|
|
4522
|
+
_fee2 = _context3.v;
|
|
4523
|
+
return _context3.a(2, {
|
|
4494
4524
|
fee: _fee2,
|
|
4495
4525
|
feeType: 'paymentInfo',
|
|
4496
4526
|
dryRunError: dryRunResult.failureReason,
|
|
@@ -4498,7 +4528,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4498
4528
|
});
|
|
4499
4529
|
case 7:
|
|
4500
4530
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4501
|
-
return
|
|
4531
|
+
return _context3.a(2, {
|
|
4502
4532
|
fee: fee,
|
|
4503
4533
|
feeType: 'dryRun',
|
|
4504
4534
|
sufficient: true,
|
|
@@ -4506,7 +4536,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4506
4536
|
destParaId: destParaId
|
|
4507
4537
|
});
|
|
4508
4538
|
}
|
|
4509
|
-
},
|
|
4539
|
+
}, _callee3);
|
|
4510
4540
|
}));
|
|
4511
4541
|
return function getDestXcmFee(_x) {
|
|
4512
4542
|
return _ref.apply(this, arguments);
|
|
@@ -5134,7 +5164,7 @@ function _traverseXcmHops() {
|
|
|
5134
5164
|
case 4:
|
|
5135
5165
|
// true if this hop should be treated as the destination
|
|
5136
5166
|
// - normally when nextChain === destination
|
|
5137
|
-
// - but if swap is required, only after (or on) the exchange hop
|
|
5167
|
+
// - but if swap is required, only after (or on) the exchange hop
|
|
5138
5168
|
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5139
5169
|
isAssetHub = nextChain === assetHubChain;
|
|
5140
5170
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
@@ -5272,8 +5302,8 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
|
5272
5302
|
};
|
|
5273
5303
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5274
5304
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5275
|
-
var _traversalResult$brid
|
|
5276
|
-
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex,
|
|
5305
|
+
var _traversalResult$brid;
|
|
5306
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
|
|
5277
5307
|
return _regenerator().w(function (_context2) {
|
|
5278
5308
|
while (1) switch (_context2.n) {
|
|
5279
5309
|
case 0:
|
|
@@ -5409,24 +5439,20 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5409
5439
|
});
|
|
5410
5440
|
}
|
|
5411
5441
|
}
|
|
5412
|
-
assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
|
|
5413
|
-
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : assets.getNativeAssetSymbol(assetHubChain),
|
|
5414
|
-
asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : assets.findNativeAssetInfoOrThrow(assetHubChain)
|
|
5415
|
-
}) : traversalResult.assetHub;
|
|
5416
5442
|
bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
|
|
5417
5443
|
currency: assets.getNativeAssetSymbol(bridgeHubChain),
|
|
5418
5444
|
asset: assets.findNativeAssetInfoOrThrow(bridgeHubChain)
|
|
5419
5445
|
}) : processedBridgeHub;
|
|
5420
5446
|
_getFailureInfo = getFailureInfo$1({
|
|
5421
5447
|
destination: traversalResult.destination,
|
|
5422
|
-
assetHub:
|
|
5448
|
+
assetHub: traversalResult.assetHub,
|
|
5423
5449
|
bridgeHub: bridgeHubWithCurrency
|
|
5424
5450
|
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5425
5451
|
return _context2.a(2, {
|
|
5426
5452
|
failureReason: failureReason,
|
|
5427
5453
|
failureChain: failureChain,
|
|
5428
5454
|
origin: originDryRun,
|
|
5429
|
-
assetHub:
|
|
5455
|
+
assetHub: traversalResult.assetHub,
|
|
5430
5456
|
bridgeHub: bridgeHubWithCurrency,
|
|
5431
5457
|
destination: traversalResult.destination,
|
|
5432
5458
|
hops: traversalResult.hops
|
|
@@ -10892,7 +10918,9 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10892
10918
|
feeAsset: feeAsset,
|
|
10893
10919
|
tx: tx,
|
|
10894
10920
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
10895
|
-
disableFallback: disableFallback
|
|
10921
|
+
disableFallback: disableFallback,
|
|
10922
|
+
hasPassedExchange: hasPassedExchange,
|
|
10923
|
+
swapConfig: swapConfig
|
|
10896
10924
|
});
|
|
10897
10925
|
case 1:
|
|
10898
10926
|
hopResult = _context.v;
|
|
@@ -10986,7 +11014,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10986
11014
|
tx: tx,
|
|
10987
11015
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
10988
11016
|
senderAddress: senderAddress,
|
|
10989
|
-
disableFallback: disableFallback
|
|
11017
|
+
disableFallback: disableFallback,
|
|
11018
|
+
swapConfig: swapConfig
|
|
10990
11019
|
});
|
|
10991
11020
|
case 11:
|
|
10992
11021
|
destFallback = _context2.v;
|
|
@@ -12117,7 +12146,7 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12117
12146
|
chain = _ref.chain, api = _ref.api;
|
|
12118
12147
|
_t = padFeeBy;
|
|
12119
12148
|
_context.n = 1;
|
|
12120
|
-
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), {
|
|
12149
|
+
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), [], {
|
|
12121
12150
|
location: DOT_LOCATION
|
|
12122
12151
|
}, true);
|
|
12123
12152
|
case 1:
|
package/dist/index.d.ts
CHANGED
|
@@ -595,6 +595,7 @@ type TGetFeeForDestChainBaseOptions<TRes> = {
|
|
|
595
595
|
originFee: bigint;
|
|
596
596
|
feeAsset?: TCurrencyInput;
|
|
597
597
|
disableFallback: boolean;
|
|
598
|
+
hasPassedExchange?: boolean;
|
|
598
599
|
swapConfig?: TSwapConfig;
|
|
599
600
|
};
|
|
600
601
|
type TGetFeeForDestChainOptions<TApi, TRes> = WithApi<TGetFeeForDestChainBaseOptions<TRes>, TApi, TRes>;
|
|
@@ -1425,7 +1426,7 @@ interface IPolkadotApi<TApi, TRes> {
|
|
|
1425
1426
|
calculateTransactionFee(tx: TRes, address: string): Promise<bigint>;
|
|
1426
1427
|
quoteAhPrice(fromMl: TLocation, toMl: TLocation, amountIn: bigint, includeFee?: boolean): Promise<bigint | undefined>;
|
|
1427
1428
|
getXcmWeight(xcm: any): Promise<TWeight>;
|
|
1428
|
-
getXcmPaymentApiFee(chain: TSubstrateChain,
|
|
1429
|
+
getXcmPaymentApiFee(chain: TSubstrateChain, localXcm: any, forwardedXcm: any, asset: TAssetInfo, transformXcm: boolean): Promise<bigint>;
|
|
1429
1430
|
getEvmStorage(contract: string, slot: string): Promise<string>;
|
|
1430
1431
|
getBalanceNative(address: string): Promise<bigint>;
|
|
1431
1432
|
getBalanceNativeAcala(address: string, symbol: string): Promise<bigint>;
|
package/dist/index.mjs
CHANGED
|
@@ -4373,95 +4373,125 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
|
4373
4373
|
};
|
|
4374
4374
|
};
|
|
4375
4375
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4376
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4376
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
4377
4377
|
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, tx, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4378
|
-
return _regenerator().w(function (
|
|
4379
|
-
while (1) switch (
|
|
4378
|
+
return _regenerator().w(function (_context3) {
|
|
4379
|
+
while (1) switch (_context3.n) {
|
|
4380
4380
|
case 0:
|
|
4381
4381
|
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
4382
4382
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4383
4383
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4384
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4385
|
-
var
|
|
4386
|
-
return _regenerator().w(function (
|
|
4387
|
-
while (1) switch (
|
|
4384
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
4385
|
+
var attempt, _t2;
|
|
4386
|
+
return _regenerator().w(function (_context2) {
|
|
4387
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
4388
4388
|
case 0:
|
|
4389
4389
|
if (!(destination === 'Ethereum')) {
|
|
4390
|
-
|
|
4390
|
+
_context2.n = 1;
|
|
4391
4391
|
break;
|
|
4392
4392
|
}
|
|
4393
|
-
return
|
|
4393
|
+
return _context2.a(2, 0n);
|
|
4394
4394
|
case 1:
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4395
|
+
attempt = /*#__PURE__*/function () {
|
|
4396
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
|
|
4397
|
+
var assetInfo, _t;
|
|
4398
|
+
return _regenerator().w(function (_context) {
|
|
4399
|
+
while (1) switch (_context.p = _context.n) {
|
|
4400
|
+
case 0:
|
|
4401
|
+
assetInfo = findAssetInfoOrThrow(chain, curr, destination);
|
|
4402
|
+
if (!assetInfo.location) {
|
|
4403
|
+
_context.n = 6;
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
_context.p = 1;
|
|
4407
|
+
_context.n = 2;
|
|
4408
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4409
|
+
destination: destination
|
|
4410
|
+
}), {
|
|
4411
|
+
location: assetInfo.location,
|
|
4412
|
+
amount: amt
|
|
4413
|
+
});
|
|
4414
|
+
case 2:
|
|
4415
|
+
return _context.a(2, _context.v);
|
|
4416
|
+
case 3:
|
|
4417
|
+
_context.p = 3;
|
|
4418
|
+
_t = _context.v;
|
|
4419
|
+
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4420
|
+
_context.n = 5;
|
|
4421
|
+
break;
|
|
4422
|
+
}
|
|
4423
|
+
_context.n = 4;
|
|
4424
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4425
|
+
destination: destination
|
|
4426
|
+
}), {
|
|
4427
|
+
symbol: assetInfo.symbol,
|
|
4428
|
+
amount: amt
|
|
4429
|
+
});
|
|
4430
|
+
case 4:
|
|
4431
|
+
return _context.a(2, _context.v);
|
|
4432
|
+
case 5:
|
|
4433
|
+
throw _t;
|
|
4434
|
+
case 6:
|
|
4435
|
+
_context.n = 7;
|
|
4436
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4437
|
+
destination: destination
|
|
4438
|
+
}), {
|
|
4439
|
+
symbol: assetInfo.symbol,
|
|
4440
|
+
amount: amt
|
|
4441
|
+
});
|
|
4442
|
+
case 7:
|
|
4443
|
+
return _context.a(2, _context.v);
|
|
4444
|
+
}
|
|
4445
|
+
}, _callee, null, [[1, 3]]);
|
|
4446
|
+
}));
|
|
4447
|
+
return function attempt(_x2, _x3, _x4) {
|
|
4448
|
+
return _ref3.apply(this, arguments);
|
|
4449
|
+
};
|
|
4450
|
+
}();
|
|
4451
|
+
_context2.p = 2;
|
|
4452
|
+
_context2.n = 3;
|
|
4453
|
+
return attempt(origin, currency, currency.amount);
|
|
4409
4454
|
case 3:
|
|
4410
|
-
return
|
|
4455
|
+
return _context2.a(2, _context2.v);
|
|
4411
4456
|
case 4:
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
if (!(
|
|
4415
|
-
|
|
4457
|
+
_context2.p = 4;
|
|
4458
|
+
_t2 = _context2.v;
|
|
4459
|
+
if (!(!(_t2 instanceof InvalidCurrencyError) || !swapConfig)) {
|
|
4460
|
+
_context2.n = 5;
|
|
4416
4461
|
break;
|
|
4417
4462
|
}
|
|
4418
|
-
|
|
4419
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4420
|
-
destination: destination
|
|
4421
|
-
}), {
|
|
4422
|
-
symbol: originAsset.symbol,
|
|
4423
|
-
amount: amount
|
|
4424
|
-
});
|
|
4463
|
+
throw _t2;
|
|
4425
4464
|
case 5:
|
|
4426
|
-
|
|
4465
|
+
_context2.n = 6;
|
|
4466
|
+
return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
|
|
4427
4467
|
case 6:
|
|
4428
|
-
|
|
4429
|
-
case 7:
|
|
4430
|
-
_context.n = 8;
|
|
4431
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4432
|
-
destination: destination
|
|
4433
|
-
}), {
|
|
4434
|
-
symbol: originAsset.symbol,
|
|
4435
|
-
amount: amount
|
|
4436
|
-
});
|
|
4437
|
-
case 8:
|
|
4438
|
-
return _context.a(2, _context.v);
|
|
4468
|
+
return _context2.a(2, _context2.v);
|
|
4439
4469
|
}
|
|
4440
|
-
},
|
|
4470
|
+
}, _callee2, null, [[2, 4]]);
|
|
4441
4471
|
}));
|
|
4442
4472
|
return function calcPaymentInfoFee() {
|
|
4443
4473
|
return _ref2.apply(this, arguments);
|
|
4444
4474
|
};
|
|
4445
4475
|
}();
|
|
4446
4476
|
if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
4447
|
-
|
|
4477
|
+
_context3.n = 3;
|
|
4448
4478
|
break;
|
|
4449
4479
|
}
|
|
4450
|
-
|
|
4480
|
+
_context3.n = 1;
|
|
4451
4481
|
return calcPaymentInfoFee();
|
|
4452
4482
|
case 1:
|
|
4453
|
-
_fee =
|
|
4454
|
-
|
|
4483
|
+
_fee = _context3.v;
|
|
4484
|
+
_context3.n = 2;
|
|
4455
4485
|
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
|
|
4456
4486
|
case 2:
|
|
4457
|
-
sufficient =
|
|
4458
|
-
return
|
|
4487
|
+
sufficient = _context3.v;
|
|
4488
|
+
return _context3.a(2, {
|
|
4459
4489
|
fee: _fee,
|
|
4460
4490
|
feeType: 'paymentInfo',
|
|
4461
4491
|
sufficient: !hasDryRunSupport(destination) ? sufficient : false
|
|
4462
4492
|
});
|
|
4463
4493
|
case 3:
|
|
4464
|
-
|
|
4494
|
+
_context3.n = 4;
|
|
4465
4495
|
return api.getDryRunXcm({
|
|
4466
4496
|
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
|
|
4467
4497
|
tx: tx,
|
|
@@ -4474,24 +4504,24 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4474
4504
|
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
4475
4505
|
});
|
|
4476
4506
|
case 4:
|
|
4477
|
-
dryRunResult =
|
|
4507
|
+
dryRunResult = _context3.v;
|
|
4478
4508
|
if (dryRunResult.success) {
|
|
4479
|
-
|
|
4509
|
+
_context3.n = 7;
|
|
4480
4510
|
break;
|
|
4481
4511
|
}
|
|
4482
4512
|
if (!disableFallback) {
|
|
4483
|
-
|
|
4513
|
+
_context3.n = 5;
|
|
4484
4514
|
break;
|
|
4485
4515
|
}
|
|
4486
|
-
return
|
|
4516
|
+
return _context3.a(2, {
|
|
4487
4517
|
dryRunError: dryRunResult.failureReason
|
|
4488
4518
|
});
|
|
4489
4519
|
case 5:
|
|
4490
|
-
|
|
4520
|
+
_context3.n = 6;
|
|
4491
4521
|
return calcPaymentInfoFee();
|
|
4492
4522
|
case 6:
|
|
4493
|
-
_fee2 =
|
|
4494
|
-
return
|
|
4523
|
+
_fee2 = _context3.v;
|
|
4524
|
+
return _context3.a(2, {
|
|
4495
4525
|
fee: _fee2,
|
|
4496
4526
|
feeType: 'paymentInfo',
|
|
4497
4527
|
dryRunError: dryRunResult.failureReason,
|
|
@@ -4499,7 +4529,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4499
4529
|
});
|
|
4500
4530
|
case 7:
|
|
4501
4531
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4502
|
-
return
|
|
4532
|
+
return _context3.a(2, {
|
|
4503
4533
|
fee: fee,
|
|
4504
4534
|
feeType: 'dryRun',
|
|
4505
4535
|
sufficient: true,
|
|
@@ -4507,7 +4537,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4507
4537
|
destParaId: destParaId
|
|
4508
4538
|
});
|
|
4509
4539
|
}
|
|
4510
|
-
},
|
|
4540
|
+
}, _callee3);
|
|
4511
4541
|
}));
|
|
4512
4542
|
return function getDestXcmFee(_x) {
|
|
4513
4543
|
return _ref.apply(this, arguments);
|
|
@@ -5135,7 +5165,7 @@ function _traverseXcmHops() {
|
|
|
5135
5165
|
case 4:
|
|
5136
5166
|
// true if this hop should be treated as the destination
|
|
5137
5167
|
// - normally when nextChain === destination
|
|
5138
|
-
// - but if swap is required, only after (or on) the exchange hop
|
|
5168
|
+
// - but if swap is required, only after (or on) the exchange hop
|
|
5139
5169
|
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5140
5170
|
isAssetHub = nextChain === assetHubChain;
|
|
5141
5171
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
@@ -5273,8 +5303,8 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
|
5273
5303
|
};
|
|
5274
5304
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5275
5305
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5276
|
-
var _traversalResult$brid
|
|
5277
|
-
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex,
|
|
5306
|
+
var _traversalResult$brid;
|
|
5307
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
|
|
5278
5308
|
return _regenerator().w(function (_context2) {
|
|
5279
5309
|
while (1) switch (_context2.n) {
|
|
5280
5310
|
case 0:
|
|
@@ -5410,24 +5440,20 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5410
5440
|
});
|
|
5411
5441
|
}
|
|
5412
5442
|
}
|
|
5413
|
-
assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
|
|
5414
|
-
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(assetHubChain),
|
|
5415
|
-
asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : findNativeAssetInfoOrThrow(assetHubChain)
|
|
5416
|
-
}) : traversalResult.assetHub;
|
|
5417
5443
|
bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
|
|
5418
5444
|
currency: getNativeAssetSymbol(bridgeHubChain),
|
|
5419
5445
|
asset: findNativeAssetInfoOrThrow(bridgeHubChain)
|
|
5420
5446
|
}) : processedBridgeHub;
|
|
5421
5447
|
_getFailureInfo = getFailureInfo$1({
|
|
5422
5448
|
destination: traversalResult.destination,
|
|
5423
|
-
assetHub:
|
|
5449
|
+
assetHub: traversalResult.assetHub,
|
|
5424
5450
|
bridgeHub: bridgeHubWithCurrency
|
|
5425
5451
|
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5426
5452
|
return _context2.a(2, {
|
|
5427
5453
|
failureReason: failureReason,
|
|
5428
5454
|
failureChain: failureChain,
|
|
5429
5455
|
origin: originDryRun,
|
|
5430
|
-
assetHub:
|
|
5456
|
+
assetHub: traversalResult.assetHub,
|
|
5431
5457
|
bridgeHub: bridgeHubWithCurrency,
|
|
5432
5458
|
destination: traversalResult.destination,
|
|
5433
5459
|
hops: traversalResult.hops
|
|
@@ -10893,7 +10919,9 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10893
10919
|
feeAsset: feeAsset,
|
|
10894
10920
|
tx: tx,
|
|
10895
10921
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
10896
|
-
disableFallback: disableFallback
|
|
10922
|
+
disableFallback: disableFallback,
|
|
10923
|
+
hasPassedExchange: hasPassedExchange,
|
|
10924
|
+
swapConfig: swapConfig
|
|
10897
10925
|
});
|
|
10898
10926
|
case 1:
|
|
10899
10927
|
hopResult = _context.v;
|
|
@@ -10987,7 +11015,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10987
11015
|
tx: tx,
|
|
10988
11016
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
10989
11017
|
senderAddress: senderAddress,
|
|
10990
|
-
disableFallback: disableFallback
|
|
11018
|
+
disableFallback: disableFallback,
|
|
11019
|
+
swapConfig: swapConfig
|
|
10991
11020
|
});
|
|
10992
11021
|
case 11:
|
|
10993
11022
|
destFallback = _context2.v;
|
|
@@ -12118,7 +12147,7 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12118
12147
|
chain = _ref.chain, api = _ref.api;
|
|
12119
12148
|
_t = padFeeBy;
|
|
12120
12149
|
_context.n = 1;
|
|
12121
|
-
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), {
|
|
12150
|
+
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), [], {
|
|
12122
12151
|
location: DOT_LOCATION
|
|
12123
12152
|
}, true);
|
|
12124
12153
|
case 1:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "11.8.
|
|
3
|
+
"version": "11.8.2",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@noble/hashes": "^1.8.0",
|
|
27
27
|
"@scure/base": "^2.0.0",
|
|
28
28
|
"viem": "^2.36.0",
|
|
29
|
-
"@paraspell/assets": "11.8.
|
|
30
|
-
"@paraspell/pallets": "11.8.
|
|
31
|
-
"@paraspell/sdk-common": "11.8.
|
|
29
|
+
"@paraspell/assets": "11.8.2",
|
|
30
|
+
"@paraspell/pallets": "11.8.2",
|
|
31
|
+
"@paraspell/sdk-common": "11.8.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|