@paraspell/sdk-core 14.2.2 → 14.3.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.d.ts +1 -15
- package/dist/index.mjs +779 -732
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { blake2b } from '@noble/hashes/blake2.js';
|
|
|
2
2
|
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAssetEqual, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositOrThrowImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
|
-
import { isAddress,
|
|
6
|
-
import { ParaSpellError, isTLocation, replaceBigInt, isExternalChain, CHAINS, Version, isRelayChain, isSubstrateBridge, Parents, deepEqual, isTrustedChain, isCustomChain, isSnowbridge, getJunctionValue, hasJunction, ETHEREUM_BRIDGE_ORIGINS, isBridge, RELAYCHAINS, DEFAULT_SS58_PREFIX } from '@paraspell/sdk-common';
|
|
5
|
+
import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
|
|
6
|
+
import { ParaSpellError, isTLocation, replaceBigInt, isExternalChain, CHAINS, Version, isRelayChain, isSubstrateBridge, Parents, deepEqual, isTrustedChain, isCustomChain, isSnowbridge, getJunctionValue, hasJunction, ETHEREUM_BRIDGE_ORIGINS, isBridge, flattenJunctions, RELAYCHAINS, DEFAULT_SS58_PREFIX } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { getXcmPallet, getOtherAssetsPallets, getNativeAssetsPallet, getSupportedPalletsDetails, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY, hasPalletImpl, getXcmPalletImpl } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
@@ -1513,17 +1513,6 @@ var CrustShadow$1 = {
|
|
|
1513
1513
|
}
|
|
1514
1514
|
]
|
|
1515
1515
|
};
|
|
1516
|
-
var Crab$1 = {
|
|
1517
|
-
name: "Crab",
|
|
1518
|
-
info: "crab",
|
|
1519
|
-
paraId: 2105,
|
|
1520
|
-
providers: [
|
|
1521
|
-
{
|
|
1522
|
-
name: "Darwinia",
|
|
1523
|
-
endpoint: "wss://crab-rpc.darwinia.network/"
|
|
1524
|
-
}
|
|
1525
|
-
]
|
|
1526
|
-
};
|
|
1527
1516
|
var RobonomicsPolkadot$1 = {
|
|
1528
1517
|
name: "Robonomics",
|
|
1529
1518
|
info: "robonomics",
|
|
@@ -1715,17 +1704,6 @@ var HydrationPaseo$1 = {
|
|
|
1715
1704
|
}
|
|
1716
1705
|
]
|
|
1717
1706
|
};
|
|
1718
|
-
var NeuroWebPaseo$1 = {
|
|
1719
|
-
name: "NeuroWeb Testnet",
|
|
1720
|
-
info: "NeuroWeb",
|
|
1721
|
-
paraId: 2043,
|
|
1722
|
-
providers: [
|
|
1723
|
-
{
|
|
1724
|
-
name: "TraceLabs",
|
|
1725
|
-
endpoint: "wss://parachain-testnet-rpc.origin-trail.network/"
|
|
1726
|
-
}
|
|
1727
|
-
]
|
|
1728
|
-
};
|
|
1729
1707
|
var PeoplePaseo$1 = {
|
|
1730
1708
|
name: "People",
|
|
1731
1709
|
info: "PaseoPeopleChain",
|
|
@@ -1897,7 +1875,6 @@ var configs = {
|
|
|
1897
1875
|
BifrostKusama: BifrostKusama$1,
|
|
1898
1876
|
Curio: Curio$1,
|
|
1899
1877
|
CrustShadow: CrustShadow$1,
|
|
1900
|
-
Crab: Crab$1,
|
|
1901
1878
|
RobonomicsPolkadot: RobonomicsPolkadot$1,
|
|
1902
1879
|
PeopleKusama: PeopleKusama$1,
|
|
1903
1880
|
Shiden: Shiden$1,
|
|
@@ -1911,7 +1888,6 @@ var configs = {
|
|
|
1911
1888
|
EnergyWebXPaseo: EnergyWebXPaseo$1,
|
|
1912
1889
|
HeimaPaseo: HeimaPaseo$1,
|
|
1913
1890
|
HydrationPaseo: HydrationPaseo$1,
|
|
1914
|
-
NeuroWebPaseo: NeuroWebPaseo$1,
|
|
1915
1891
|
PeoplePaseo: PeoplePaseo$1,
|
|
1916
1892
|
Polkadot: Polkadot$1,
|
|
1917
1893
|
Kusama: Kusama$1,
|
|
@@ -2563,21 +2539,6 @@ var FungiblesPallet = /*#__PURE__*/function (_AssetsPallet) {
|
|
|
2563
2539
|
}]);
|
|
2564
2540
|
}(AssetsPallet);
|
|
2565
2541
|
|
|
2566
|
-
var SIZE = 32;
|
|
2567
|
-
var BALANCE_SLOT = 0;
|
|
2568
|
-
var BALANCE_SLOT_WORMHOLE = 5;
|
|
2569
|
-
var calculateMappingSlot = function calculateMappingSlot(key, assetId) {
|
|
2570
|
-
var normalizedKey = getAddress(key);
|
|
2571
|
-
var keyPadded = pad(normalizedKey, {
|
|
2572
|
-
size: SIZE
|
|
2573
|
-
});
|
|
2574
|
-
var resolvedSlot = assetId !== null && assetId !== void 0 && assetId.startsWith('0x') ? BALANCE_SLOT_WORMHOLE : BALANCE_SLOT;
|
|
2575
|
-
var slotHex = pad(toHex(resolvedSlot), {
|
|
2576
|
-
size: SIZE
|
|
2577
|
-
});
|
|
2578
|
-
var encoded = concat([keyPadded, slotHex]);
|
|
2579
|
-
return keccak256(encoded);
|
|
2580
|
-
};
|
|
2581
2542
|
var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
2582
2543
|
function SystemPallet() {
|
|
2583
2544
|
_classCallCheck(this, SystemPallet);
|
|
@@ -2586,61 +2547,31 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2586
2547
|
_inherits(SystemPallet, _BaseAssetsPallet);
|
|
2587
2548
|
return _createClass(SystemPallet, [{
|
|
2588
2549
|
key: "mint",
|
|
2589
|
-
value: function () {
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
return _regenerator().w(function (_context) {
|
|
2593
|
-
while (1) switch (_context.n) {
|
|
2594
|
-
case 0:
|
|
2595
|
-
assertHasId(assetInfo);
|
|
2596
|
-
contractAddr = formatAssetIdToERC20(assetInfo.assetId);
|
|
2597
|
-
slot = calculateMappingSlot(address, assetInfo.assetId);
|
|
2598
|
-
amountEncoded = pad(toHex(assetInfo.amount + balance), {
|
|
2599
|
-
size: SIZE
|
|
2600
|
-
});
|
|
2601
|
-
_context.n = 1;
|
|
2602
|
-
return api.getEvmStorage(contractAddr, slot);
|
|
2603
|
-
case 1:
|
|
2604
|
-
storageKey = _context.v;
|
|
2605
|
-
return _context.a(2, {
|
|
2606
|
-
balanceTx: {
|
|
2607
|
-
module: this.palletName,
|
|
2608
|
-
method: 'set_storage',
|
|
2609
|
-
params: {
|
|
2610
|
-
items: [[storageKey, amountEncoded]]
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
});
|
|
2614
|
-
}
|
|
2615
|
-
}, _callee, this);
|
|
2616
|
-
}));
|
|
2617
|
-
function mint(_x, _x2, _x3, _x4) {
|
|
2618
|
-
return _mint.apply(this, arguments);
|
|
2619
|
-
}
|
|
2620
|
-
return mint;
|
|
2621
|
-
}()
|
|
2550
|
+
value: function mint(_api, _address, _assetInfo, _balance) {
|
|
2551
|
+
throw new UnsupportedOperationError('System pallet does not support minting.');
|
|
2552
|
+
}
|
|
2622
2553
|
}, {
|
|
2623
2554
|
key: "getBalance",
|
|
2624
2555
|
value: function () {
|
|
2625
|
-
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2556
|
+
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
|
|
2626
2557
|
var _asset$existentialDep;
|
|
2627
2558
|
var account, free, reserved, frozen, ed, frozenUntouchable, untouchable, spendable;
|
|
2628
|
-
return _regenerator().w(function (
|
|
2629
|
-
while (1) switch (
|
|
2559
|
+
return _regenerator().w(function (_context) {
|
|
2560
|
+
while (1) switch (_context.n) {
|
|
2630
2561
|
case 0:
|
|
2631
|
-
|
|
2562
|
+
_context.n = 1;
|
|
2632
2563
|
return api.queryState({
|
|
2633
2564
|
module: this.palletName,
|
|
2634
2565
|
method: 'Account',
|
|
2635
2566
|
params: [address]
|
|
2636
2567
|
});
|
|
2637
2568
|
case 1:
|
|
2638
|
-
account =
|
|
2569
|
+
account = _context.v;
|
|
2639
2570
|
if (!((account === null || account === void 0 ? void 0 : account.data) === undefined)) {
|
|
2640
|
-
|
|
2571
|
+
_context.n = 2;
|
|
2641
2572
|
break;
|
|
2642
2573
|
}
|
|
2643
|
-
return
|
|
2574
|
+
return _context.a(2, 0n);
|
|
2644
2575
|
case 2:
|
|
2645
2576
|
free = BigInt(account.data.free);
|
|
2646
2577
|
reserved = BigInt(account.data.reserved);
|
|
@@ -2649,11 +2580,11 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2649
2580
|
frozenUntouchable = frozen - reserved;
|
|
2650
2581
|
untouchable = frozenUntouchable > ed ? frozenUntouchable : ed;
|
|
2651
2582
|
spendable = free - untouchable;
|
|
2652
|
-
return
|
|
2583
|
+
return _context.a(2, spendable > 0n ? spendable : 0n);
|
|
2653
2584
|
}
|
|
2654
|
-
},
|
|
2585
|
+
}, _callee, this);
|
|
2655
2586
|
}));
|
|
2656
|
-
function getBalance(
|
|
2587
|
+
function getBalance(_x, _x2, _x3) {
|
|
2657
2588
|
return _getBalance.apply(this, arguments);
|
|
2658
2589
|
}
|
|
2659
2590
|
return getBalance;
|
|
@@ -3756,109 +3687,429 @@ var getMythosOriginFee = /*#__PURE__*/function () {
|
|
|
3756
3687
|
};
|
|
3757
3688
|
}();
|
|
3758
3689
|
|
|
3759
|
-
var
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
}
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
return evmExtension;
|
|
3690
|
+
var createX1Payload = function createX1Payload(version, junction) {
|
|
3691
|
+
return version === Version.V3 ? {
|
|
3692
|
+
X1: junction
|
|
3693
|
+
} : {
|
|
3694
|
+
X1: [junction]
|
|
3695
|
+
};
|
|
3766
3696
|
};
|
|
3767
3697
|
|
|
3768
|
-
var
|
|
3769
|
-
|
|
3770
|
-
|
|
3698
|
+
var createAccountPayload = function createAccountPayload(api, address) {
|
|
3699
|
+
return isAddress(address) ? {
|
|
3700
|
+
AccountKey20: {
|
|
3701
|
+
key: address
|
|
3702
|
+
}
|
|
3703
|
+
} : {
|
|
3704
|
+
AccountId32: {
|
|
3705
|
+
id: api.accountToHex(address)
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3771
3708
|
};
|
|
3772
|
-
var
|
|
3773
|
-
|
|
3774
|
-
|
|
3709
|
+
var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
|
|
3710
|
+
var api = _ref.api,
|
|
3711
|
+
recipient = _ref.recipient,
|
|
3712
|
+
origin = _ref.origin,
|
|
3713
|
+
destination = _ref.destination,
|
|
3714
|
+
version = _ref.version,
|
|
3715
|
+
paraId = _ref.paraId;
|
|
3716
|
+
if (isTLocation(recipient)) {
|
|
3717
|
+
return recipient;
|
|
3718
|
+
}
|
|
3719
|
+
var scenario = resolveScenario(origin, destination);
|
|
3720
|
+
var accountPayload = createAccountPayload(api, recipient);
|
|
3721
|
+
if (scenario === 'ParaToRelay') {
|
|
3722
|
+
return {
|
|
3723
|
+
parents: Parents.ONE,
|
|
3724
|
+
interior: createX1Payload(version, {
|
|
3725
|
+
AccountId32: {
|
|
3726
|
+
id: api.accountToHex(recipient)
|
|
3727
|
+
}
|
|
3728
|
+
})
|
|
3729
|
+
};
|
|
3730
|
+
} else if (scenario === 'ParaToPara') {
|
|
3731
|
+
return {
|
|
3732
|
+
parents: Parents.ONE,
|
|
3733
|
+
interior: {
|
|
3734
|
+
X2: [{
|
|
3735
|
+
Parachain: paraId
|
|
3736
|
+
}, accountPayload]
|
|
3737
|
+
}
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
return {
|
|
3741
|
+
parents: Parents.ZERO,
|
|
3742
|
+
interior: createX1Payload(version, accountPayload)
|
|
3743
|
+
};
|
|
3744
|
+
};
|
|
3745
|
+
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
3746
|
+
var api = _ref2.api,
|
|
3747
|
+
address = _ref2.address,
|
|
3748
|
+
version = _ref2.version;
|
|
3749
|
+
if (isTLocation(address)) return address;
|
|
3750
|
+
var accountPayload = createAccountPayload(api, address);
|
|
3751
|
+
return {
|
|
3752
|
+
parents: Parents.ZERO,
|
|
3753
|
+
interior: createX1Payload(version, accountPayload)
|
|
3754
|
+
};
|
|
3775
3755
|
};
|
|
3776
3756
|
|
|
3777
|
-
var
|
|
3778
|
-
var
|
|
3779
|
-
|
|
3757
|
+
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
3758
|
+
var isLocDestination = isTLocation(destination);
|
|
3759
|
+
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
3760
|
+
if (isSubBridge) {
|
|
3761
|
+
return {
|
|
3762
|
+
parents: Parents.TWO,
|
|
3763
|
+
interior: {
|
|
3764
|
+
X2: [{
|
|
3765
|
+
GlobalConsensus: api.getRelayChainOf(destination)
|
|
3766
|
+
}, {
|
|
3767
|
+
Parachain: chainId
|
|
3768
|
+
}]
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
3773
|
+
if (isExternalDestination) {
|
|
3774
|
+
return {
|
|
3775
|
+
parents: Parents.TWO,
|
|
3776
|
+
interior: {
|
|
3777
|
+
X1: [getEthereumJunction(api, origin)]
|
|
3778
|
+
}
|
|
3779
|
+
};
|
|
3780
|
+
}
|
|
3781
|
+
var scenario = resolveScenario(origin, destination);
|
|
3782
|
+
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
3783
|
+
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
3784
|
+
Parachain: chainId
|
|
3785
|
+
});
|
|
3786
|
+
return isLocDestination ? destination : {
|
|
3787
|
+
parents: parentsResolved,
|
|
3788
|
+
interior: interior
|
|
3789
|
+
};
|
|
3780
3790
|
};
|
|
3781
|
-
var
|
|
3782
|
-
|
|
3783
|
-
return
|
|
3791
|
+
var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
3792
|
+
var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
|
|
3793
|
+
return addXcmVersionHeader(plainDestination, version);
|
|
3784
3794
|
};
|
|
3785
3795
|
|
|
3786
|
-
var
|
|
3796
|
+
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
3797
|
+
var fromRelay = isRelayChain(chain);
|
|
3798
|
+
var toRelay = isRelayChain(destChain);
|
|
3799
|
+
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
3800
|
+
var interior = toRelay ? 'Here' : {
|
|
3801
|
+
X1: [{
|
|
3802
|
+
Parachain: getParaIdImpl(destChain, customCtx)
|
|
3803
|
+
}]
|
|
3804
|
+
};
|
|
3805
|
+
return {
|
|
3806
|
+
parents: parents,
|
|
3807
|
+
interior: interior
|
|
3808
|
+
};
|
|
3809
|
+
};
|
|
3787
3810
|
|
|
3788
3811
|
/**
|
|
3789
|
-
*
|
|
3812
|
+
* This function localizes a location by removing the `Parachain` junction
|
|
3813
|
+
* if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
|
|
3814
|
+
* or if the resulting interior is `'Here'` and the chain is a relay chain.
|
|
3815
|
+
*
|
|
3816
|
+
* @param chain - The current chain
|
|
3817
|
+
* @param location - The location to localize
|
|
3818
|
+
* @returns The localized location
|
|
3790
3819
|
*/
|
|
3791
|
-
var
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
var
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
}
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3820
|
+
var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
|
|
3821
|
+
var _Object$keys$;
|
|
3822
|
+
var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
|
|
3823
|
+
var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
|
|
3824
|
+
var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
3825
|
+
var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
|
|
3826
|
+
var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
|
|
3827
|
+
var junctions = location.interior === 'Here' ? [] : flattenJunctions(location.interior);
|
|
3828
|
+
var junctionCount = junctions.length;
|
|
3829
|
+
var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
|
|
3830
|
+
// Check if target is an external chain and location's GlobalConsensus matches it
|
|
3831
|
+
var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
|
|
3832
|
+
var isConsensusAnchored = junctions.findIndex(function (junction) {
|
|
3833
|
+
return 'GlobalConsensus' in junction;
|
|
3834
|
+
}) === 0;
|
|
3835
|
+
if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
|
|
3836
|
+
return location;
|
|
3837
|
+
}
|
|
3838
|
+
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
3839
|
+
return RELAY_LOCATION;
|
|
3840
|
+
}
|
|
3841
|
+
var newInterior = location.interior;
|
|
3842
|
+
var parachainRemoved = false;
|
|
3843
|
+
if (location.interior !== 'Here') {
|
|
3844
|
+
var paraId = resolveParaId(chain);
|
|
3845
|
+
var filteredJunctions = junctions.filter(function (junction) {
|
|
3846
|
+
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
3847
|
+
return false;
|
|
3848
|
+
}
|
|
3849
|
+
if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
|
|
3850
|
+
var paraJunctionId = getJunctionValue(location, 'Parachain');
|
|
3851
|
+
if (paraJunctionId === paraId) {
|
|
3852
|
+
parachainRemoved = true;
|
|
3853
|
+
return false;
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
return true;
|
|
3857
|
+
});
|
|
3858
|
+
if (filteredJunctions.length === 0) {
|
|
3859
|
+
newInterior = 'Here';
|
|
3860
|
+
} else {
|
|
3861
|
+
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
|
|
3865
|
+
var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
|
|
3866
|
+
if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
|
|
3867
|
+
return {
|
|
3868
|
+
parents: Parents.ONE,
|
|
3869
|
+
interior: {
|
|
3870
|
+
X1: [{
|
|
3871
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3872
|
+
}]
|
|
3873
|
+
}
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
|
|
3877
|
+
return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
|
|
3878
|
+
})) {
|
|
3879
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3880
|
+
parents: Parents.ONE
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
3884
|
+
return {
|
|
3885
|
+
parents: Parents.TWO,
|
|
3886
|
+
interior: {
|
|
3887
|
+
X2: [{
|
|
3888
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3889
|
+
}, {
|
|
3890
|
+
Parachain: resolveParaId(origin)
|
|
3891
|
+
}]
|
|
3892
|
+
}
|
|
3893
|
+
};
|
|
3894
|
+
}
|
|
3895
|
+
if (origin && ecosystemDiffers && newInterior !== 'Here' && !hasGlobalConsensus && originRelay !== undefined) {
|
|
3896
|
+
var _junctions = flattenJunctions(newInterior);
|
|
3897
|
+
var updatedJunctions = [{
|
|
3898
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3899
|
+
}].concat(_toConsumableArray(_junctions));
|
|
3900
|
+
return {
|
|
3901
|
+
parents: Parents.TWO,
|
|
3902
|
+
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3905
|
+
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
3906
|
+
return {
|
|
3907
|
+
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
3908
|
+
interior: newInterior
|
|
3909
|
+
};
|
|
3910
|
+
};
|
|
3911
|
+
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
3912
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
3913
|
+
return getRelayChainOf(c);
|
|
3914
|
+
}, function (c) {
|
|
3915
|
+
return getParaId(c);
|
|
3916
|
+
});
|
|
3917
|
+
};
|
|
3918
|
+
var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
|
|
3919
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
3920
|
+
return getRelayChainOfImpl(api, c);
|
|
3921
|
+
}, function (c) {
|
|
3922
|
+
return getParaIdImpl(c, api._customCtx);
|
|
3923
|
+
});
|
|
3924
|
+
};
|
|
3925
|
+
|
|
3926
|
+
var reverseTransformLocation = function reverseTransformLocation(location) {
|
|
3927
|
+
var parachainJunction = {
|
|
3928
|
+
Parachain: 1000
|
|
3929
|
+
};
|
|
3930
|
+
var alreadyHasP1000 = location.interior !== 'Here' && Object.values(location.interior).flat().some(function (j) {
|
|
3931
|
+
return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
|
|
3932
|
+
});
|
|
3933
|
+
if (alreadyHasP1000) {
|
|
3934
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3935
|
+
parents: Parents.ONE
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
var existingJunctions = location.interior === 'Here' ? [] // no other junctions
|
|
3939
|
+
: Object.values(location.interior).flat();
|
|
3940
|
+
var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
|
|
3941
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3942
|
+
parents: Parents.ONE,
|
|
3943
|
+
interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
|
|
3944
|
+
});
|
|
3945
|
+
};
|
|
3946
|
+
|
|
3947
|
+
var EMPTY_TOPIC = "0x".concat('00'.repeat(32));
|
|
3948
|
+
var getBridgeDestFee = /*#__PURE__*/function () {
|
|
3949
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, destApi, origin, destination, assetInfo, feeAssetInfo, hasSystemFeeAsset, recipient, version) {
|
|
3950
|
+
var systemAsset, transferredAsset, assets, destIsReserve, feeAssetLocation, buyExecution, depositAsset, feesSplitFromAssets, prologue, xcm;
|
|
3951
|
+
return _regenerator().w(function (_context) {
|
|
3952
|
+
while (1) switch (_context.n) {
|
|
3953
|
+
case 0:
|
|
3954
|
+
systemAsset = createAsset(version, MIN_AMOUNT, RELAY_LOCATION);
|
|
3955
|
+
transferredAsset = createAsset(version, assetInfo.amount, normalizeLocation(api.localizeLocation(origin, assetInfo.location), version));
|
|
3956
|
+
assets = hasSystemFeeAsset ? sortAssets([systemAsset, transferredAsset]) : [transferredAsset];
|
|
3957
|
+
destIsReserve = hasSystemFeeAsset ? destination === 'AssetHubPolkadot' : deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null));
|
|
3958
|
+
feeAssetLocation = hasSystemFeeAsset ? RELAY_LOCATION : assetInfo.location;
|
|
3959
|
+
buyExecution = {
|
|
3960
|
+
BuyExecution: {
|
|
3961
|
+
fees: createAsset(version, MIN_AMOUNT, api.localizeLocation(destination, feeAssetLocation, origin)),
|
|
3962
|
+
weight_limit: 'Unlimited'
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
depositAsset = {
|
|
3966
|
+
DepositAsset: {
|
|
3967
|
+
assets: {
|
|
3968
|
+
Wild: hasSystemFeeAsset ? {
|
|
3969
|
+
AllOf: {
|
|
3970
|
+
id: api.localizeLocation(destination, assetInfo.location, origin),
|
|
3971
|
+
fun: 'Fungible'
|
|
3972
|
+
}
|
|
3973
|
+
} : {
|
|
3974
|
+
AllCounted: 1
|
|
3975
|
+
}
|
|
3976
|
+
},
|
|
3977
|
+
beneficiary: createBeneficiaryLocation({
|
|
3978
|
+
api: destApi,
|
|
3979
|
+
address: recipient,
|
|
3980
|
+
version: version
|
|
3981
|
+
})
|
|
3982
|
+
}
|
|
3983
|
+
};
|
|
3984
|
+
feesSplitFromAssets = destIsReserve && hasSystemFeeAsset;
|
|
3985
|
+
prologue = feesSplitFromAssets ? [{
|
|
3986
|
+
ReserveAssetDeposited: [systemAsset]
|
|
3987
|
+
}, buyExecution, {
|
|
3988
|
+
WithdrawAsset: [transferredAsset]
|
|
3989
|
+
}, {
|
|
3990
|
+
ClearOrigin: null
|
|
3991
|
+
}] : [destIsReserve ? {
|
|
3992
|
+
WithdrawAsset: assets
|
|
3993
|
+
} : {
|
|
3994
|
+
ReserveAssetDeposited: assets
|
|
3995
|
+
}, {
|
|
3996
|
+
ClearOrigin: null
|
|
3997
|
+
}, buyExecution];
|
|
3998
|
+
xcm = [].concat(prologue, [buyExecution, depositAsset, {
|
|
3999
|
+
SetTopic: EMPTY_TOPIC
|
|
4000
|
+
}]);
|
|
4001
|
+
return _context.a(2, destApi.getXcmPaymentApiFee(destination, addXcmVersionHeader(xcm, version), [], feeAssetInfo, version, true));
|
|
4002
|
+
}
|
|
4003
|
+
}, _callee);
|
|
4004
|
+
}));
|
|
4005
|
+
return function getBridgeDestFee(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
|
4006
|
+
return _ref.apply(this, arguments);
|
|
4007
|
+
};
|
|
4008
|
+
}();
|
|
4009
|
+
|
|
4010
|
+
var evmExtension;
|
|
4011
|
+
var registerEvmExtension = function registerEvmExtension(extension) {
|
|
4012
|
+
evmExtension = extension;
|
|
4013
|
+
};
|
|
4014
|
+
var getEvmExtensionOrThrow = function getEvmExtensionOrThrow() {
|
|
4015
|
+
assertExtensionInstalled(evmExtension, 'EVM', '@paraspell/evm', 'using an EVM origin');
|
|
4016
|
+
return evmExtension;
|
|
4017
|
+
};
|
|
4018
|
+
|
|
4019
|
+
var evmSnowbridgeExtension;
|
|
4020
|
+
var registerEvmSnowbridgeExtension = function registerEvmSnowbridgeExtension(extension) {
|
|
4021
|
+
evmSnowbridgeExtension = extension;
|
|
4022
|
+
};
|
|
4023
|
+
var getEvmSnowbridgeExtensionOrThrow = function getEvmSnowbridgeExtensionOrThrow() {
|
|
4024
|
+
assertExtensionInstalled(evmSnowbridgeExtension, 'EVM Snowbridge', '@paraspell/evm-snowbridge', 'using Ethereum as an origin');
|
|
4025
|
+
return evmSnowbridgeExtension;
|
|
4026
|
+
};
|
|
4027
|
+
|
|
4028
|
+
var swapExtension;
|
|
4029
|
+
var registerSwapExtension = function registerSwapExtension(extension) {
|
|
4030
|
+
swapExtension = extension;
|
|
4031
|
+
};
|
|
4032
|
+
var getSwapExtensionOrThrow = function getSwapExtensionOrThrow() {
|
|
4033
|
+
assertExtensionInstalled(swapExtension, 'swap', '@paraspell/swap', 'using swap features');
|
|
4034
|
+
return swapExtension;
|
|
4035
|
+
};
|
|
4036
|
+
|
|
4037
|
+
var API_TYPES = ['PAPI', 'PJS', 'DEDOT'];
|
|
4038
|
+
|
|
4039
|
+
/**
|
|
4040
|
+
* The options for the batch builder.
|
|
4041
|
+
*/
|
|
4042
|
+
var BatchMode;
|
|
4043
|
+
(function (BatchMode) {
|
|
4044
|
+
/**
|
|
4045
|
+
* Does not commit if one of the calls in the batch fails.
|
|
4046
|
+
*/
|
|
4047
|
+
BatchMode["BATCH_ALL"] = "BATCH_ALL";
|
|
4048
|
+
/**
|
|
4049
|
+
* Commits each successful call regardless if a call fails.
|
|
4050
|
+
*/
|
|
4051
|
+
BatchMode["BATCH"] = "BATCH";
|
|
4052
|
+
})(BatchMode || (BatchMode = {}));
|
|
4053
|
+
|
|
4054
|
+
var XTokensError;
|
|
4055
|
+
(function (XTokensError) {
|
|
4056
|
+
XTokensError["AssetHasNoReserve"] = "AssetHasNoReserve";
|
|
4057
|
+
XTokensError["NotCrossChainTransfer"] = "NotCrossChainTransfer";
|
|
4058
|
+
XTokensError["InvalidDest"] = "InvalidDest";
|
|
4059
|
+
XTokensError["NotCrossChainTransferableCurrency"] = "NotCrossChainTransferableCurrency";
|
|
4060
|
+
XTokensError["UnweighableMessage"] = "UnweighableMessage";
|
|
4061
|
+
XTokensError["XcmExecutionFailed"] = "XcmExecutionFailed";
|
|
4062
|
+
XTokensError["CannotReanchor"] = "CannotReanchor";
|
|
4063
|
+
XTokensError["InvalidAncestry"] = "InvalidAncestry";
|
|
4064
|
+
XTokensError["InvalidAsset"] = "InvalidAsset";
|
|
4065
|
+
XTokensError["DestinationNotInvertible"] = "DestinationNotInvertible";
|
|
4066
|
+
XTokensError["BadVersion"] = "BadVersion";
|
|
4067
|
+
XTokensError["DistinctReserveForAssetAndFee"] = "DistinctReserveForAssetAndFee";
|
|
4068
|
+
XTokensError["ZeroFee"] = "ZeroFee";
|
|
4069
|
+
XTokensError["ZeroAmount"] = "ZeroAmount";
|
|
4070
|
+
XTokensError["TooManyAssetsBeingSent"] = "TooManyAssetsBeingSent";
|
|
4071
|
+
XTokensError["AssetIndexNonExistent"] = "AssetIndexNonExistent";
|
|
4072
|
+
XTokensError["FeeNotEnough"] = "FeeNotEnough";
|
|
4073
|
+
XTokensError["NotSupportedLocation"] = "NotSupportedLocation";
|
|
4074
|
+
XTokensError["MinXcmFeeNotDefined"] = "MinXcmFeeNotDefined";
|
|
4075
|
+
XTokensError["RateLimited"] = "RateLimited";
|
|
4076
|
+
})(XTokensError || (XTokensError = {}));
|
|
4077
|
+
// Mirrors https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/src/errors.rs
|
|
4078
|
+
var PolkadotXcmError;
|
|
4079
|
+
(function (PolkadotXcmError) {
|
|
4080
|
+
PolkadotXcmError["Unreachable"] = "Unreachable";
|
|
4081
|
+
PolkadotXcmError["SendFailure"] = "SendFailure";
|
|
4082
|
+
PolkadotXcmError["Filtered"] = "Filtered";
|
|
4083
|
+
PolkadotXcmError["UnweighableMessage"] = "UnweighableMessage";
|
|
4084
|
+
PolkadotXcmError["DestinationNotInvertible"] = "DestinationNotInvertible";
|
|
4085
|
+
PolkadotXcmError["Empty"] = "Empty";
|
|
4086
|
+
PolkadotXcmError["CannotReanchor"] = "CannotReanchor";
|
|
4087
|
+
PolkadotXcmError["TooManyAssets"] = "TooManyAssets";
|
|
4088
|
+
PolkadotXcmError["InvalidOrigin"] = "InvalidOrigin";
|
|
4089
|
+
PolkadotXcmError["BadVersion"] = "BadVersion";
|
|
4090
|
+
PolkadotXcmError["BadLocation"] = "BadLocation";
|
|
4091
|
+
PolkadotXcmError["NoSubscription"] = "NoSubscription";
|
|
4092
|
+
PolkadotXcmError["AlreadySubscribed"] = "AlreadySubscribed";
|
|
4093
|
+
PolkadotXcmError["CannotCheckOutTeleport"] = "CannotCheckOutTeleport";
|
|
4094
|
+
PolkadotXcmError["LowBalance"] = "LowBalance";
|
|
4095
|
+
PolkadotXcmError["TooManyLocks"] = "TooManyLocks";
|
|
4096
|
+
PolkadotXcmError["AccountNotSovereign"] = "AccountNotSovereign";
|
|
4097
|
+
PolkadotXcmError["FeesNotMet"] = "FeesNotMet";
|
|
4098
|
+
PolkadotXcmError["LockNotFound"] = "LockNotFound";
|
|
4099
|
+
PolkadotXcmError["InUse"] = "InUse";
|
|
4100
|
+
PolkadotXcmError["REMOVED"] = "REMOVED";
|
|
4101
|
+
PolkadotXcmError["InvalidAssetUnknownReserve"] = "InvalidAssetUnknownReserve";
|
|
4102
|
+
PolkadotXcmError["InvalidAssetUnsupportedReserve"] = "InvalidAssetUnsupportedReserve";
|
|
4103
|
+
PolkadotXcmError["TooManyReserves"] = "TooManyReserves";
|
|
4104
|
+
PolkadotXcmError["LocalExecutionIncomplete"] = "LocalExecutionIncomplete";
|
|
4105
|
+
PolkadotXcmError["TooManyAuthorizedAliases"] = "TooManyAuthorizedAliases";
|
|
4106
|
+
PolkadotXcmError["ExpiresInPast"] = "ExpiresInPast";
|
|
4107
|
+
PolkadotXcmError["AliasNotFound"] = "AliasNotFound";
|
|
4108
|
+
PolkadotXcmError["LocalExecutionIncompleteWithError"] = "LocalExecutionIncompleteWithError";
|
|
4109
|
+
})(PolkadotXcmError || (PolkadotXcmError = {}));
|
|
4110
|
+
var PolkadotXcmExecutionError;
|
|
4111
|
+
(function (PolkadotXcmExecutionError) {
|
|
4112
|
+
PolkadotXcmExecutionError["Overflow"] = "Overflow";
|
|
3862
4113
|
PolkadotXcmExecutionError["Unimplemented"] = "Unimplemented";
|
|
3863
4114
|
PolkadotXcmExecutionError["UntrustedReserveLocation"] = "UntrustedReserveLocation";
|
|
3864
4115
|
PolkadotXcmExecutionError["UntrustedTeleportLocation"] = "UntrustedTeleportLocation";
|
|
@@ -5877,17 +6128,18 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5877
6128
|
}();
|
|
5878
6129
|
|
|
5879
6130
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5880
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5881
|
-
var
|
|
5882
|
-
|
|
5883
|
-
|
|
6131
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6132
|
+
var _traversalResult$dest;
|
|
6133
|
+
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, keepAlive, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, resolveBridgeDestination, result, dryRunError, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14;
|
|
6134
|
+
return _regenerator().w(function (_context3) {
|
|
6135
|
+
while (1) switch (_context3.n) {
|
|
5884
6136
|
case 0:
|
|
5885
6137
|
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, keepAlive = options.keepAlive, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
5886
6138
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
5887
6139
|
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
5888
6140
|
amount = asset.amount;
|
|
5889
6141
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
5890
|
-
|
|
6142
|
+
_context3.n = 1;
|
|
5891
6143
|
return api.getDryRunCall({
|
|
5892
6144
|
tx: tx,
|
|
5893
6145
|
chain: origin,
|
|
@@ -5904,12 +6156,12 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5904
6156
|
useRootOrigin: useRootOrigin || !!bypassOptions
|
|
5905
6157
|
});
|
|
5906
6158
|
case 1:
|
|
5907
|
-
originDryRun =
|
|
6159
|
+
originDryRun = _context3.v;
|
|
5908
6160
|
if (originDryRun.success) {
|
|
5909
|
-
|
|
6161
|
+
_context3.n = 2;
|
|
5910
6162
|
break;
|
|
5911
6163
|
}
|
|
5912
|
-
return
|
|
6164
|
+
return _context3.a(2, {
|
|
5913
6165
|
success: false,
|
|
5914
6166
|
dryRunError: _objectSpread2({
|
|
5915
6167
|
chainKind: 'origin',
|
|
@@ -5921,27 +6173,27 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5921
6173
|
case 2:
|
|
5922
6174
|
isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
|
|
5923
6175
|
if (!isMythosToEthereum) {
|
|
5924
|
-
|
|
6176
|
+
_context3.n = 4;
|
|
5925
6177
|
break;
|
|
5926
6178
|
}
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
6179
|
+
_t5 = _objectSpread2;
|
|
6180
|
+
_t6 = _objectSpread2({}, originDryRun);
|
|
6181
|
+
_t7 = {};
|
|
6182
|
+
_t8 = originDryRun.fee;
|
|
6183
|
+
_context3.n = 3;
|
|
5932
6184
|
return getMythosOriginFee(api);
|
|
5933
6185
|
case 3:
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
fee:
|
|
6186
|
+
_t9 = _context3.v;
|
|
6187
|
+
_t0 = _t8 + _t9;
|
|
6188
|
+
_t4 = _t5(_t6, _t7, {
|
|
6189
|
+
fee: _t0
|
|
5938
6190
|
});
|
|
5939
|
-
|
|
6191
|
+
_context3.n = 5;
|
|
5940
6192
|
break;
|
|
5941
6193
|
case 4:
|
|
5942
|
-
|
|
6194
|
+
_t4 = originDryRun;
|
|
5943
6195
|
case 5:
|
|
5944
|
-
originDryModified =
|
|
6196
|
+
originDryModified = _t4;
|
|
5945
6197
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5946
6198
|
processHop = /*#__PURE__*/function () {
|
|
5947
6199
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
@@ -5999,7 +6251,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5999
6251
|
return _ref2.apply(this, arguments);
|
|
6000
6252
|
};
|
|
6001
6253
|
}();
|
|
6002
|
-
|
|
6254
|
+
_context3.n = 6;
|
|
6003
6255
|
return traverseXcmHops({
|
|
6004
6256
|
api: api,
|
|
6005
6257
|
origin: origin,
|
|
@@ -6020,7 +6272,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
6020
6272
|
}
|
|
6021
6273
|
});
|
|
6022
6274
|
case 6:
|
|
6023
|
-
traversalResult =
|
|
6275
|
+
traversalResult = _context3.v;
|
|
6024
6276
|
// Process Ethereum bridge fees
|
|
6025
6277
|
relayChain = api.getRelayChainOf(origin);
|
|
6026
6278
|
bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
|
|
@@ -6029,29 +6281,29 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
6029
6281
|
return hop.chain === bridgeHubChain;
|
|
6030
6282
|
}); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
|
|
6031
6283
|
if (!isMythosToEthereum) {
|
|
6032
|
-
|
|
6284
|
+
_context3.n = 7;
|
|
6033
6285
|
break;
|
|
6034
6286
|
}
|
|
6035
|
-
|
|
6036
|
-
|
|
6287
|
+
_t1 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
6288
|
+
_context3.n = 11;
|
|
6037
6289
|
break;
|
|
6038
6290
|
case 7:
|
|
6039
6291
|
if (!(bridgeHubHop !== null && bridgeHubHop !== void 0 && bridgeHubHop.result.success)) {
|
|
6040
|
-
|
|
6292
|
+
_context3.n = 9;
|
|
6041
6293
|
break;
|
|
6042
6294
|
}
|
|
6043
|
-
|
|
6295
|
+
_context3.n = 8;
|
|
6044
6296
|
return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
|
|
6045
6297
|
case 8:
|
|
6046
|
-
|
|
6047
|
-
|
|
6298
|
+
_t10 = _context3.v;
|
|
6299
|
+
_context3.n = 10;
|
|
6048
6300
|
break;
|
|
6049
6301
|
case 9:
|
|
6050
|
-
|
|
6302
|
+
_t10 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
6051
6303
|
case 10:
|
|
6052
|
-
|
|
6304
|
+
_t1 = _t10;
|
|
6053
6305
|
case 11:
|
|
6054
|
-
processedBridgeHub =
|
|
6306
|
+
processedBridgeHub = _t1;
|
|
6055
6307
|
// Update bridge hub in hops if needed
|
|
6056
6308
|
if (processedBridgeHub && processedBridgeHub.success && bridgeHubHop && bridgeHubHop.result.success && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
|
|
6057
6309
|
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
@@ -6063,10 +6315,67 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
6063
6315
|
});
|
|
6064
6316
|
}
|
|
6065
6317
|
}
|
|
6318
|
+
resolveBridgeDestination = /*#__PURE__*/function () {
|
|
6319
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
6320
|
+
var _api$findAssetInfoOnD;
|
|
6321
|
+
var destApi, systemAsset, hasSystemFeeAsset, destAsset, _t, _t2, _t3;
|
|
6322
|
+
return _regenerator().w(function (_context2) {
|
|
6323
|
+
while (1) switch (_context2.n) {
|
|
6324
|
+
case 0:
|
|
6325
|
+
if (!(isExternalChain(destination) || !isSubstrateBridge(origin, destination))) {
|
|
6326
|
+
_context2.n = 1;
|
|
6327
|
+
break;
|
|
6328
|
+
}
|
|
6329
|
+
return _context2.a(2, undefined);
|
|
6330
|
+
case 1:
|
|
6331
|
+
destApi = api.clone();
|
|
6332
|
+
_context2.n = 2;
|
|
6333
|
+
return destApi.init(destination);
|
|
6334
|
+
case 2:
|
|
6335
|
+
systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
|
|
6336
|
+
hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
|
|
6337
|
+
destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
|
|
6338
|
+
symbol: systemAsset.symbol
|
|
6339
|
+
}) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
|
|
6340
|
+
_context2.n = 3;
|
|
6341
|
+
return getBridgeDestFee(api, destApi, origin, destination, asset, destAsset, hasSystemFeeAsset, sender, resolvedVersion);
|
|
6342
|
+
case 3:
|
|
6343
|
+
_t = _context2.v;
|
|
6344
|
+
_t2 = destAsset;
|
|
6345
|
+
_t3 = [];
|
|
6346
|
+
return _context2.a(2, {
|
|
6347
|
+
success: true,
|
|
6348
|
+
fee: _t,
|
|
6349
|
+
asset: _t2,
|
|
6350
|
+
forwardedXcms: _t3
|
|
6351
|
+
});
|
|
6352
|
+
}
|
|
6353
|
+
}, _callee2);
|
|
6354
|
+
}));
|
|
6355
|
+
return function resolveBridgeDestination() {
|
|
6356
|
+
return _ref3.apply(this, arguments);
|
|
6357
|
+
};
|
|
6358
|
+
}();
|
|
6359
|
+
_t11 = originDryModified;
|
|
6360
|
+
if (!((_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0)) {
|
|
6361
|
+
_context3.n = 12;
|
|
6362
|
+
break;
|
|
6363
|
+
}
|
|
6364
|
+
_t12 = _traversalResult$dest;
|
|
6365
|
+
_context3.n = 14;
|
|
6366
|
+
break;
|
|
6367
|
+
case 12:
|
|
6368
|
+
_context3.n = 13;
|
|
6369
|
+
return resolveBridgeDestination();
|
|
6370
|
+
case 13:
|
|
6371
|
+
_t12 = _context3.v;
|
|
6372
|
+
case 14:
|
|
6373
|
+
_t13 = _t12;
|
|
6374
|
+
_t14 = traversalResult.hops;
|
|
6066
6375
|
result = {
|
|
6067
|
-
origin:
|
|
6068
|
-
destination:
|
|
6069
|
-
hops:
|
|
6376
|
+
origin: _t11,
|
|
6377
|
+
destination: _t13,
|
|
6378
|
+
hops: _t14
|
|
6070
6379
|
};
|
|
6071
6380
|
dryRunError = getDryRunError({
|
|
6072
6381
|
origin: {
|
|
@@ -6079,12 +6388,12 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
6079
6388
|
} : undefined,
|
|
6080
6389
|
hops: result.hops
|
|
6081
6390
|
});
|
|
6082
|
-
return
|
|
6391
|
+
return _context3.a(2, _objectSpread2({
|
|
6083
6392
|
success: !dryRunError,
|
|
6084
6393
|
dryRunError: dryRunError
|
|
6085
6394
|
}, result));
|
|
6086
6395
|
}
|
|
6087
|
-
},
|
|
6396
|
+
}, _callee3);
|
|
6088
6397
|
}));
|
|
6089
6398
|
return function dryRunInternal(_x) {
|
|
6090
6399
|
return _ref.apply(this, arguments);
|
|
@@ -6206,7 +6515,7 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
|
|
|
6206
6515
|
var preminted = [_native, relay, feeAsset].filter(function (a) {
|
|
6207
6516
|
return !!a;
|
|
6208
6517
|
}).filter(function (a) {
|
|
6209
|
-
var k = JSON.stringify(a.location);
|
|
6518
|
+
var k = JSON.stringify(a.location, replaceBigInt);
|
|
6210
6519
|
if (seen.has(k)) return false;
|
|
6211
6520
|
seen.add(k);
|
|
6212
6521
|
return true;
|
|
@@ -6714,7 +7023,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
6714
7023
|
|
|
6715
7024
|
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
6716
7025
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
6717
|
-
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
7026
|
+
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, _api$findAssetInfoOnD, _destApi2, systemAsset, hasSystemFeeAsset, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
6718
7027
|
return _regenerator().w(function (_context2) {
|
|
6719
7028
|
while (1) switch (_context2.p = _context2.n) {
|
|
6720
7029
|
case 0:
|
|
@@ -6926,7 +7235,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6926
7235
|
destDryRunError = destResult.dryRunError;
|
|
6927
7236
|
destSufficient = destResult.sufficient;
|
|
6928
7237
|
destAsset = destResult.asset;
|
|
6929
|
-
_context2.n =
|
|
7238
|
+
_context2.n = 19;
|
|
6930
7239
|
break;
|
|
6931
7240
|
case 12:
|
|
6932
7241
|
if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
|
|
@@ -6965,14 +7274,36 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6965
7274
|
destFeeType = destFallback.feeType;
|
|
6966
7275
|
destSufficient = destFallback.sufficient;
|
|
6967
7276
|
destAsset = api.findNativeAssetInfoOrThrow(destination);
|
|
6968
|
-
_context2.n =
|
|
7277
|
+
_context2.n = 19;
|
|
6969
7278
|
break;
|
|
6970
7279
|
case 15:
|
|
7280
|
+
if (!(!isExternalChain(destination) && isSubstrateBridge(origin, destination))) {
|
|
7281
|
+
_context2.n = 18;
|
|
7282
|
+
break;
|
|
7283
|
+
}
|
|
7284
|
+
_destApi2 = api.clone();
|
|
7285
|
+
_context2.n = 16;
|
|
7286
|
+
return _destApi2.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
7287
|
+
case 16:
|
|
7288
|
+
systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
|
|
7289
|
+
hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
|
|
7290
|
+
destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
|
|
7291
|
+
symbol: systemAsset.symbol
|
|
7292
|
+
}) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
|
|
7293
|
+
_context2.n = 17;
|
|
7294
|
+
return getBridgeDestFee(api, _destApi2, origin, destination, asset, destAsset, hasSystemFeeAsset, recipient, resolvedVersion);
|
|
7295
|
+
case 17:
|
|
7296
|
+
destFee = _context2.v;
|
|
7297
|
+
destFeeType = 'dryRun';
|
|
7298
|
+
destSufficient = true;
|
|
7299
|
+
_context2.n = 19;
|
|
7300
|
+
break;
|
|
7301
|
+
case 18:
|
|
6971
7302
|
destFee = 0n;
|
|
6972
7303
|
destFeeType = 'noFeeRequired';
|
|
6973
7304
|
destSufficient = true;
|
|
6974
7305
|
destAsset = api.findNativeAssetInfoOrThrow(destination);
|
|
6975
|
-
case
|
|
7306
|
+
case 19:
|
|
6976
7307
|
// Process Ethereum bridge fees
|
|
6977
7308
|
relayChain = api.getRelayChainOf(origin);
|
|
6978
7309
|
bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
|
|
@@ -6981,18 +7312,18 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6981
7312
|
return hop.chain === bridgeHubChain;
|
|
6982
7313
|
});
|
|
6983
7314
|
if (!isMythosToEthereum) {
|
|
6984
|
-
_context2.n =
|
|
7315
|
+
_context2.n = 20;
|
|
6985
7316
|
break;
|
|
6986
7317
|
}
|
|
6987
7318
|
_t4 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
6988
|
-
_context2.n =
|
|
7319
|
+
_context2.n = 22;
|
|
6989
7320
|
break;
|
|
6990
|
-
case
|
|
6991
|
-
_context2.n =
|
|
7321
|
+
case 20:
|
|
7322
|
+
_context2.n = 21;
|
|
6992
7323
|
return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
|
|
6993
|
-
case
|
|
7324
|
+
case 21:
|
|
6994
7325
|
_t4 = _context2.v;
|
|
6995
|
-
case
|
|
7326
|
+
case 22:
|
|
6996
7327
|
processedBridgeHub = _t4;
|
|
6997
7328
|
// Update bridge hub fee in hops if needed
|
|
6998
7329
|
if (processedBridgeHub && bridgeHubHop && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
|
|
@@ -7799,490 +8130,232 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7799
8130
|
})));
|
|
7800
8131
|
case 10:
|
|
7801
8132
|
_context3.n = 11;
|
|
7802
|
-
return dryRunInternal({
|
|
7803
|
-
api: api,
|
|
7804
|
-
tx: tx,
|
|
7805
|
-
origin: origin,
|
|
7806
|
-
destination: destination,
|
|
7807
|
-
sender: sender,
|
|
7808
|
-
version: version,
|
|
7809
|
-
currency: buildMinCurrency(amounts),
|
|
7810
|
-
feeAsset: feeAsset
|
|
7811
|
-
});
|
|
7812
|
-
case 11:
|
|
7813
|
-
dryRunResult = _context3.v;
|
|
7814
|
-
if (dryRunResult.success) {
|
|
7815
|
-
_context3.n = 12;
|
|
7816
|
-
break;
|
|
7817
|
-
}
|
|
7818
|
-
return _context3.a(2, toResult(amounts.map(function () {
|
|
7819
|
-
return 0n;
|
|
7820
|
-
})));
|
|
7821
|
-
case 12:
|
|
7822
|
-
return _context3.a(2, toResult(amounts));
|
|
7823
|
-
}
|
|
7824
|
-
}, _callee3, null, [[7, 9], [4, 6]]);
|
|
7825
|
-
}));
|
|
7826
|
-
return function getMinTransferableAmountInternal(_x) {
|
|
7827
|
-
return _ref2.apply(this, arguments);
|
|
7828
|
-
};
|
|
7829
|
-
}();
|
|
7830
|
-
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
7831
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
7832
|
-
var api;
|
|
7833
|
-
return _regenerator().w(function (_context4) {
|
|
7834
|
-
while (1) switch (_context4.p = _context4.n) {
|
|
7835
|
-
case 0:
|
|
7836
|
-
api = options.api;
|
|
7837
|
-
api.disconnectAllowed = false;
|
|
7838
|
-
_context4.p = 1;
|
|
7839
|
-
_context4.n = 2;
|
|
7840
|
-
return getMinTransferableAmountInternal(options);
|
|
7841
|
-
case 2:
|
|
7842
|
-
return _context4.a(2, _context4.v);
|
|
7843
|
-
case 3:
|
|
7844
|
-
_context4.p = 3;
|
|
7845
|
-
api.disconnectAllowed = true;
|
|
7846
|
-
_context4.n = 4;
|
|
7847
|
-
return api.disconnect();
|
|
7848
|
-
case 4:
|
|
7849
|
-
return _context4.f(3);
|
|
7850
|
-
case 5:
|
|
7851
|
-
return _context4.a(2);
|
|
7852
|
-
}
|
|
7853
|
-
}, _callee4, null, [[1,, 3, 5]]);
|
|
7854
|
-
}));
|
|
7855
|
-
return function getMinTransferableAmount(_x5) {
|
|
7856
|
-
return _ref5.apply(this, arguments);
|
|
7857
|
-
};
|
|
7858
|
-
}();
|
|
7859
|
-
|
|
7860
|
-
var getOriginFeeOrThrow = /*#__PURE__*/function () {
|
|
7861
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
|
|
7862
|
-
var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
|
|
7863
|
-
return _regenerator().w(function (_context) {
|
|
7864
|
-
while (1) switch (_context.n) {
|
|
7865
|
-
case 0:
|
|
7866
|
-
api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
|
|
7867
|
-
_context.n = 1;
|
|
7868
|
-
return getOriginXcmFee({
|
|
7869
|
-
api: api,
|
|
7870
|
-
buildTx: buildTx,
|
|
7871
|
-
origin: chain,
|
|
7872
|
-
destination: chain,
|
|
7873
|
-
sender: sender,
|
|
7874
|
-
feeAsset: feeAsset,
|
|
7875
|
-
version: version,
|
|
7876
|
-
currency: feeCurrency,
|
|
7877
|
-
disableFallback: false
|
|
7878
|
-
});
|
|
7879
|
-
case 1:
|
|
7880
|
-
_yield$getOriginXcmFe = _context.v;
|
|
7881
|
-
fee = _yield$getOriginXcmFe.fee;
|
|
7882
|
-
if (!(fee === undefined)) {
|
|
7883
|
-
_context.n = 2;
|
|
7884
|
-
break;
|
|
7885
|
-
}
|
|
7886
|
-
throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
|
|
7887
|
-
case 2:
|
|
7888
|
-
return _context.a(2, fee);
|
|
7889
|
-
}
|
|
7890
|
-
}, _callee);
|
|
7891
|
-
}));
|
|
7892
|
-
return function getOriginFeeOrThrow(_x, _x2) {
|
|
7893
|
-
return _ref2.apply(this, arguments);
|
|
7894
|
-
};
|
|
7895
|
-
}();
|
|
7896
|
-
var computeTransferableAmount = /*#__PURE__*/function () {
|
|
7897
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
|
|
7898
|
-
var balance, transferable;
|
|
7899
|
-
return _regenerator().w(function (_context2) {
|
|
7900
|
-
while (1) switch (_context2.n) {
|
|
7901
|
-
case 0:
|
|
7902
|
-
_context2.n = 1;
|
|
7903
|
-
return getAssetBalanceInternal({
|
|
7904
|
-
api: api,
|
|
7905
|
-
address: sender,
|
|
7906
|
-
chain: chain,
|
|
7907
|
-
asset: asset
|
|
7908
|
-
});
|
|
7909
|
-
case 1:
|
|
7910
|
-
balance = _context2.v;
|
|
7911
|
-
transferable = balance - getEdFromAssetOrThrow(asset) - fee;
|
|
7912
|
-
return _context2.a(2, transferable > 0n ? transferable : 0n);
|
|
7913
|
-
}
|
|
7914
|
-
}, _callee2);
|
|
7915
|
-
}));
|
|
7916
|
-
return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
|
|
7917
|
-
return _ref3.apply(this, arguments);
|
|
7918
|
-
};
|
|
7919
|
-
}();
|
|
7920
|
-
var getTransferableAmountForAsset = /*#__PURE__*/function () {
|
|
7921
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
|
|
7922
|
-
var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
|
|
7923
|
-
return _regenerator().w(function (_context3) {
|
|
7924
|
-
while (1) switch (_context3.n) {
|
|
7925
|
-
case 0:
|
|
7926
|
-
api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
|
|
7927
|
-
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
7928
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
7929
|
-
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
7930
|
-
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
7931
|
-
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
7932
|
-
if (!paysOriginInSendingAsset) {
|
|
7933
|
-
_context3.n = 2;
|
|
7934
|
-
break;
|
|
7935
|
-
}
|
|
7936
|
-
_context3.n = 1;
|
|
7937
|
-
return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
7938
|
-
amount: amount
|
|
7939
|
-
}));
|
|
7940
|
-
case 1:
|
|
7941
|
-
_t = _context3.v;
|
|
7942
|
-
_context3.n = 3;
|
|
7943
|
-
break;
|
|
7944
|
-
case 2:
|
|
7945
|
-
_t = 0n;
|
|
7946
|
-
case 3:
|
|
7947
|
-
fee = _t;
|
|
7948
|
-
return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
|
|
7949
|
-
}
|
|
7950
|
-
}, _callee3);
|
|
7951
|
-
}));
|
|
7952
|
-
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
7953
|
-
return _ref4.apply(this, arguments);
|
|
7954
|
-
};
|
|
7955
|
-
}();
|
|
7956
|
-
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
7957
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
7958
|
-
var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
|
|
7959
|
-
return _regenerator().w(function (_context4) {
|
|
7960
|
-
while (1) switch (_context4.n) {
|
|
7961
|
-
case 0:
|
|
7962
|
-
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
7963
|
-
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
7964
|
-
_context4.n = 1;
|
|
7965
|
-
return getOriginFeeOrThrow(options, currency);
|
|
7966
|
-
case 1:
|
|
7967
|
-
fee = _context4.v;
|
|
7968
|
-
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
7969
|
-
return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
|
|
8133
|
+
return dryRunInternal({
|
|
8134
|
+
api: api,
|
|
8135
|
+
tx: tx,
|
|
8136
|
+
origin: origin,
|
|
8137
|
+
destination: destination,
|
|
8138
|
+
sender: sender,
|
|
8139
|
+
version: version,
|
|
8140
|
+
currency: buildMinCurrency(amounts),
|
|
8141
|
+
feeAsset: feeAsset
|
|
8142
|
+
});
|
|
8143
|
+
case 11:
|
|
8144
|
+
dryRunResult = _context3.v;
|
|
8145
|
+
if (dryRunResult.success) {
|
|
8146
|
+
_context3.n = 12;
|
|
8147
|
+
break;
|
|
8148
|
+
}
|
|
8149
|
+
return _context3.a(2, toResult(amounts.map(function () {
|
|
8150
|
+
return 0n;
|
|
7970
8151
|
})));
|
|
8152
|
+
case 12:
|
|
8153
|
+
return _context3.a(2, toResult(amounts));
|
|
7971
8154
|
}
|
|
7972
|
-
},
|
|
7973
|
-
}));
|
|
7974
|
-
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
7975
|
-
return _ref5.apply(this, arguments);
|
|
7976
|
-
};
|
|
7977
|
-
}();
|
|
7978
|
-
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
7979
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
7980
|
-
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
7981
|
-
return _regenerator().w(function (_context5) {
|
|
7982
|
-
while (1) switch (_context5.n) {
|
|
7983
|
-
case 0:
|
|
7984
|
-
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
7985
|
-
validateAddress(api, sender, chain, false);
|
|
7986
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
7987
|
-
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7988
|
-
currency: currency
|
|
7989
|
-
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7990
|
-
currency: currency
|
|
7991
|
-
}), resolvedFeeAsset));
|
|
7992
|
-
}
|
|
7993
|
-
}, _callee5);
|
|
8155
|
+
}, _callee3, null, [[7, 9], [4, 6]]);
|
|
7994
8156
|
}));
|
|
7995
|
-
return function
|
|
7996
|
-
return
|
|
8157
|
+
return function getMinTransferableAmountInternal(_x) {
|
|
8158
|
+
return _ref2.apply(this, arguments);
|
|
7997
8159
|
};
|
|
7998
8160
|
}();
|
|
7999
|
-
var
|
|
8000
|
-
var
|
|
8161
|
+
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
8162
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
8001
8163
|
var api;
|
|
8002
|
-
return _regenerator().w(function (
|
|
8003
|
-
while (1) switch (
|
|
8164
|
+
return _regenerator().w(function (_context4) {
|
|
8165
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
8004
8166
|
case 0:
|
|
8005
8167
|
api = options.api;
|
|
8006
8168
|
api.disconnectAllowed = false;
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
return
|
|
8169
|
+
_context4.p = 1;
|
|
8170
|
+
_context4.n = 2;
|
|
8171
|
+
return getMinTransferableAmountInternal(options);
|
|
8010
8172
|
case 2:
|
|
8011
|
-
return
|
|
8173
|
+
return _context4.a(2, _context4.v);
|
|
8012
8174
|
case 3:
|
|
8013
|
-
|
|
8175
|
+
_context4.p = 3;
|
|
8014
8176
|
api.disconnectAllowed = true;
|
|
8015
|
-
|
|
8177
|
+
_context4.n = 4;
|
|
8016
8178
|
return api.disconnect();
|
|
8017
8179
|
case 4:
|
|
8018
|
-
return
|
|
8180
|
+
return _context4.f(3);
|
|
8019
8181
|
case 5:
|
|
8020
|
-
return
|
|
8182
|
+
return _context4.a(2);
|
|
8021
8183
|
}
|
|
8022
|
-
},
|
|
8184
|
+
}, _callee4, null, [[1,, 3, 5]]);
|
|
8023
8185
|
}));
|
|
8024
|
-
return function
|
|
8025
|
-
return
|
|
8186
|
+
return function getMinTransferableAmount(_x5) {
|
|
8187
|
+
return _ref5.apply(this, arguments);
|
|
8026
8188
|
};
|
|
8027
8189
|
}();
|
|
8028
8190
|
|
|
8029
|
-
var
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
};
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
var scenario = resolveScenario(origin, destination);
|
|
8059
|
-
var accountPayload = createAccountPayload(api, recipient);
|
|
8060
|
-
if (scenario === 'ParaToRelay') {
|
|
8061
|
-
return {
|
|
8062
|
-
parents: Parents.ONE,
|
|
8063
|
-
interior: createX1Payload(version, {
|
|
8064
|
-
AccountId32: {
|
|
8065
|
-
id: api.accountToHex(recipient)
|
|
8066
|
-
}
|
|
8067
|
-
})
|
|
8068
|
-
};
|
|
8069
|
-
} else if (scenario === 'ParaToPara') {
|
|
8070
|
-
return {
|
|
8071
|
-
parents: Parents.ONE,
|
|
8072
|
-
interior: {
|
|
8073
|
-
X2: [{
|
|
8074
|
-
Parachain: paraId
|
|
8075
|
-
}, accountPayload]
|
|
8076
|
-
}
|
|
8077
|
-
};
|
|
8078
|
-
}
|
|
8079
|
-
return {
|
|
8080
|
-
parents: Parents.ZERO,
|
|
8081
|
-
interior: createX1Payload(version, accountPayload)
|
|
8082
|
-
};
|
|
8083
|
-
};
|
|
8084
|
-
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
8085
|
-
var api = _ref2.api,
|
|
8086
|
-
address = _ref2.address,
|
|
8087
|
-
version = _ref2.version;
|
|
8088
|
-
if (isTLocation(address)) return address;
|
|
8089
|
-
var accountPayload = createAccountPayload(api, address);
|
|
8090
|
-
return {
|
|
8091
|
-
parents: Parents.ZERO,
|
|
8092
|
-
interior: createX1Payload(version, accountPayload)
|
|
8093
|
-
};
|
|
8094
|
-
};
|
|
8095
|
-
|
|
8096
|
-
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
8097
|
-
var isLocDestination = isTLocation(destination);
|
|
8098
|
-
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
8099
|
-
if (isSubBridge) {
|
|
8100
|
-
return {
|
|
8101
|
-
parents: Parents.TWO,
|
|
8102
|
-
interior: {
|
|
8103
|
-
X2: [{
|
|
8104
|
-
GlobalConsensus: api.getRelayChainOf(destination)
|
|
8105
|
-
}, {
|
|
8106
|
-
Parachain: chainId
|
|
8107
|
-
}]
|
|
8108
|
-
}
|
|
8109
|
-
};
|
|
8110
|
-
}
|
|
8111
|
-
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
8112
|
-
if (isExternalDestination) {
|
|
8113
|
-
return {
|
|
8114
|
-
parents: Parents.TWO,
|
|
8115
|
-
interior: {
|
|
8116
|
-
X1: [getEthereumJunction(api, origin)]
|
|
8117
|
-
}
|
|
8118
|
-
};
|
|
8119
|
-
}
|
|
8120
|
-
var scenario = resolveScenario(origin, destination);
|
|
8121
|
-
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
8122
|
-
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
8123
|
-
Parachain: chainId
|
|
8124
|
-
});
|
|
8125
|
-
return isLocDestination ? destination : {
|
|
8126
|
-
parents: parentsResolved,
|
|
8127
|
-
interior: interior
|
|
8128
|
-
};
|
|
8129
|
-
};
|
|
8130
|
-
var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
8131
|
-
var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
|
|
8132
|
-
return addXcmVersionHeader(plainDestination, version);
|
|
8133
|
-
};
|
|
8134
|
-
|
|
8135
|
-
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
8136
|
-
var fromRelay = isRelayChain(chain);
|
|
8137
|
-
var toRelay = isRelayChain(destChain);
|
|
8138
|
-
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
8139
|
-
var interior = toRelay ? 'Here' : {
|
|
8140
|
-
X1: [{
|
|
8141
|
-
Parachain: getParaIdImpl(destChain, customCtx)
|
|
8142
|
-
}]
|
|
8143
|
-
};
|
|
8144
|
-
return {
|
|
8145
|
-
parents: parents,
|
|
8146
|
-
interior: interior
|
|
8147
|
-
};
|
|
8148
|
-
};
|
|
8149
|
-
|
|
8150
|
-
/**
|
|
8151
|
-
* This function localizes a location by removing the `Parachain` junction
|
|
8152
|
-
* if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
|
|
8153
|
-
* or if the resulting interior is `'Here'` and the chain is a relay chain.
|
|
8154
|
-
*
|
|
8155
|
-
* @param chain - The current chain
|
|
8156
|
-
* @param location - The location to localize
|
|
8157
|
-
* @returns The localized location
|
|
8158
|
-
*/
|
|
8159
|
-
var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
|
|
8160
|
-
var _Object$keys$;
|
|
8161
|
-
var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
|
|
8162
|
-
var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
|
|
8163
|
-
var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
8164
|
-
var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
|
|
8165
|
-
var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
|
|
8166
|
-
var junctions = location.interior === 'Here' ? [] : Object.values(location.interior).flat().filter(function (junction) {
|
|
8167
|
-
return _typeof(junction) === 'object' && junction !== null;
|
|
8168
|
-
});
|
|
8169
|
-
var junctionCount = junctions.length;
|
|
8170
|
-
var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
|
|
8171
|
-
// Check if target is an external chain and location's GlobalConsensus matches it
|
|
8172
|
-
var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
|
|
8173
|
-
if (!origin && locationRelay && targetRelay && locationRelay !== targetRelay) {
|
|
8174
|
-
return location;
|
|
8175
|
-
}
|
|
8176
|
-
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
8177
|
-
return RELAY_LOCATION;
|
|
8178
|
-
}
|
|
8179
|
-
var newInterior = location.interior;
|
|
8180
|
-
var parachainRemoved = false;
|
|
8181
|
-
if (location.interior !== 'Here') {
|
|
8182
|
-
var paraId = resolveParaId(chain);
|
|
8183
|
-
var filteredJunctions = junctions.filter(function (junction) {
|
|
8184
|
-
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
8185
|
-
return false;
|
|
8191
|
+
var getOriginFeeOrThrow = /*#__PURE__*/function () {
|
|
8192
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
|
|
8193
|
+
var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
|
|
8194
|
+
return _regenerator().w(function (_context) {
|
|
8195
|
+
while (1) switch (_context.n) {
|
|
8196
|
+
case 0:
|
|
8197
|
+
api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
|
|
8198
|
+
_context.n = 1;
|
|
8199
|
+
return getOriginXcmFee({
|
|
8200
|
+
api: api,
|
|
8201
|
+
buildTx: buildTx,
|
|
8202
|
+
origin: chain,
|
|
8203
|
+
destination: chain,
|
|
8204
|
+
sender: sender,
|
|
8205
|
+
feeAsset: feeAsset,
|
|
8206
|
+
version: version,
|
|
8207
|
+
currency: feeCurrency,
|
|
8208
|
+
disableFallback: false
|
|
8209
|
+
});
|
|
8210
|
+
case 1:
|
|
8211
|
+
_yield$getOriginXcmFe = _context.v;
|
|
8212
|
+
fee = _yield$getOriginXcmFe.fee;
|
|
8213
|
+
if (!(fee === undefined)) {
|
|
8214
|
+
_context.n = 2;
|
|
8215
|
+
break;
|
|
8216
|
+
}
|
|
8217
|
+
throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
|
|
8218
|
+
case 2:
|
|
8219
|
+
return _context.a(2, fee);
|
|
8186
8220
|
}
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8221
|
+
}, _callee);
|
|
8222
|
+
}));
|
|
8223
|
+
return function getOriginFeeOrThrow(_x, _x2) {
|
|
8224
|
+
return _ref2.apply(this, arguments);
|
|
8225
|
+
};
|
|
8226
|
+
}();
|
|
8227
|
+
var computeTransferableAmount = /*#__PURE__*/function () {
|
|
8228
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
|
|
8229
|
+
var balance, transferable;
|
|
8230
|
+
return _regenerator().w(function (_context2) {
|
|
8231
|
+
while (1) switch (_context2.n) {
|
|
8232
|
+
case 0:
|
|
8233
|
+
_context2.n = 1;
|
|
8234
|
+
return getAssetBalanceInternal({
|
|
8235
|
+
api: api,
|
|
8236
|
+
address: sender,
|
|
8237
|
+
chain: chain,
|
|
8238
|
+
asset: asset
|
|
8239
|
+
});
|
|
8240
|
+
case 1:
|
|
8241
|
+
balance = _context2.v;
|
|
8242
|
+
transferable = balance - getEdFromAssetOrThrow(asset) - fee;
|
|
8243
|
+
return _context2.a(2, transferable > 0n ? transferable : 0n);
|
|
8193
8244
|
}
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8245
|
+
}, _callee2);
|
|
8246
|
+
}));
|
|
8247
|
+
return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
|
|
8248
|
+
return _ref3.apply(this, arguments);
|
|
8249
|
+
};
|
|
8250
|
+
}();
|
|
8251
|
+
var getTransferableAmountForAsset = /*#__PURE__*/function () {
|
|
8252
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
|
|
8253
|
+
var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
|
|
8254
|
+
return _regenerator().w(function (_context3) {
|
|
8255
|
+
while (1) switch (_context3.n) {
|
|
8256
|
+
case 0:
|
|
8257
|
+
api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
|
|
8258
|
+
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
8259
|
+
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
8260
|
+
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
8261
|
+
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
8262
|
+
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
8263
|
+
if (!paysOriginInSendingAsset) {
|
|
8264
|
+
_context3.n = 2;
|
|
8265
|
+
break;
|
|
8266
|
+
}
|
|
8267
|
+
_context3.n = 1;
|
|
8268
|
+
return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
8269
|
+
amount: amount
|
|
8270
|
+
}));
|
|
8271
|
+
case 1:
|
|
8272
|
+
_t = _context3.v;
|
|
8273
|
+
_context3.n = 3;
|
|
8274
|
+
break;
|
|
8275
|
+
case 2:
|
|
8276
|
+
_t = 0n;
|
|
8277
|
+
case 3:
|
|
8278
|
+
fee = _t;
|
|
8279
|
+
return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
|
|
8211
8280
|
}
|
|
8212
|
-
};
|
|
8213
|
-
}
|
|
8214
|
-
|
|
8215
|
-
return
|
|
8216
|
-
}
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8281
|
+
}, _callee3);
|
|
8282
|
+
}));
|
|
8283
|
+
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
8284
|
+
return _ref4.apply(this, arguments);
|
|
8285
|
+
};
|
|
8286
|
+
}();
|
|
8287
|
+
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
8288
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
8289
|
+
var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
|
|
8290
|
+
return _regenerator().w(function (_context4) {
|
|
8291
|
+
while (1) switch (_context4.n) {
|
|
8292
|
+
case 0:
|
|
8293
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
8294
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
8295
|
+
_context4.n = 1;
|
|
8296
|
+
return getOriginFeeOrThrow(options, currency);
|
|
8297
|
+
case 1:
|
|
8298
|
+
fee = _context4.v;
|
|
8299
|
+
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
8300
|
+
return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
|
|
8301
|
+
})));
|
|
8230
8302
|
}
|
|
8231
|
-
};
|
|
8232
|
-
}
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
return _typeof(junction) === 'object' && junction !== null;
|
|
8236
|
-
});
|
|
8237
|
-
var updatedJunctions = [{
|
|
8238
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8239
|
-
}].concat(_toConsumableArray(_junctions));
|
|
8240
|
-
return {
|
|
8241
|
-
parents: Parents.TWO,
|
|
8242
|
-
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
8243
|
-
};
|
|
8244
|
-
}
|
|
8245
|
-
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
8246
|
-
return {
|
|
8247
|
-
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
8248
|
-
interior: newInterior
|
|
8303
|
+
}, _callee4);
|
|
8304
|
+
}));
|
|
8305
|
+
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
8306
|
+
return _ref5.apply(this, arguments);
|
|
8249
8307
|
};
|
|
8250
|
-
};
|
|
8251
|
-
var
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
};
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8308
|
+
}();
|
|
8309
|
+
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
8310
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
8311
|
+
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
8312
|
+
return _regenerator().w(function (_context5) {
|
|
8313
|
+
while (1) switch (_context5.n) {
|
|
8314
|
+
case 0:
|
|
8315
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
8316
|
+
validateAddress(api, sender, chain, false);
|
|
8317
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
8318
|
+
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8319
|
+
currency: currency
|
|
8320
|
+
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8321
|
+
currency: currency
|
|
8322
|
+
}), resolvedFeeAsset));
|
|
8323
|
+
}
|
|
8324
|
+
}, _callee5);
|
|
8325
|
+
}));
|
|
8326
|
+
return function getTransferableAmountInternal(_x10) {
|
|
8327
|
+
return _ref6.apply(this, arguments);
|
|
8269
8328
|
};
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
return
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8329
|
+
}();
|
|
8330
|
+
var getTransferableAmount = /*#__PURE__*/function () {
|
|
8331
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
|
|
8332
|
+
var api;
|
|
8333
|
+
return _regenerator().w(function (_context6) {
|
|
8334
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
8335
|
+
case 0:
|
|
8336
|
+
api = options.api;
|
|
8337
|
+
api.disconnectAllowed = false;
|
|
8338
|
+
_context6.p = 1;
|
|
8339
|
+
_context6.n = 2;
|
|
8340
|
+
return getTransferableAmountInternal(options);
|
|
8341
|
+
case 2:
|
|
8342
|
+
return _context6.a(2, _context6.v);
|
|
8343
|
+
case 3:
|
|
8344
|
+
_context6.p = 3;
|
|
8345
|
+
api.disconnectAllowed = true;
|
|
8346
|
+
_context6.n = 4;
|
|
8347
|
+
return api.disconnect();
|
|
8348
|
+
case 4:
|
|
8349
|
+
return _context6.f(3);
|
|
8350
|
+
case 5:
|
|
8351
|
+
return _context6.a(2);
|
|
8352
|
+
}
|
|
8353
|
+
}, _callee6, null, [[1,, 3, 5]]);
|
|
8354
|
+
}));
|
|
8355
|
+
return function getTransferableAmount(_x11) {
|
|
8356
|
+
return _ref7.apply(this, arguments);
|
|
8357
|
+
};
|
|
8358
|
+
}();
|
|
8286
8359
|
|
|
8287
8360
|
var resolveTransferType = function resolveTransferType(_ref) {
|
|
8288
8361
|
var origin = _ref.origin,
|
|
@@ -8305,6 +8378,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8305
8378
|
dest = context.dest,
|
|
8306
8379
|
assetInfo = context.assetInfo,
|
|
8307
8380
|
bridgeHopChain = context.bridgeHopChain,
|
|
8381
|
+
isSubBridge = context.isSubBridge,
|
|
8308
8382
|
_context$options = context.options,
|
|
8309
8383
|
version = _context$options.version,
|
|
8310
8384
|
pallet = _context$options.pallet,
|
|
@@ -8314,6 +8388,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8314
8388
|
var finalDest = bridgeHopChain !== null && bridgeHopChain !== void 0 ? bridgeHopChain : origin.chain === reserve.chain ? dest.chain : reserve.chain;
|
|
8315
8389
|
var destLocation = createDestination(origin.api, version, origin.chain, finalDest, origin.api.getParaId(finalDest));
|
|
8316
8390
|
var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
|
|
8391
|
+
var feesTransferType = isSubBridge && !isDotAsset ? 'LocalReserve' : transferType;
|
|
8317
8392
|
var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
|
|
8318
8393
|
return a.isFeeAsset;
|
|
8319
8394
|
}) : null;
|
|
@@ -8328,7 +8403,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8328
8403
|
assets: addXcmVersionHeader(assets, version),
|
|
8329
8404
|
assets_transfer_type: transferType,
|
|
8330
8405
|
remote_fees_id: addXcmVersionHeader(feeMultiAsset.id, version),
|
|
8331
|
-
fees_transfer_type:
|
|
8406
|
+
fees_transfer_type: feesTransferType,
|
|
8332
8407
|
custom_xcm_on_dest: addXcmVersionHeader(customXcm, version),
|
|
8333
8408
|
weight_limit: 'Unlimited'
|
|
8334
8409
|
}
|
|
@@ -8356,9 +8431,13 @@ var requiresSystemAssetByLocation = function requiresSystemAssetByLocation(api,
|
|
|
8356
8431
|
});
|
|
8357
8432
|
};
|
|
8358
8433
|
var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
|
|
8359
|
-
var
|
|
8360
|
-
var
|
|
8361
|
-
|
|
8434
|
+
var assetConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
8435
|
+
var ethereumConsensus = getEthereumJunction(api, chain, false).GlobalConsensus;
|
|
8436
|
+
if (!isExternalChain(destination) && deepEqual(assetConsensus, ethereumConsensus)) {
|
|
8437
|
+
return 'AssetHubPolkadot';
|
|
8438
|
+
}
|
|
8439
|
+
var expectedConsensus = isExternalChain(destination) ? ethereumConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
|
|
8440
|
+
return deepEqual(assetConsensus, expectedConsensus) ? destination : chain;
|
|
8362
8441
|
};
|
|
8363
8442
|
var resolveReserveChain = function resolveReserveChain(api, chain, destination, assetLocation, isSubBridge, overrideReserve) {
|
|
8364
8443
|
if (isSubBridge) {
|
|
@@ -8501,7 +8580,7 @@ var resolveSnowbridgeMessageId = function resolveSnowbridgeMessageId(_ref3) {
|
|
|
8501
8580
|
recipient = _ref3$options.recipient;
|
|
8502
8581
|
if (!isSnowbridge) return Promise.resolve(null);
|
|
8503
8582
|
assertSender(sender);
|
|
8504
|
-
return generateMessageId(origin.api, sender, origin.api.getParaId(origin.chain), JSON.stringify(assetInfo.location), JSON.stringify(recipient), assetInfo.amount);
|
|
8583
|
+
return generateMessageId(origin.api, sender, origin.api.getParaId(origin.chain), JSON.stringify(assetInfo.location, replaceBigInt), JSON.stringify(recipient), assetInfo.amount);
|
|
8505
8584
|
};
|
|
8506
8585
|
var createCustomXcm = /*#__PURE__*/function () {
|
|
8507
8586
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, assetCount, isForFeeCalc, systemAssetAmount) {
|
|
@@ -10642,8 +10721,9 @@ var AssetHubKusama = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10642
10721
|
key: "transferPolkadotXCM",
|
|
10643
10722
|
value: function transferPolkadotXCM(input) {
|
|
10644
10723
|
var asset = input.assetInfo,
|
|
10645
|
-
scenario = input.scenario
|
|
10646
|
-
|
|
10724
|
+
scenario = input.scenario,
|
|
10725
|
+
destination = input.destination;
|
|
10726
|
+
if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && asset.assetId === undefined && destination !== 'Curio') {
|
|
10647
10727
|
throw new ScenarioNotSupportedError('Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
|
|
10648
10728
|
}
|
|
10649
10729
|
return transferPolkadotXcm(input);
|
|
@@ -11414,34 +11494,6 @@ var CoretimeWestend = /*#__PURE__*/function (_CoretimePolkadot) {
|
|
|
11414
11494
|
return _createClass(CoretimeWestend);
|
|
11415
11495
|
}(CoretimePolkadot);
|
|
11416
11496
|
|
|
11417
|
-
var Crab = /*#__PURE__*/function (_SubstrateChain) {
|
|
11418
|
-
function Crab() {
|
|
11419
|
-
_classCallCheck(this, Crab);
|
|
11420
|
-
return _callSuper(this, Crab, ['Crab', 'crab', 'Kusama', Version.V4]);
|
|
11421
|
-
}
|
|
11422
|
-
_inherits(Crab, _SubstrateChain);
|
|
11423
|
-
return _createClass(Crab, [{
|
|
11424
|
-
key: "transferPolkadotXCM",
|
|
11425
|
-
value: function transferPolkadotXCM(input) {
|
|
11426
|
-
if (input.scenario === 'ParaToPara') return transferPolkadotXcm(input);
|
|
11427
|
-
throw new ScenarioNotSupportedError({
|
|
11428
|
-
chain: this.chain,
|
|
11429
|
-
scenario: input.scenario
|
|
11430
|
-
});
|
|
11431
|
-
}
|
|
11432
|
-
}, {
|
|
11433
|
-
key: "isRelayToParaEnabled",
|
|
11434
|
-
value: function isRelayToParaEnabled() {
|
|
11435
|
-
return false;
|
|
11436
|
-
}
|
|
11437
|
-
}, {
|
|
11438
|
-
key: "transferLocalNonNativeAsset",
|
|
11439
|
-
value: function transferLocalNonNativeAsset(options) {
|
|
11440
|
-
return getSubstrateChainImpl('Darwinia').transferLocalNonNativeAsset(options);
|
|
11441
|
-
}
|
|
11442
|
-
}]);
|
|
11443
|
-
}(SubstrateChain);
|
|
11444
|
-
|
|
11445
11497
|
var Crust = /*#__PURE__*/function (_SubstrateChain) {
|
|
11446
11498
|
function Crust() {
|
|
11447
11499
|
_classCallCheck(this, Crust);
|
|
@@ -11840,7 +11892,7 @@ var Jamton = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11840
11892
|
destination = input.destination;
|
|
11841
11893
|
if (assetInfo.isNative) return transferPolkadotXcm(input);
|
|
11842
11894
|
if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot') {
|
|
11843
|
-
throw new ScenarioNotSupportedError("Transfer from ".concat(this.chain, " to ").concat(JSON.stringify(destination), " is not yet supported"));
|
|
11895
|
+
throw new ScenarioNotSupportedError("Transfer from ".concat(this.chain, " to ").concat(JSON.stringify(destination, replaceBigInt), " is not yet supported"));
|
|
11844
11896
|
}
|
|
11845
11897
|
return transferPolkadotXcm(input);
|
|
11846
11898
|
}
|
|
@@ -12076,15 +12128,6 @@ var NeuroWeb = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12076
12128
|
}]);
|
|
12077
12129
|
}(SubstrateChain);
|
|
12078
12130
|
|
|
12079
|
-
var NeuroWebPaseo = /*#__PURE__*/function (_NeuroWeb) {
|
|
12080
|
-
function NeuroWebPaseo() {
|
|
12081
|
-
_classCallCheck(this, NeuroWebPaseo);
|
|
12082
|
-
return _callSuper(this, NeuroWebPaseo, ['NeuroWebPaseo', 'NeuroWeb', 'Paseo', Version.V4]);
|
|
12083
|
-
}
|
|
12084
|
-
_inherits(NeuroWebPaseo, _NeuroWeb);
|
|
12085
|
-
return _createClass(NeuroWebPaseo);
|
|
12086
|
-
}(NeuroWeb);
|
|
12087
|
-
|
|
12088
12131
|
var Paseo = /*#__PURE__*/function (_Polkadot) {
|
|
12089
12132
|
function Paseo() {
|
|
12090
12133
|
_classCallCheck(this, Paseo);
|
|
@@ -12483,7 +12526,6 @@ var chains = function chains() {
|
|
|
12483
12526
|
BifrostKusama: new BifrostKusama(),
|
|
12484
12527
|
Curio: new Curio(),
|
|
12485
12528
|
CrustShadow: new CrustShadow(),
|
|
12486
|
-
Crab: new Crab(),
|
|
12487
12529
|
Karura: new Karura(),
|
|
12488
12530
|
PeopleKusama: new PeopleKusama(),
|
|
12489
12531
|
Shiden: new Shiden(),
|
|
@@ -12502,7 +12544,6 @@ var chains = function chains() {
|
|
|
12502
12544
|
PeoplePaseo: new PeoplePaseo(),
|
|
12503
12545
|
HeimaPaseo: new HeimaPaseo(),
|
|
12504
12546
|
HydrationPaseo: new HydrationPaseo(),
|
|
12505
|
-
NeuroWebPaseo: new NeuroWebPaseo(),
|
|
12506
12547
|
// External chains
|
|
12507
12548
|
Ethereum: new Ethereum(),
|
|
12508
12549
|
EthereumTestnet: new EthereumTestnet()
|
|
@@ -12786,7 +12827,9 @@ var sortAssets = function sortAssets(assets) {
|
|
|
12786
12827
|
if (aGeneralIndex === undefined && bGeneralIndex === undefined) return 0;
|
|
12787
12828
|
if (aGeneralIndex === undefined) return 1;
|
|
12788
12829
|
if (bGeneralIndex === undefined) return -1;
|
|
12789
|
-
|
|
12830
|
+
var aIndex = BigInt(aGeneralIndex);
|
|
12831
|
+
var bIndex = BigInt(bGeneralIndex);
|
|
12832
|
+
return aIndex < bIndex ? -1 : aIndex > bIndex ? 1 : 0;
|
|
12790
12833
|
});
|
|
12791
12834
|
};
|
|
12792
12835
|
|
|
@@ -13780,7 +13823,11 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
|
|
|
13780
13823
|
clearTimeout(timers.get(k));
|
|
13781
13824
|
timers["delete"](k);
|
|
13782
13825
|
data["delete"](k);
|
|
13783
|
-
|
|
13826
|
+
try {
|
|
13827
|
+
onEviction === null || onEviction === void 0 || onEviction(k, w.value);
|
|
13828
|
+
} catch (_unused2) {
|
|
13829
|
+
/* ignore */
|
|
13830
|
+
}
|
|
13784
13831
|
};
|
|
13785
13832
|
var evictIfNeeded = function evictIfNeeded() {
|
|
13786
13833
|
if (data.size <= maxSize) return;
|