@paraspell/sdk-core 11.8.3 → 11.8.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/dist/index.cjs +217 -134
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +218 -135
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3695,6 +3695,44 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3695
3695
|
};
|
|
3696
3696
|
}();
|
|
3697
3697
|
|
|
3698
|
+
var getMythosOriginFee = /*#__PURE__*/function () {
|
|
3699
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
|
|
3700
|
+
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
|
|
3701
|
+
return _regenerator().w(function (_context) {
|
|
3702
|
+
while (1) switch (_context.n) {
|
|
3703
|
+
case 0:
|
|
3704
|
+
ahApi = api.clone();
|
|
3705
|
+
_context.n = 1;
|
|
3706
|
+
return ahApi.init('AssetHubPolkadot');
|
|
3707
|
+
case 1:
|
|
3708
|
+
_context.n = 2;
|
|
3709
|
+
return getParaEthTransferFees(ahApi);
|
|
3710
|
+
case 2:
|
|
3711
|
+
_yield$getParaEthTran = _context.v;
|
|
3712
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
3713
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
3714
|
+
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
3715
|
+
nativeAsset = assets.findNativeAssetInfoOrThrow('Mythos');
|
|
3716
|
+
assertHasLocation(nativeAsset);
|
|
3717
|
+
_context.n = 3;
|
|
3718
|
+
return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
|
|
3719
|
+
case 3:
|
|
3720
|
+
feeConverted = _context.v;
|
|
3721
|
+
if (feeConverted) {
|
|
3722
|
+
_context.n = 4;
|
|
3723
|
+
break;
|
|
3724
|
+
}
|
|
3725
|
+
throw new InvalidParameterError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
|
|
3726
|
+
case 4:
|
|
3727
|
+
return _context.a(2, padFeeBy(feeConverted, 10));
|
|
3728
|
+
}
|
|
3729
|
+
}, _callee);
|
|
3730
|
+
}));
|
|
3731
|
+
return function getMythosOriginFee(_x) {
|
|
3732
|
+
return _ref.apply(this, arguments);
|
|
3733
|
+
};
|
|
3734
|
+
}();
|
|
3735
|
+
|
|
3698
3736
|
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
3699
3737
|
var asset = assets.findAssetInfo(origin, feeAsset, !sdkCommon.isTLocation(destination) ? destination : null);
|
|
3700
3738
|
var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(assets.isTAsset);
|
|
@@ -4487,7 +4525,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4487
4525
|
return _context3.a(2, {
|
|
4488
4526
|
fee: _fee,
|
|
4489
4527
|
feeType: 'paymentInfo',
|
|
4490
|
-
sufficient: sufficient
|
|
4528
|
+
sufficient: sufficient,
|
|
4529
|
+
asset: asset,
|
|
4530
|
+
currency: asset.symbol
|
|
4491
4531
|
});
|
|
4492
4532
|
case 3:
|
|
4493
4533
|
_context3.n = 4;
|
|
@@ -4524,7 +4564,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4524
4564
|
fee: _fee2,
|
|
4525
4565
|
feeType: 'paymentInfo',
|
|
4526
4566
|
dryRunError: dryRunResult.failureReason,
|
|
4527
|
-
sufficient: false
|
|
4567
|
+
sufficient: false,
|
|
4568
|
+
asset: asset,
|
|
4569
|
+
currency: asset.symbol
|
|
4528
4570
|
});
|
|
4529
4571
|
case 7:
|
|
4530
4572
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
@@ -4533,7 +4575,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4533
4575
|
feeType: 'dryRun',
|
|
4534
4576
|
sufficient: true,
|
|
4535
4577
|
forwardedXcms: newForwardedXcms,
|
|
4536
|
-
destParaId: destParaId
|
|
4578
|
+
destParaId: destParaId,
|
|
4579
|
+
asset: asset,
|
|
4580
|
+
currency: asset.symbol
|
|
4537
4581
|
});
|
|
4538
4582
|
}
|
|
4539
4583
|
}, _callee3);
|
|
@@ -5125,14 +5169,11 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
5125
5169
|
};
|
|
5126
5170
|
}();
|
|
5127
5171
|
|
|
5128
|
-
function
|
|
5129
|
-
|
|
5130
|
-
}
|
|
5131
|
-
function _traverseXcmHops() {
|
|
5132
|
-
_traverseXcmHops = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(config) {
|
|
5172
|
+
var traverseXcmHops = /*#__PURE__*/function () {
|
|
5173
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
5133
5174
|
var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, assetHubChain, bridgeHubChain, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, intermediateResults, destinationResult, nextChain, hopApi, isDestination, isAssetHub, isBridgeHub, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
5134
|
-
return _regenerator().w(function (
|
|
5135
|
-
while (1) switch (
|
|
5175
|
+
return _regenerator().w(function (_context) {
|
|
5176
|
+
while (1) switch (_context.p = _context.n) {
|
|
5136
5177
|
case 0:
|
|
5137
5178
|
api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
5138
5179
|
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
@@ -5147,19 +5188,19 @@ function _traverseXcmHops() {
|
|
|
5147
5188
|
intermediateResults = {};
|
|
5148
5189
|
case 1:
|
|
5149
5190
|
if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
|
|
5150
|
-
|
|
5191
|
+
_context.n = 10;
|
|
5151
5192
|
break;
|
|
5152
5193
|
}
|
|
5153
5194
|
nextChain = getTChain(nextParaId, getRelayChainOf(origin));
|
|
5154
5195
|
if (nextChain) {
|
|
5155
|
-
|
|
5196
|
+
_context.n = 2;
|
|
5156
5197
|
break;
|
|
5157
5198
|
}
|
|
5158
5199
|
throw new InvalidParameterError("Unable to find TChain for paraId ".concat(nextParaId));
|
|
5159
5200
|
case 2:
|
|
5160
5201
|
hopApi = api.clone();
|
|
5161
|
-
|
|
5162
|
-
|
|
5202
|
+
_context.p = 3;
|
|
5203
|
+
_context.n = 4;
|
|
5163
5204
|
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5164
5205
|
case 4:
|
|
5165
5206
|
// true if this hop should be treated as the destination
|
|
@@ -5168,7 +5209,7 @@ function _traverseXcmHops() {
|
|
|
5168
5209
|
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5169
5210
|
isAssetHub = nextChain === assetHubChain;
|
|
5170
5211
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
5171
|
-
|
|
5212
|
+
_context.n = 5;
|
|
5172
5213
|
return processHop({
|
|
5173
5214
|
api: hopApi,
|
|
5174
5215
|
currentChain: nextChain,
|
|
@@ -5181,7 +5222,7 @@ function _traverseXcmHops() {
|
|
|
5181
5222
|
isBridgeHub: isBridgeHub
|
|
5182
5223
|
});
|
|
5183
5224
|
case 5:
|
|
5184
|
-
hopResult =
|
|
5225
|
+
hopResult = _context.v;
|
|
5185
5226
|
if (!isDestination) {
|
|
5186
5227
|
hops.push({
|
|
5187
5228
|
chain: nextChain,
|
|
@@ -5196,10 +5237,10 @@ function _traverseXcmHops() {
|
|
|
5196
5237
|
intermediateResults.bridgeHub = hopResult;
|
|
5197
5238
|
}
|
|
5198
5239
|
if (shouldContinue(hopResult)) {
|
|
5199
|
-
|
|
5240
|
+
_context.n = 6;
|
|
5200
5241
|
break;
|
|
5201
5242
|
}
|
|
5202
|
-
return
|
|
5243
|
+
return _context.a(3, 10);
|
|
5203
5244
|
case 6:
|
|
5204
5245
|
// Update state for next iteration
|
|
5205
5246
|
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
@@ -5211,16 +5252,16 @@ function _traverseXcmHops() {
|
|
|
5211
5252
|
nextParaId = destParaId;
|
|
5212
5253
|
currentOrigin = nextChain;
|
|
5213
5254
|
case 7:
|
|
5214
|
-
|
|
5215
|
-
|
|
5255
|
+
_context.p = 7;
|
|
5256
|
+
_context.n = 8;
|
|
5216
5257
|
return hopApi.disconnect();
|
|
5217
5258
|
case 8:
|
|
5218
|
-
return
|
|
5259
|
+
return _context.f(7);
|
|
5219
5260
|
case 9:
|
|
5220
|
-
|
|
5261
|
+
_context.n = 1;
|
|
5221
5262
|
break;
|
|
5222
5263
|
case 10:
|
|
5223
|
-
return
|
|
5264
|
+
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
5224
5265
|
hops: hops
|
|
5225
5266
|
}, intermediateResults.assetHub && {
|
|
5226
5267
|
assetHub: intermediateResults.assetHub
|
|
@@ -5232,40 +5273,42 @@ function _traverseXcmHops() {
|
|
|
5232
5273
|
lastProcessedChain: currentOrigin
|
|
5233
5274
|
}));
|
|
5234
5275
|
}
|
|
5235
|
-
},
|
|
5276
|
+
}, _callee, null, [[3,, 7, 9]]);
|
|
5236
5277
|
}));
|
|
5237
|
-
return
|
|
5238
|
-
|
|
5278
|
+
return function traverseXcmHops(_x) {
|
|
5279
|
+
return _ref.apply(this, arguments);
|
|
5280
|
+
};
|
|
5281
|
+
}();
|
|
5239
5282
|
var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
5240
|
-
var
|
|
5283
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, bridgeHubResult, destination, assetHubChain) {
|
|
5241
5284
|
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
5242
|
-
return _regenerator().w(function (
|
|
5243
|
-
while (1) switch (
|
|
5285
|
+
return _regenerator().w(function (_context2) {
|
|
5286
|
+
while (1) switch (_context2.n) {
|
|
5244
5287
|
case 0:
|
|
5245
5288
|
if (!(!bridgeHubResult || !('fee' in bridgeHubResult) || destination !== 'Ethereum')) {
|
|
5246
|
-
|
|
5289
|
+
_context2.n = 1;
|
|
5247
5290
|
break;
|
|
5248
5291
|
}
|
|
5249
|
-
return
|
|
5292
|
+
return _context2.a(2, bridgeHubResult);
|
|
5250
5293
|
case 1:
|
|
5251
5294
|
ahApi = api.clone();
|
|
5252
|
-
|
|
5295
|
+
_context2.n = 2;
|
|
5253
5296
|
return ahApi.init(assetHubChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5254
5297
|
case 2:
|
|
5255
|
-
|
|
5298
|
+
_context2.n = 3;
|
|
5256
5299
|
return getParaEthTransferFees(ahApi);
|
|
5257
5300
|
case 3:
|
|
5258
|
-
_yield$getParaEthTran =
|
|
5301
|
+
_yield$getParaEthTran = _context2.v;
|
|
5259
5302
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
5260
5303
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
5261
|
-
return
|
|
5304
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
|
|
5262
5305
|
fee: bridgeHubResult.fee + bridgeFee
|
|
5263
5306
|
}));
|
|
5264
5307
|
}
|
|
5265
|
-
},
|
|
5308
|
+
}, _callee2);
|
|
5266
5309
|
}));
|
|
5267
5310
|
return function addEthereumBridgeFees(_x2, _x3, _x4, _x5) {
|
|
5268
|
-
return
|
|
5311
|
+
return _ref2.apply(this, arguments);
|
|
5269
5312
|
};
|
|
5270
5313
|
}();
|
|
5271
5314
|
|
|
@@ -5303,7 +5346,7 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
|
5303
5346
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5304
5347
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5305
5348
|
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;
|
|
5349
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
5307
5350
|
return _regenerator().w(function (_context2) {
|
|
5308
5351
|
while (1) switch (_context2.n) {
|
|
5309
5352
|
case 0:
|
|
@@ -5315,6 +5358,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5315
5358
|
return api.getDryRunCall({
|
|
5316
5359
|
tx: tx,
|
|
5317
5360
|
chain: origin,
|
|
5361
|
+
destination: destination,
|
|
5318
5362
|
address: senderAddress,
|
|
5319
5363
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5320
5364
|
amount: amount
|
|
@@ -5336,7 +5380,30 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5336
5380
|
hops: []
|
|
5337
5381
|
});
|
|
5338
5382
|
case 2:
|
|
5339
|
-
|
|
5383
|
+
isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
|
|
5384
|
+
if (!isMythosToEthereum) {
|
|
5385
|
+
_context2.n = 4;
|
|
5386
|
+
break;
|
|
5387
|
+
}
|
|
5388
|
+
_t2 = _objectSpread2;
|
|
5389
|
+
_t3 = _objectSpread2({}, originDryRun);
|
|
5390
|
+
_t4 = {};
|
|
5391
|
+
_t5 = originDryRun.fee;
|
|
5392
|
+
_context2.n = 3;
|
|
5393
|
+
return getMythosOriginFee(api);
|
|
5394
|
+
case 3:
|
|
5395
|
+
_t6 = _context2.v;
|
|
5396
|
+
_t7 = _t5 + _t6;
|
|
5397
|
+
_t = _t2(_t3, _t4, {
|
|
5398
|
+
fee: _t7
|
|
5399
|
+
});
|
|
5400
|
+
_context2.n = 5;
|
|
5401
|
+
break;
|
|
5402
|
+
case 4:
|
|
5403
|
+
_t = originDryRun;
|
|
5404
|
+
case 5:
|
|
5405
|
+
originDryModified = _t;
|
|
5406
|
+
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5340
5407
|
processHop = /*#__PURE__*/function () {
|
|
5341
5408
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5342
5409
|
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopAsset, hopDryRun;
|
|
@@ -5344,8 +5411,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5344
5411
|
while (1) switch (_context.n) {
|
|
5345
5412
|
case 0:
|
|
5346
5413
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
5347
|
-
if (
|
|
5348
|
-
hopAsset = assets.findNativeAssetInfoOrThrow(currentChain);
|
|
5414
|
+
if (asset.location && asset.location.parents === sdkCommon.Parents.TWO) {
|
|
5415
|
+
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
5349
5416
|
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5350
5417
|
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
5351
5418
|
} else if (isDestination) {
|
|
@@ -5371,9 +5438,9 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5371
5438
|
xcm: forwardedXcms[1][0],
|
|
5372
5439
|
chain: currentChain,
|
|
5373
5440
|
origin: currentOrigin,
|
|
5374
|
-
asset:
|
|
5441
|
+
asset: hopAsset,
|
|
5375
5442
|
feeAsset: resolvedFeeAsset,
|
|
5376
|
-
originFee:
|
|
5443
|
+
originFee: originDryModified.fee,
|
|
5377
5444
|
amount: amount
|
|
5378
5445
|
});
|
|
5379
5446
|
case 2:
|
|
@@ -5389,7 +5456,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5389
5456
|
return _ref2.apply(this, arguments);
|
|
5390
5457
|
};
|
|
5391
5458
|
}();
|
|
5392
|
-
_context2.n =
|
|
5459
|
+
_context2.n = 6;
|
|
5393
5460
|
return traverseXcmHops({
|
|
5394
5461
|
api: api,
|
|
5395
5462
|
origin: origin,
|
|
@@ -5409,25 +5476,35 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5409
5476
|
};
|
|
5410
5477
|
}
|
|
5411
5478
|
});
|
|
5412
|
-
case
|
|
5479
|
+
case 6:
|
|
5413
5480
|
traversalResult = _context2.v;
|
|
5414
5481
|
// Process Ethereum bridge fees
|
|
5415
5482
|
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
5416
|
-
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
|
|
5483
|
+
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin)); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
|
|
5484
|
+
if (!isMythosToEthereum) {
|
|
5485
|
+
_context2.n = 7;
|
|
5486
|
+
break;
|
|
5487
|
+
}
|
|
5488
|
+
_t8 = traversalResult.bridgeHub;
|
|
5489
|
+
_context2.n = 11;
|
|
5490
|
+
break;
|
|
5491
|
+
case 7:
|
|
5417
5492
|
if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
|
|
5418
|
-
_context2.n =
|
|
5493
|
+
_context2.n = 9;
|
|
5419
5494
|
break;
|
|
5420
5495
|
}
|
|
5421
|
-
_context2.n =
|
|
5496
|
+
_context2.n = 8;
|
|
5422
5497
|
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
|
|
5423
|
-
case
|
|
5424
|
-
|
|
5425
|
-
_context2.n =
|
|
5498
|
+
case 8:
|
|
5499
|
+
_t9 = _context2.v;
|
|
5500
|
+
_context2.n = 10;
|
|
5426
5501
|
break;
|
|
5427
|
-
case
|
|
5428
|
-
|
|
5429
|
-
case
|
|
5430
|
-
|
|
5502
|
+
case 9:
|
|
5503
|
+
_t9 = traversalResult.bridgeHub;
|
|
5504
|
+
case 10:
|
|
5505
|
+
_t8 = _t9;
|
|
5506
|
+
case 11:
|
|
5507
|
+
processedBridgeHub = _t8;
|
|
5431
5508
|
// Update bridge hub in hops if needed
|
|
5432
5509
|
if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
5433
5510
|
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
@@ -5451,7 +5528,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5451
5528
|
return _context2.a(2, {
|
|
5452
5529
|
failureReason: failureReason,
|
|
5453
5530
|
failureChain: failureChain,
|
|
5454
|
-
origin:
|
|
5531
|
+
origin: originDryModified,
|
|
5455
5532
|
assetHub: traversalResult.assetHub,
|
|
5456
5533
|
bridgeHub: bridgeHubWithCurrency,
|
|
5457
5534
|
destination: traversalResult.destination,
|
|
@@ -8878,7 +8955,7 @@ var Moonriver = /*#__PURE__*/function (_Parachain) {
|
|
|
8878
8955
|
|
|
8879
8956
|
var createTypeAndThenTransfer = /*#__PURE__*/function () {
|
|
8880
8957
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, chain, version) {
|
|
8881
|
-
var api, asset, senderAddress, address, destination, messageId,
|
|
8958
|
+
var api, asset, senderAddress, address, destination, messageId, nativeMythAmount;
|
|
8882
8959
|
return _regenerator().w(function (_context) {
|
|
8883
8960
|
while (1) switch (_context.n) {
|
|
8884
8961
|
case 0:
|
|
@@ -8896,28 +8973,10 @@ var createTypeAndThenTransfer = /*#__PURE__*/function () {
|
|
|
8896
8973
|
return generateMessageId(api, senderAddress, getParaId(chain), asset.assetId, address, asset.amount);
|
|
8897
8974
|
case 2:
|
|
8898
8975
|
messageId = _context.v;
|
|
8899
|
-
ahApi = api.clone();
|
|
8900
8976
|
_context.n = 3;
|
|
8901
|
-
return
|
|
8977
|
+
return getMythosOriginFee(api);
|
|
8902
8978
|
case 3:
|
|
8903
|
-
|
|
8904
|
-
return getParaEthTransferFees(ahApi);
|
|
8905
|
-
case 4:
|
|
8906
|
-
_yield$getParaEthTran = _context.v;
|
|
8907
|
-
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
8908
|
-
bridgeFee = _yield$getParaEthTran2[0];
|
|
8909
|
-
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
8910
|
-
_context.n = 5;
|
|
8911
|
-
return ahApi.quoteAhPrice(DOT_LOCATION, assets.getNativeAssets(chain)[0].location, bridgeFee + ahExecutionFee);
|
|
8912
|
-
case 5:
|
|
8913
|
-
feeConverted = _context.v;
|
|
8914
|
-
if (feeConverted) {
|
|
8915
|
-
_context.n = 6;
|
|
8916
|
-
break;
|
|
8917
|
-
}
|
|
8918
|
-
throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
|
|
8919
|
-
case 6:
|
|
8920
|
-
nativeMythAmount = padFeeBy(feeConverted, 10);
|
|
8979
|
+
nativeMythAmount = _context.v;
|
|
8921
8980
|
return _context.a(2, {
|
|
8922
8981
|
module: 'PolkadotXcm',
|
|
8923
8982
|
method: 'transfer_assets_using_type_and_then',
|
|
@@ -10104,7 +10163,7 @@ var createMintTxs = function createMintTxs(chain, asset, balance, address, api)
|
|
|
10104
10163
|
var nativePallet = pallets.getNativeAssetsPallet(chain);
|
|
10105
10164
|
var otherPallets = pallets.getOtherAssetsPallets(chain);
|
|
10106
10165
|
var isMainNativeAsset = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(chain));
|
|
10107
|
-
var pallet = assets.isForeignAsset(asset) || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10166
|
+
var pallet = assets.isForeignAsset(asset) && chain !== 'Mythos' || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10108
10167
|
var palletInstance = getPalletInstance(pallet);
|
|
10109
10168
|
return palletInstance.mint(address, asset, balance, chain, api);
|
|
10110
10169
|
};
|
|
@@ -10465,6 +10524,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10465
10524
|
return api.getDryRunCall({
|
|
10466
10525
|
tx: tx,
|
|
10467
10526
|
chain: origin,
|
|
10527
|
+
destination: destination,
|
|
10468
10528
|
address: senderAddress,
|
|
10469
10529
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10470
10530
|
amount: amount
|
|
@@ -10796,7 +10856,7 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
|
10796
10856
|
};
|
|
10797
10857
|
var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
10798
10858
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
10799
|
-
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe,
|
|
10859
|
+
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFeeRaw, originCurrency, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, _t, _t2, _t3, _t4;
|
|
10800
10860
|
return _regenerator().w(function (_context2) {
|
|
10801
10861
|
while (1) switch (_context2.p = _context2.n) {
|
|
10802
10862
|
case 0:
|
|
@@ -10817,7 +10877,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10817
10877
|
});
|
|
10818
10878
|
case 1:
|
|
10819
10879
|
_yield$getOriginXcmFe = _context2.v;
|
|
10820
|
-
|
|
10880
|
+
originFeeRaw = _yield$getOriginXcmFe.fee;
|
|
10821
10881
|
originCurrency = _yield$getOriginXcmFe.currency;
|
|
10822
10882
|
originAsset = _yield$getOriginXcmFe.asset;
|
|
10823
10883
|
originFeeType = _yield$getOriginXcmFe.feeType;
|
|
@@ -10826,17 +10886,34 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10826
10886
|
initialDestParaId = _yield$getOriginXcmFe.destParaId;
|
|
10827
10887
|
originWeight = _yield$getOriginXcmFe.weight;
|
|
10828
10888
|
sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
|
|
10889
|
+
isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
|
|
10890
|
+
if (!isMythosToEthereum) {
|
|
10891
|
+
_context2.n = 3;
|
|
10892
|
+
break;
|
|
10893
|
+
}
|
|
10894
|
+
_context2.n = 2;
|
|
10895
|
+
return getMythosOriginFee(api);
|
|
10896
|
+
case 2:
|
|
10897
|
+
_t2 = _context2.v;
|
|
10898
|
+
_t3 = originFeeRaw !== null && originFeeRaw !== void 0 ? originFeeRaw : 0n;
|
|
10899
|
+
_t = _t2 + _t3;
|
|
10900
|
+
_context2.n = 4;
|
|
10901
|
+
break;
|
|
10902
|
+
case 3:
|
|
10903
|
+
_t = originFeeRaw;
|
|
10904
|
+
case 4:
|
|
10905
|
+
originFee = _t;
|
|
10829
10906
|
if (!(originDryRunError || originFeeType === 'paymentInfo')) {
|
|
10830
|
-
_context2.n =
|
|
10907
|
+
_context2.n = 10;
|
|
10831
10908
|
break;
|
|
10832
10909
|
}
|
|
10833
10910
|
destApi = api.clone();
|
|
10834
|
-
_context2.p =
|
|
10835
|
-
_context2.n =
|
|
10911
|
+
_context2.p = 5;
|
|
10912
|
+
_context2.n = 6;
|
|
10836
10913
|
return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
10837
|
-
case
|
|
10914
|
+
case 6:
|
|
10838
10915
|
destApi.setDisconnectAllowed(false);
|
|
10839
|
-
_context2.n =
|
|
10916
|
+
_context2.n = 7;
|
|
10840
10917
|
return getDestXcmFee({
|
|
10841
10918
|
api: destApi,
|
|
10842
10919
|
forwardedXcms: undefined,
|
|
@@ -10855,7 +10932,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10855
10932
|
disableFallback: disableFallback,
|
|
10856
10933
|
swapConfig: swapConfig
|
|
10857
10934
|
});
|
|
10858
|
-
case
|
|
10935
|
+
case 7:
|
|
10859
10936
|
destFeeRes = _context2.v;
|
|
10860
10937
|
_result = {
|
|
10861
10938
|
origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
|
|
@@ -10891,21 +10968,32 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10891
10968
|
failureChain: _failureChain,
|
|
10892
10969
|
failureReason: _failureReason
|
|
10893
10970
|
}));
|
|
10894
|
-
case
|
|
10895
|
-
_context2.p =
|
|
10971
|
+
case 8:
|
|
10972
|
+
_context2.p = 8;
|
|
10896
10973
|
destApi.setDisconnectAllowed(true);
|
|
10897
|
-
_context2.n =
|
|
10974
|
+
_context2.n = 9;
|
|
10898
10975
|
return destApi.disconnect();
|
|
10899
|
-
case
|
|
10900
|
-
return _context2.f(
|
|
10901
|
-
case
|
|
10976
|
+
case 9:
|
|
10977
|
+
return _context2.f(8);
|
|
10978
|
+
case 10:
|
|
10902
10979
|
processHop = /*#__PURE__*/function () {
|
|
10903
10980
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
10904
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange,
|
|
10981
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
10905
10982
|
return _regenerator().w(function (_context) {
|
|
10906
10983
|
while (1) switch (_context.n) {
|
|
10907
10984
|
case 0:
|
|
10908
10985
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
10986
|
+
if (!(currentAsset.location && currentAsset.location.parents === sdkCommon.Parents.TWO)) {
|
|
10987
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10988
|
+
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10989
|
+
} else if (destination === currentChain) {
|
|
10990
|
+
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10991
|
+
} else {
|
|
10992
|
+
hopAsset = currentAsset;
|
|
10993
|
+
}
|
|
10994
|
+
} else {
|
|
10995
|
+
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
10996
|
+
}
|
|
10909
10997
|
_context.n = 1;
|
|
10910
10998
|
return getDestXcmFee({
|
|
10911
10999
|
api: hopApi,
|
|
@@ -10918,7 +11006,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10918
11006
|
}),
|
|
10919
11007
|
address: address,
|
|
10920
11008
|
senderAddress: senderAddress,
|
|
10921
|
-
asset:
|
|
11009
|
+
asset: hopAsset,
|
|
10922
11010
|
feeAsset: feeAsset,
|
|
10923
11011
|
tx: tx,
|
|
10924
11012
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -10928,21 +11016,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10928
11016
|
});
|
|
10929
11017
|
case 1:
|
|
10930
11018
|
hopResult = _context.v;
|
|
10931
|
-
|
|
10932
|
-
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10933
|
-
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10934
|
-
} else if (destination === currentChain) {
|
|
10935
|
-
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10936
|
-
} else {
|
|
10937
|
-
hopAsset = asset;
|
|
10938
|
-
}
|
|
10939
|
-
} else {
|
|
10940
|
-
hopAsset = assets.findNativeAssetInfoOrThrow(currentChain);
|
|
10941
|
-
}
|
|
10942
|
-
return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
|
|
10943
|
-
currency: hopAsset.symbol,
|
|
10944
|
-
asset: hopAsset
|
|
10945
|
-
}));
|
|
11019
|
+
return _context.a(2, hopResult);
|
|
10946
11020
|
}
|
|
10947
11021
|
}, _callee);
|
|
10948
11022
|
}));
|
|
@@ -10950,7 +11024,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10950
11024
|
return _ref3.apply(this, arguments);
|
|
10951
11025
|
};
|
|
10952
11026
|
}();
|
|
10953
|
-
_context2.n =
|
|
11027
|
+
_context2.n = 11;
|
|
10954
11028
|
return traverseXcmHops({
|
|
10955
11029
|
api: api,
|
|
10956
11030
|
origin: origin,
|
|
@@ -10970,14 +11044,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10970
11044
|
};
|
|
10971
11045
|
}
|
|
10972
11046
|
});
|
|
10973
|
-
case
|
|
11047
|
+
case 11:
|
|
10974
11048
|
traversalResult = _context2.v;
|
|
10975
11049
|
// Handle case where we failed before reaching destination
|
|
10976
11050
|
destFee = 0n;
|
|
10977
11051
|
destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
|
|
10978
11052
|
destSufficient = undefined;
|
|
10979
11053
|
if (!traversalResult.destination) {
|
|
10980
|
-
_context2.n =
|
|
11054
|
+
_context2.n = 12;
|
|
10981
11055
|
break;
|
|
10982
11056
|
}
|
|
10983
11057
|
destResult = traversalResult.destination;
|
|
@@ -10987,23 +11061,19 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10987
11061
|
destSufficient = destResult.sufficient;
|
|
10988
11062
|
destCurrency = destResult.currency;
|
|
10989
11063
|
destAsset = destResult.asset;
|
|
10990
|
-
_context2.n =
|
|
11064
|
+
_context2.n = 16;
|
|
10991
11065
|
break;
|
|
10992
|
-
case
|
|
11066
|
+
case 12:
|
|
10993
11067
|
if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
|
|
10994
|
-
_context2.n =
|
|
11068
|
+
_context2.n = 15;
|
|
10995
11069
|
break;
|
|
10996
11070
|
}
|
|
10997
11071
|
// We failed before reaching destination, use fallback
|
|
10998
11072
|
_destApi = api.clone();
|
|
10999
|
-
|
|
11000
|
-
_context2.n = 10;
|
|
11001
|
-
break;
|
|
11002
|
-
}
|
|
11003
|
-
_context2.n = 10;
|
|
11073
|
+
_context2.n = 13;
|
|
11004
11074
|
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
11005
|
-
case
|
|
11006
|
-
_context2.n =
|
|
11075
|
+
case 13:
|
|
11076
|
+
_context2.n = 14;
|
|
11007
11077
|
return getDestXcmFee({
|
|
11008
11078
|
api: _destApi,
|
|
11009
11079
|
forwardedXcms: undefined,
|
|
@@ -11021,28 +11091,38 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11021
11091
|
disableFallback: disableFallback,
|
|
11022
11092
|
swapConfig: swapConfig
|
|
11023
11093
|
});
|
|
11024
|
-
case
|
|
11094
|
+
case 14:
|
|
11025
11095
|
destFallback = _context2.v;
|
|
11026
11096
|
destFee = destFallback.fee;
|
|
11027
11097
|
destFeeType = destFallback.feeType;
|
|
11028
11098
|
destSufficient = destFallback.sufficient;
|
|
11029
11099
|
destCurrency = assets.getNativeAssetSymbol(destination);
|
|
11030
11100
|
destAsset = assets.findNativeAssetInfoOrThrow(destination);
|
|
11031
|
-
_context2.n =
|
|
11101
|
+
_context2.n = 16;
|
|
11032
11102
|
break;
|
|
11033
|
-
case
|
|
11103
|
+
case 15:
|
|
11034
11104
|
destFee = 0n;
|
|
11035
11105
|
destFeeType = 'noFeeRequired';
|
|
11036
11106
|
destSufficient = true;
|
|
11037
11107
|
destCurrency = assets.getNativeAssetSymbol(destination);
|
|
11038
11108
|
destAsset = assets.findNativeAssetInfoOrThrow(destination);
|
|
11039
|
-
case
|
|
11109
|
+
case 16:
|
|
11040
11110
|
// Process Ethereum bridge fees
|
|
11041
11111
|
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
11042
|
-
|
|
11112
|
+
if (!isMythosToEthereum) {
|
|
11113
|
+
_context2.n = 17;
|
|
11114
|
+
break;
|
|
11115
|
+
}
|
|
11116
|
+
_t4 = traversalResult.bridgeHub;
|
|
11117
|
+
_context2.n = 19;
|
|
11118
|
+
break;
|
|
11119
|
+
case 17:
|
|
11120
|
+
_context2.n = 18;
|
|
11043
11121
|
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
|
|
11044
|
-
case
|
|
11045
|
-
|
|
11122
|
+
case 18:
|
|
11123
|
+
_t4 = _context2.v;
|
|
11124
|
+
case 19:
|
|
11125
|
+
processedBridgeHub = _t4;
|
|
11046
11126
|
// Update bridge hub fee in hops if needed
|
|
11047
11127
|
if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
11048
11128
|
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
|
|
@@ -11118,7 +11198,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11118
11198
|
failureReason: failureReason
|
|
11119
11199
|
}));
|
|
11120
11200
|
}
|
|
11121
|
-
}, _callee2, null, [[
|
|
11201
|
+
}, _callee2, null, [[5,, 8, 10]]);
|
|
11122
11202
|
}));
|
|
11123
11203
|
return function getXcmFeeInternal(_x) {
|
|
11124
11204
|
return _ref2.apply(this, arguments);
|
|
@@ -12356,12 +12436,14 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12356
12436
|
return depositInstruction;
|
|
12357
12437
|
};
|
|
12358
12438
|
|
|
12359
|
-
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version) {
|
|
12439
|
+
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
12360
12440
|
return {
|
|
12361
12441
|
SetAppendix: [{
|
|
12362
12442
|
DepositAsset: {
|
|
12363
12443
|
assets: {
|
|
12364
|
-
Wild:
|
|
12444
|
+
Wild: {
|
|
12445
|
+
AllCounted: assetCount
|
|
12446
|
+
}
|
|
12365
12447
|
},
|
|
12366
12448
|
beneficiary: createBeneficiaryLocation({
|
|
12367
12449
|
api: api,
|
|
@@ -12386,7 +12468,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12386
12468
|
*/
|
|
12387
12469
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12388
12470
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12389
|
-
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12471
|
+
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12390
12472
|
return _regenerator().w(function (_context) {
|
|
12391
12473
|
while (1) switch (_context.n) {
|
|
12392
12474
|
case 0:
|
|
@@ -12407,7 +12489,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12407
12489
|
}
|
|
12408
12490
|
});
|
|
12409
12491
|
customXcm = createCustomXcm(context, isDotAsset);
|
|
12410
|
-
|
|
12492
|
+
assetCount = isDotAsset ? 1 : 2;
|
|
12493
|
+
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12411
12494
|
_context.n = 2;
|
|
12412
12495
|
return computeAllFees(context, customXcm, isDotAsset, refundInstruction);
|
|
12413
12496
|
case 2:
|