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