@paraspell/sdk-core 11.12.2 → 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 +384 -328
- package/dist/index.d.ts +211 -207
- package/dist/index.mjs +386 -330
- 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');
|
|
@@ -4498,6 +4518,204 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4498
4518
|
};
|
|
4499
4519
|
}();
|
|
4500
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
|
+
|
|
4501
4719
|
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
4502
4720
|
var orderedChecks = [{
|
|
4503
4721
|
chain: 'origin',
|
|
@@ -5330,19 +5548,19 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5330
5548
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5331
5549
|
processHop = /*#__PURE__*/function () {
|
|
5332
5550
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5333
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset,
|
|
5551
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopDryRun;
|
|
5334
5552
|
return _regenerator().w(function (_context) {
|
|
5335
5553
|
while (1) switch (_context.n) {
|
|
5336
5554
|
case 0:
|
|
5337
5555
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
}
|
|
5556
|
+
hopAsset = resolveHopAsset({
|
|
5557
|
+
originChain: origin,
|
|
5558
|
+
currentChain: currentChain,
|
|
5559
|
+
asset: currentAsset,
|
|
5560
|
+
currency: currency,
|
|
5561
|
+
swapConfig: swapConfig,
|
|
5562
|
+
hasPassedExchange: hasPassedExchange
|
|
5563
|
+
});
|
|
5346
5564
|
if (assets.hasDryRunSupport(currentChain)) {
|
|
5347
5565
|
_context.n = 1;
|
|
5348
5566
|
break;
|
|
@@ -5906,22 +6124,6 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5906
6124
|
};
|
|
5907
6125
|
}();
|
|
5908
6126
|
|
|
5909
|
-
var validateAddress = function validateAddress(address, chain) {
|
|
5910
|
-
var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
5911
|
-
if (sdkCommon.isTLocation(address)) return;
|
|
5912
|
-
var isEvm = assets.isChainEvm(chain);
|
|
5913
|
-
var isEthereumAddress = viem.isAddress(address);
|
|
5914
|
-
if (isEvm) {
|
|
5915
|
-
if (!isEthereumAddress) {
|
|
5916
|
-
throw new InvalidAddressError("".concat(isDestination ? 'Destination chain' : 'Chain', " is an EVM chain, but the address provided is not a valid Ethereum address."));
|
|
5917
|
-
}
|
|
5918
|
-
} else {
|
|
5919
|
-
if (isEthereumAddress) {
|
|
5920
|
-
throw new InvalidAddressError("EVM address provided but ".concat(isDestination ? 'destination ' : '', "chain is not an EVM chain."));
|
|
5921
|
-
}
|
|
5922
|
-
}
|
|
5923
|
-
};
|
|
5924
|
-
|
|
5925
6127
|
var resolveLocationFromDest = function resolveLocationFromDest(destination, asset) {
|
|
5926
6128
|
if (_typeof(destination) === 'object') return destination;
|
|
5927
6129
|
if (sdkCommon.isRelayChain(destination)) return DOT_LOCATION;
|
|
@@ -6228,15 +6430,16 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6228
6430
|
}, {
|
|
6229
6431
|
key: "canUseXTokens",
|
|
6230
6432
|
value: function canUseXTokens(options) {
|
|
6433
|
+
var _asset$location;
|
|
6231
6434
|
var asset = options.assetInfo;
|
|
6232
|
-
var isExternalAsset =
|
|
6435
|
+
var isExternalAsset = ((_asset$location = asset.location) === null || _asset$location === void 0 ? void 0 : _asset$location.parents) === sdkCommon.Parents.TWO;
|
|
6233
6436
|
return !isExternalAsset && !this.shouldUseNativeAssetTeleport(options);
|
|
6234
6437
|
}
|
|
6235
6438
|
}, {
|
|
6236
6439
|
key: "transfer",
|
|
6237
6440
|
value: function () {
|
|
6238
6441
|
var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
|
|
6239
|
-
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;
|
|
6240
6443
|
return _regenerator().w(function (_context) {
|
|
6241
6444
|
while (1) switch (_context.n) {
|
|
6242
6445
|
case 0:
|
|
@@ -6270,7 +6473,8 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6270
6473
|
}
|
|
6271
6474
|
throw new InvalidParameterError('Relaychain assets can only be transferred using the type-and-then method which is not supported by this chain');
|
|
6272
6475
|
case 4:
|
|
6273
|
-
|
|
6476
|
+
isSubBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(this.chain, destination);
|
|
6477
|
+
useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && !feeAsset && (!sdkCommon.isTrustedChain(this.chain) || !sdkCommon.isTrustedChain(destChain)) || isSubBridge;
|
|
6274
6478
|
if (!(supportsXTokens(this) && this.canUseXTokens(sendOptions) && !useTypeAndThen)) {
|
|
6275
6479
|
_context.n = 6;
|
|
6276
6480
|
break;
|
|
@@ -6363,17 +6567,17 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6363
6567
|
}
|
|
6364
6568
|
throw new InvalidParameterError('Astar system asset transfers are temporarily disabled');
|
|
6365
6569
|
case 9:
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
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;
|
|
6369
6573
|
isEthDest = destination === 'Ethereum'; // External asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
|
|
6370
|
-
isExternalAssetViaAh = isExternalAsset && !
|
|
6371
|
-
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;
|
|
6372
6576
|
if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
|
|
6373
6577
|
_context.n = 15;
|
|
6374
6578
|
break;
|
|
6375
6579
|
}
|
|
6376
|
-
if (!(useTypeAndThen && supportsPolkadotXCM(this))) {
|
|
6580
|
+
if (!(useTypeAndThen && supportsPolkadotXCM(this) && !isSubBridge)) {
|
|
6377
6581
|
_context.n = 10;
|
|
6378
6582
|
break;
|
|
6379
6583
|
}
|
|
@@ -6460,7 +6664,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6460
6664
|
value: function shouldUseNativeAssetTeleport(_ref) {
|
|
6461
6665
|
var asset = _ref.assetInfo,
|
|
6462
6666
|
to = _ref.to;
|
|
6463
|
-
if (sdkCommon.isTLocation(to) || sdkCommon.
|
|
6667
|
+
if (sdkCommon.isTLocation(to) || sdkCommon.isSubstrateBridge(this.chain, to) || to === 'Ethereum') return false;
|
|
6464
6668
|
var isAHPOrigin = this.chain.includes('AssetHub');
|
|
6465
6669
|
var isAHPDest = !sdkCommon.isTLocation(to) && to.includes('AssetHub');
|
|
6466
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)));
|
|
@@ -6556,51 +6760,57 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6556
6760
|
key: "transferLocal",
|
|
6557
6761
|
value: function () {
|
|
6558
6762
|
var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6559
|
-
var api, asset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
|
|
6763
|
+
var api, asset, feeAsset, address, senderAddress, currency, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
|
|
6560
6764
|
return _regenerator().w(function (_context3) {
|
|
6561
6765
|
while (1) switch (_context3.n) {
|
|
6562
6766
|
case 0:
|
|
6563
|
-
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;
|
|
6564
6768
|
if (!sdkCommon.isTLocation(address)) {
|
|
6565
6769
|
_context3.n = 1;
|
|
6566
6770
|
break;
|
|
6567
6771
|
}
|
|
6568
6772
|
throw new InvalidAddressError('Location address is not supported for local transfers');
|
|
6569
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:
|
|
6570
6780
|
validatedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
6571
6781
|
address: address
|
|
6572
6782
|
});
|
|
6573
6783
|
isNativeAsset = asset.symbol === this.getNativeAssetSymbol() && !assets.isForeignAsset(asset);
|
|
6574
6784
|
if (!isAmountAll) {
|
|
6575
|
-
_context3.n =
|
|
6785
|
+
_context3.n = 4;
|
|
6576
6786
|
break;
|
|
6577
6787
|
}
|
|
6578
6788
|
assertSenderAddress(senderAddress);
|
|
6579
|
-
_context3.n =
|
|
6789
|
+
_context3.n = 3;
|
|
6580
6790
|
return getAssetBalanceInternal({
|
|
6581
6791
|
api: api,
|
|
6582
6792
|
chain: this.chain,
|
|
6583
6793
|
address: senderAddress,
|
|
6584
6794
|
currency: currency
|
|
6585
6795
|
});
|
|
6586
|
-
case
|
|
6796
|
+
case 3:
|
|
6587
6797
|
balance = _context3.v;
|
|
6588
|
-
_context3.n =
|
|
6798
|
+
_context3.n = 5;
|
|
6589
6799
|
break;
|
|
6590
|
-
case 3:
|
|
6591
|
-
balance = MIN_AMOUNT;
|
|
6592
6800
|
case 4:
|
|
6801
|
+
balance = MIN_AMOUNT;
|
|
6802
|
+
case 5:
|
|
6593
6803
|
localOptions = _objectSpread2(_objectSpread2({}, validatedOptions), {}, {
|
|
6594
6804
|
balance: balance
|
|
6595
6805
|
});
|
|
6596
6806
|
if (!isNativeAsset) {
|
|
6597
|
-
_context3.n =
|
|
6807
|
+
_context3.n = 6;
|
|
6598
6808
|
break;
|
|
6599
6809
|
}
|
|
6600
6810
|
return _context3.a(2, this.transferLocalNativeAsset(localOptions));
|
|
6601
|
-
case 5:
|
|
6602
|
-
return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
|
|
6603
6811
|
case 6:
|
|
6812
|
+
return _context3.a(2, this.transferLocalNonNativeAsset(localOptions));
|
|
6813
|
+
case 7:
|
|
6604
6814
|
return _context3.a(2);
|
|
6605
6815
|
}
|
|
6606
6816
|
}, _callee3, this);
|
|
@@ -7101,9 +7311,6 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
7101
7311
|
scenario = input.scenario;
|
|
7102
7312
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
|
|
7103
7313
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
|
|
7104
|
-
if (destination === 'AssetHubPolkadot') {
|
|
7105
|
-
return getChain('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
|
|
7106
|
-
}
|
|
7107
7314
|
if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset)) {
|
|
7108
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>}.');
|
|
7109
7316
|
}
|
|
@@ -7149,36 +7356,6 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7149
7356
|
}
|
|
7150
7357
|
_inherits(AssetHubPolkadot, _Parachain);
|
|
7151
7358
|
return _createClass(AssetHubPolkadot, [{
|
|
7152
|
-
key: "handleBridgeTransfer",
|
|
7153
|
-
value: function handleBridgeTransfer(input, targetChain) {
|
|
7154
|
-
var _asset$symbol, _asset$symbol2, _asset$symbol3;
|
|
7155
|
-
var api = input.api,
|
|
7156
|
-
asset = input.assetInfo,
|
|
7157
|
-
destination = input.destination,
|
|
7158
|
-
address = input.address,
|
|
7159
|
-
version = input.version,
|
|
7160
|
-
paraIdTo = input.paraIdTo;
|
|
7161
|
-
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') {
|
|
7162
|
-
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7163
|
-
destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
|
|
7164
|
-
beneficiaryLocation: createBeneficiaryLocation({
|
|
7165
|
-
api: api,
|
|
7166
|
-
address: address,
|
|
7167
|
-
version: version
|
|
7168
|
-
}),
|
|
7169
|
-
asset: createAsset(version, asset.amount, asset.location)
|
|
7170
|
-
});
|
|
7171
|
-
return transferPolkadotXcm(modifiedInput, 'transfer_assets', 'Unlimited');
|
|
7172
|
-
} else if (targetChain === 'Polkadot' && ((_asset$symbol3 = asset.symbol) === null || _asset$symbol3 === void 0 ? void 0 : _asset$symbol3.toUpperCase()) === 'KSM' || targetChain === 'Kusama' && 'DOT') {
|
|
7173
|
-
var _modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7174
|
-
destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
|
|
7175
|
-
asset: createAsset(version, asset.amount, DOT_LOCATION)
|
|
7176
|
-
});
|
|
7177
|
-
return transferPolkadotXcm(_modifiedInput, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
7178
|
-
}
|
|
7179
|
-
throw new assets.InvalidCurrencyError("Polkadot <-> Kusama bridge does not support currency ".concat(asset.symbol));
|
|
7180
|
-
}
|
|
7181
|
-
}, {
|
|
7182
7359
|
key: "handleEthBridgeNativeTransfer",
|
|
7183
7360
|
value: function () {
|
|
7184
7361
|
var _handleEthBridgeNativeTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
|
|
@@ -7383,52 +7560,46 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7383
7560
|
case 4:
|
|
7384
7561
|
return _context3.a(2, _t.callTxMethod.call(_t, _context3.v));
|
|
7385
7562
|
case 5:
|
|
7386
|
-
if (!(destination === 'AssetHubKusama')) {
|
|
7387
|
-
_context3.n = 6;
|
|
7388
|
-
break;
|
|
7389
|
-
}
|
|
7390
|
-
return _context3.a(2, this.handleBridgeTransfer(options, 'Kusama'));
|
|
7391
|
-
case 6:
|
|
7392
7563
|
if (!(destination === 'Ethereum')) {
|
|
7393
|
-
_context3.n =
|
|
7564
|
+
_context3.n = 6;
|
|
7394
7565
|
break;
|
|
7395
7566
|
}
|
|
7396
7567
|
return _context3.a(2, this.handleEthBridgeTransfer(options));
|
|
7397
|
-
case
|
|
7568
|
+
case 6:
|
|
7398
7569
|
if (!(destination === 'Mythos')) {
|
|
7399
|
-
_context3.n =
|
|
7570
|
+
_context3.n = 7;
|
|
7400
7571
|
break;
|
|
7401
7572
|
}
|
|
7402
7573
|
return _context3.a(2, this.handleMythosTransfer(options));
|
|
7403
|
-
case
|
|
7574
|
+
case 7:
|
|
7404
7575
|
isExternalAsset = assetInfo.location && assetInfo.location.parents === sdkCommon.Parents.TWO;
|
|
7405
7576
|
if (!isExternalAsset) {
|
|
7406
|
-
_context3.n =
|
|
7577
|
+
_context3.n = 9;
|
|
7407
7578
|
break;
|
|
7408
7579
|
}
|
|
7409
|
-
_context3.n =
|
|
7580
|
+
_context3.n = 8;
|
|
7410
7581
|
return createTypeAndThenCall(this.chain, options);
|
|
7411
|
-
case
|
|
7582
|
+
case 8:
|
|
7412
7583
|
_call = _context3.v;
|
|
7413
7584
|
return _context3.a(2, api.callTxMethod(_call));
|
|
7414
|
-
case
|
|
7585
|
+
case 9:
|
|
7415
7586
|
if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !assets.isForeignAsset(assetInfo))) {
|
|
7416
|
-
_context3.n =
|
|
7587
|
+
_context3.n = 10;
|
|
7417
7588
|
break;
|
|
7418
7589
|
}
|
|
7419
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>}.');
|
|
7420
|
-
case
|
|
7591
|
+
case 10:
|
|
7421
7592
|
method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
|
|
7422
7593
|
if (!(method === 'transfer_assets' && assets.isSymbolMatch(assetInfo.symbol, assets.getRelayChainSymbol(this.chain)))) {
|
|
7423
|
-
_context3.n =
|
|
7594
|
+
_context3.n = 12;
|
|
7424
7595
|
break;
|
|
7425
7596
|
}
|
|
7426
7597
|
_t2 = api;
|
|
7427
|
-
_context3.n =
|
|
7598
|
+
_context3.n = 11;
|
|
7428
7599
|
return createTypeAndThenCall(this.chain, options);
|
|
7429
|
-
case
|
|
7600
|
+
case 11:
|
|
7430
7601
|
return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
|
|
7431
|
-
case
|
|
7602
|
+
case 12:
|
|
7432
7603
|
modifiedInput = this.patchInput(options);
|
|
7433
7604
|
return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
|
|
7434
7605
|
}
|
|
@@ -11126,156 +11297,6 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
11126
11297
|
};
|
|
11127
11298
|
}();
|
|
11128
11299
|
|
|
11129
|
-
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
11130
|
-
return assetCheckEnabled ? assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null) : null;
|
|
11131
|
-
};
|
|
11132
|
-
|
|
11133
|
-
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
11134
|
-
var origin = _ref.from,
|
|
11135
|
-
destination = _ref.to,
|
|
11136
|
-
currency = _ref.currency;
|
|
11137
|
-
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
11138
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
11139
|
-
if (!isBridge && !isRelayDestination && !isLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !assets.hasSupportForAsset(destination, asset.symbol)) {
|
|
11140
|
-
throw new assets.InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
|
|
11141
|
-
}
|
|
11142
|
-
if (!isBridge && asset === null && assetCheckEnabled) {
|
|
11143
|
-
throwUnsupportedCurrency(currency, origin);
|
|
11144
|
-
}
|
|
11145
|
-
};
|
|
11146
|
-
|
|
11147
|
-
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
11148
|
-
var api = options.api,
|
|
11149
|
-
currency = options.currency,
|
|
11150
|
-
feeAsset = options.feeAsset,
|
|
11151
|
-
origin = options.from,
|
|
11152
|
-
destination = options.to;
|
|
11153
|
-
if ('location' in currency && assets.isOverrideLocationSpecifier(currency.location)) {
|
|
11154
|
-
return currency.location.value;
|
|
11155
|
-
}
|
|
11156
|
-
if (Array.isArray(currency)) {
|
|
11157
|
-
if (!feeAsset) {
|
|
11158
|
-
throw new assets.InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
11159
|
-
}
|
|
11160
|
-
if ('location' in feeAsset && assets.isOverrideLocationSpecifier(feeAsset.location)) {
|
|
11161
|
-
throw new assets.InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
11162
|
-
}
|
|
11163
|
-
if (currency.every(function (asset) {
|
|
11164
|
-
return assets.isTAsset(asset);
|
|
11165
|
-
})) {
|
|
11166
|
-
if (!feeAsset) {
|
|
11167
|
-
throw new assets.InvalidCurrencyError('Fee asset not provided');
|
|
11168
|
-
}
|
|
11169
|
-
if (!('location' in feeAsset)) {
|
|
11170
|
-
throw new assets.InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
11171
|
-
}
|
|
11172
|
-
return currency.map(function (asset) {
|
|
11173
|
-
var ml = assets.extractAssetLocation(asset);
|
|
11174
|
-
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
11175
|
-
fun: {
|
|
11176
|
-
Fungible: BigInt(asset.fun.Fungible)
|
|
11177
|
-
},
|
|
11178
|
-
isFeeAsset: sdkCommon.deepEqual(ml, feeAsset.location)
|
|
11179
|
-
});
|
|
11180
|
-
});
|
|
11181
|
-
}
|
|
11182
|
-
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
11183
|
-
var assets$1 = currency.map(function (currency) {
|
|
11184
|
-
if (currency.amount === AMOUNT_ALL) {
|
|
11185
|
-
throw new assets.InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
11186
|
-
}
|
|
11187
|
-
var asset = assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null);
|
|
11188
|
-
if (!asset) {
|
|
11189
|
-
throw new assets.InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
11190
|
-
}
|
|
11191
|
-
assertHasLocation(asset);
|
|
11192
|
-
if (!resolvedFeeAsset) {
|
|
11193
|
-
throw new assets.InvalidCurrencyError('Fee asset not found');
|
|
11194
|
-
}
|
|
11195
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
11196
|
-
var version = getChainVersion(origin);
|
|
11197
|
-
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
11198
|
-
return _objectSpread2({
|
|
11199
|
-
isFeeAsset: assets.isAssetEqual(resolvedFeeAsset, asset)
|
|
11200
|
-
}, createAsset(version, abstractedAmount, asset.location));
|
|
11201
|
-
});
|
|
11202
|
-
if (assets$1.filter(function (asset) {
|
|
11203
|
-
return asset.isFeeAsset;
|
|
11204
|
-
}).length > 1) {
|
|
11205
|
-
throw new assets.InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
11206
|
-
}
|
|
11207
|
-
if (assets$1.filter(function (asset) {
|
|
11208
|
-
return asset.isFeeAsset;
|
|
11209
|
-
}).length === 0) {
|
|
11210
|
-
throw new assets.InvalidCurrencyError("Fee asset not found in multiassets");
|
|
11211
|
-
}
|
|
11212
|
-
return assets$1;
|
|
11213
|
-
}
|
|
11214
|
-
return undefined;
|
|
11215
|
-
};
|
|
11216
|
-
|
|
11217
|
-
var selectXcmVersion = function selectXcmVersion(forcedVersion, originVersion, destMaxVersion) {
|
|
11218
|
-
if (forcedVersion) return forcedVersion;
|
|
11219
|
-
var destVersion = destMaxVersion !== null && destMaxVersion !== void 0 ? destMaxVersion : originVersion;
|
|
11220
|
-
return destVersion < originVersion ? destVersion : originVersion;
|
|
11221
|
-
};
|
|
11222
|
-
|
|
11223
|
-
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
11224
|
-
if (sdkCommon.isRelayChain(origin)) return true;
|
|
11225
|
-
var isMultipleAssets = Array.isArray(currency);
|
|
11226
|
-
var hasOverriddenLocation = 'location' in currency && assets.isOverrideLocationSpecifier(currency.location);
|
|
11227
|
-
return !(isMultipleAssets || hasOverriddenLocation);
|
|
11228
|
-
};
|
|
11229
|
-
|
|
11230
|
-
var validateDestinationAddress = function validateDestinationAddress(address, destination) {
|
|
11231
|
-
if (typeof address === 'string' && !sdkCommon.isTLocation(destination)) {
|
|
11232
|
-
validateAddress(address, destination);
|
|
11233
|
-
}
|
|
11234
|
-
};
|
|
11235
|
-
|
|
11236
|
-
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
11237
|
-
if (Array.isArray(currency)) {
|
|
11238
|
-
if (currency.length === 0) {
|
|
11239
|
-
throw new assets.InvalidCurrencyError('Overridden assets cannot be empty');
|
|
11240
|
-
}
|
|
11241
|
-
if (currency.length === 1) {
|
|
11242
|
-
throw new assets.InvalidCurrencyError('Please provide more than one asset');
|
|
11243
|
-
}
|
|
11244
|
-
if (currency.length > 1 && !currency.every(function (asset) {
|
|
11245
|
-
return assets.isTAsset(asset);
|
|
11246
|
-
}) && !feeAsset) {
|
|
11247
|
-
throw new assets.InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
11248
|
-
}
|
|
11249
|
-
}
|
|
11250
|
-
};
|
|
11251
|
-
var validateDestination = function validateDestination(origin, destination) {
|
|
11252
|
-
if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
|
|
11253
|
-
throw new IncompatibleChainsError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
11254
|
-
}
|
|
11255
|
-
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
11256
|
-
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
11257
|
-
throw new IncompatibleChainsError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
11258
|
-
}
|
|
11259
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
11260
|
-
var isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isDotKsmBridge(origin, destination);
|
|
11261
|
-
var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
|
|
11262
|
-
if (!isRelayDestination && !isLocationDestination) {
|
|
11263
|
-
var originRelayChainSymbol = assets.getRelayChainSymbol(origin);
|
|
11264
|
-
var destinationRelayChainSymbol = assets.getRelayChainSymbol(destination);
|
|
11265
|
-
if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
11266
|
-
throw new IncompatibleChainsError();
|
|
11267
|
-
}
|
|
11268
|
-
}
|
|
11269
|
-
};
|
|
11270
|
-
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
11271
|
-
if (!assetCheckEnabled && 'symbol' in currency && assets.isSymbolSpecifier(currency.symbol)) {
|
|
11272
|
-
throw new assets.InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
11273
|
-
}
|
|
11274
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
11275
|
-
throw new assets.InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
11276
|
-
}
|
|
11277
|
-
};
|
|
11278
|
-
|
|
11279
11300
|
var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
11280
11301
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
11281
11302
|
var api, tx, origin, destination, currency, senderAddress, feeAsset, originAsset, amount, rawOriginFee, originFee, resolvedFeeAsset, sufficient, asset;
|
|
@@ -11475,20 +11496,19 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11475
11496
|
case 10:
|
|
11476
11497
|
processHop = /*#__PURE__*/function () {
|
|
11477
11498
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
11478
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset,
|
|
11499
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
11479
11500
|
return _regenerator().w(function (_context) {
|
|
11480
11501
|
while (1) switch (_context.n) {
|
|
11481
11502
|
case 0:
|
|
11482
11503
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
}
|
|
11504
|
+
hopAsset = resolveHopAsset({
|
|
11505
|
+
originChain: origin,
|
|
11506
|
+
currentChain: currentChain,
|
|
11507
|
+
asset: currentAsset,
|
|
11508
|
+
currency: currency,
|
|
11509
|
+
swapConfig: swapConfig,
|
|
11510
|
+
hasPassedExchange: hasPassedExchange
|
|
11511
|
+
});
|
|
11492
11512
|
_context.n = 1;
|
|
11493
11513
|
return getDestXcmFee({
|
|
11494
11514
|
api: hopApi,
|
|
@@ -11942,7 +11962,7 @@ var send = /*#__PURE__*/function () {
|
|
|
11942
11962
|
validateDestination(origin, destination);
|
|
11943
11963
|
validateDestinationAddress(address, destination);
|
|
11944
11964
|
if (senderAddress) validateAddress(senderAddress, origin, false);
|
|
11945
|
-
isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.
|
|
11965
|
+
isBridge = !sdkCommon.isTLocation(destination) && sdkCommon.isSubstrateBridge(origin, destination);
|
|
11946
11966
|
assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
|
|
11947
11967
|
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
11948
11968
|
asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
@@ -12716,18 +12736,19 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12716
12736
|
}();
|
|
12717
12737
|
var computeAllFees = /*#__PURE__*/function () {
|
|
12718
12738
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3, customXcm, isDotAsset, refundInstruction) {
|
|
12719
|
-
var _customXcm$DepositRes;
|
|
12720
12739
|
var reserve, dest, version, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
12721
12740
|
return _regenerator().w(function (_context2) {
|
|
12722
12741
|
while (1) switch (_context2.n) {
|
|
12723
12742
|
case 0:
|
|
12724
12743
|
reserve = _ref3.reserve, dest = _ref3.dest, version = _ref3.options.version;
|
|
12725
|
-
if (!(
|
|
12744
|
+
if (!customXcm.some(function (x) {
|
|
12745
|
+
return 'DepositReserveAsset' in x || 'InitiateTeleport' in x;
|
|
12746
|
+
})) {
|
|
12726
12747
|
_context2.n = 6;
|
|
12727
12748
|
break;
|
|
12728
12749
|
}
|
|
12729
12750
|
_context2.n = 1;
|
|
12730
|
-
return computeInstructionFee(reserve, version,
|
|
12751
|
+
return computeInstructionFee(reserve, version, customXcm);
|
|
12731
12752
|
case 1:
|
|
12732
12753
|
_t3 = _context2.v;
|
|
12733
12754
|
if (!refundInstruction) {
|
|
@@ -12745,7 +12766,12 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12745
12766
|
case 4:
|
|
12746
12767
|
_t5 = _t4;
|
|
12747
12768
|
_context2.n = 5;
|
|
12748
|
-
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
|
+
}());
|
|
12749
12775
|
case 5:
|
|
12750
12776
|
_t6 = _context2.v;
|
|
12751
12777
|
_t2 = {
|
|
@@ -12761,7 +12787,7 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12761
12787
|
break;
|
|
12762
12788
|
}
|
|
12763
12789
|
_context2.n = 7;
|
|
12764
|
-
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version,
|
|
12790
|
+
return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm);
|
|
12765
12791
|
case 7:
|
|
12766
12792
|
_t7 = _context2.v;
|
|
12767
12793
|
_context2.n = 9;
|
|
@@ -12799,28 +12825,49 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12799
12825
|
};
|
|
12800
12826
|
}();
|
|
12801
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
|
+
};
|
|
12802
12849
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
12803
12850
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12804
|
-
var api,
|
|
12851
|
+
var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, destApi, reserveApi;
|
|
12805
12852
|
return _regenerator().w(function (_context) {
|
|
12806
12853
|
while (1) switch (_context.n) {
|
|
12807
12854
|
case 0:
|
|
12808
|
-
api = options.api,
|
|
12855
|
+
api = options.api, destination = options.destination, assetInfo = options.assetInfo;
|
|
12809
12856
|
assertHasLocation(assetInfo);
|
|
12810
|
-
if (
|
|
12857
|
+
if (!sdkCommon.isTLocation(destination)) {
|
|
12811
12858
|
_context.n = 1;
|
|
12812
12859
|
break;
|
|
12813
12860
|
}
|
|
12814
12861
|
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
12815
12862
|
case 1:
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12863
|
+
destinationChain = destination;
|
|
12864
|
+
isSubBridge = sdkCommon.isSubstrateBridge(chain, destinationChain);
|
|
12865
|
+
reserveChain = resolveReserveChain(chain, destinationChain, assetInfo.location, isSubBridge, overrideReserve);
|
|
12819
12866
|
destApi = api.clone();
|
|
12820
12867
|
_context.n = 2;
|
|
12821
|
-
return destApi.init(
|
|
12868
|
+
return destApi.init(destinationChain);
|
|
12822
12869
|
case 2:
|
|
12823
|
-
reserveApi = reserveChain === chain ? api : reserveChain ===
|
|
12870
|
+
reserveApi = reserveChain === chain ? api : reserveChain === destinationChain ? destApi : api.clone();
|
|
12824
12871
|
_context.n = 3;
|
|
12825
12872
|
return reserveApi.init(reserveChain);
|
|
12826
12873
|
case 3:
|
|
@@ -12831,12 +12878,13 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12831
12878
|
},
|
|
12832
12879
|
dest: {
|
|
12833
12880
|
api: destApi,
|
|
12834
|
-
chain:
|
|
12881
|
+
chain: destinationChain
|
|
12835
12882
|
},
|
|
12836
12883
|
reserve: {
|
|
12837
12884
|
api: reserveApi,
|
|
12838
12885
|
chain: reserveChain
|
|
12839
12886
|
},
|
|
12887
|
+
isSubBridge: isSubBridge,
|
|
12840
12888
|
assetInfo: assetInfo,
|
|
12841
12889
|
options: options
|
|
12842
12890
|
});
|
|
@@ -12848,13 +12896,14 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12848
12896
|
};
|
|
12849
12897
|
}();
|
|
12850
12898
|
|
|
12851
|
-
var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
12899
|
+
var createCustomXcm = function createCustomXcm(_ref, isDotAsset, assetCount) {
|
|
12852
12900
|
var origin = _ref.origin,
|
|
12853
12901
|
dest = _ref.dest,
|
|
12854
12902
|
reserve = _ref.reserve,
|
|
12903
|
+
isSubBridge = _ref.isSubBridge,
|
|
12855
12904
|
assetInfo = _ref.assetInfo,
|
|
12856
12905
|
options = _ref.options;
|
|
12857
|
-
var fees = arguments.length >
|
|
12906
|
+
var fees = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
12858
12907
|
reserveFee: MIN_FEE,
|
|
12859
12908
|
refundFee: 0n,
|
|
12860
12909
|
destFee: MIN_FEE
|
|
@@ -12867,20 +12916,22 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12867
12916
|
refundFee = fees.refundFee,
|
|
12868
12917
|
destFee = fees.destFee;
|
|
12869
12918
|
var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
|
|
12870
|
-
var feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation);
|
|
12871
|
-
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));
|
|
12872
12921
|
var depositInstruction = {
|
|
12873
12922
|
DepositAsset: {
|
|
12874
12923
|
assets: {
|
|
12875
|
-
Wild: {
|
|
12924
|
+
Wild: assetCount > 1 ? {
|
|
12876
12925
|
AllOf: {
|
|
12877
12926
|
id: asset.id,
|
|
12878
12927
|
fun: 'Fungible'
|
|
12879
12928
|
}
|
|
12929
|
+
} : {
|
|
12930
|
+
AllCounted: 1
|
|
12880
12931
|
}
|
|
12881
12932
|
},
|
|
12882
12933
|
beneficiary: createBeneficiaryLocation({
|
|
12883
|
-
api: origin.api,
|
|
12934
|
+
api: isSubBridge ? dest.api : origin.api,
|
|
12884
12935
|
address: address,
|
|
12885
12936
|
version: version
|
|
12886
12937
|
})
|
|
@@ -12889,7 +12940,7 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12889
12940
|
var assetsFilter = [];
|
|
12890
12941
|
if (!isDotAsset) assetsFilter.push(createAsset(version, reserveFee + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
|
|
12891
12942
|
assetsFilter.push(createAsset(version, assetInfo.amount, localizeLocation(reserve.chain, assetInfo.location)));
|
|
12892
|
-
if (origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12943
|
+
if (isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12893
12944
|
var buyExecutionAmount = !isDotAsset ? destFee : assetInfo.amount - reserveFee - refundFee;
|
|
12894
12945
|
if (buyExecutionAmount < 0n) throw new AmountTooLowError();
|
|
12895
12946
|
var filter = fees.destFee === MIN_FEE ? {
|
|
@@ -12903,26 +12954,29 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12903
12954
|
weight_limit: 'Unlimited'
|
|
12904
12955
|
}
|
|
12905
12956
|
};
|
|
12957
|
+
if (isSubBridge) {
|
|
12958
|
+
return [buyExecution, depositInstruction];
|
|
12959
|
+
}
|
|
12906
12960
|
var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
|
|
12907
12961
|
// If destination is a system chain, use teleport instead of reserve deposit
|
|
12908
12962
|
if (sdkCommon.isSystemChain(dest.chain)) {
|
|
12909
|
-
return {
|
|
12963
|
+
return [{
|
|
12910
12964
|
InitiateTeleport: {
|
|
12911
12965
|
assets: filter,
|
|
12912
12966
|
dest: destLoc,
|
|
12913
12967
|
xcm: [buyExecution, depositInstruction]
|
|
12914
12968
|
}
|
|
12915
|
-
};
|
|
12969
|
+
}];
|
|
12916
12970
|
}
|
|
12917
|
-
return {
|
|
12971
|
+
return [{
|
|
12918
12972
|
DepositReserveAsset: {
|
|
12919
12973
|
assets: filter,
|
|
12920
12974
|
dest: destLoc,
|
|
12921
12975
|
xcm: [buyExecution, depositInstruction]
|
|
12922
12976
|
}
|
|
12923
|
-
};
|
|
12977
|
+
}];
|
|
12924
12978
|
}
|
|
12925
|
-
return depositInstruction;
|
|
12979
|
+
return [depositInstruction];
|
|
12926
12980
|
};
|
|
12927
12981
|
|
|
12928
12982
|
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
@@ -12957,7 +13011,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12957
13011
|
*/
|
|
12958
13012
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12959
13013
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12960
|
-
var api, senderAddress, version, context, assetInfo,
|
|
13014
|
+
var api, senderAddress, version, context, assetInfo, isSubBridge, LOCATIONS, isRelayAsset, assetCount, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12961
13015
|
return _regenerator().w(function (_context) {
|
|
12962
13016
|
while (1) switch (_context.n) {
|
|
12963
13017
|
case 0:
|
|
@@ -12966,8 +13020,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12966
13020
|
return createTypeAndThenCallContext(chain, options, overrideReserve);
|
|
12967
13021
|
case 1:
|
|
12968
13022
|
context = _context.v;
|
|
12969
|
-
assetInfo = context.assetInfo;
|
|
12970
|
-
|
|
13023
|
+
assetInfo = context.assetInfo, isSubBridge = context.isSubBridge;
|
|
13024
|
+
LOCATIONS = [RELAY_LOCATION, {
|
|
12971
13025
|
parents: 2,
|
|
12972
13026
|
interior: {
|
|
12973
13027
|
X1: [{
|
|
@@ -12976,20 +13030,32 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12976
13030
|
}
|
|
12977
13031
|
}]
|
|
12978
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);
|
|
12979
13045
|
});
|
|
12980
|
-
|
|
12981
|
-
|
|
13046
|
+
assetCount = isRelayAsset ? 1 : 2;
|
|
13047
|
+
customXcm = createCustomXcm(context, isRelayAsset, assetCount);
|
|
12982
13048
|
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12983
13049
|
_context.n = 2;
|
|
12984
|
-
return computeAllFees(context, customXcm,
|
|
13050
|
+
return computeAllFees(context, customXcm, isRelayAsset, refundInstruction);
|
|
12985
13051
|
case 2:
|
|
12986
13052
|
fees = _context.v;
|
|
12987
13053
|
finalCustomXcm = [];
|
|
12988
|
-
if (refundInstruction) finalCustomXcm.push(refundInstruction);
|
|
12989
|
-
finalCustomXcm.push(createCustomXcm(context,
|
|
13054
|
+
if (refundInstruction && !isSubBridge) finalCustomXcm.push(refundInstruction);
|
|
13055
|
+
finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, isRelayAsset, assetCount, fees)));
|
|
12990
13056
|
totalFee = fees.reserveFee + fees.destFee + fees.refundFee;
|
|
12991
|
-
assets = buildAssets(chain, assetInfo, totalFee,
|
|
12992
|
-
return _context.a(2, buildTypeAndThenCall(context,
|
|
13057
|
+
assets = buildAssets(chain, assetInfo, totalFee, isRelayAsset, version);
|
|
13058
|
+
return _context.a(2, buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets));
|
|
12993
13059
|
}
|
|
12994
13060
|
}, _callee);
|
|
12995
13061
|
}));
|
|
@@ -13816,9 +13882,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13816
13882
|
value: function () {
|
|
13817
13883
|
var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
13818
13884
|
var isCalledInternally,
|
|
13819
|
-
_this$_options,
|
|
13820
|
-
from,
|
|
13821
|
-
to,
|
|
13822
13885
|
_yield$this$prepareNo,
|
|
13823
13886
|
normalizedOptions,
|
|
13824
13887
|
tx,
|
|
@@ -13833,25 +13896,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13833
13896
|
}
|
|
13834
13897
|
throw new InvalidParameterError('Transaction manager contains batched items. Use buildBatch() to process them.');
|
|
13835
13898
|
case 1:
|
|
13836
|
-
|
|
13837
|
-
if (!(!sdkCommon.isTLocation(to) && sdkCommon.isRelayChain(from) && sdkCommon.isRelayChain(to) && from !== to)) {
|
|
13838
|
-
_context4.n = 2;
|
|
13839
|
-
break;
|
|
13840
|
-
}
|
|
13841
|
-
throw new InvalidParameterError('Transfers between relay chains are not yet supported.');
|
|
13842
|
-
case 2:
|
|
13843
|
-
_context4.n = 3;
|
|
13899
|
+
_context4.n = 2;
|
|
13844
13900
|
return this.prepareNormalizedOptions(this._options);
|
|
13845
|
-
case
|
|
13901
|
+
case 2:
|
|
13846
13902
|
_yield$this$prepareNo = _context4.v;
|
|
13847
13903
|
normalizedOptions = _yield$this$prepareNo.normalizedOptions;
|
|
13848
|
-
_context4.n =
|
|
13904
|
+
_context4.n = 3;
|
|
13849
13905
|
return send(normalizedOptions);
|
|
13850
|
-
case
|
|
13906
|
+
case 3:
|
|
13851
13907
|
tx = _context4.v;
|
|
13852
|
-
_context4.n =
|
|
13908
|
+
_context4.n = 4;
|
|
13853
13909
|
return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
|
|
13854
|
-
case
|
|
13910
|
+
case 4:
|
|
13855
13911
|
return _context4.a(2, {
|
|
13856
13912
|
tx: tx,
|
|
13857
13913
|
options: normalizedOptions
|