@paraspell/sdk-core 11.7.2 → 11.8.0
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 +175 -129
- package/dist/index.d.ts +31 -25
- package/dist/index.mjs +175 -129
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -505,7 +505,7 @@ var IncompatibleChainsError = /*#__PURE__*/function (_Error) {
|
|
|
505
505
|
var _this;
|
|
506
506
|
_classCallCheck(this, IncompatibleChainsError);
|
|
507
507
|
_this = _callSuper(this, IncompatibleChainsError, [message !== null && message !== void 0 ? message : 'Transactions between chains on different relaychains are not yet possible.']);
|
|
508
|
-
_this.name = '
|
|
508
|
+
_this.name = 'IncompatibleChains';
|
|
509
509
|
return _this;
|
|
510
510
|
}
|
|
511
511
|
_inherits(IncompatibleChainsError, _Error);
|
|
@@ -1625,6 +1625,21 @@ var Unique$1 = {
|
|
|
1625
1625
|
}
|
|
1626
1626
|
]
|
|
1627
1627
|
};
|
|
1628
|
+
var Xode$1 = {
|
|
1629
|
+
name: "Xode",
|
|
1630
|
+
info: "xode",
|
|
1631
|
+
paraId: 3417,
|
|
1632
|
+
providers: [
|
|
1633
|
+
{
|
|
1634
|
+
name: "XodeCommunity",
|
|
1635
|
+
endpoint: "wss://polkadot-rpcnode.xode.net"
|
|
1636
|
+
},
|
|
1637
|
+
{
|
|
1638
|
+
name: "Zeeve",
|
|
1639
|
+
endpoint: "wss://xode-polkadot-rpc-01.zeeve.net/y0yxg038wn1fncc/rpc"
|
|
1640
|
+
}
|
|
1641
|
+
]
|
|
1642
|
+
};
|
|
1628
1643
|
var AssetHubKusama$1 = {
|
|
1629
1644
|
name: "AssetHub",
|
|
1630
1645
|
info: "KusamaAssetHub",
|
|
@@ -2585,6 +2600,7 @@ var configs = {
|
|
|
2585
2600
|
RobonomicsPolkadot: RobonomicsPolkadot$1,
|
|
2586
2601
|
PeoplePolkadot: PeoplePolkadot$1,
|
|
2587
2602
|
Unique: Unique$1,
|
|
2603
|
+
Xode: Xode$1,
|
|
2588
2604
|
AssetHubKusama: AssetHubKusama$1,
|
|
2589
2605
|
BridgeHubKusama: BridgeHubKusama$1,
|
|
2590
2606
|
IntegriteeKusama: IntegriteeKusama$1,
|
|
@@ -2703,7 +2719,7 @@ var getLocationTokenId = function getLocationTokenId(location, chain) {
|
|
|
2703
2719
|
return null;
|
|
2704
2720
|
};
|
|
2705
2721
|
|
|
2706
|
-
var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain,
|
|
2722
|
+
var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain, _executionFee) {
|
|
2707
2723
|
var isFeeAsset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2708
2724
|
// Extract delivery fees from emitted events
|
|
2709
2725
|
var deliveryFees = [];
|
|
@@ -2755,7 +2771,7 @@ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain, executio
|
|
|
2755
2771
|
}).reduce(function (acc, df) {
|
|
2756
2772
|
return acc + df.plancks;
|
|
2757
2773
|
}, 0n);
|
|
2758
|
-
return totalDeliveryFees
|
|
2774
|
+
return totalDeliveryFees;
|
|
2759
2775
|
}
|
|
2760
2776
|
};
|
|
2761
2777
|
|
|
@@ -3695,17 +3711,15 @@ var determineAddress = function determineAddress(chain, address, senderAddress)
|
|
|
3695
3711
|
};
|
|
3696
3712
|
var getReverseTxFee = /*#__PURE__*/function () {
|
|
3697
3713
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
3698
|
-
var api, origin, destination, senderAddress, address,
|
|
3714
|
+
var api, origin, destination, senderAddress, address, toAddress, fromAddress, tx, rawFee;
|
|
3699
3715
|
return _regenerator().w(function (_context) {
|
|
3700
3716
|
while (1) switch (_context.n) {
|
|
3701
3717
|
case 0:
|
|
3702
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address
|
|
3718
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address;
|
|
3703
3719
|
toAddress = determineAddress(origin, address, senderAddress);
|
|
3704
3720
|
fromAddress = determineAddress(destination, address, senderAddress);
|
|
3705
3721
|
_context.n = 1;
|
|
3706
|
-
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(
|
|
3707
|
-
amount: currency.amount
|
|
3708
|
-
}))['buildInternal']();
|
|
3722
|
+
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
|
|
3709
3723
|
case 1:
|
|
3710
3724
|
tx = _context.v;
|
|
3711
3725
|
_context.n = 2;
|
|
@@ -4366,7 +4380,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4366
4380
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4367
4381
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4368
4382
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
4369
|
-
var originAsset, _t;
|
|
4383
|
+
var originAsset, amount, _t;
|
|
4370
4384
|
return _regenerator().w(function (_context) {
|
|
4371
4385
|
while (1) switch (_context.p = _context.n) {
|
|
4372
4386
|
case 0:
|
|
@@ -4377,6 +4391,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4377
4391
|
return _context.a(2, 0n);
|
|
4378
4392
|
case 1:
|
|
4379
4393
|
originAsset = swapConfig !== null && swapConfig !== void 0 && swapConfig.currencyTo ? assets.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, destination) : assets.findAssetInfoOrThrow(origin, currency, destination);
|
|
4394
|
+
amount = swapConfig !== null && swapConfig !== void 0 && swapConfig.currencyTo ? swapConfig.amountOut : currency.amount;
|
|
4380
4395
|
if (!originAsset.location) {
|
|
4381
4396
|
_context.n = 7;
|
|
4382
4397
|
break;
|
|
@@ -4386,7 +4401,8 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4386
4401
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4387
4402
|
destination: destination
|
|
4388
4403
|
}), {
|
|
4389
|
-
location: originAsset.location
|
|
4404
|
+
location: originAsset.location,
|
|
4405
|
+
amount: amount
|
|
4390
4406
|
});
|
|
4391
4407
|
case 3:
|
|
4392
4408
|
return _context.a(2, _context.v);
|
|
@@ -4401,7 +4417,8 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4401
4417
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4402
4418
|
destination: destination
|
|
4403
4419
|
}), {
|
|
4404
|
-
symbol: originAsset.symbol
|
|
4420
|
+
symbol: originAsset.symbol,
|
|
4421
|
+
amount: amount
|
|
4405
4422
|
});
|
|
4406
4423
|
case 5:
|
|
4407
4424
|
return _context.a(2, _context.v);
|
|
@@ -4412,7 +4429,8 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4412
4429
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4413
4430
|
destination: destination
|
|
4414
4431
|
}), {
|
|
4415
|
-
symbol: originAsset.symbol
|
|
4432
|
+
symbol: originAsset.symbol,
|
|
4433
|
+
amount: amount
|
|
4416
4434
|
});
|
|
4417
4435
|
case 8:
|
|
4418
4436
|
return _context.a(2, _context.v);
|
|
@@ -5113,7 +5131,10 @@ function _traverseXcmHops() {
|
|
|
5113
5131
|
_context2.n = 4;
|
|
5114
5132
|
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5115
5133
|
case 4:
|
|
5116
|
-
|
|
5134
|
+
// true if this hop should be treated as the destination
|
|
5135
|
+
// - normally when nextChain === destination
|
|
5136
|
+
// - but if swap is required, only after (or on) the exchange hop const isDestination =
|
|
5137
|
+
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5117
5138
|
isAssetHub = nextChain === assetHubChain;
|
|
5118
5139
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
5119
5140
|
_context2.n = 5;
|
|
@@ -5476,16 +5497,17 @@ var createExchangeInstructions = /*#__PURE__*/function () {
|
|
|
5476
5497
|
}();
|
|
5477
5498
|
var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
5478
5499
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5479
|
-
var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, exchangeFee, destReserveFee, recipientAddress, version, paraIdTo, assetFrom, amountOut, assetTo, assetToLocalizedToDest, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, finalXcm, fullXcm;
|
|
5500
|
+
var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, exchangeFee, destReserveFee, recipientAddress, version, paraIdTo, assetFrom, MIN_FEE, amountOut, assetTo, assetToLocalizedToDest, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, finalXcm, fullXcm;
|
|
5480
5501
|
return _regenerator().w(function (_context2) {
|
|
5481
5502
|
while (1) switch (_context2.n) {
|
|
5482
5503
|
case 0:
|
|
5483
5504
|
api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, _options$fees2 = options.fees, originReserveFee = _options$fees2.originReserveFee, exchangeFee = _options$fees2.exchangeFee, destReserveFee = _options$fees2.destReserveFee, recipientAddress = options.recipientAddress, version = options.version, paraIdTo = options.paraIdTo;
|
|
5484
5505
|
assertHasLocation(assetInfoFrom);
|
|
5485
5506
|
assertHasLocation(assetInfoTo);
|
|
5486
|
-
assetFrom = createAsset(version,
|
|
5507
|
+
assetFrom = createAsset(version, assetInfoFrom.amount, localizeLocation(exchangeChain, assetInfoFrom.location));
|
|
5508
|
+
MIN_FEE = 1000n; // Exchange fee 0n means we are creating a dummy tx
|
|
5487
5509
|
// Set want to 1000n to prevent NoDeal
|
|
5488
|
-
amountOut = chain && exchangeFee === 0n ?
|
|
5510
|
+
amountOut = chain && exchangeFee === 0n ? MIN_FEE : assetInfoTo.amount;
|
|
5489
5511
|
assetTo = createAsset(version, amountOut, localizeLocation(exchangeChain, assetInfoTo.location));
|
|
5490
5512
|
assetToLocalizedToDest = createAsset(version, amountOut, localizeLocation(destChain !== null && destChain !== void 0 ? destChain : exchangeChain, assetInfoTo.location));
|
|
5491
5513
|
_prepareCommonExecute = prepareCommonExecuteXcm({
|
|
@@ -5505,6 +5527,12 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
|
5505
5527
|
return createExchangeInstructions(options, assetFrom, assetTo);
|
|
5506
5528
|
case 1:
|
|
5507
5529
|
exchangeInstructions = _context2.v;
|
|
5530
|
+
if (!(assetInfoTo.amount < MIN_FEE)) {
|
|
5531
|
+
_context2.n = 2;
|
|
5532
|
+
break;
|
|
5533
|
+
}
|
|
5534
|
+
throw new AmountTooLowError('Amount to receive after swap is too low, Increase Currency From amount.');
|
|
5535
|
+
case 2:
|
|
5508
5536
|
exchangeToDestXcm = destChain ? createBaseExecuteXcm({
|
|
5509
5537
|
chain: exchangeChain,
|
|
5510
5538
|
destChain: destChain,
|
|
@@ -5544,9 +5572,12 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
|
5544
5572
|
var FEE_PADDING_PERCENTAGE$1 = 20;
|
|
5545
5573
|
var validateAmount = function validateAmount(amount, requiredFee) {
|
|
5546
5574
|
if (amount <= requiredFee) {
|
|
5547
|
-
throw new
|
|
5575
|
+
throw new AmountTooLowError("Asset amount is too low, please increase the amount or use a different fee asset.");
|
|
5548
5576
|
}
|
|
5549
5577
|
};
|
|
5578
|
+
var calculateTotalFees = function calculateTotalFees(chain, fees) {
|
|
5579
|
+
return chain ? fees.originReserveFee + fees.exchangeFee : 0n;
|
|
5580
|
+
};
|
|
5550
5581
|
var executeDryRun = /*#__PURE__*/function () {
|
|
5551
5582
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5552
5583
|
var result;
|
|
@@ -5571,13 +5602,13 @@ var executeDryRun = /*#__PURE__*/function () {
|
|
|
5571
5602
|
return _ref.apply(this, arguments);
|
|
5572
5603
|
};
|
|
5573
5604
|
}();
|
|
5574
|
-
var findExchangeHopIndex = function findExchangeHopIndex(chain,
|
|
5605
|
+
var findExchangeHopIndex = function findExchangeHopIndex(chain, dryRunResult, exchangeChain, destChain) {
|
|
5575
5606
|
// If destChain is undefined, exchange chain is the final destination
|
|
5576
5607
|
if (!destChain) {
|
|
5577
5608
|
// Exchange is the final destination, so it's not in hops array
|
|
5578
5609
|
return -1;
|
|
5579
5610
|
}
|
|
5580
|
-
var index = hops.findIndex(function (hop) {
|
|
5611
|
+
var index = dryRunResult.hops.findIndex(function (hop) {
|
|
5581
5612
|
return hop.chain === exchangeChain;
|
|
5582
5613
|
});
|
|
5583
5614
|
// If chain is defined but no exchange hop found, it might be because
|
|
@@ -5697,7 +5728,7 @@ var createXcmAndCall = /*#__PURE__*/function () {
|
|
|
5697
5728
|
}();
|
|
5698
5729
|
var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
5699
5730
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
5700
|
-
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, internalOptions, dryRunParams, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees,
|
|
5731
|
+
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, internalOptions, dryRunParams, fees, totalFeesPre, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees, totalFees, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
|
|
5701
5732
|
return _regenerator().w(function (_context3) {
|
|
5702
5733
|
while (1) switch (_context3.n) {
|
|
5703
5734
|
case 0:
|
|
@@ -5705,7 +5736,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
5705
5736
|
_context3.n = 1;
|
|
5706
5737
|
return api.init(chain !== null && chain !== void 0 ? chain : exchangeChain);
|
|
5707
5738
|
case 1:
|
|
5708
|
-
validateAmount(
|
|
5739
|
+
validateAmount(assetFrom.amount, MIN_FEE);
|
|
5709
5740
|
version = getChainVersion(chain !== null && chain !== void 0 ? chain : exchangeChain);
|
|
5710
5741
|
internalOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
5711
5742
|
version: version,
|
|
@@ -5723,17 +5754,22 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
5723
5754
|
},
|
|
5724
5755
|
swapConfig: {
|
|
5725
5756
|
currencyTo: currencyTo,
|
|
5726
|
-
exchangeChain: exchangeChain
|
|
5757
|
+
exchangeChain: exchangeChain,
|
|
5758
|
+
amountOut: assetTo.amount
|
|
5727
5759
|
},
|
|
5728
5760
|
useRootOrigin: true
|
|
5729
|
-
};
|
|
5761
|
+
};
|
|
5762
|
+
fees = {
|
|
5763
|
+
originReserveFee: MIN_FEE,
|
|
5764
|
+
exchangeFee: 0n,
|
|
5765
|
+
destReserveFee: MIN_FEE
|
|
5766
|
+
};
|
|
5767
|
+
totalFeesPre = calculateTotalFees(chain, fees);
|
|
5768
|
+
validateAmount(assetFrom.amount, totalFeesPre);
|
|
5769
|
+
// First dry run with dummy fees to extract actual fees
|
|
5730
5770
|
_context3.n = 2;
|
|
5731
5771
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
5732
|
-
fees:
|
|
5733
|
-
originReserveFee: MIN_FEE,
|
|
5734
|
-
exchangeFee: 0n,
|
|
5735
|
-
destReserveFee: MIN_FEE
|
|
5736
|
-
}
|
|
5772
|
+
fees: fees
|
|
5737
5773
|
}));
|
|
5738
5774
|
case 2:
|
|
5739
5775
|
_yield$createXcmAndCa = _context3.v;
|
|
@@ -5744,35 +5780,40 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
5744
5780
|
}));
|
|
5745
5781
|
case 3:
|
|
5746
5782
|
firstDryRunResult = _context3.v;
|
|
5747
|
-
|
|
5783
|
+
if (!(firstDryRunResult.failureReason === 'NotHoldingFees')) {
|
|
5784
|
+
_context3.n = 4;
|
|
5785
|
+
break;
|
|
5786
|
+
}
|
|
5787
|
+
throw new AmountTooLowError("Asset amount is too low to cover the fees, please increase the amount.");
|
|
5788
|
+
case 4:
|
|
5789
|
+
exchangeHopIndex = findExchangeHopIndex(chain, firstDryRunResult, exchangeChain, destChain);
|
|
5748
5790
|
extractedFees = extractFeesFromDryRun(chain, firstDryRunResult, exchangeHopIndex, destChain, false);
|
|
5749
5791
|
if (extractedFees.exchangeFee === 0n) {
|
|
5750
5792
|
// We set the exchange fee to non-zero value to prevent creating dummy tx
|
|
5751
5793
|
extractedFees.exchangeFee = MIN_FEE;
|
|
5752
5794
|
}
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
validateAmount(BigInt(assetFrom.amount), totalFeesInFromAsset);
|
|
5795
|
+
totalFees = calculateTotalFees(chain, extractedFees);
|
|
5796
|
+
validateAmount(assetFrom.amount, totalFees);
|
|
5756
5797
|
updatedAssetTo = assetTo;
|
|
5757
5798
|
if (!chain) {
|
|
5758
|
-
_context3.n =
|
|
5799
|
+
_context3.n = 6;
|
|
5759
5800
|
break;
|
|
5760
5801
|
}
|
|
5761
|
-
amountAvailableForSwap =
|
|
5762
|
-
_context3.n =
|
|
5802
|
+
amountAvailableForSwap = assetFrom.amount - totalFees;
|
|
5803
|
+
_context3.n = 5;
|
|
5763
5804
|
return calculateMinAmountOut(amountAvailableForSwap);
|
|
5764
|
-
case
|
|
5805
|
+
case 5:
|
|
5765
5806
|
recalculatedMinAmountOut = _context3.v;
|
|
5766
5807
|
updatedAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
5767
5808
|
amount: recalculatedMinAmountOut
|
|
5768
5809
|
});
|
|
5769
|
-
case
|
|
5770
|
-
_context3.n =
|
|
5810
|
+
case 6:
|
|
5811
|
+
_context3.n = 7;
|
|
5771
5812
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
5772
5813
|
assetInfoTo: updatedAssetTo,
|
|
5773
5814
|
fees: extractedFees
|
|
5774
5815
|
}), firstDryRunResult.origin.success ? firstDryRunResult.origin.weight : undefined);
|
|
5775
|
-
case
|
|
5816
|
+
case 7:
|
|
5776
5817
|
_yield$createXcmAndCa2 = _context3.v;
|
|
5777
5818
|
finalCall = _yield$createXcmAndCa2.call;
|
|
5778
5819
|
return _context3.a(2, api.callTxMethod(finalCall));
|
|
@@ -6069,7 +6110,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6069
6110
|
api = sendOptions.api, asset = sendOptions.assetInfo, currency = sendOptions.currency, feeAsset = sendOptions.feeAsset, feeCurrency = sendOptions.feeCurrency, address = sendOptions.address, destination = sendOptions.to, paraIdTo = sendOptions.paraIdTo, overriddenAsset = sendOptions.overriddenAsset, version = sendOptions.version, senderAddress = sendOptions.senderAddress, ahAddress = sendOptions.ahAddress, pallet = sendOptions.pallet, method = sendOptions.method;
|
|
6070
6111
|
scenario = resolveScenario(this.chain, destination);
|
|
6071
6112
|
paraId = resolveParaId(paraIdTo, destination);
|
|
6072
|
-
destChain = resolveDestChain(this.chain, paraId);
|
|
6113
|
+
destChain = resolveDestChain(this.chain, paraId); // TODO: Use canReceiveFrom for this condition
|
|
6073
6114
|
if (!(destination === 'Polimec' && this.chain !== 'AssetHubPolkadot' && this.chain !== 'Hydration' && this.chain !== destination)) {
|
|
6074
6115
|
_context.n = 1;
|
|
6075
6116
|
break;
|
|
@@ -6084,6 +6125,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6084
6125
|
return _context.a(2, this.transferLocal(sendOptions));
|
|
6085
6126
|
case 2:
|
|
6086
6127
|
this.throwIfTempDisabled(sendOptions, destChain);
|
|
6128
|
+
this.throwIfCantReceive(destChain);
|
|
6087
6129
|
isRelayAsset = sdkCommon.deepEqual(asset.location, RELAY_LOCATION);
|
|
6088
6130
|
_context.n = 3;
|
|
6089
6131
|
return api.hasMethod('PolkadotXcm', 'transfer_assets_using_type_and_then');
|
|
@@ -6142,7 +6184,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6142
6184
|
}));
|
|
6143
6185
|
case 7:
|
|
6144
6186
|
if (!(supportsPolkadotXCM(this) || useTypeAndThen)) {
|
|
6145
|
-
_context.n =
|
|
6187
|
+
_context.n = 13;
|
|
6146
6188
|
break;
|
|
6147
6189
|
}
|
|
6148
6190
|
options = {
|
|
@@ -6195,23 +6237,30 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6195
6237
|
isExternalAssetViaAh = isExternalAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
|
|
6196
6238
|
isExternalAssetToAh = isExternalAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
|
|
6197
6239
|
if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
|
|
6198
|
-
_context.n =
|
|
6240
|
+
_context.n = 12;
|
|
6241
|
+
break;
|
|
6242
|
+
}
|
|
6243
|
+
if (!(useTypeAndThen && supportsPolkadotXCM(this))) {
|
|
6244
|
+
_context.n = 10;
|
|
6199
6245
|
break;
|
|
6200
6246
|
}
|
|
6201
6247
|
_context.n = 10;
|
|
6202
|
-
return
|
|
6248
|
+
return this.transferPolkadotXCM(options);
|
|
6203
6249
|
case 10:
|
|
6250
|
+
_context.n = 11;
|
|
6251
|
+
return createTypeAndThenCall(this.chain, options);
|
|
6252
|
+
case 11:
|
|
6204
6253
|
call = _context.v;
|
|
6205
6254
|
return _context.a(2, api.callTxMethod(call));
|
|
6206
|
-
case
|
|
6255
|
+
case 12:
|
|
6207
6256
|
if (!supportsPolkadotXCM(this)) {
|
|
6208
|
-
_context.n =
|
|
6257
|
+
_context.n = 13;
|
|
6209
6258
|
break;
|
|
6210
6259
|
}
|
|
6211
6260
|
return _context.a(2, this.transferPolkadotXCM(options));
|
|
6212
|
-
case 12:
|
|
6213
|
-
throw new NoXCMSupportImplementedError(this._chain);
|
|
6214
6261
|
case 13:
|
|
6262
|
+
throw new NoXCMSupportImplementedError(this._chain);
|
|
6263
|
+
case 14:
|
|
6215
6264
|
return _context.a(2);
|
|
6216
6265
|
}
|
|
6217
6266
|
}, _callee, this);
|
|
@@ -6221,6 +6270,16 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6221
6270
|
}
|
|
6222
6271
|
return transfer;
|
|
6223
6272
|
}()
|
|
6273
|
+
}, {
|
|
6274
|
+
key: "throwIfCantReceive",
|
|
6275
|
+
value: function throwIfCantReceive(destChain) {
|
|
6276
|
+
if (destChain && !sdkCommon.isRelayChain(destChain) && !sdkCommon.isExternalChain(destChain)) {
|
|
6277
|
+
var dest = getChain(destChain);
|
|
6278
|
+
if (!dest.canReceiveFrom(this.chain)) {
|
|
6279
|
+
throw new IncompatibleChainsError("Receiving on ".concat(destChain, " from ").concat(this.chain, " is not yet enabled"));
|
|
6280
|
+
}
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6224
6283
|
}, {
|
|
6225
6284
|
key: "throwIfTempDisabled",
|
|
6226
6285
|
value: function throwIfTempDisabled(options, destChain) {
|
|
@@ -6243,6 +6302,12 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6243
6302
|
value: function isReceivingTempDisabled(_options) {
|
|
6244
6303
|
return false;
|
|
6245
6304
|
}
|
|
6305
|
+
}, {
|
|
6306
|
+
key: "canReceiveFrom",
|
|
6307
|
+
value: function canReceiveFrom(_origin) {
|
|
6308
|
+
// Default: destination accepts from any origin
|
|
6309
|
+
return true;
|
|
6310
|
+
}
|
|
6246
6311
|
}, {
|
|
6247
6312
|
key: "shouldUseNativeAssetTeleport",
|
|
6248
6313
|
value: function shouldUseNativeAssetTeleport(_ref) {
|
|
@@ -6593,50 +6658,11 @@ var Ajuna = /*#__PURE__*/function (_Parachain) {
|
|
|
6593
6658
|
}
|
|
6594
6659
|
return transferXTokens(input, this.getNativeAssetSymbol());
|
|
6595
6660
|
}
|
|
6596
|
-
}, {
|
|
6597
|
-
key: "transferPolkadotXCM",
|
|
6598
|
-
value: function () {
|
|
6599
|
-
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
|
|
6600
|
-
var api, _t;
|
|
6601
|
-
return _regenerator().w(function (_context) {
|
|
6602
|
-
while (1) switch (_context.n) {
|
|
6603
|
-
case 0:
|
|
6604
|
-
api = input.api;
|
|
6605
|
-
_t = api;
|
|
6606
|
-
_context.n = 1;
|
|
6607
|
-
return createTypeAndThenCall(this.chain, input);
|
|
6608
|
-
case 1:
|
|
6609
|
-
return _context.a(2, _t.callTxMethod.call(_t, _context.v));
|
|
6610
|
-
}
|
|
6611
|
-
}, _callee, this);
|
|
6612
|
-
}));
|
|
6613
|
-
function transferPolkadotXCM(_x) {
|
|
6614
|
-
return _transferPolkadotXCM.apply(this, arguments);
|
|
6615
|
-
}
|
|
6616
|
-
return transferPolkadotXCM;
|
|
6617
|
-
}()
|
|
6618
|
-
}, {
|
|
6619
|
-
key: "canUseXTokens",
|
|
6620
|
-
value: function canUseXTokens(_ref) {
|
|
6621
|
-
var assetInfo = _ref.assetInfo,
|
|
6622
|
-
destination = _ref.to;
|
|
6623
|
-
return !(assetInfo.symbol === 'DOT' && destination === 'AssetHubPolkadot');
|
|
6624
|
-
}
|
|
6625
6661
|
}, {
|
|
6626
6662
|
key: "transferRelayToPara",
|
|
6627
6663
|
value: function transferRelayToPara() {
|
|
6628
6664
|
throw new ChainNotSupportedError();
|
|
6629
6665
|
}
|
|
6630
|
-
}, {
|
|
6631
|
-
key: "isSendingTempDisabled",
|
|
6632
|
-
value: function isSendingTempDisabled(_options) {
|
|
6633
|
-
return true;
|
|
6634
|
-
}
|
|
6635
|
-
}, {
|
|
6636
|
-
key: "isReceivingTempDisabled",
|
|
6637
|
-
value: function isReceivingTempDisabled(_options) {
|
|
6638
|
-
return true;
|
|
6639
|
-
}
|
|
6640
6666
|
}, {
|
|
6641
6667
|
key: "transferLocalNonNativeAsset",
|
|
6642
6668
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -6796,10 +6822,6 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
6796
6822
|
if (destination === 'AssetHubPolkadot') {
|
|
6797
6823
|
return getChain('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
|
|
6798
6824
|
}
|
|
6799
|
-
var isTrusted = !sdkCommon.isTLocation(destination) && sdkCommon.isTrustedChain(destination);
|
|
6800
|
-
if (scenario === 'ParaToPara' && asset.symbol === 'KSM' && !assets.isForeignAsset(asset) && !isTrusted) {
|
|
6801
|
-
throw new ScenarioNotSupportedError(this.chain, scenario, 'Para to Para scenarios for KSM transfer from AssetHub are not supported, you have to transfer KSM to Relay chain and transfer to destination chain from Relay chain.');
|
|
6802
|
-
}
|
|
6803
6825
|
if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset)) {
|
|
6804
6826
|
throw new ScenarioNotSupportedError(this.chain, scenario, 'Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
|
|
6805
6827
|
}
|
|
@@ -7042,7 +7064,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7042
7064
|
key: "transferPolkadotXCM",
|
|
7043
7065
|
value: function () {
|
|
7044
7066
|
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
7045
|
-
var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call,
|
|
7067
|
+
var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call, method, modifiedInput, _t, _t2;
|
|
7046
7068
|
return _regenerator().w(function (_context3) {
|
|
7047
7069
|
while (1) switch (_context3.n) {
|
|
7048
7070
|
case 0:
|
|
@@ -7108,32 +7130,23 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7108
7130
|
_call = _context3.v;
|
|
7109
7131
|
return _context3.a(2, api.callTxMethod(_call));
|
|
7110
7132
|
case 10:
|
|
7111
|
-
CHAINS_SUPPORT_DOT_TRANSFER = new Set(['Hydration', 'Polimec', 'Moonbeam', 'BifrostPolkadot', 'PeoplePolkadot', 'Ajuna']);
|
|
7112
|
-
isTrusted = !sdkCommon.isTLocation(destination) && sdkCommon.isTrustedChain(destination);
|
|
7113
|
-
isDotReserveAh = !sdkCommon.isTLocation(destination) && CHAINS_SUPPORT_DOT_TRANSFER.has(destination);
|
|
7114
|
-
if (!(scenario === 'ParaToPara' && assetInfo.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(assetInfo) && !isDotReserveAh && !isTrusted)) {
|
|
7115
|
-
_context3.n = 11;
|
|
7116
|
-
break;
|
|
7117
|
-
}
|
|
7118
|
-
throw new ScenarioNotSupportedError(this.chain, scenario, 'Some Parachains do not have a reserve for DOT on AssetHub. This can also include multihop transfers that have AssetHub as a hop chain and the call contains DOT. Chains that do not have a DOT reserve on AssetHub are not allowed to transfer DOT to it or through it because this transfer will result in asset loss.');
|
|
7119
|
-
case 11:
|
|
7120
7133
|
if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !assets.isForeignAsset(assetInfo))) {
|
|
7121
|
-
_context3.n =
|
|
7134
|
+
_context3.n = 11;
|
|
7122
7135
|
break;
|
|
7123
7136
|
}
|
|
7124
7137
|
throw new ScenarioNotSupportedError(this.chain, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
|
|
7125
|
-
case
|
|
7138
|
+
case 11:
|
|
7126
7139
|
method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
|
|
7127
7140
|
if (!(method === 'transfer_assets' && assets.isSymbolMatch(assetInfo.symbol, assets.getRelayChainSymbol(this.chain)))) {
|
|
7128
|
-
_context3.n =
|
|
7141
|
+
_context3.n = 13;
|
|
7129
7142
|
break;
|
|
7130
7143
|
}
|
|
7131
7144
|
_t2 = api;
|
|
7132
|
-
_context3.n =
|
|
7145
|
+
_context3.n = 12;
|
|
7133
7146
|
return createTypeAndThenCall(this.chain, options);
|
|
7134
|
-
case
|
|
7147
|
+
case 12:
|
|
7135
7148
|
return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
|
|
7136
|
-
case
|
|
7149
|
+
case 13:
|
|
7137
7150
|
modifiedInput = this.patchInput(options);
|
|
7138
7151
|
return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
|
|
7139
7152
|
}
|
|
@@ -7398,12 +7411,12 @@ var BifrostPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7398
7411
|
}()
|
|
7399
7412
|
}, {
|
|
7400
7413
|
key: "transferPolkadotXCM",
|
|
7401
|
-
value: function transferPolkadotXCM(
|
|
7402
|
-
var destination =
|
|
7414
|
+
value: function transferPolkadotXCM(options) {
|
|
7415
|
+
var destination = options.destination;
|
|
7403
7416
|
if (destination === 'Ethereum') {
|
|
7404
|
-
return this.transferToEthereum(
|
|
7417
|
+
return this.transferToEthereum(options);
|
|
7405
7418
|
}
|
|
7406
|
-
return this.transferToAssetHub(
|
|
7419
|
+
return this.transferToAssetHub(options);
|
|
7407
7420
|
}
|
|
7408
7421
|
}, {
|
|
7409
7422
|
key: "canUseXTokens",
|
|
@@ -9459,6 +9472,34 @@ var Unique = /*#__PURE__*/function (_Parachain) {
|
|
|
9459
9472
|
}(Parachain);
|
|
9460
9473
|
Unique.NATIVE_ASSET_ID = 0;
|
|
9461
9474
|
|
|
9475
|
+
var Xode = /*#__PURE__*/function (_Parachain) {
|
|
9476
|
+
function Xode() {
|
|
9477
|
+
_classCallCheck(this, Xode);
|
|
9478
|
+
return _callSuper(this, Xode, ['Xode', 'xode', 'Polkadot', sdkCommon.Version.V4]);
|
|
9479
|
+
}
|
|
9480
|
+
_inherits(Xode, _Parachain);
|
|
9481
|
+
return _createClass(Xode, [{
|
|
9482
|
+
key: "transferPolkadotXCM",
|
|
9483
|
+
value: function transferPolkadotXCM(options) {
|
|
9484
|
+
var destChain = options.destChain,
|
|
9485
|
+
assetInfo = options.assetInfo,
|
|
9486
|
+
scenario = options.scenario;
|
|
9487
|
+
if (destChain !== 'AssetHubPolkadot' && scenario === 'ParaToPara') {
|
|
9488
|
+
throw new IncompatibleChainsError('Xode chain only supports transfers to / from AssetHubPolkadot');
|
|
9489
|
+
}
|
|
9490
|
+
assertHasLocation(assetInfo);
|
|
9491
|
+
return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9492
|
+
asset: createAsset(this.version, assetInfo.amount, assetInfo.location)
|
|
9493
|
+
}), 'limited_reserve_transfer_assets', 'Unlimited');
|
|
9494
|
+
}
|
|
9495
|
+
}, {
|
|
9496
|
+
key: "canReceiveFrom",
|
|
9497
|
+
value: function canReceiveFrom(origin) {
|
|
9498
|
+
return origin === 'AssetHubPolkadot';
|
|
9499
|
+
}
|
|
9500
|
+
}]);
|
|
9501
|
+
}(Parachain);
|
|
9502
|
+
|
|
9462
9503
|
var Zeitgeist = /*#__PURE__*/function (_Parachain) {
|
|
9463
9504
|
function Zeitgeist() {
|
|
9464
9505
|
var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Zeitgeist';
|
|
@@ -9518,6 +9559,7 @@ var ZeitgeistPaseo = /*#__PURE__*/function (_Zeitgeist) {
|
|
|
9518
9559
|
|
|
9519
9560
|
var chains = function chains() {
|
|
9520
9561
|
return {
|
|
9562
|
+
// Polkadot chains
|
|
9521
9563
|
AssetHubPolkadot: new AssetHubPolkadot(),
|
|
9522
9564
|
Acala: new Acala(),
|
|
9523
9565
|
Ajuna: new Ajuna(),
|
|
@@ -9526,21 +9568,37 @@ var chains = function chains() {
|
|
|
9526
9568
|
Crust: new Crust(),
|
|
9527
9569
|
BifrostPolkadot: new BifrostPolkadot(),
|
|
9528
9570
|
BridgeHubPolkadot: new BridgeHubPolkadot(),
|
|
9529
|
-
BridgeHubKusama: new BridgeHubKusama(),
|
|
9530
9571
|
Centrifuge: new Centrifuge(),
|
|
9531
9572
|
ComposableFinance: new ComposableFinance(),
|
|
9532
9573
|
Darwinia: new Darwinia(),
|
|
9533
9574
|
EnergyWebX: new EnergyWebX(),
|
|
9534
9575
|
Hydration: new Hydration(),
|
|
9535
|
-
IntegriteeKusama: new IntegriteeKusama(),
|
|
9536
9576
|
IntegriteePolkadot: new IntegriteePolkadot(),
|
|
9537
9577
|
Interlay: new Interlay(),
|
|
9538
9578
|
Heima: new Heima(),
|
|
9539
9579
|
Jamton: new Jamton(),
|
|
9540
9580
|
Moonbeam: new Moonbeam(),
|
|
9581
|
+
CoretimePolkadot: new CoretimePolkadot(),
|
|
9582
|
+
RobonomicsPolkadot: new RobonomicsPolkadot(),
|
|
9583
|
+
PeoplePolkadot: new PeoplePolkadot(),
|
|
9584
|
+
Manta: new Manta(),
|
|
9585
|
+
Nodle: new Nodle(),
|
|
9586
|
+
NeuroWeb: new NeuroWeb(),
|
|
9587
|
+
Pendulum: new Pendulum(),
|
|
9588
|
+
Collectives: new Collectives(),
|
|
9589
|
+
Phala: new Phala(),
|
|
9590
|
+
Subsocial: new Subsocial(),
|
|
9591
|
+
KiltSpiritnet: new KiltSpiritnet(),
|
|
9592
|
+
Curio: new Curio(),
|
|
9593
|
+
Mythos: new Mythos(),
|
|
9594
|
+
Peaq: new Peaq(),
|
|
9595
|
+
Polimec: new Polimec(),
|
|
9596
|
+
Xode: new Xode(),
|
|
9597
|
+
// Kusama chains
|
|
9541
9598
|
AssetHubKusama: new AssetHubKusama(),
|
|
9599
|
+
BridgeHubKusama: new BridgeHubKusama(),
|
|
9542
9600
|
CoretimeKusama: new CoretimeKusama(),
|
|
9543
|
-
|
|
9601
|
+
IntegriteeKusama: new IntegriteeKusama(),
|
|
9544
9602
|
Encointer: new Encointer(),
|
|
9545
9603
|
Altair: new Altair(),
|
|
9546
9604
|
Amplitude: new Amplitude(),
|
|
@@ -9554,23 +9612,9 @@ var chains = function chains() {
|
|
|
9554
9612
|
Laos: new Laos(),
|
|
9555
9613
|
Quartz: new Quartz(),
|
|
9556
9614
|
RobonomicsKusama: new RobonomicsKusama(),
|
|
9557
|
-
RobonomicsPolkadot: new RobonomicsPolkadot(),
|
|
9558
|
-
PeoplePolkadot: new PeoplePolkadot(),
|
|
9559
9615
|
PeopleKusama: new PeopleKusama(),
|
|
9560
9616
|
Shiden: new Shiden(),
|
|
9561
|
-
Manta: new Manta(),
|
|
9562
|
-
Nodle: new Nodle(),
|
|
9563
|
-
NeuroWeb: new NeuroWeb(),
|
|
9564
|
-
Pendulum: new Pendulum(),
|
|
9565
9617
|
Zeitgeist: new Zeitgeist(),
|
|
9566
|
-
Collectives: new Collectives(),
|
|
9567
|
-
Phala: new Phala(),
|
|
9568
|
-
Subsocial: new Subsocial(),
|
|
9569
|
-
KiltSpiritnet: new KiltSpiritnet(),
|
|
9570
|
-
Curio: new Curio(),
|
|
9571
|
-
Mythos: new Mythos(),
|
|
9572
|
-
Peaq: new Peaq(),
|
|
9573
|
-
Polimec: new Polimec(),
|
|
9574
9618
|
// Westend chains
|
|
9575
9619
|
AssetHubWestend: new AssetHubWestend(),
|
|
9576
9620
|
BridgeHubWestend: new BridgeHubWestend(),
|
|
@@ -11023,9 +11067,11 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
11023
11067
|
case 6:
|
|
11024
11068
|
originFeeDetails = _context.v;
|
|
11025
11069
|
currencyInput = originAsset.location ? {
|
|
11026
|
-
location: originAsset.location
|
|
11070
|
+
location: originAsset.location,
|
|
11071
|
+
amount: amount
|
|
11027
11072
|
} : {
|
|
11028
|
-
symbol: originAsset.symbol
|
|
11073
|
+
symbol: originAsset.symbol,
|
|
11074
|
+
amount: amount
|
|
11029
11075
|
};
|
|
11030
11076
|
if (!(destination === 'Ethereum')) {
|
|
11031
11077
|
_context.n = 7;
|