@paraspell/sdk-core 11.12.1 → 11.12.3
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 +385 -331
- package/dist/index.d.ts +211 -207
- package/dist/index.mjs +387 -333
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3090,7 +3090,13 @@ var getChainLocation = function getChainLocation(chain, destChain) {
|
|
|
3090
3090
|
* @param location - The location to localize
|
|
3091
3091
|
* @returns The localized location
|
|
3092
3092
|
*/
|
|
3093
|
-
var localizeLocation = function localizeLocation(chain, location) {
|
|
3093
|
+
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
3094
|
+
var targetRelay = sdkCommon.isExternalChain(chain) ? undefined : getRelayChainOf(chain).toLowerCase();
|
|
3095
|
+
var originRelay = origin && !sdkCommon.isExternalChain(origin) ? getRelayChainOf(origin).toLowerCase() : undefined;
|
|
3096
|
+
var ecosystemDiffers = originRelay !== targetRelay;
|
|
3097
|
+
if (origin && ecosystemDiffers && location.parents === sdkCommon.Parents.TWO && originRelay !== undefined && targetRelay !== undefined && sdkCommon.deepEqual(sdkCommon.getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null))) {
|
|
3098
|
+
return RELAY_LOCATION;
|
|
3099
|
+
}
|
|
3094
3100
|
var newInterior = location.interior;
|
|
3095
3101
|
var parachainRemoved = false;
|
|
3096
3102
|
if (location.interior !== 'Here') {
|
|
@@ -3114,6 +3120,20 @@ var localizeLocation = function localizeLocation(chain, location) {
|
|
|
3114
3120
|
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
3115
3121
|
}
|
|
3116
3122
|
}
|
|
3123
|
+
var isOriginRelayHere = sdkCommon.deepEqual(location, RELAY_LOCATION);
|
|
3124
|
+
var hasGlobalConsensus = sdkCommon.hasJunction(location, 'GlobalConsensus');
|
|
3125
|
+
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
3126
|
+
return {
|
|
3127
|
+
parents: sdkCommon.Parents.TWO,
|
|
3128
|
+
interior: {
|
|
3129
|
+
X2: [{
|
|
3130
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3131
|
+
}, {
|
|
3132
|
+
Parachain: getParaId(origin)
|
|
3133
|
+
}]
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
}
|
|
3117
3137
|
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && sdkCommon.isRelayChain(chain);
|
|
3118
3138
|
return {
|
|
3119
3139
|
parents: shouldSetParentsToZero ? sdkCommon.Parents.ZERO : location.parents,
|
|
@@ -3242,13 +3262,26 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
|
|
|
3242
3262
|
};
|
|
3243
3263
|
|
|
3244
3264
|
var createDestination = function createDestination(version, origin, destination, chainId, junction, parents) {
|
|
3265
|
+
var isLocDestination = sdkCommon.isTLocation(destination);
|
|
3266
|
+
var isSubBridge = !isLocDestination && !sdkCommon.isExternalChain(destination) && sdkCommon.isSubstrateBridge(origin, destination);
|
|
3267
|
+
if (isSubBridge) {
|
|
3268
|
+
return {
|
|
3269
|
+
parents: sdkCommon.Parents.TWO,
|
|
3270
|
+
interior: {
|
|
3271
|
+
X2: [{
|
|
3272
|
+
GlobalConsensus: getRelayChainOf(destination)
|
|
3273
|
+
}, {
|
|
3274
|
+
Parachain: chainId
|
|
3275
|
+
}]
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3245
3279
|
var scenario = resolveScenario(origin, destination);
|
|
3246
3280
|
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? sdkCommon.Parents.ZERO : sdkCommon.Parents.ONE;
|
|
3247
3281
|
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
3248
3282
|
Parachain: chainId
|
|
3249
3283
|
});
|
|
3250
|
-
|
|
3251
|
-
return isLocationDestination ? destination : {
|
|
3284
|
+
return isLocDestination ? destination : {
|
|
3252
3285
|
parents: parentsResolved,
|
|
3253
3286
|
interior: interior
|
|
3254
3287
|
};
|
|
@@ -3257,19 +3290,6 @@ var createVersionedDestination = function createVersionedDestination(version, or
|
|
|
3257
3290
|
var plainDestination = createDestination(version, origin, destination, chainId, junction, parents);
|
|
3258
3291
|
return addXcmVersionHeader(plainDestination, version);
|
|
3259
3292
|
};
|
|
3260
|
-
var createBridgeDestination = function createBridgeDestination(ecosystem, destination, chainId) {
|
|
3261
|
-
var location = {
|
|
3262
|
-
parents: sdkCommon.Parents.TWO,
|
|
3263
|
-
interior: {
|
|
3264
|
-
X2: [{
|
|
3265
|
-
GlobalConsensus: ecosystem
|
|
3266
|
-
}, {
|
|
3267
|
-
Parachain: chainId
|
|
3268
|
-
}]
|
|
3269
|
-
}
|
|
3270
|
-
};
|
|
3271
|
-
return sdkCommon.isTLocation(destination) ? destination : location;
|
|
3272
|
-
};
|
|
3273
3293
|
var resolveTChainFromLocation = function resolveTChainFromLocation(relaychain, location) {
|
|
3274
3294
|
var _PARACHAINS$find;
|
|
3275
3295
|
var parachainId = sdkCommon.getJunctionValue(location, 'Parachain');
|
|
@@ -3649,9 +3669,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3649
3669
|
assertSenderAddress(senderAddress);
|
|
3650
3670
|
assertAddressIsString(address);
|
|
3651
3671
|
checkAmount = function checkAmount(fee) {
|
|
3652
|
-
if (assetInfo.amount <= fee)
|
|
3653
|
-
throw new InvalidParameterError("Asset amount is too low, please increase the amount or use a different fee asset.");
|
|
3654
|
-
}
|
|
3672
|
+
if (assetInfo.amount <= fee) throw new AmountTooLowError();
|
|
3655
3673
|
};
|
|
3656
3674
|
checkAmount(MIN_FEE);
|
|
3657
3675
|
destChain = getTChain(paraIdTo, getRelayChainOf(chain));
|
|
@@ -4500,6 +4518,204 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4500
4518
|
};
|
|
4501
4519
|
}();
|
|
4502
4520
|
|
|
4521
|
+
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
4522
|
+
return assetCheckEnabled ? assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null) : null;
|
|
4523
|
+
};
|
|
4524
|
+
|
|
4525
|
+
var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
4526
|
+
var _asset$location, _findAssetInfoOnDest;
|
|
4527
|
+
var originChain = _ref.originChain,
|
|
4528
|
+
currentChain = _ref.currentChain,
|
|
4529
|
+
swapConfig = _ref.swapConfig,
|
|
4530
|
+
asset = _ref.asset,
|
|
4531
|
+
hasPassedExchange = _ref.hasPassedExchange,
|
|
4532
|
+
currency = _ref.currency;
|
|
4533
|
+
var isExternalAsset = ((_asset$location = asset.location) === null || _asset$location === void 0 ? void 0 : _asset$location.parents) === sdkCommon.Parents.TWO;
|
|
4534
|
+
if (isExternalAsset) {
|
|
4535
|
+
return assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
4536
|
+
}
|
|
4537
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
4538
|
+
return assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
4539
|
+
}
|
|
4540
|
+
return (_findAssetInfoOnDest = assets.findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge) {
|
|
4544
|
+
var _asset$location;
|
|
4545
|
+
if (!asset || sdkCommon.isTLocation(destination) || sdkCommon.isExternalChain(destination) || !isBridge) {
|
|
4546
|
+
return;
|
|
4547
|
+
}
|
|
4548
|
+
var nativeAsset = assets.findNativeAssetInfoOrThrow(origin);
|
|
4549
|
+
var isNativeAsset = assets.isAssetEqual(asset, nativeAsset);
|
|
4550
|
+
var ecosystem = getRelayChainOf(destination).toLowerCase();
|
|
4551
|
+
var isBridgedAsset = ((_asset$location = asset.location) === null || _asset$location === void 0 ? void 0 : _asset$location.parents) === sdkCommon.Parents.TWO && sdkCommon.deepEqual(sdkCommon.getJunctionValue(asset.location, 'GlobalConsensus'), _defineProperty({}, ecosystem, null));
|
|
4552
|
+
if (!(isNativeAsset || isBridgedAsset)) {
|
|
4553
|
+
throw new assets.InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
|
|
4554
|
+
}
|
|
4555
|
+
};
|
|
4556
|
+
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
4557
|
+
var origin = _ref.from,
|
|
4558
|
+
destination = _ref.to,
|
|
4559
|
+
currency = _ref.currency;
|
|
4560
|
+
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
4561
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
4562
|
+
if (!isBridge && !isRelayDestination && !isLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !assets.hasSupportForAsset(destination, asset.symbol)) {
|
|
4563
|
+
throw new assets.InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
|
|
4564
|
+
}
|
|
4565
|
+
if (asset === null && assetCheckEnabled) {
|
|
4566
|
+
throwUnsupportedCurrency(currency, origin);
|
|
4567
|
+
}
|
|
4568
|
+
validateBridgeAsset(origin, destination, asset, currency, isBridge);
|
|
4569
|
+
};
|
|
4570
|
+
|
|
4571
|
+
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
4572
|
+
var api = options.api,
|
|
4573
|
+
currency = options.currency,
|
|
4574
|
+
feeAsset = options.feeAsset,
|
|
4575
|
+
origin = options.from,
|
|
4576
|
+
destination = options.to;
|
|
4577
|
+
if ('location' in currency && assets.isOverrideLocationSpecifier(currency.location)) {
|
|
4578
|
+
return currency.location.value;
|
|
4579
|
+
}
|
|
4580
|
+
if (Array.isArray(currency)) {
|
|
4581
|
+
if (!feeAsset) {
|
|
4582
|
+
throw new assets.InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
4583
|
+
}
|
|
4584
|
+
if ('location' in feeAsset && assets.isOverrideLocationSpecifier(feeAsset.location)) {
|
|
4585
|
+
throw new assets.InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
4586
|
+
}
|
|
4587
|
+
if (currency.every(function (asset) {
|
|
4588
|
+
return assets.isTAsset(asset);
|
|
4589
|
+
})) {
|
|
4590
|
+
if (!feeAsset) {
|
|
4591
|
+
throw new assets.InvalidCurrencyError('Fee asset not provided');
|
|
4592
|
+
}
|
|
4593
|
+
if (!('location' in feeAsset)) {
|
|
4594
|
+
throw new assets.InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
4595
|
+
}
|
|
4596
|
+
return currency.map(function (asset) {
|
|
4597
|
+
var ml = assets.extractAssetLocation(asset);
|
|
4598
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4599
|
+
fun: {
|
|
4600
|
+
Fungible: BigInt(asset.fun.Fungible)
|
|
4601
|
+
},
|
|
4602
|
+
isFeeAsset: sdkCommon.deepEqual(ml, feeAsset.location)
|
|
4603
|
+
});
|
|
4604
|
+
});
|
|
4605
|
+
}
|
|
4606
|
+
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
4607
|
+
var assets$1 = currency.map(function (currency) {
|
|
4608
|
+
if (currency.amount === AMOUNT_ALL) {
|
|
4609
|
+
throw new assets.InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
4610
|
+
}
|
|
4611
|
+
var asset = assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null);
|
|
4612
|
+
if (!asset) {
|
|
4613
|
+
throw new assets.InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
4614
|
+
}
|
|
4615
|
+
assertHasLocation(asset);
|
|
4616
|
+
if (!resolvedFeeAsset) {
|
|
4617
|
+
throw new assets.InvalidCurrencyError('Fee asset not found');
|
|
4618
|
+
}
|
|
4619
|
+
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
4620
|
+
var version = getChainVersion(origin);
|
|
4621
|
+
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
4622
|
+
return _objectSpread2({
|
|
4623
|
+
isFeeAsset: assets.isAssetEqual(resolvedFeeAsset, asset)
|
|
4624
|
+
}, createAsset(version, abstractedAmount, asset.location));
|
|
4625
|
+
});
|
|
4626
|
+
if (assets$1.filter(function (asset) {
|
|
4627
|
+
return asset.isFeeAsset;
|
|
4628
|
+
}).length > 1) {
|
|
4629
|
+
throw new assets.InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
4630
|
+
}
|
|
4631
|
+
if (assets$1.filter(function (asset) {
|
|
4632
|
+
return asset.isFeeAsset;
|
|
4633
|
+
}).length === 0) {
|
|
4634
|
+
throw new assets.InvalidCurrencyError("Fee asset not found in multiassets");
|
|
4635
|
+
}
|
|
4636
|
+
return assets$1;
|
|
4637
|
+
}
|
|
4638
|
+
return undefined;
|
|
4639
|
+
};
|
|
4640
|
+
|
|
4641
|
+
var selectXcmVersion = function selectXcmVersion(forcedVersion, originVersion, destMaxVersion) {
|
|
4642
|
+
if (forcedVersion) return forcedVersion;
|
|
4643
|
+
var destVersion = destMaxVersion !== null && destMaxVersion !== void 0 ? destMaxVersion : originVersion;
|
|
4644
|
+
return destVersion < originVersion ? destVersion : originVersion;
|
|
4645
|
+
};
|
|
4646
|
+
|
|
4647
|
+
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
4648
|
+
if (sdkCommon.isRelayChain(origin)) return true;
|
|
4649
|
+
var isMultipleAssets = Array.isArray(currency);
|
|
4650
|
+
var hasOverriddenLocation = 'location' in currency && assets.isOverrideLocationSpecifier(currency.location);
|
|
4651
|
+
return !(isMultipleAssets || hasOverriddenLocation);
|
|
4652
|
+
};
|
|
4653
|
+
|
|
4654
|
+
var validateAddress = function validateAddress(address, chain) {
|
|
4655
|
+
var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
4656
|
+
if (sdkCommon.isTLocation(address)) return;
|
|
4657
|
+
var isEvm = assets.isChainEvm(chain);
|
|
4658
|
+
var isEthereumAddress = viem.isAddress(address);
|
|
4659
|
+
if (isEvm) {
|
|
4660
|
+
if (!isEthereumAddress) {
|
|
4661
|
+
throw new InvalidAddressError("".concat(isDestination ? 'Destination chain' : 'Chain', " is an EVM chain, but the address provided is not a valid Ethereum address."));
|
|
4662
|
+
}
|
|
4663
|
+
} else {
|
|
4664
|
+
if (isEthereumAddress) {
|
|
4665
|
+
throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "chain is not an EVM chain."));
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
};
|
|
4669
|
+
|
|
4670
|
+
var validateDestinationAddress = function validateDestinationAddress(address, destination) {
|
|
4671
|
+
if (typeof address === 'string' && !sdkCommon.isTLocation(destination)) {
|
|
4672
|
+
validateAddress(address, destination);
|
|
4673
|
+
}
|
|
4674
|
+
};
|
|
4675
|
+
|
|
4676
|
+
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
4677
|
+
if (Array.isArray(currency)) {
|
|
4678
|
+
if (currency.length === 0) {
|
|
4679
|
+
throw new assets.InvalidCurrencyError('Overridden assets cannot be empty');
|
|
4680
|
+
}
|
|
4681
|
+
if (currency.length === 1) {
|
|
4682
|
+
throw new assets.InvalidCurrencyError('Please provide more than one asset');
|
|
4683
|
+
}
|
|
4684
|
+
if (currency.length > 1 && !currency.every(function (asset) {
|
|
4685
|
+
return assets.isTAsset(asset);
|
|
4686
|
+
}) && !feeAsset) {
|
|
4687
|
+
throw new assets.InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
};
|
|
4691
|
+
var validateDestination = function validateDestination(origin, destination) {
|
|
4692
|
+
if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
|
|
4693
|
+
throw new IncompatibleChainsError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4694
|
+
}
|
|
4695
|
+
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
4696
|
+
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
4697
|
+
throw new IncompatibleChainsError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
4698
|
+
}
|
|
4699
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
4700
|
+
var isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(origin, destination);
|
|
4701
|
+
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
4702
|
+
if (!isRelayDestination && !isLocationDestination) {
|
|
4703
|
+
var originRelayChainSymbol = assets.getRelayChainSymbol(origin);
|
|
4704
|
+
var destinationRelayChainSymbol = assets.getRelayChainSymbol(destination);
|
|
4705
|
+
if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
4706
|
+
throw new IncompatibleChainsError();
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
};
|
|
4710
|
+
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
4711
|
+
if (!assetCheckEnabled && 'symbol' in currency && assets.isSymbolSpecifier(currency.symbol)) {
|
|
4712
|
+
throw new assets.InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
4713
|
+
}
|
|
4714
|
+
if (!assetCheckEnabled && 'id' in currency) {
|
|
4715
|
+
throw new assets.InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4716
|
+
}
|
|
4717
|
+
};
|
|
4718
|
+
|
|
4503
4719
|
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
4504
4720
|
var orderedChecks = [{
|
|
4505
4721
|
chain: 'origin',
|
|
@@ -5332,19 +5548,19 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5332
5548
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5333
5549
|
processHop = /*#__PURE__*/function () {
|
|
5334
5550
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5335
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset,
|
|
5551
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopDryRun;
|
|
5336
5552
|
return _regenerator().w(function (_context) {
|
|
5337
5553
|
while (1) switch (_context.n) {
|
|
5338
5554
|
case 0:
|
|
5339
5555
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
}
|
|
5556
|
+
hopAsset = resolveHopAsset({
|
|
5557
|
+
originChain: origin,
|
|
5558
|
+
currentChain: currentChain,
|
|
5559
|
+
asset: currentAsset,
|
|
5560
|
+
currency: currency,
|
|
5561
|
+
swapConfig: swapConfig,
|
|
5562
|
+
hasPassedExchange: hasPassedExchange
|
|
5563
|
+
});
|
|
5348
5564
|
if (assets.hasDryRunSupport(currentChain)) {
|
|
5349
5565
|
_context.n = 1;
|
|
5350
5566
|
break;
|
|
@@ -5908,22 +6124,6 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5908
6124
|
};
|
|
5909
6125
|
}();
|
|
5910
6126
|
|
|
5911
|
-
var validateAddress = function validateAddress(address, chain) {
|
|
5912
|
-
var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
5913
|
-
if (sdkCommon.isTLocation(address)) return;
|
|
5914
|
-
var isEvm = assets.isChainEvm(chain);
|
|
5915
|
-
var isEthereumAddress = viem.isAddress(address);
|
|
5916
|
-
if (isEvm) {
|
|
5917
|
-
if (!isEthereumAddress) {
|
|
5918
|
-
throw new InvalidAddressError("".concat(isDestination ? 'Destination chain' : 'Chain', " is an EVM chain, but the address provided is not a valid Ethereum address."));
|
|
5919
|
-
}
|
|
5920
|
-
} else {
|
|
5921
|
-
if (isEthereumAddress) {
|
|
5922
|
-
throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "chain is not an EVM chain."));
|
|
5923
|
-
}
|
|
5924
|
-
}
|
|
5925
|
-
};
|
|
5926
|
-
|
|
5927
6127
|
var resolveLocationFromDest = function resolveLocationFromDest(destination, asset) {
|
|
5928
6128
|
if (_typeof(destination) === 'object') return destination;
|
|
5929
6129
|
if (sdkCommon.isRelayChain(destination)) return DOT_LOCATION;
|
|
@@ -6230,15 +6430,16 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6230
6430
|
}, {
|
|
6231
6431
|
key: "canUseXTokens",
|
|
6232
6432
|
value: function canUseXTokens(options) {
|
|
6433
|
+
var _asset$location;
|
|
6233
6434
|
var asset = options.assetInfo;
|
|
6234
|
-
var isExternalAsset =
|
|
6435
|
+
var isExternalAsset = ((_asset$location = asset.location) === null || _asset$location === void 0 ? void 0 : _asset$location.parents) === sdkCommon.Parents.TWO;
|
|
6235
6436
|
return !isExternalAsset && !this.shouldUseNativeAssetTeleport(options);
|
|
6236
6437
|
}
|
|
6237
6438
|
}, {
|
|
6238
6439
|
key: "transfer",
|
|
6239
6440
|
value: function () {
|
|
6240
6441
|
var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
|
|
6241
|
-
var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer,
|
|
6442
|
+
var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, isSubBridge, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, _asset$location2, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHOrigin, isAHDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call, _t;
|
|
6242
6443
|
return _regenerator().w(function (_context) {
|
|
6243
6444
|
while (1) switch (_context.n) {
|
|
6244
6445
|
case 0:
|
|
@@ -6272,7 +6473,8 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6272
6473
|
}
|
|
6273
6474
|
throw new InvalidParameterError('Relaychain assets can only be transferred using the type-and-then method which is not supported by this chain');
|
|
6274
6475
|
case 4:
|
|
6275
|
-
|
|
6476
|
+
isSubBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(this.chain, destination);
|
|
6477
|
+
useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && !feeAsset && (!sdkCommon.isTrustedChain(this.chain) || !sdkCommon.isTrustedChain(destChain)) || isSubBridge;
|
|
6276
6478
|
if (!(supportsXTokens(this) && this.canUseXTokens(sendOptions) && !useTypeAndThen)) {
|
|
6277
6479
|
_context.n = 6;
|
|
6278
6480
|
break;
|
|
@@ -6365,17 +6567,17 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6365
6567
|
}
|
|
6366
6568
|
throw new InvalidParameterError('Astar system asset transfers are temporarily disabled');
|
|
6367
6569
|
case 9:
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
isExternalAsset = asset.location
|
|
6570
|
+
isAHOrigin = this.chain.includes('AssetHub');
|
|
6571
|
+
isAHDest = !sdkCommon.isTLocation(destination) && destination.includes('AssetHub'); // Handle common cases
|
|
6572
|
+
isExternalAsset = ((_asset$location2 = asset.location) === null || _asset$location2 === void 0 ? void 0 : _asset$location2.parents) === sdkCommon.Parents.TWO;
|
|
6371
6573
|
isEthDest = destination === 'Ethereum'; // External asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
|
|
6372
|
-
isExternalAssetViaAh = isExternalAsset && !
|
|
6373
|
-
isExternalAssetToAh = isExternalAsset &&
|
|
6574
|
+
isExternalAssetViaAh = isExternalAsset && !isAHOrigin && !isAHDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
|
|
6575
|
+
isExternalAssetToAh = isExternalAsset && isAHDest && !isAHOrigin && !isEthDest && !feeAsset;
|
|
6374
6576
|
if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
|
|
6375
6577
|
_context.n = 15;
|
|
6376
6578
|
break;
|
|
6377
6579
|
}
|
|
6378
|
-
if (!(useTypeAndThen && supportsPolkadotXCM(this))) {
|
|
6580
|
+
if (!(useTypeAndThen && supportsPolkadotXCM(this) && !isSubBridge)) {
|
|
6379
6581
|
_context.n = 10;
|
|
6380
6582
|
break;
|
|
6381
6583
|
}
|
|
@@ -6462,7 +6664,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6462
6664
|
value: function shouldUseNativeAssetTeleport(_ref) {
|
|
6463
6665
|
var asset = _ref.assetInfo,
|
|
6464
6666
|
to = _ref.to;
|
|
6465
|
-
if (sdkCommon.isTLocation(to) || sdkCommon.
|
|
6667
|
+
if (sdkCommon.isTLocation(to) || sdkCommon.isSubstrateBridge(this.chain, to) || to === 'Ethereum') return false;
|
|
6466
6668
|
var isAHPOrigin = this.chain.includes('AssetHub');
|
|
6467
6669
|
var isAHPDest = !sdkCommon.isTLocation(to) && to.includes('AssetHub');
|
|
6468
6670
|
var isNativeAsset = !sdkCommon.isTLocation(to) && (isAHPOrigin && assets.isForeignAsset(asset) && assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(to)) || isAHPDest && !assets.isForeignAsset(asset) && assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(this.chain)));
|
|
@@ -6558,51 +6760,57 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6558
6760
|
key: "transferLocal",
|
|
6559
6761
|
value: function () {
|
|
6560
6762
|
var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6561
|
-
var api, asset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
|
|
6763
|
+
var api, asset, feeAsset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
|
|
6562
6764
|
return _regenerator().w(function (_context3) {
|
|
6563
6765
|
while (1) switch (_context3.n) {
|
|
6564
6766
|
case 0:
|
|
6565
|
-
api = options.api, asset = options.assetInfo, address = options.address, senderAddress = options.senderAddress, currency = options.currency, isAmountAll = options.isAmountAll;
|
|
6767
|
+
api = options.api, asset = options.assetInfo, feeAsset = options.feeAsset, address = options.address, senderAddress = options.senderAddress, currency = options.currency, isAmountAll = options.isAmountAll;
|
|
6566
6768
|
if (!sdkCommon.isTLocation(address)) {
|
|
6567
6769
|
_context3.n = 1;
|
|
6568
6770
|
break;
|
|
6569
6771
|
}
|
|
6570
6772
|
throw new InvalidAddressError('Location address is not supported for local transfers');
|
|
6571
6773
|
case 1:
|
|
6774
|
+
if (!feeAsset) {
|
|
6775
|
+
_context3.n = 2;
|
|
6776
|
+
break;
|
|
6777
|
+
}
|
|
6778
|
+
throw new InvalidParameterError('Fee asset is not supported for local transfers');
|
|
6779
|
+
case 2:
|
|
6572
6780
|
validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
6573
6781
|
address: address
|
|
6574
6782
|
});
|
|
6575
6783
|
isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(asset);
|
|
6576
6784
|
if (!isAmountAll) {
|
|
6577
|
-
_context3.n =
|
|
6785
|
+
_context3.n = 4;
|
|
6578
6786
|
break;
|
|
6579
6787
|
}
|
|
6580
6788
|
assertSenderAddress(senderAddress);
|
|
6581
|
-
_context3.n =
|
|
6789
|
+
_context3.n = 3;
|
|
6582
6790
|
return getAssetBalanceInternal({
|
|
6583
6791
|
api: api,
|
|
6584
6792
|
chain: this.chain,
|
|
6585
6793
|
address: senderAddress,
|
|
6586
6794
|
currency: currency
|
|
6587
6795
|
});
|
|
6588
|
-
case
|
|
6796
|
+
case 3:
|
|
6589
6797
|
balance = _context3.v;
|
|
6590
|
-
_context3.n =
|
|
6798
|
+
_context3.n = 5;
|
|
6591
6799
|
break;
|
|
6592
|
-
case 3:
|
|
6593
|
-
balance = MIN_AMOUNT;
|
|
6594
6800
|
case 4:
|
|
6801
|
+
balance = MIN_AMOUNT;
|
|
6802
|
+
case 5:
|
|
6595
6803
|
localOptions = _objectSpread2(_objectSpread2({}, validatedOptions), {}, {
|
|
6596
6804
|
balance: balance
|
|
6597
6805
|
});
|
|
6598
6806
|
if (!isNativeAsset) {
|
|
6599
|
-
_context3.n =
|
|
6807
|
+
_context3.n = 6;
|
|
6600
6808
|
break;
|
|
6601
6809
|
}
|
|
6602
6810
|
return _context3.a(2, this.transferLocalNativeAsset(localOptions));
|
|
6603
|
-
case 5:
|
|
6604
|
-
return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
|
|
6605
6811
|
case 6:
|
|
6812
|
+
return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
|
|
6813
|
+
case 7:
|
|
6606
6814
|
return _context3.a(2);
|
|
6607
6815
|
}
|
|
6608
6816
|
}, _callee3, this);
|
|
@@ -7103,9 +7311,6 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
7103
7311
|
scenario = input.scenario;
|
|
7104
7312
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
|
|
7105
7313
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
|
|
7106
|
-
if (destination === 'AssetHubPolkadot') {
|
|
7107
|
-
return getChain('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
|
|
7108
|
-
}
|
|
7109
7314
|
if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset)) {
|
|
7110
7315
|
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>}.');
|
|
7111
7316
|
}
|
|
@@ -7151,36 +7356,6 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7151
7356
|
}
|
|
7152
7357
|
_inherits(AssetHubPolkadot, _Parachain);
|
|
7153
7358
|
return _createClass(AssetHubPolkadot, [{
|
|
7154
|
-
key: "handleBridgeTransfer",
|
|
7155
|
-
value: function handleBridgeTransfer(input, targetChain) {
|
|
7156
|
-
var _asset$symbol, _asset$symbol2, _asset$symbol3;
|
|
7157
|
-
var api = input.api,
|
|
7158
|
-
asset = input.assetInfo,
|
|
7159
|
-
destination = input.destination,
|
|
7160
|
-
address = input.address,
|
|
7161
|
-
version = input.version,
|
|
7162
|
-
paraIdTo = input.paraIdTo;
|
|
7163
|
-
if (targetChain === 'Kusama' && ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toUpperCase()) === 'KSM' || targetChain === 'Polkadot' && ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toUpperCase()) === 'DOT') {
|
|
7164
|
-
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7165
|
-
destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
|
|
7166
|
-
beneficiaryLocation: createBeneficiaryLocation({
|
|
7167
|
-
api: api,
|
|
7168
|
-
address: address,
|
|
7169
|
-
version: version
|
|
7170
|
-
}),
|
|
7171
|
-
asset: createAsset(version, asset.amount, asset.location)
|
|
7172
|
-
});
|
|
7173
|
-
return transferPolkadotXcm(modifiedInput, 'transfer_assets', 'Unlimited');
|
|
7174
|
-
} else if (targetChain === 'Polkadot' && ((_asset$symbol3 = asset.symbol) === null || _asset$symbol3 === void 0 ? void 0 : _asset$symbol3.toUpperCase()) === 'KSM' || targetChain === 'Kusama' && 'DOT') {
|
|
7175
|
-
var _modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7176
|
-
destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
|
|
7177
|
-
asset: createAsset(version, asset.amount, DOT_LOCATION)
|
|
7178
|
-
});
|
|
7179
|
-
return transferPolkadotXcm(_modifiedInput, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
7180
|
-
}
|
|
7181
|
-
throw new assets.InvalidCurrencyError("Polkadot <-> Kusama bridge does not support currency ".concat(asset.symbol));
|
|
7182
|
-
}
|
|
7183
|
-
}, {
|
|
7184
7359
|
key: "handleEthBridgeNativeTransfer",
|
|
7185
7360
|
value: function () {
|
|
7186
7361
|
var _handleEthBridgeNativeTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
|
|
@@ -7385,52 +7560,46 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7385
7560
|
case 4:
|
|
7386
7561
|
return _context3.a(2, _t.callTxMethod.call(_t, _context3.v));
|
|
7387
7562
|
case 5:
|
|
7388
|
-
if (!(destination === 'AssetHubKusama')) {
|
|
7389
|
-
_context3.n = 6;
|
|
7390
|
-
break;
|
|
7391
|
-
}
|
|
7392
|
-
return _context3.a(2, this.handleBridgeTransfer(options, 'Kusama'));
|
|
7393
|
-
case 6:
|
|
7394
7563
|
if (!(destination === 'Ethereum')) {
|
|
7395
|
-
_context3.n =
|
|
7564
|
+
_context3.n = 6;
|
|
7396
7565
|
break;
|
|
7397
7566
|
}
|
|
7398
7567
|
return _context3.a(2, this.handleEthBridgeTransfer(options));
|
|
7399
|
-
case
|
|
7568
|
+
case 6:
|
|
7400
7569
|
if (!(destination === 'Mythos')) {
|
|
7401
|
-
_context3.n =
|
|
7570
|
+
_context3.n = 7;
|
|
7402
7571
|
break;
|
|
7403
7572
|
}
|
|
7404
7573
|
return _context3.a(2, this.handleMythosTransfer(options));
|
|
7405
|
-
case
|
|
7574
|
+
case 7:
|
|
7406
7575
|
isExternalAsset = assetInfo.location && assetInfo.location.parents === sdkCommon.Parents.TWO;
|
|
7407
7576
|
if (!isExternalAsset) {
|
|
7408
|
-
_context3.n =
|
|
7577
|
+
_context3.n = 9;
|
|
7409
7578
|
break;
|
|
7410
7579
|
}
|
|
7411
|
-
_context3.n =
|
|
7580
|
+
_context3.n = 8;
|
|
7412
7581
|
return createTypeAndThenCall(this.chain, options);
|
|
7413
|
-
case
|
|
7582
|
+
case 8:
|
|
7414
7583
|
_call = _context3.v;
|
|
7415
7584
|
return _context3.a(2, api.callTxMethod(_call));
|
|
7416
|
-
case
|
|
7585
|
+
case 9:
|
|
7417
7586
|
if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !assets.isForeignAsset(assetInfo))) {
|
|
7418
|
-
_context3.n =
|
|
7587
|
+
_context3.n = 10;
|
|
7419
7588
|
break;
|
|
7420
7589
|
}
|
|
7421
7590
|
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>}.');
|
|
7422
|
-
case
|
|
7591
|
+
case 10:
|
|
7423
7592
|
method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
|
|
7424
7593
|
if (!(method === 'transfer_assets' && assets.isSymbolMatch(assetInfo.symbol, assets.getRelayChainSymbol(this.chain)))) {
|
|
7425
|
-
_context3.n =
|
|
7594
|
+
_context3.n = 12;
|
|
7426
7595
|
break;
|
|
7427
7596
|
}
|
|
7428
7597
|
_t2 = api;
|
|
7429
|
-
_context3.n =
|
|
7598
|
+
_context3.n = 11;
|
|
7430
7599
|
return createTypeAndThenCall(this.chain, options);
|
|
7431
|
-
case
|
|
7600
|
+
case 11:
|
|
7432
7601
|
return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
|
|
7433
|
-
case
|
|
7602
|
+
case 12:
|
|
7434
7603
|
modifiedInput = this.patchInput(options);
|
|
7435
7604
|
return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
|
|
7436
7605
|
}
|
|
@@ -11128,156 +11297,6 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
11128
11297
|
};
|
|
11129
11298
|
}();
|
|
11130
11299
|
|
|
11131
|
-
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
11132
|
-
return assetCheckEnabled ? assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null) : null;
|
|
11133
|
-
};
|
|
11134
|
-
|
|
11135
|
-
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
11136
|
-
var origin = _ref.from,
|
|
11137
|
-
destination = _ref.to,
|
|
11138
|
-
currency = _ref.currency;
|
|
11139
|
-
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
11140
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
11141
|
-
if (!isBridge && !isRelayDestination && !isLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !assets.hasSupportForAsset(destination, asset.symbol)) {
|
|
11142
|
-
throw new assets.InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
|
|
11143
|
-
}
|
|
11144
|
-
if (!isBridge && asset === null && assetCheckEnabled) {
|
|
11145
|
-
throwUnsupportedCurrency(currency, origin);
|
|
11146
|
-
}
|
|
11147
|
-
};
|
|
11148
|
-
|
|
11149
|
-
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
11150
|
-
var api = options.api,
|
|
11151
|
-
currency = options.currency,
|
|
11152
|
-
feeAsset = options.feeAsset,
|
|
11153
|
-
origin = options.from,
|
|
11154
|
-
destination = options.to;
|
|
11155
|
-
if ('location' in currency && assets.isOverrideLocationSpecifier(currency.location)) {
|
|
11156
|
-
return currency.location.value;
|
|
11157
|
-
}
|
|
11158
|
-
if (Array.isArray(currency)) {
|
|
11159
|
-
if (!feeAsset) {
|
|
11160
|
-
throw new assets.InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
11161
|
-
}
|
|
11162
|
-
if ('location' in feeAsset && assets.isOverrideLocationSpecifier(feeAsset.location)) {
|
|
11163
|
-
throw new assets.InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
11164
|
-
}
|
|
11165
|
-
if (currency.every(function (asset) {
|
|
11166
|
-
return assets.isTAsset(asset);
|
|
11167
|
-
})) {
|
|
11168
|
-
if (!feeAsset) {
|
|
11169
|
-
throw new assets.InvalidCurrencyError('Fee asset not provided');
|
|
11170
|
-
}
|
|
11171
|
-
if (!('location' in feeAsset)) {
|
|
11172
|
-
throw new assets.InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
11173
|
-
}
|
|
11174
|
-
return currency.map(function (asset) {
|
|
11175
|
-
var ml = assets.extractAssetLocation(asset);
|
|
11176
|
-
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
11177
|
-
fun: {
|
|
11178
|
-
Fungible: BigInt(asset.fun.Fungible)
|
|
11179
|
-
},
|
|
11180
|
-
isFeeAsset: sdkCommon.deepEqual(ml, feeAsset.location)
|
|
11181
|
-
});
|
|
11182
|
-
});
|
|
11183
|
-
}
|
|
11184
|
-
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
11185
|
-
var assets$1 = currency.map(function (currency) {
|
|
11186
|
-
if (currency.amount === AMOUNT_ALL) {
|
|
11187
|
-
throw new assets.InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
11188
|
-
}
|
|
11189
|
-
var asset = assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null);
|
|
11190
|
-
if (!asset) {
|
|
11191
|
-
throw new assets.InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
11192
|
-
}
|
|
11193
|
-
assertHasLocation(asset);
|
|
11194
|
-
if (!resolvedFeeAsset) {
|
|
11195
|
-
throw new assets.InvalidCurrencyError('Fee asset not found');
|
|
11196
|
-
}
|
|
11197
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
11198
|
-
var version = getChainVersion(origin);
|
|
11199
|
-
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
11200
|
-
return _objectSpread2({
|
|
11201
|
-
isFeeAsset: assets.isAssetEqual(resolvedFeeAsset, asset)
|
|
11202
|
-
}, createAsset(version, abstractedAmount, asset.location));
|
|
11203
|
-
});
|
|
11204
|
-
if (assets$1.filter(function (asset) {
|
|
11205
|
-
return asset.isFeeAsset;
|
|
11206
|
-
}).length > 1) {
|
|
11207
|
-
throw new assets.InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
11208
|
-
}
|
|
11209
|
-
if (assets$1.filter(function (asset) {
|
|
11210
|
-
return asset.isFeeAsset;
|
|
11211
|
-
}).length === 0) {
|
|
11212
|
-
throw new assets.InvalidCurrencyError("Fee asset not found in multiassets");
|
|
11213
|
-
}
|
|
11214
|
-
return assets$1;
|
|
11215
|
-
}
|
|
11216
|
-
return undefined;
|
|
11217
|
-
};
|
|
11218
|
-
|
|
11219
|
-
var selectXcmVersion = function selectXcmVersion(forcedVersion, originVersion, destMaxVersion) {
|
|
11220
|
-
if (forcedVersion) return forcedVersion;
|
|
11221
|
-
var destVersion = destMaxVersion !== null && destMaxVersion !== void 0 ? destMaxVersion : originVersion;
|
|
11222
|
-
return destVersion < originVersion ? destVersion : originVersion;
|
|
11223
|
-
};
|
|
11224
|
-
|
|
11225
|
-
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
11226
|
-
if (sdkCommon.isRelayChain(origin)) return true;
|
|
11227
|
-
var isMultipleAssets = Array.isArray(currency);
|
|
11228
|
-
var hasOverriddenLocation = 'location' in currency && assets.isOverrideLocationSpecifier(currency.location);
|
|
11229
|
-
return !(isMultipleAssets || hasOverriddenLocation);
|
|
11230
|
-
};
|
|
11231
|
-
|
|
11232
|
-
var validateDestinationAddress = function validateDestinationAddress(address, destination) {
|
|
11233
|
-
if (typeof address === 'string' && !sdkCommon.isTLocation(destination)) {
|
|
11234
|
-
validateAddress(address, destination);
|
|
11235
|
-
}
|
|
11236
|
-
};
|
|
11237
|
-
|
|
11238
|
-
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
11239
|
-
if (Array.isArray(currency)) {
|
|
11240
|
-
if (currency.length === 0) {
|
|
11241
|
-
throw new assets.InvalidCurrencyError('Overridden assets cannot be empty');
|
|
11242
|
-
}
|
|
11243
|
-
if (currency.length === 1) {
|
|
11244
|
-
throw new assets.InvalidCurrencyError('Please provide more than one asset');
|
|
11245
|
-
}
|
|
11246
|
-
if (currency.length > 1 && !currency.every(function (asset) {
|
|
11247
|
-
return assets.isTAsset(asset);
|
|
11248
|
-
}) && !feeAsset) {
|
|
11249
|
-
throw new assets.InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
11250
|
-
}
|
|
11251
|
-
}
|
|
11252
|
-
};
|
|
11253
|
-
var validateDestination = function validateDestination(origin, destination) {
|
|
11254
|
-
if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
|
|
11255
|
-
throw new IncompatibleChainsError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
11256
|
-
}
|
|
11257
|
-
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
11258
|
-
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
11259
|
-
throw new IncompatibleChainsError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
11260
|
-
}
|
|
11261
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
11262
|
-
var isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isDotKsmBridge(origin, destination);
|
|
11263
|
-
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
11264
|
-
if (!isRelayDestination && !isLocationDestination) {
|
|
11265
|
-
var originRelayChainSymbol = assets.getRelayChainSymbol(origin);
|
|
11266
|
-
var destinationRelayChainSymbol = assets.getRelayChainSymbol(destination);
|
|
11267
|
-
if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
11268
|
-
throw new IncompatibleChainsError();
|
|
11269
|
-
}
|
|
11270
|
-
}
|
|
11271
|
-
};
|
|
11272
|
-
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
11273
|
-
if (!assetCheckEnabled && 'symbol' in currency && assets.isSymbolSpecifier(currency.symbol)) {
|
|
11274
|
-
throw new assets.InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
11275
|
-
}
|
|
11276
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
11277
|
-
throw new assets.InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
11278
|
-
}
|
|
11279
|
-
};
|
|
11280
|
-
|
|
11281
11300
|
var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
11282
11301
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
11283
11302
|
var api, tx, origin, destination, currency, senderAddress, feeAsset, originAsset, amount, rawOriginFee, originFee, resolvedFeeAsset, sufficient, asset;
|
|
@@ -11477,20 +11496,19 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11477
11496
|
case 10:
|
|
11478
11497
|
processHop = /*#__PURE__*/function () {
|
|
11479
11498
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
11480
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset,
|
|
11499
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
11481
11500
|
return _regenerator().w(function (_context) {
|
|
11482
11501
|
while (1) switch (_context.n) {
|
|
11483
11502
|
case 0:
|
|
11484
11503
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
}
|
|
11504
|
+
hopAsset = resolveHopAsset({
|
|
11505
|
+
originChain: origin,
|
|
11506
|
+
currentChain: currentChain,
|
|
11507
|
+
asset: currentAsset,
|
|
11508
|
+
currency: currency,
|
|
11509
|
+
swapConfig: swapConfig,
|
|
11510
|
+
hasPassedExchange: hasPassedExchange
|
|
11511
|
+
});
|
|
11494
11512
|
_context.n = 1;
|
|
11495
11513
|
return getDestXcmFee({
|
|
11496
11514
|
api: hopApi,
|
|
@@ -11944,7 +11962,7 @@ var send = /*#__PURE__*/function () {
|
|
|
11944
11962
|
validateDestination(origin, destination);
|
|
11945
11963
|
validateDestinationAddress(address, destination);
|
|
11946
11964
|
if (senderAddress) validateAddress(senderAddress, origin, false);
|
|
11947
|
-
isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.
|
|
11965
|
+
isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(origin, destination);
|
|
11948
11966
|
assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
|
|
11949
11967
|
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
11950
11968
|
asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
@@ -12718,18 +12736,19 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12718
12736
|
}();
|
|
12719
12737
|
var computeAllFees = /*#__PURE__*/function () {
|
|
12720
12738
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3, customXcm, isDotAsset, refundInstruction) {
|
|
12721
|
-
var _customXcm$DepositRes;
|
|
12722
12739
|
var reserve, dest, version, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
12723
12740
|
return _regenerator().w(function (_context2) {
|
|
12724
12741
|
while (1) switch (_context2.n) {
|
|
12725
12742
|
case 0:
|
|
12726
12743
|
reserve = _ref3.reserve, dest = _ref3.dest, version = _ref3.options.version;
|
|
12727
|
-
if (!(
|
|
12744
|
+
if (!customXcm.some(function (x) {
|
|
12745
|
+
return 'DepositReserveAsset' in x || 'InitiateTeleport' in x;
|
|
12746
|
+
})) {
|
|
12728
12747
|
_context2.n = 6;
|
|
12729
12748
|
break;
|
|
12730
12749
|
}
|
|
12731
12750
|
_context2.n = 1;
|
|
12732
|
-
return computeInstructionFee(reserve, version,
|
|
12751
|
+
return computeInstructionFee(reserve, version, customXcm);
|
|
12733
12752
|
case 1:
|
|
12734
12753
|
_t3 = _context2.v;
|
|
12735
12754
|
if (!refundInstruction) {
|
|
@@ -12747,7 +12766,12 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12747
12766
|
case 4:
|
|
12748
12767
|
_t5 = _t4;
|
|
12749
12768
|
_context2.n = 5;
|
|
12750
|
-
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, (
|
|
12769
|
+
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, function () {
|
|
12770
|
+
var instr = customXcm.find(function (j) {
|
|
12771
|
+
return 'DepositReserveAsset' in j || 'InitiateTeleport' in j;
|
|
12772
|
+
});
|
|
12773
|
+
return instr ? 'DepositReserveAsset' in instr ? instr.DepositReserveAsset.xcm : instr.InitiateTeleport.xcm : undefined;
|
|
12774
|
+
}());
|
|
12751
12775
|
case 5:
|
|
12752
12776
|
_t6 = _context2.v;
|
|
12753
12777
|
_t2 = {
|
|
@@ -12763,7 +12787,7 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12763
12787
|
break;
|
|
12764
12788
|
}
|
|
12765
12789
|
_context2.n = 7;
|
|
12766
|
-
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version,
|
|
12790
|
+
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm);
|
|
12767
12791
|
case 7:
|
|
12768
12792
|
_t7 = _context2.v;
|
|
12769
12793
|
_context2.n = 9;
|
|
@@ -12801,28 +12825,49 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12801
12825
|
};
|
|
12802
12826
|
}();
|
|
12803
12827
|
|
|
12828
|
+
var getSubBridgeReserve = function getSubBridgeReserve(chain, destination, location) {
|
|
12829
|
+
if (sdkCommon.deepEqual(location, RELAY_LOCATION)) return chain;
|
|
12830
|
+
return destination;
|
|
12831
|
+
};
|
|
12832
|
+
var resolveReserveChain = function resolveReserveChain(chain, destination, assetLocation, isSubBridge, overrideReserve) {
|
|
12833
|
+
if (isSubBridge) {
|
|
12834
|
+
return getSubBridgeReserve(chain, destination, assetLocation);
|
|
12835
|
+
}
|
|
12836
|
+
if (overrideReserve !== undefined) {
|
|
12837
|
+
return overrideReserve;
|
|
12838
|
+
}
|
|
12839
|
+
var relayChain = getRelayChainOf(chain);
|
|
12840
|
+
if (relayChain === 'Paseo' || relayChain === 'Kusama') {
|
|
12841
|
+
// Paseo and Kusama ecosystems migrate reserves to AssetHub
|
|
12842
|
+
return getAssetReserveChain(chain, chain, assetLocation);
|
|
12843
|
+
}
|
|
12844
|
+
if (sdkCommon.isRelayChain(destination)) {
|
|
12845
|
+
return destination;
|
|
12846
|
+
}
|
|
12847
|
+
return getAssetReserveChain(chain, chain, assetLocation);
|
|
12848
|
+
};
|
|
12804
12849
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
12805
12850
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12806
|
-
var api,
|
|
12851
|
+
var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, destApi, reserveApi;
|
|
12807
12852
|
return _regenerator().w(function (_context) {
|
|
12808
12853
|
while (1) switch (_context.n) {
|
|
12809
12854
|
case 0:
|
|
12810
|
-
api = options.api,
|
|
12855
|
+
api = options.api, destination = options.destination, assetInfo = options.assetInfo;
|
|
12811
12856
|
assertHasLocation(assetInfo);
|
|
12812
|
-
if (
|
|
12857
|
+
if (!sdkCommon.isTLocation(destination)) {
|
|
12813
12858
|
_context.n = 1;
|
|
12814
12859
|
break;
|
|
12815
12860
|
}
|
|
12816
12861
|
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
12817
12862
|
case 1:
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12863
|
+
destinationChain = destination;
|
|
12864
|
+
isSubBridge = sdkCommon.isSubstrateBridge(chain, destinationChain);
|
|
12865
|
+
reserveChain = resolveReserveChain(chain, destinationChain, assetInfo.location, isSubBridge, overrideReserve);
|
|
12821
12866
|
destApi = api.clone();
|
|
12822
12867
|
_context.n = 2;
|
|
12823
|
-
return destApi.init(
|
|
12868
|
+
return destApi.init(destinationChain);
|
|
12824
12869
|
case 2:
|
|
12825
|
-
reserveApi = reserveChain === chain ? api : reserveChain ===
|
|
12870
|
+
reserveApi = reserveChain === chain ? api : reserveChain === destinationChain ? destApi : api.clone();
|
|
12826
12871
|
_context.n = 3;
|
|
12827
12872
|
return reserveApi.init(reserveChain);
|
|
12828
12873
|
case 3:
|
|
@@ -12833,12 +12878,13 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12833
12878
|
},
|
|
12834
12879
|
dest: {
|
|
12835
12880
|
api: destApi,
|
|
12836
|
-
chain:
|
|
12881
|
+
chain: destinationChain
|
|
12837
12882
|
},
|
|
12838
12883
|
reserve: {
|
|
12839
12884
|
api: reserveApi,
|
|
12840
12885
|
chain: reserveChain
|
|
12841
12886
|
},
|
|
12887
|
+
isSubBridge: isSubBridge,
|
|
12842
12888
|
assetInfo: assetInfo,
|
|
12843
12889
|
options: options
|
|
12844
12890
|
});
|
|
@@ -12850,13 +12896,14 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12850
12896
|
};
|
|
12851
12897
|
}();
|
|
12852
12898
|
|
|
12853
|
-
var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
12899
|
+
var createCustomXcm = function createCustomXcm(_ref, isDotAsset, assetCount) {
|
|
12854
12900
|
var origin = _ref.origin,
|
|
12855
12901
|
dest = _ref.dest,
|
|
12856
12902
|
reserve = _ref.reserve,
|
|
12903
|
+
isSubBridge = _ref.isSubBridge,
|
|
12857
12904
|
assetInfo = _ref.assetInfo,
|
|
12858
12905
|
options = _ref.options;
|
|
12859
|
-
var fees = arguments.length >
|
|
12906
|
+
var fees = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
12860
12907
|
reserveFee: MIN_FEE,
|
|
12861
12908
|
refundFee: 0n,
|
|
12862
12909
|
destFee: MIN_FEE
|
|
@@ -12869,20 +12916,22 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12869
12916
|
refundFee = fees.refundFee,
|
|
12870
12917
|
destFee = fees.destFee;
|
|
12871
12918
|
var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
|
|
12872
|
-
var feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation);
|
|
12873
|
-
var asset = createAsset(version, assetInfo.amount, localizeLocation(dest.chain, assetInfo.location));
|
|
12919
|
+
var feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation, origin.chain);
|
|
12920
|
+
var asset = createAsset(version, assetInfo.amount, localizeLocation(dest.chain, assetInfo.location, origin.chain));
|
|
12874
12921
|
var depositInstruction = {
|
|
12875
12922
|
DepositAsset: {
|
|
12876
12923
|
assets: {
|
|
12877
|
-
Wild: {
|
|
12924
|
+
Wild: assetCount > 1 ? {
|
|
12878
12925
|
AllOf: {
|
|
12879
12926
|
id: asset.id,
|
|
12880
12927
|
fun: 'Fungible'
|
|
12881
12928
|
}
|
|
12929
|
+
} : {
|
|
12930
|
+
AllCounted: 1
|
|
12882
12931
|
}
|
|
12883
12932
|
},
|
|
12884
12933
|
beneficiary: createBeneficiaryLocation({
|
|
12885
|
-
api: origin.api,
|
|
12934
|
+
api: isSubBridge ? dest.api : origin.api,
|
|
12886
12935
|
address: address,
|
|
12887
12936
|
version: version
|
|
12888
12937
|
})
|
|
@@ -12891,7 +12940,7 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12891
12940
|
var assetsFilter = [];
|
|
12892
12941
|
if (!isDotAsset) assetsFilter.push(createAsset(version, reserveFee + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
|
|
12893
12942
|
assetsFilter.push(createAsset(version, assetInfo.amount, localizeLocation(reserve.chain, assetInfo.location)));
|
|
12894
|
-
if (origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12943
|
+
if (isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12895
12944
|
var buyExecutionAmount = !isDotAsset ? destFee : assetInfo.amount - reserveFee - refundFee;
|
|
12896
12945
|
if (buyExecutionAmount < 0n) throw new AmountTooLowError();
|
|
12897
12946
|
var filter = fees.destFee === MIN_FEE ? {
|
|
@@ -12905,26 +12954,29 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12905
12954
|
weight_limit: 'Unlimited'
|
|
12906
12955
|
}
|
|
12907
12956
|
};
|
|
12957
|
+
if (isSubBridge) {
|
|
12958
|
+
return [buyExecution, depositInstruction];
|
|
12959
|
+
}
|
|
12908
12960
|
var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
|
|
12909
12961
|
// If destination is a system chain, use teleport instead of reserve deposit
|
|
12910
12962
|
if (sdkCommon.isSystemChain(dest.chain)) {
|
|
12911
|
-
return {
|
|
12963
|
+
return [{
|
|
12912
12964
|
InitiateTeleport: {
|
|
12913
12965
|
assets: filter,
|
|
12914
12966
|
dest: destLoc,
|
|
12915
12967
|
xcm: [buyExecution, depositInstruction]
|
|
12916
12968
|
}
|
|
12917
|
-
};
|
|
12969
|
+
}];
|
|
12918
12970
|
}
|
|
12919
|
-
return {
|
|
12971
|
+
return [{
|
|
12920
12972
|
DepositReserveAsset: {
|
|
12921
12973
|
assets: filter,
|
|
12922
12974
|
dest: destLoc,
|
|
12923
12975
|
xcm: [buyExecution, depositInstruction]
|
|
12924
12976
|
}
|
|
12925
|
-
};
|
|
12977
|
+
}];
|
|
12926
12978
|
}
|
|
12927
|
-
return depositInstruction;
|
|
12979
|
+
return [depositInstruction];
|
|
12928
12980
|
};
|
|
12929
12981
|
|
|
12930
12982
|
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
@@ -12959,7 +13011,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12959
13011
|
*/
|
|
12960
13012
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12961
13013
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12962
|
-
var api, senderAddress, version, context, assetInfo,
|
|
13014
|
+
var api, senderAddress, version, context, assetInfo, isSubBridge, LOCATIONS, isRelayAsset, assetCount, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12963
13015
|
return _regenerator().w(function (_context) {
|
|
12964
13016
|
while (1) switch (_context.n) {
|
|
12965
13017
|
case 0:
|
|
@@ -12968,8 +13020,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12968
13020
|
return createTypeAndThenCallContext(chain, options, overrideReserve);
|
|
12969
13021
|
case 1:
|
|
12970
13022
|
context = _context.v;
|
|
12971
|
-
assetInfo = context.assetInfo;
|
|
12972
|
-
|
|
13023
|
+
assetInfo = context.assetInfo, isSubBridge = context.isSubBridge;
|
|
13024
|
+
LOCATIONS = [RELAY_LOCATION, {
|
|
12973
13025
|
parents: 2,
|
|
12974
13026
|
interior: {
|
|
12975
13027
|
X1: [{
|
|
@@ -12978,20 +13030,32 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12978
13030
|
}
|
|
12979
13031
|
}]
|
|
12980
13032
|
}
|
|
13033
|
+
}, {
|
|
13034
|
+
parents: 2,
|
|
13035
|
+
interior: {
|
|
13036
|
+
X1: [{
|
|
13037
|
+
GlobalConsensus: {
|
|
13038
|
+
Polkadot: null
|
|
13039
|
+
}
|
|
13040
|
+
}]
|
|
13041
|
+
}
|
|
13042
|
+
}];
|
|
13043
|
+
isRelayAsset = LOCATIONS.some(function (loc) {
|
|
13044
|
+
return sdkCommon.deepEqual(assetInfo.location, loc);
|
|
12981
13045
|
});
|
|
12982
|
-
|
|
12983
|
-
|
|
13046
|
+
assetCount = isRelayAsset ? 1 : 2;
|
|
13047
|
+
customXcm = createCustomXcm(context, isRelayAsset, assetCount);
|
|
12984
13048
|
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12985
13049
|
_context.n = 2;
|
|
12986
|
-
return computeAllFees(context, customXcm,
|
|
13050
|
+
return computeAllFees(context, customXcm, isRelayAsset, refundInstruction);
|
|
12987
13051
|
case 2:
|
|
12988
13052
|
fees = _context.v;
|
|
12989
13053
|
finalCustomXcm = [];
|
|
12990
|
-
if (refundInstruction) finalCustomXcm.push(refundInstruction);
|
|
12991
|
-
finalCustomXcm.push(createCustomXcm(context,
|
|
13054
|
+
if (refundInstruction && !isSubBridge) finalCustomXcm.push(refundInstruction);
|
|
13055
|
+
finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, isRelayAsset, assetCount, fees)));
|
|
12992
13056
|
totalFee = fees.reserveFee + fees.destFee + fees.refundFee;
|
|
12993
|
-
assets = buildAssets(chain, assetInfo, totalFee,
|
|
12994
|
-
return _context.a(2, buildTypeAndThenCall(context,
|
|
13057
|
+
assets = buildAssets(chain, assetInfo, totalFee, isRelayAsset, version);
|
|
13058
|
+
return _context.a(2, buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets));
|
|
12995
13059
|
}
|
|
12996
13060
|
}, _callee);
|
|
12997
13061
|
}));
|
|
@@ -13818,9 +13882,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13818
13882
|
value: function () {
|
|
13819
13883
|
var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
13820
13884
|
var isCalledInternally,
|
|
13821
|
-
_this$_options,
|
|
13822
|
-
from,
|
|
13823
|
-
to,
|
|
13824
13885
|
_yield$this$prepareNo,
|
|
13825
13886
|
normalizedOptions,
|
|
13826
13887
|
tx,
|
|
@@ -13835,25 +13896,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13835
13896
|
}
|
|
13836
13897
|
throw new InvalidParameterError('Transaction manager contains batched items. Use buildBatch() to process them.');
|
|
13837
13898
|
case 1:
|
|
13838
|
-
|
|
13839
|
-
if (!(!sdkCommon.isTLocation(to) && sdkCommon.isRelayChain(from) && sdkCommon.isRelayChain(to) && from !== to)) {
|
|
13840
|
-
_context4.n = 2;
|
|
13841
|
-
break;
|
|
13842
|
-
}
|
|
13843
|
-
throw new InvalidParameterError('Transfers between relay chains are not yet supported.');
|
|
13844
|
-
case 2:
|
|
13845
|
-
_context4.n = 3;
|
|
13899
|
+
_context4.n = 2;
|
|
13846
13900
|
return this.prepareNormalizedOptions(this._options);
|
|
13847
|
-
case
|
|
13901
|
+
case 2:
|
|
13848
13902
|
_yield$this$prepareNo = _context4.v;
|
|
13849
13903
|
normalizedOptions = _yield$this$prepareNo.normalizedOptions;
|
|
13850
|
-
_context4.n =
|
|
13904
|
+
_context4.n = 3;
|
|
13851
13905
|
return send(normalizedOptions);
|
|
13852
|
-
case
|
|
13906
|
+
case 3:
|
|
13853
13907
|
tx = _context4.v;
|
|
13854
|
-
_context4.n =
|
|
13908
|
+
_context4.n = 4;
|
|
13855
13909
|
return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
|
|
13856
|
-
case
|
|
13910
|
+
case 4:
|
|
13857
13911
|
return _context4.a(2, {
|
|
13858
13912
|
tx: tx,
|
|
13859
13913
|
options: normalizedOptions
|