@paraspell/sdk-core 13.7.1 → 13.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +405 -345
- package/dist/index.mjs +876 -823
- package/package.json +6 -9
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
2
|
-
import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset,
|
|
2
|
+
import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isSymbolSpecifier, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrowImpl, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, pad, toHex, getAddress, concat, keccak256, isHex, createPublicClient, http, getContract, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
|
|
6
|
-
import { isTLocation, replaceBigInt, isExternalChain, Version, isRelayChain, Parents, isSubstrateBridge, isSnowbridge,
|
|
6
|
+
import { isTLocation, replaceBigInt, isExternalChain, Version, isCustomChain, isRelayChain, Parents, isSubstrateBridge, isSnowbridge, getJunctionValue, deepEqual, hasJunction, RELAYCHAINS, PARACHAINS, isTrustedChain, ETHEREUM_BRIDGE_ORIGINS, isBridge, DEFAULT_SS58_PREFIX, CHAINS } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { getXcmPallet, getSupportedPallets, hasPalletImpl, getOtherAssetsPallets, getNativeAssetsPallet, getXcmPalletImpl, getSupportedPalletsDetails, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
@@ -1076,7 +1076,7 @@ var assertCurrencyCore = function assertCurrencyCore(value) {
|
|
|
1076
1076
|
throw new InvalidCurrencyError('A currency selector is required.');
|
|
1077
1077
|
}
|
|
1078
1078
|
if (Array.isArray(value)) {
|
|
1079
|
-
throw new InvalidCurrencyError('
|
|
1079
|
+
throw new InvalidCurrencyError('An array of currencies is not supported here. Provide a single currency selector ({ symbol }, { id }, or { location }).');
|
|
1080
1080
|
}
|
|
1081
1081
|
if (_typeof(value) === 'object' && 'location' in value && isOverrideLocationSpecifier(value.location)) {
|
|
1082
1082
|
throw new InvalidCurrencyError('Override location specifier is not supported here. Provide a regular location.');
|
|
@@ -1791,9 +1791,9 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1791
1791
|
}, {
|
|
1792
1792
|
key: "getBalance",
|
|
1793
1793
|
value: function () {
|
|
1794
|
-
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, address) {
|
|
1795
|
-
var
|
|
1796
|
-
var
|
|
1794
|
+
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, address, asset) {
|
|
1795
|
+
var _asset$existentialDep;
|
|
1796
|
+
var account, free, reserved, frozen, ed, frozenUntouchable, untouchable, spendable;
|
|
1797
1797
|
return _regenerator().w(function (_context2) {
|
|
1798
1798
|
while (1) switch (_context2.n) {
|
|
1799
1799
|
case 0:
|
|
@@ -1804,13 +1804,25 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1804
1804
|
params: [address]
|
|
1805
1805
|
});
|
|
1806
1806
|
case 1:
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1807
|
+
account = _context2.v;
|
|
1808
|
+
if (!((account === null || account === void 0 ? void 0 : account.data) === undefined)) {
|
|
1809
|
+
_context2.n = 2;
|
|
1810
|
+
break;
|
|
1811
|
+
}
|
|
1812
|
+
return _context2.a(2, 0n);
|
|
1813
|
+
case 2:
|
|
1814
|
+
free = BigInt(account.data.free);
|
|
1815
|
+
reserved = BigInt(account.data.reserved);
|
|
1816
|
+
frozen = BigInt(account.data.frozen);
|
|
1817
|
+
ed = BigInt((_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : 0);
|
|
1818
|
+
frozenUntouchable = frozen - reserved;
|
|
1819
|
+
untouchable = frozenUntouchable > ed ? frozenUntouchable : ed;
|
|
1820
|
+
spendable = free - untouchable;
|
|
1821
|
+
return _context2.a(2, spendable > 0n ? spendable : 0n);
|
|
1810
1822
|
}
|
|
1811
1823
|
}, _callee2, this);
|
|
1812
1824
|
}));
|
|
1813
|
-
function getBalance(_x6, _x7) {
|
|
1825
|
+
function getBalance(_x6, _x7, _x8) {
|
|
1814
1826
|
return _getBalance.apply(this, arguments);
|
|
1815
1827
|
}
|
|
1816
1828
|
return getBalance;
|
|
@@ -1819,7 +1831,7 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1819
1831
|
}(BaseAssetsPallet);
|
|
1820
1832
|
|
|
1821
1833
|
var resolveId = function resolveId(api, asset, chain) {
|
|
1822
|
-
if (chain === 'BifrostPolkadot' || chain === 'BifrostKusama' || chain === 'BifrostPaseo') {
|
|
1834
|
+
if (!isCustomChain(chain) && (chain === 'BifrostPolkadot' || chain === 'BifrostKusama' || chain === 'BifrostPaseo')) {
|
|
1823
1835
|
var _asset$assetId;
|
|
1824
1836
|
var isEthAsset = !asset.isNative && ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.startsWith('0x'));
|
|
1825
1837
|
var resolvedAsset = isEthAsset ? api.findAssetInfoOrThrow(chain, {
|
|
@@ -2120,7 +2132,7 @@ var createDestination = function createDestination(api, version, origin, destina
|
|
|
2120
2132
|
parents: Parents.TWO,
|
|
2121
2133
|
interior: {
|
|
2122
2134
|
X2: [{
|
|
2123
|
-
GlobalConsensus:
|
|
2135
|
+
GlobalConsensus: getRelayChainOfImpl(api, destination)
|
|
2124
2136
|
}, {
|
|
2125
2137
|
Parachain: chainId
|
|
2126
2138
|
}]
|
|
@@ -2160,14 +2172,6 @@ var AssetHubPolkadot$1 = {
|
|
|
2160
2172
|
name: "Dwellir",
|
|
2161
2173
|
endpoint: "wss://asset-hub-polkadot-rpc.n.dwellir.com"
|
|
2162
2174
|
},
|
|
2163
|
-
{
|
|
2164
|
-
name: "IBP1",
|
|
2165
|
-
endpoint: "wss://asset-hub-polkadot.ibp.network"
|
|
2166
|
-
},
|
|
2167
|
-
{
|
|
2168
|
-
name: "IBP2",
|
|
2169
|
-
endpoint: "wss://asset-hub-polkadot.dotters.network"
|
|
2170
|
-
},
|
|
2171
2175
|
{
|
|
2172
2176
|
name: "LuckyFriday",
|
|
2173
2177
|
endpoint: "wss://rpc-asset-hub-polkadot.luckyfriday.io"
|
|
@@ -2179,10 +2183,6 @@ var AssetHubPolkadot$1 = {
|
|
|
2179
2183
|
{
|
|
2180
2184
|
name: "Parity",
|
|
2181
2185
|
endpoint: "wss://polkadot-asset-hub-rpc.polkadot.io"
|
|
2182
|
-
},
|
|
2183
|
-
{
|
|
2184
|
-
name: "RadiumBlock",
|
|
2185
|
-
endpoint: "wss://statemint.public.curie.radiumblock.co/ws"
|
|
2186
2186
|
}
|
|
2187
2187
|
]
|
|
2188
2188
|
};
|
|
@@ -2236,10 +2236,6 @@ var Astar$1 = {
|
|
|
2236
2236
|
{
|
|
2237
2237
|
name: "OnFinality",
|
|
2238
2238
|
endpoint: "wss://astar.api.onfinality.io/public-ws"
|
|
2239
|
-
},
|
|
2240
|
-
{
|
|
2241
|
-
name: "RadiumBlock",
|
|
2242
|
-
endpoint: "wss://astar.public.curie.radiumblock.co/ws"
|
|
2243
2239
|
}
|
|
2244
2240
|
]
|
|
2245
2241
|
};
|
|
@@ -2267,14 +2263,6 @@ var BridgeHubPolkadot$1 = {
|
|
|
2267
2263
|
name: "Dwellir",
|
|
2268
2264
|
endpoint: "wss://bridge-hub-polkadot-rpc.n.dwellir.com"
|
|
2269
2265
|
},
|
|
2270
|
-
{
|
|
2271
|
-
name: "IBP1",
|
|
2272
|
-
endpoint: "wss://bridge-hub-polkadot.ibp.network"
|
|
2273
|
-
},
|
|
2274
|
-
{
|
|
2275
|
-
name: "IBP2",
|
|
2276
|
-
endpoint: "wss://bridge-hub-polkadot.dotters.network"
|
|
2277
|
-
},
|
|
2278
2266
|
{
|
|
2279
2267
|
name: "LuckyFriday",
|
|
2280
2268
|
endpoint: "wss://rpc-bridge-hub-polkadot.luckyfriday.io"
|
|
@@ -2287,10 +2275,6 @@ var BridgeHubPolkadot$1 = {
|
|
|
2287
2275
|
name: "Parity",
|
|
2288
2276
|
endpoint: "wss://polkadot-bridge-hub-rpc.polkadot.io"
|
|
2289
2277
|
},
|
|
2290
|
-
{
|
|
2291
|
-
name: "RadiumBlock",
|
|
2292
|
-
endpoint: "wss://bridgehub-polkadot.public.curie.radiumblock.co/ws"
|
|
2293
|
-
},
|
|
2294
2278
|
{
|
|
2295
2279
|
name: "Spectrum",
|
|
2296
2280
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/mgX--uWlEtmNKw/polkadotbridgehub/mainnet/"
|
|
@@ -2344,16 +2328,12 @@ var Hydration$1 = {
|
|
|
2344
2328
|
paraId: 2034,
|
|
2345
2329
|
providers: [
|
|
2346
2330
|
{
|
|
2347
|
-
name: "
|
|
2348
|
-
endpoint: "wss://rpc.
|
|
2349
|
-
},
|
|
2350
|
-
{
|
|
2351
|
-
name: "IBP1",
|
|
2352
|
-
endpoint: "wss://hydration.ibp.network"
|
|
2331
|
+
name: "Dwellir",
|
|
2332
|
+
endpoint: "wss://hydration-rpc.n.dwellir.com"
|
|
2353
2333
|
},
|
|
2354
2334
|
{
|
|
2355
|
-
name: "
|
|
2356
|
-
endpoint: "wss://
|
|
2335
|
+
name: "Helikon",
|
|
2336
|
+
endpoint: "wss://rpc.helikon.io/hydradx"
|
|
2357
2337
|
}
|
|
2358
2338
|
]
|
|
2359
2339
|
};
|
|
@@ -2434,14 +2414,6 @@ var CoretimePolkadot$1 = {
|
|
|
2434
2414
|
name: "Dwellir",
|
|
2435
2415
|
endpoint: "wss://coretime-polkadot-rpc.n.dwellir.com"
|
|
2436
2416
|
},
|
|
2437
|
-
{
|
|
2438
|
-
name: "IBP1",
|
|
2439
|
-
endpoint: "wss://coretime-polkadot.ibp.network"
|
|
2440
|
-
},
|
|
2441
|
-
{
|
|
2442
|
-
name: "IBP2",
|
|
2443
|
-
endpoint: "wss://coretime-polkadot.dotters.network"
|
|
2444
|
-
},
|
|
2445
2417
|
{
|
|
2446
2418
|
name: "LuckyFriday",
|
|
2447
2419
|
endpoint: "wss://rpc-coretime-polkadot.luckyfriday.io"
|
|
@@ -2453,10 +2425,6 @@ var CoretimePolkadot$1 = {
|
|
|
2453
2425
|
{
|
|
2454
2426
|
name: "Parity",
|
|
2455
2427
|
endpoint: "wss://polkadot-coretime-rpc.polkadot.io"
|
|
2456
|
-
},
|
|
2457
|
-
{
|
|
2458
|
-
name: "RadiumBlock",
|
|
2459
|
-
endpoint: "wss://coretime-polkadot.public.curie.radiumblock.co/ws"
|
|
2460
2428
|
}
|
|
2461
2429
|
]
|
|
2462
2430
|
};
|
|
@@ -2469,14 +2437,6 @@ var Collectives$1 = {
|
|
|
2469
2437
|
name: "Dwellir",
|
|
2470
2438
|
endpoint: "wss://collectives-polkadot-rpc.n.dwellir.com"
|
|
2471
2439
|
},
|
|
2472
|
-
{
|
|
2473
|
-
name: "IBP1",
|
|
2474
|
-
endpoint: "wss://collectives-polkadot.ibp.network"
|
|
2475
|
-
},
|
|
2476
|
-
{
|
|
2477
|
-
name: "IBP2",
|
|
2478
|
-
endpoint: "wss://collectives-polkadot.dotters.network"
|
|
2479
|
-
},
|
|
2480
2440
|
{
|
|
2481
2441
|
name: "LuckyFriday",
|
|
2482
2442
|
endpoint: "wss://rpc-collectives-polkadot.luckyfriday.io"
|
|
@@ -2488,10 +2448,6 @@ var Collectives$1 = {
|
|
|
2488
2448
|
{
|
|
2489
2449
|
name: "Parity",
|
|
2490
2450
|
endpoint: "wss://polkadot-collectives-rpc.polkadot.io"
|
|
2491
|
-
},
|
|
2492
|
-
{
|
|
2493
|
-
name: "RadiumBlock",
|
|
2494
|
-
endpoint: "wss://collectives.public.curie.radiumblock.co/ws"
|
|
2495
2451
|
}
|
|
2496
2452
|
]
|
|
2497
2453
|
};
|
|
@@ -2571,14 +2527,6 @@ var PeoplePolkadot$1 = {
|
|
|
2571
2527
|
name: "Dwellir",
|
|
2572
2528
|
endpoint: "wss://people-polkadot-rpc.n.dwellir.com"
|
|
2573
2529
|
},
|
|
2574
|
-
{
|
|
2575
|
-
name: "IBP1",
|
|
2576
|
-
endpoint: "wss://people-polkadot.ibp.network"
|
|
2577
|
-
},
|
|
2578
|
-
{
|
|
2579
|
-
name: "IBP2",
|
|
2580
|
-
endpoint: "wss://people-polkadot.dotters.network"
|
|
2581
|
-
},
|
|
2582
2530
|
{
|
|
2583
2531
|
name: "LuckyFriday",
|
|
2584
2532
|
endpoint: "wss://rpc-people-polkadot.luckyfriday.io"
|
|
@@ -2590,10 +2538,6 @@ var PeoplePolkadot$1 = {
|
|
|
2590
2538
|
{
|
|
2591
2539
|
name: "Parity",
|
|
2592
2540
|
endpoint: "wss://polkadot-people-rpc.polkadot.io"
|
|
2593
|
-
},
|
|
2594
|
-
{
|
|
2595
|
-
name: "RadiumBlock",
|
|
2596
|
-
endpoint: "wss://people-polkadot.public.curie.radiumblock.co/ws"
|
|
2597
2541
|
}
|
|
2598
2542
|
]
|
|
2599
2543
|
};
|
|
@@ -2636,14 +2580,6 @@ var AssetHubKusama$1 = {
|
|
|
2636
2580
|
name: "Dwellir",
|
|
2637
2581
|
endpoint: "wss://asset-hub-kusama-rpc.n.dwellir.com"
|
|
2638
2582
|
},
|
|
2639
|
-
{
|
|
2640
|
-
name: "IBP1",
|
|
2641
|
-
endpoint: "wss://asset-hub-kusama.ibp.network"
|
|
2642
|
-
},
|
|
2643
|
-
{
|
|
2644
|
-
name: "IBP2",
|
|
2645
|
-
endpoint: "wss://asset-hub-kusama.dotters.network"
|
|
2646
|
-
},
|
|
2647
2583
|
{
|
|
2648
2584
|
name: "LuckyFriday",
|
|
2649
2585
|
endpoint: "wss://rpc-asset-hub-kusama.luckyfriday.io"
|
|
@@ -2655,10 +2591,6 @@ var AssetHubKusama$1 = {
|
|
|
2655
2591
|
{
|
|
2656
2592
|
name: "Parity",
|
|
2657
2593
|
endpoint: "wss://kusama-asset-hub-rpc.polkadot.io"
|
|
2658
|
-
},
|
|
2659
|
-
{
|
|
2660
|
-
name: "RadiumBlock",
|
|
2661
|
-
endpoint: "wss://statemine.public.curie.radiumblock.co/ws"
|
|
2662
2594
|
}
|
|
2663
2595
|
]
|
|
2664
2596
|
};
|
|
@@ -2671,14 +2603,6 @@ var BridgeHubKusama$1 = {
|
|
|
2671
2603
|
name: "Dwellir",
|
|
2672
2604
|
endpoint: "wss://bridge-hub-kusama-rpc.n.dwellir.com"
|
|
2673
2605
|
},
|
|
2674
|
-
{
|
|
2675
|
-
name: "IBP1",
|
|
2676
|
-
endpoint: "wss://bridge-hub-kusama.ibp.network"
|
|
2677
|
-
},
|
|
2678
|
-
{
|
|
2679
|
-
name: "IBP2",
|
|
2680
|
-
endpoint: "wss://bridge-hub-kusama.dotters.network"
|
|
2681
|
-
},
|
|
2682
2606
|
{
|
|
2683
2607
|
name: "LuckyFriday",
|
|
2684
2608
|
endpoint: "wss://rpc-bridge-hub-kusama.luckyfriday.io"
|
|
@@ -2691,10 +2615,6 @@ var BridgeHubKusama$1 = {
|
|
|
2691
2615
|
name: "Parity",
|
|
2692
2616
|
endpoint: "wss://kusama-bridge-hub-rpc.polkadot.io"
|
|
2693
2617
|
},
|
|
2694
|
-
{
|
|
2695
|
-
name: "RadiumBlock",
|
|
2696
|
-
endpoint: "wss://bridgehub-kusama.public.curie.radiumblock.co/ws"
|
|
2697
|
-
},
|
|
2698
2618
|
{
|
|
2699
2619
|
name: "Spectrum",
|
|
2700
2620
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/balkpUVauqyv8g/kusamabridgehub/mainnet/"
|
|
@@ -2779,14 +2699,6 @@ var CoretimeKusama$1 = {
|
|
|
2779
2699
|
name: "Dwellir",
|
|
2780
2700
|
endpoint: "wss://coretime-kusama-rpc.n.dwellir.com"
|
|
2781
2701
|
},
|
|
2782
|
-
{
|
|
2783
|
-
name: "IBP1",
|
|
2784
|
-
endpoint: "wss://coretime-kusama.ibp.network"
|
|
2785
|
-
},
|
|
2786
|
-
{
|
|
2787
|
-
name: "IBP2",
|
|
2788
|
-
endpoint: "wss://coretime-kusama.dotters.network"
|
|
2789
|
-
},
|
|
2790
2702
|
{
|
|
2791
2703
|
name: "LuckyFriday",
|
|
2792
2704
|
endpoint: "wss://rpc-coretime-kusama.luckyfriday.io"
|
|
@@ -2814,14 +2726,6 @@ var Encointer$1 = {
|
|
|
2814
2726
|
name: "Encointer Association",
|
|
2815
2727
|
endpoint: "wss://kusama.api.encointer.org"
|
|
2816
2728
|
},
|
|
2817
|
-
{
|
|
2818
|
-
name: "IBP1",
|
|
2819
|
-
endpoint: "wss://encointer-kusama.ibp.network"
|
|
2820
|
-
},
|
|
2821
|
-
{
|
|
2822
|
-
name: "IBP2",
|
|
2823
|
-
endpoint: "wss://encointer-kusama.dotters.network"
|
|
2824
|
-
},
|
|
2825
2729
|
{
|
|
2826
2730
|
name: "LuckyFriday",
|
|
2827
2731
|
endpoint: "wss://rpc-encointer-kusama.luckyfriday.io"
|
|
@@ -2927,14 +2831,6 @@ var PeopleKusama$1 = {
|
|
|
2927
2831
|
name: "Helixstreet",
|
|
2928
2832
|
endpoint: "wss://rpc-people-kusama.helixstreet.io"
|
|
2929
2833
|
},
|
|
2930
|
-
{
|
|
2931
|
-
name: "IBP1",
|
|
2932
|
-
endpoint: "wss://people-kusama.ibp.network"
|
|
2933
|
-
},
|
|
2934
|
-
{
|
|
2935
|
-
name: "IBP2",
|
|
2936
|
-
endpoint: "wss://people-kusama.dotters.network"
|
|
2937
|
-
},
|
|
2938
2834
|
{
|
|
2939
2835
|
name: "LuckyFriday",
|
|
2940
2836
|
endpoint: "wss://rpc-people-kusama.luckyfriday.io"
|
|
@@ -2946,10 +2842,6 @@ var PeopleKusama$1 = {
|
|
|
2946
2842
|
{
|
|
2947
2843
|
name: "Parity",
|
|
2948
2844
|
endpoint: "wss://kusama-people-rpc.polkadot.io"
|
|
2949
|
-
},
|
|
2950
|
-
{
|
|
2951
|
-
name: "RadiumBlock",
|
|
2952
|
-
endpoint: "wss://people-kusama.public.curie.radiumblock.co/ws"
|
|
2953
2845
|
}
|
|
2954
2846
|
]
|
|
2955
2847
|
};
|
|
@@ -2969,10 +2861,6 @@ var Shiden$1 = {
|
|
|
2969
2861
|
{
|
|
2970
2862
|
name: "OnFinality",
|
|
2971
2863
|
endpoint: "wss://shiden.api.onfinality.io/public-ws"
|
|
2972
|
-
},
|
|
2973
|
-
{
|
|
2974
|
-
name: "RadiumBlock",
|
|
2975
|
-
endpoint: "wss://shiden.public.curie.radiumblock.co/ws"
|
|
2976
2864
|
}
|
|
2977
2865
|
]
|
|
2978
2866
|
};
|
|
@@ -3093,17 +2981,13 @@ var AssetHubPaseo$1 = {
|
|
|
3093
2981
|
name: "Dwellir",
|
|
3094
2982
|
endpoint: "wss://asset-hub-paseo-rpc.n.dwellir.com"
|
|
3095
2983
|
},
|
|
3096
|
-
{
|
|
3097
|
-
name: "IBP1",
|
|
3098
|
-
endpoint: "wss://asset-hub-paseo.ibp.network"
|
|
3099
|
-
},
|
|
3100
|
-
{
|
|
3101
|
-
name: "IBP2",
|
|
3102
|
-
endpoint: "wss://asset-hub-paseo.dotters.network"
|
|
3103
|
-
},
|
|
3104
2984
|
{
|
|
3105
2985
|
name: "TurboFlakes",
|
|
3106
2986
|
endpoint: "wss://sys.turboflakes.io/asset-hub-paseo"
|
|
2987
|
+
},
|
|
2988
|
+
{
|
|
2989
|
+
name: "Zondax",
|
|
2990
|
+
endpoint: "wss://api2.zondax.ch/pas/assethub/node/rpc"
|
|
3107
2991
|
}
|
|
3108
2992
|
]
|
|
3109
2993
|
};
|
|
@@ -3128,12 +3012,8 @@ var BridgeHubPaseo$1 = {
|
|
|
3128
3012
|
paraId: 1002,
|
|
3129
3013
|
providers: [
|
|
3130
3014
|
{
|
|
3131
|
-
name: "
|
|
3132
|
-
endpoint: "wss://
|
|
3133
|
-
},
|
|
3134
|
-
{
|
|
3135
|
-
name: "IBP2",
|
|
3136
|
-
endpoint: "wss://bridge-hub-paseo.dotters.network"
|
|
3015
|
+
name: "Zondax",
|
|
3016
|
+
endpoint: "wss://api2.zondax.ch/pas/bridgehub/node/rpc"
|
|
3137
3017
|
}
|
|
3138
3018
|
]
|
|
3139
3019
|
};
|
|
@@ -3143,12 +3023,8 @@ var CoretimePaseo$1 = {
|
|
|
3143
3023
|
paraId: 1005,
|
|
3144
3024
|
providers: [
|
|
3145
3025
|
{
|
|
3146
|
-
name: "
|
|
3147
|
-
endpoint: "wss://
|
|
3148
|
-
},
|
|
3149
|
-
{
|
|
3150
|
-
name: "IBP2",
|
|
3151
|
-
endpoint: "wss://coretime-paseo.dotters.network"
|
|
3026
|
+
name: "Zondax",
|
|
3027
|
+
endpoint: "wss://api2.zondax.ch/pas/coretime/node/rpc"
|
|
3152
3028
|
}
|
|
3153
3029
|
]
|
|
3154
3030
|
};
|
|
@@ -3206,12 +3082,8 @@ var PeoplePaseo$1 = {
|
|
|
3206
3082
|
endpoint: "wss://people-paseo.rpc.amforc.com"
|
|
3207
3083
|
},
|
|
3208
3084
|
{
|
|
3209
|
-
name: "
|
|
3210
|
-
endpoint: "wss://
|
|
3211
|
-
},
|
|
3212
|
-
{
|
|
3213
|
-
name: "IBP2",
|
|
3214
|
-
endpoint: "wss://people-paseo.dotters.network"
|
|
3085
|
+
name: "Zondax",
|
|
3086
|
+
endpoint: "wss://api2.zondax.ch/pas/people/node/rpc"
|
|
3215
3087
|
}
|
|
3216
3088
|
]
|
|
3217
3089
|
};
|
|
@@ -3243,14 +3115,6 @@ var Polkadot$1 = {
|
|
|
3243
3115
|
name: "Helixstreet",
|
|
3244
3116
|
endpoint: "wss://rpc-polkadot.helixstreet.io"
|
|
3245
3117
|
},
|
|
3246
|
-
{
|
|
3247
|
-
name: "IBP1",
|
|
3248
|
-
endpoint: "wss://polkadot.ibp.network"
|
|
3249
|
-
},
|
|
3250
|
-
{
|
|
3251
|
-
name: "IBP2",
|
|
3252
|
-
endpoint: "wss://polkadot.dotters.network"
|
|
3253
|
-
},
|
|
3254
3118
|
{
|
|
3255
3119
|
name: "LuckyFriday",
|
|
3256
3120
|
endpoint: "wss://rpc-polkadot.luckyfriday.io"
|
|
@@ -3259,10 +3123,6 @@ var Polkadot$1 = {
|
|
|
3259
3123
|
name: "OnFinality",
|
|
3260
3124
|
endpoint: "wss://polkadot.api.onfinality.io/public-ws"
|
|
3261
3125
|
},
|
|
3262
|
-
{
|
|
3263
|
-
name: "RadiumBlock",
|
|
3264
|
-
endpoint: "wss://polkadot.public.curie.radiumblock.co/ws"
|
|
3265
|
-
},
|
|
3266
3126
|
{
|
|
3267
3127
|
name: "Spectrum",
|
|
3268
3128
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/LjwBJpV3dIKyWQ/polkadot/mainnet/"
|
|
@@ -3294,14 +3154,6 @@ var Kusama$1 = {
|
|
|
3294
3154
|
name: "Helixstreet",
|
|
3295
3155
|
endpoint: "wss://rpc-kusama.helixstreet.io"
|
|
3296
3156
|
},
|
|
3297
|
-
{
|
|
3298
|
-
name: "IBP1",
|
|
3299
|
-
endpoint: "wss://kusama.ibp.network"
|
|
3300
|
-
},
|
|
3301
|
-
{
|
|
3302
|
-
name: "IBP2",
|
|
3303
|
-
endpoint: "wss://kusama.dotters.network"
|
|
3304
|
-
},
|
|
3305
3157
|
{
|
|
3306
3158
|
name: "LuckyFriday",
|
|
3307
3159
|
endpoint: "wss://rpc-kusama.luckyfriday.io"
|
|
@@ -3310,10 +3162,6 @@ var Kusama$1 = {
|
|
|
3310
3162
|
name: "OnFinality",
|
|
3311
3163
|
endpoint: "wss://kusama.api.onfinality.io/public-ws"
|
|
3312
3164
|
},
|
|
3313
|
-
{
|
|
3314
|
-
name: "RadiumBlock",
|
|
3315
|
-
endpoint: "wss://kusama.public.curie.radiumblock.co/ws"
|
|
3316
|
-
},
|
|
3317
3165
|
{
|
|
3318
3166
|
name: "Spectrum",
|
|
3319
3167
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/QXq7QZ6Q60NDzA/kusama/mainnet/"
|
|
@@ -3340,10 +3188,6 @@ var Westend$1 = {
|
|
|
3340
3188
|
{
|
|
3341
3189
|
name: "Parity",
|
|
3342
3190
|
endpoint: "wss://westend-rpc.polkadot.io"
|
|
3343
|
-
},
|
|
3344
|
-
{
|
|
3345
|
-
name: "RadiumBlock",
|
|
3346
|
-
endpoint: "wss://rpc.public.curie.radiumblock.xyz/ws-westend"
|
|
3347
3191
|
}
|
|
3348
3192
|
]
|
|
3349
3193
|
};
|
|
@@ -3361,12 +3205,8 @@ var Paseo$1 = {
|
|
|
3361
3205
|
endpoint: "wss://paseo-rpc.n.dwellir.com"
|
|
3362
3206
|
},
|
|
3363
3207
|
{
|
|
3364
|
-
name: "
|
|
3365
|
-
endpoint: "wss://
|
|
3366
|
-
},
|
|
3367
|
-
{
|
|
3368
|
-
name: "IBP2",
|
|
3369
|
-
endpoint: "wss://paseo.dotters.network"
|
|
3208
|
+
name: "Zondax",
|
|
3209
|
+
endpoint: "wss://api2.zondax.ch/pas/relay/node/rpc"
|
|
3370
3210
|
}
|
|
3371
3211
|
]
|
|
3372
3212
|
};
|
|
@@ -3485,13 +3325,13 @@ var getParaId = function getParaId(chain) {
|
|
|
3485
3325
|
return getParaIdImpl(chain);
|
|
3486
3326
|
};
|
|
3487
3327
|
|
|
3488
|
-
var getChainLocation = function getChainLocation(chain, destChain) {
|
|
3328
|
+
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
3489
3329
|
var fromRelay = isRelayChain(chain);
|
|
3490
3330
|
var toRelay = isRelayChain(destChain);
|
|
3491
3331
|
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
3492
3332
|
var interior = toRelay ? 'Here' : {
|
|
3493
3333
|
X1: [{
|
|
3494
|
-
Parachain:
|
|
3334
|
+
Parachain: getParaIdImpl(destChain, customCtx)
|
|
3495
3335
|
}]
|
|
3496
3336
|
};
|
|
3497
3337
|
return {
|
|
@@ -3668,7 +3508,6 @@ var Chain = /*#__PURE__*/function () {
|
|
|
3668
3508
|
get: function get() {
|
|
3669
3509
|
return this._ecosystem;
|
|
3670
3510
|
}
|
|
3671
|
-
// TODO: Fix this type cast in a subsequent refactor
|
|
3672
3511
|
}, {
|
|
3673
3512
|
key: "chain",
|
|
3674
3513
|
get: function get() {
|
|
@@ -4185,17 +4024,159 @@ var resolveAsset = function resolveAsset(currency, origin, destination, assetChe
|
|
|
4185
4024
|
return api.findAssetInfo(origin, currency, dest);
|
|
4186
4025
|
};
|
|
4187
4026
|
|
|
4027
|
+
var assertNotRawAssets = function assertNotRawAssets(currency) {
|
|
4028
|
+
if (Array.isArray(currency) && currency.length > 0 && currency.every(function (asset) {
|
|
4029
|
+
return isTAsset(asset);
|
|
4030
|
+
})) {
|
|
4031
|
+
throw new InvalidCurrencyError('Raw asset overrides are no longer supported. Please use custom assets instead.');
|
|
4032
|
+
}
|
|
4033
|
+
};
|
|
4034
|
+
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
4035
|
+
if (Array.isArray(currency)) {
|
|
4036
|
+
if (currency.length === 0) {
|
|
4037
|
+
throw new InvalidCurrencyError('Overridden assets cannot be empty');
|
|
4038
|
+
}
|
|
4039
|
+
if (currency.length === 1) {
|
|
4040
|
+
throw new InvalidCurrencyError('Please provide more than one asset');
|
|
4041
|
+
}
|
|
4042
|
+
assertNotRawAssets(currency);
|
|
4043
|
+
if (!feeAsset) {
|
|
4044
|
+
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
};
|
|
4048
|
+
var validateDestination = function validateDestination(origin, destination, api) {
|
|
4049
|
+
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
4050
|
+
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4051
|
+
}
|
|
4052
|
+
if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
|
|
4053
|
+
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
|
|
4054
|
+
}
|
|
4055
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
4056
|
+
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
4057
|
+
if (!isLocationDestination) {
|
|
4058
|
+
var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
|
|
4059
|
+
var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
|
|
4060
|
+
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
4061
|
+
throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
|
|
4065
|
+
var chain = getChain(destination);
|
|
4066
|
+
if (!chain.isRelayToParaEnabled()) {
|
|
4067
|
+
throw new ScenarioNotSupportedError({
|
|
4068
|
+
chain: destination,
|
|
4069
|
+
scenario: 'RelayToPara'
|
|
4070
|
+
});
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
};
|
|
4074
|
+
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
4075
|
+
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
4076
|
+
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
4077
|
+
}
|
|
4078
|
+
if (!assetCheckEnabled && 'id' in currency) {
|
|
4079
|
+
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4080
|
+
}
|
|
4081
|
+
};
|
|
4082
|
+
var validateTransact = function validateTransact(_ref) {
|
|
4083
|
+
var api = _ref.api,
|
|
4084
|
+
from = _ref.from,
|
|
4085
|
+
to = _ref.to,
|
|
4086
|
+
sender = _ref.sender,
|
|
4087
|
+
address = _ref.recipient,
|
|
4088
|
+
currency = _ref.currency,
|
|
4089
|
+
transactOptions = _ref.transactOptions;
|
|
4090
|
+
var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
|
|
4091
|
+
if (!call) return;
|
|
4092
|
+
if (from === to) {
|
|
4093
|
+
throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
|
|
4094
|
+
}
|
|
4095
|
+
if (Array.isArray(currency)) {
|
|
4096
|
+
throw new UnsupportedOperationError('Cannot use transact options with multiple currencies.');
|
|
4097
|
+
}
|
|
4098
|
+
if (typeof call === 'string' && !isHex(call)) {
|
|
4099
|
+
throw new ValidationError('Transact call hex must be a valid hex string.');
|
|
4100
|
+
}
|
|
4101
|
+
if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
|
|
4102
|
+
throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
|
|
4103
|
+
}
|
|
4104
|
+
if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
|
|
4105
|
+
return new ValidationError('Sender address must match the destination address for transact to work.');
|
|
4106
|
+
}
|
|
4107
|
+
};
|
|
4108
|
+
|
|
4109
|
+
var resolveCurrency = function resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, onAsset) {
|
|
4110
|
+
var dest = !isTLocation(destination) ? destination : null;
|
|
4111
|
+
if (Array.isArray(currency)) {
|
|
4112
|
+
var _resolvedFeeAsset$amo;
|
|
4113
|
+
if (!resolvedFeeAsset) {
|
|
4114
|
+
throw new InvalidCurrencyError('Fee asset is required when providing more than one asset');
|
|
4115
|
+
}
|
|
4116
|
+
assertNotRawAssets(currency);
|
|
4117
|
+
var assets = currency.map(function (item) {
|
|
4118
|
+
if (item.amount === AMOUNT_ALL) {
|
|
4119
|
+
throw new InvalidCurrencyError('Provided assets cannot use amount all. Please specify amount.');
|
|
4120
|
+
}
|
|
4121
|
+
var asset = api.findAssetInfo(origin, item, dest);
|
|
4122
|
+
if (!asset) {
|
|
4123
|
+
throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(item, replaceBigInt)));
|
|
4124
|
+
}
|
|
4125
|
+
onAsset === null || onAsset === void 0 || onAsset(asset);
|
|
4126
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4127
|
+
amount: abstractDecimals(item.amount, asset.decimals, api),
|
|
4128
|
+
isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
|
|
4129
|
+
});
|
|
4130
|
+
});
|
|
4131
|
+
var feeAssetCount = assets.filter(function (asset) {
|
|
4132
|
+
return asset.isFeeAsset;
|
|
4133
|
+
}).length;
|
|
4134
|
+
if (feeAssetCount > 1) {
|
|
4135
|
+
throw new InvalidCurrencyError("Fee asset matches more than one of the provided assets");
|
|
4136
|
+
}
|
|
4137
|
+
if (feeAssetCount === 0) {
|
|
4138
|
+
throw new InvalidCurrencyError("Fee asset must be one of the provided assets");
|
|
4139
|
+
}
|
|
4140
|
+
return {
|
|
4141
|
+
assets: assets,
|
|
4142
|
+
asset: _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
|
|
4143
|
+
amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
|
|
4144
|
+
})
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4147
|
+
var asset = api.findAssetInfoOrThrow(origin, currency, dest);
|
|
4148
|
+
var resolved = _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4149
|
+
amount: abstractDecimals(currency.amount, asset.decimals, api)
|
|
4150
|
+
});
|
|
4151
|
+
return {
|
|
4152
|
+
assets: [resolved],
|
|
4153
|
+
asset: resolved
|
|
4154
|
+
};
|
|
4155
|
+
};
|
|
4156
|
+
|
|
4188
4157
|
var resolveFeeAsset = function resolveFeeAsset(api, feeAsset, origin, destination, currency) {
|
|
4189
|
-
if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
4158
|
+
if (!Array.isArray(currency) && !origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
4190
4159
|
throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
|
|
4191
4160
|
}
|
|
4161
|
+
assertNotRawAssets(currency);
|
|
4192
4162
|
var dest = !isTLocation(destination) ? destination : null;
|
|
4193
4163
|
var asset = api.findAssetInfo(origin, feeAsset, dest);
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
throwUnsupportedCurrency(feeAsset, origin);
|
|
4164
|
+
if (!asset) {
|
|
4165
|
+
return throwUnsupportedCurrency(feeAsset, origin);
|
|
4197
4166
|
}
|
|
4198
|
-
|
|
4167
|
+
if (!Array.isArray(currency)) {
|
|
4168
|
+
return asset;
|
|
4169
|
+
}
|
|
4170
|
+
var feeElement = currency.find(function (item) {
|
|
4171
|
+
var resolved = api.findAssetInfo(origin, item, dest);
|
|
4172
|
+
return resolved !== null && isAssetEqual(resolved, asset);
|
|
4173
|
+
});
|
|
4174
|
+
if (!feeElement) {
|
|
4175
|
+
throw new InvalidCurrencyError('Fee asset must be one of the provided assets');
|
|
4176
|
+
}
|
|
4177
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4178
|
+
amount: abstractDecimals(feeElement.amount, asset.decimals, api)
|
|
4179
|
+
});
|
|
4199
4180
|
};
|
|
4200
4181
|
|
|
4201
4182
|
var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
@@ -4207,9 +4188,10 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
|
4207
4188
|
destination = _ref.destination,
|
|
4208
4189
|
swapConfig = _ref.swapConfig,
|
|
4209
4190
|
asset = _ref.asset,
|
|
4191
|
+
currentAsset = _ref.currentAsset,
|
|
4210
4192
|
hasPassedExchange = _ref.hasPassedExchange,
|
|
4211
4193
|
currency = _ref.currency;
|
|
4212
|
-
var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
|
|
4194
|
+
var isRelayAssetIncluded = !Array.isArray(currency) && api.getTypeThenAssetCount(tx) === 2;
|
|
4213
4195
|
var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
|
|
4214
4196
|
if (useRelayAssetAsFee) {
|
|
4215
4197
|
return api.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
@@ -4217,7 +4199,7 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
|
4217
4199
|
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
4218
4200
|
return api.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
4219
4201
|
}
|
|
4220
|
-
return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD :
|
|
4202
|
+
return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : currentAsset;
|
|
4221
4203
|
};
|
|
4222
4204
|
|
|
4223
4205
|
var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge, api) {
|
|
@@ -4293,60 +4275,22 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
4293
4275
|
}
|
|
4294
4276
|
if (Array.isArray(currency)) {
|
|
4295
4277
|
if (!feeAsset) {
|
|
4296
|
-
throw new InvalidCurrencyError('Overridden
|
|
4278
|
+
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4297
4279
|
}
|
|
4298
4280
|
if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
|
|
4299
4281
|
throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
4300
4282
|
}
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
4309
|
-
}
|
|
4310
|
-
return currency.map(function (asset) {
|
|
4311
|
-
var ml = extractAssetLocation(asset);
|
|
4312
|
-
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4313
|
-
fun: {
|
|
4314
|
-
Fungible: BigInt(asset.fun.Fungible)
|
|
4315
|
-
},
|
|
4316
|
-
isFeeAsset: deepEqual(ml, feeAsset.location)
|
|
4317
|
-
});
|
|
4318
|
-
});
|
|
4319
|
-
}
|
|
4320
|
-
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
4321
|
-
var assets = currency.map(function (currency) {
|
|
4322
|
-
if (currency.amount === AMOUNT_ALL) {
|
|
4323
|
-
throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
4324
|
-
}
|
|
4325
|
-
var asset = api.findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
|
|
4326
|
-
if (!asset) {
|
|
4327
|
-
throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
4328
|
-
}
|
|
4329
|
-
if (!resolvedFeeAsset) {
|
|
4330
|
-
throw new InvalidCurrencyError('Fee asset not found');
|
|
4331
|
-
}
|
|
4332
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
4333
|
-
var version = getChainVersion(api, origin);
|
|
4334
|
-
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
4283
|
+
assertNotRawAssets(currency);
|
|
4284
|
+
var version = getChainVersion(api, origin);
|
|
4285
|
+
var _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, function (asset) {
|
|
4286
|
+
return validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
4287
|
+
}),
|
|
4288
|
+
assets = _resolveCurrency.assets;
|
|
4289
|
+
return sortAssets(assets.map(function (asset) {
|
|
4335
4290
|
return _objectSpread2({
|
|
4336
|
-
isFeeAsset:
|
|
4337
|
-
}, createAsset(version,
|
|
4338
|
-
});
|
|
4339
|
-
if (assets.filter(function (asset) {
|
|
4340
|
-
return asset.isFeeAsset;
|
|
4341
|
-
}).length > 1) {
|
|
4342
|
-
throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
4343
|
-
}
|
|
4344
|
-
if (assets.filter(function (asset) {
|
|
4345
|
-
return asset.isFeeAsset;
|
|
4346
|
-
}).length === 0) {
|
|
4347
|
-
throw new InvalidCurrencyError("Fee asset not found in multiassets");
|
|
4348
|
-
}
|
|
4349
|
-
return assets;
|
|
4291
|
+
isFeeAsset: asset.isFeeAsset
|
|
4292
|
+
}, createAsset(version, asset.amount, asset.location));
|
|
4293
|
+
}));
|
|
4350
4294
|
}
|
|
4351
4295
|
return undefined;
|
|
4352
4296
|
};
|
|
@@ -4358,79 +4302,8 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
|
|
|
4358
4302
|
return !(isMultipleAssets || hasOverriddenLocation);
|
|
4359
4303
|
};
|
|
4360
4304
|
|
|
4361
|
-
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
4362
|
-
if (Array.isArray(currency)) {
|
|
4363
|
-
if (currency.length === 0) {
|
|
4364
|
-
throw new InvalidCurrencyError('Overridden assets cannot be empty');
|
|
4365
|
-
}
|
|
4366
|
-
if (currency.length === 1) {
|
|
4367
|
-
throw new InvalidCurrencyError('Please provide more than one asset');
|
|
4368
|
-
}
|
|
4369
|
-
if (currency.length > 1 && !currency.every(function (asset) {
|
|
4370
|
-
return isTAsset(asset);
|
|
4371
|
-
}) && !feeAsset) {
|
|
4372
|
-
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4373
|
-
}
|
|
4374
|
-
}
|
|
4375
|
-
};
|
|
4376
|
-
var validateDestination = function validateDestination(origin, destination, api) {
|
|
4377
|
-
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
4378
|
-
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4379
|
-
}
|
|
4380
|
-
if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
|
|
4381
|
-
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
|
|
4382
|
-
}
|
|
4383
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
4384
|
-
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
4385
|
-
if (!isLocationDestination) {
|
|
4386
|
-
var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
|
|
4387
|
-
var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
|
|
4388
|
-
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
4389
|
-
throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
|
|
4393
|
-
var chain = getChain(destination);
|
|
4394
|
-
if (!chain.isRelayToParaEnabled()) {
|
|
4395
|
-
throw new ScenarioNotSupportedError({
|
|
4396
|
-
chain: destination,
|
|
4397
|
-
scenario: 'RelayToPara'
|
|
4398
|
-
});
|
|
4399
|
-
}
|
|
4400
|
-
}
|
|
4401
|
-
};
|
|
4402
|
-
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
4403
|
-
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
4404
|
-
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
4405
|
-
}
|
|
4406
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
4407
|
-
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4408
|
-
}
|
|
4409
|
-
};
|
|
4410
|
-
var validateTransact = function validateTransact(_ref) {
|
|
4411
|
-
var api = _ref.api,
|
|
4412
|
-
from = _ref.from,
|
|
4413
|
-
to = _ref.to,
|
|
4414
|
-
sender = _ref.sender,
|
|
4415
|
-
address = _ref.recipient,
|
|
4416
|
-
transactOptions = _ref.transactOptions;
|
|
4417
|
-
var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
|
|
4418
|
-
if (!call) return;
|
|
4419
|
-
if (from === to) {
|
|
4420
|
-
throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
|
|
4421
|
-
}
|
|
4422
|
-
if (typeof call === 'string' && !isHex(call)) {
|
|
4423
|
-
throw new ValidationError('Transact call hex must be a valid hex string.');
|
|
4424
|
-
}
|
|
4425
|
-
if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
|
|
4426
|
-
throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
|
|
4427
|
-
}
|
|
4428
|
-
if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
|
|
4429
|
-
return new ValidationError('Sender address must match the destination address for transact to work.');
|
|
4430
|
-
}
|
|
4431
|
-
};
|
|
4432
|
-
|
|
4433
4305
|
var resolveTransferParams = function resolveTransferParams(options) {
|
|
4306
|
+
var _resolvedFeeAsset$amo;
|
|
4434
4307
|
var api = options.api,
|
|
4435
4308
|
origin = options.from,
|
|
4436
4309
|
currency = options.currency,
|
|
@@ -4458,18 +4331,8 @@ var resolveTransferParams = function resolveTransferParams(options) {
|
|
|
4458
4331
|
var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
4459
4332
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
4460
4333
|
};
|
|
4461
|
-
var finalAsset = Array.isArray(currency) ?
|
|
4462
|
-
|
|
4463
|
-
// since these values won't be used but need to pass checks
|
|
4464
|
-
_objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
4465
|
-
amount: 0n,
|
|
4466
|
-
assetId: '1',
|
|
4467
|
-
location: {
|
|
4468
|
-
parents: Parents.ZERO,
|
|
4469
|
-
interior: {
|
|
4470
|
-
Here: null
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4334
|
+
var finalAsset = Array.isArray(currency) && resolvedFeeAsset ? _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
|
|
4335
|
+
amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
|
|
4473
4336
|
}) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
4474
4337
|
amount: finalAmount
|
|
4475
4338
|
});
|
|
@@ -5805,16 +5668,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5805
5668
|
return _getOriginXcmFee2.apply(this, arguments);
|
|
5806
5669
|
}
|
|
5807
5670
|
return getOriginXcmFee$1;
|
|
5808
|
-
}()
|
|
5809
|
-
/**
|
|
5810
|
-
* Returns the max transferable amount for the transfer
|
|
5811
|
-
*
|
|
5812
|
-
* @returns The max transferable amount.
|
|
5813
|
-
*/
|
|
5814
|
-
)
|
|
5671
|
+
}())
|
|
5815
5672
|
}, {
|
|
5816
5673
|
key: "getTransferableAmount",
|
|
5817
|
-
value:
|
|
5674
|
+
value: function () {
|
|
5818
5675
|
var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
5819
5676
|
var senderSource, _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
|
|
5820
5677
|
return _regenerator().w(function (_context11) {
|
|
@@ -5859,15 +5716,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5859
5716
|
}
|
|
5860
5717
|
return getTransferableAmount$1;
|
|
5861
5718
|
}()
|
|
5862
|
-
/**
|
|
5863
|
-
* Returns the min transferable amount for the transfer
|
|
5864
|
-
*
|
|
5865
|
-
* @returns The min transferable amount.
|
|
5866
|
-
*/
|
|
5867
|
-
)
|
|
5868
5719
|
}, {
|
|
5869
5720
|
key: "getMinTransferableAmount",
|
|
5870
|
-
value:
|
|
5721
|
+
value: function () {
|
|
5871
5722
|
var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
5872
5723
|
var senderSource, _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
|
|
5873
5724
|
return _regenerator().w(function (_context12) {
|
|
@@ -5920,7 +5771,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5920
5771
|
*
|
|
5921
5772
|
* @returns The max transferable amount.
|
|
5922
5773
|
*/
|
|
5923
|
-
)
|
|
5924
5774
|
}, {
|
|
5925
5775
|
key: "verifyEdOnDestination",
|
|
5926
5776
|
value: (function () {
|
|
@@ -5959,16 +5809,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5959
5809
|
return _verifyEdOnDestination2.apply(this, arguments);
|
|
5960
5810
|
}
|
|
5961
5811
|
return verifyEdOnDestination$1;
|
|
5962
|
-
}()
|
|
5963
|
-
/**
|
|
5964
|
-
* Returns the transfer info for the transfer
|
|
5965
|
-
*
|
|
5966
|
-
* @returns The transfer info.
|
|
5967
|
-
*/
|
|
5968
|
-
)
|
|
5812
|
+
}())
|
|
5969
5813
|
}, {
|
|
5970
5814
|
key: "getTransferInfo",
|
|
5971
|
-
value:
|
|
5815
|
+
value: function () {
|
|
5972
5816
|
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
5973
5817
|
var senderSource, _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
|
|
5974
5818
|
return _regenerator().w(function (_context14) {
|
|
@@ -6017,18 +5861,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6017
5861
|
}
|
|
6018
5862
|
return getTransferInfo$1;
|
|
6019
5863
|
}()
|
|
6020
|
-
/**
|
|
6021
|
-
* Returns the receivable amount on the destination after the transfer
|
|
6022
|
-
*
|
|
6023
|
-
* @returns The computed receivable amount.
|
|
6024
|
-
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
6025
|
-
*/
|
|
6026
|
-
)
|
|
6027
5864
|
}, {
|
|
6028
5865
|
key: "getReceivableAmount",
|
|
6029
|
-
value:
|
|
5866
|
+
value: function () {
|
|
6030
5867
|
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
6031
|
-
var _yield$this$getTransf,
|
|
5868
|
+
var _yield$this$getTransf, receivedCurrency, getAmountOrThrow;
|
|
6032
5869
|
return _regenerator().w(function (_context15) {
|
|
6033
5870
|
while (1) switch (_context15.n) {
|
|
6034
5871
|
case 0:
|
|
@@ -6036,14 +5873,15 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6036
5873
|
return this.getTransferInfo();
|
|
6037
5874
|
case 1:
|
|
6038
5875
|
_yield$this$getTransf = _context15.v;
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
5876
|
+
receivedCurrency = _yield$this$getTransf.destination.receivedCurrency;
|
|
5877
|
+
getAmountOrThrow = function getAmountOrThrow(_ref) {
|
|
5878
|
+
var receivedAmount = _ref.receivedAmount;
|
|
5879
|
+
if (receivedAmount instanceof UnableToComputeError) {
|
|
5880
|
+
throw receivedAmount;
|
|
5881
|
+
}
|
|
5882
|
+
return receivedAmount;
|
|
5883
|
+
};
|
|
5884
|
+
return _context15.a(2, Array.isArray(receivedCurrency) ? receivedCurrency.map(getAmountOrThrow) : getAmountOrThrow(receivedCurrency));
|
|
6047
5885
|
}
|
|
6048
5886
|
}, _callee15, this);
|
|
6049
5887
|
}));
|
|
@@ -6051,7 +5889,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6051
5889
|
return _getReceivableAmount.apply(this, arguments);
|
|
6052
5890
|
}
|
|
6053
5891
|
return getReceivableAmount;
|
|
6054
|
-
}()
|
|
5892
|
+
}()
|
|
6055
5893
|
}, {
|
|
6056
5894
|
key: "getBestAmountOut",
|
|
6057
5895
|
value: function () {
|
|
@@ -6483,7 +6321,7 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
|
|
|
6483
6321
|
}();
|
|
6484
6322
|
|
|
6485
6323
|
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
6486
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative,
|
|
6324
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, asset, feeAsset) {
|
|
6487
6325
|
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
6488
6326
|
return _regenerator().w(function (_context) {
|
|
6489
6327
|
while (1) switch (_context.n) {
|
|
@@ -6509,7 +6347,7 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6509
6347
|
_context.n = 3;
|
|
6510
6348
|
break;
|
|
6511
6349
|
}
|
|
6512
|
-
return _context.a(2, balanceNative - edNative - feeNative -
|
|
6350
|
+
return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
|
|
6513
6351
|
case 3:
|
|
6514
6352
|
if (isNativeAssetToOrigin) {
|
|
6515
6353
|
_context.n = 5;
|
|
@@ -6529,18 +6367,18 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6529
6367
|
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
6530
6368
|
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
6531
6369
|
case 5:
|
|
6532
|
-
return _context.a(2, balanceNative - edNative - feeNative -
|
|
6370
|
+
return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
|
|
6533
6371
|
case 6:
|
|
6534
6372
|
return _context.a(2);
|
|
6535
6373
|
}
|
|
6536
6374
|
}, _callee);
|
|
6537
6375
|
}));
|
|
6538
|
-
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7
|
|
6376
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
|
6539
6377
|
return _ref.apply(this, arguments);
|
|
6540
6378
|
};
|
|
6541
6379
|
}();
|
|
6542
6380
|
var isSufficientDestination = /*#__PURE__*/function () {
|
|
6543
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address,
|
|
6381
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, asset, feeNative) {
|
|
6544
6382
|
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
6545
6383
|
return _regenerator().w(function (_context2) {
|
|
6546
6384
|
while (1) switch (_context2.n) {
|
|
@@ -6561,35 +6399,35 @@ var isSufficientDestination = /*#__PURE__*/function () {
|
|
|
6561
6399
|
});
|
|
6562
6400
|
case 2:
|
|
6563
6401
|
nativeBalance = _context2.v;
|
|
6564
|
-
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
6402
|
+
return _context2.a(2, nativeBalance + asset.amount - existentialDeposit - feeNative > 0n);
|
|
6565
6403
|
}
|
|
6566
6404
|
}, _callee2);
|
|
6567
6405
|
}));
|
|
6568
|
-
return function isSufficientDestination(_x9, _x0, _x1, _x10
|
|
6406
|
+
return function isSufficientDestination(_x8, _x9, _x0, _x1, _x10) {
|
|
6569
6407
|
return _ref2.apply(this, arguments);
|
|
6570
6408
|
};
|
|
6571
6409
|
}();
|
|
6572
6410
|
|
|
6573
|
-
var createOriginLocation = function createOriginLocation(origin, destination, version) {
|
|
6411
|
+
var createOriginLocation = function createOriginLocation(origin, destination, version, customCtx) {
|
|
6574
6412
|
if (isRelayChain(origin)) return DOT_LOCATION;
|
|
6575
6413
|
return {
|
|
6576
6414
|
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
6577
6415
|
interior: createX1Payload(version, {
|
|
6578
|
-
Parachain:
|
|
6416
|
+
Parachain: getParaIdImpl(origin, customCtx)
|
|
6579
6417
|
})
|
|
6580
6418
|
};
|
|
6581
6419
|
};
|
|
6582
6420
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
6583
6421
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6584
|
-
var api, origin, hopChain, destination, currency,
|
|
6422
|
+
var api, origin, hopChain, destination, currency, asset, currentAsset, forwardedXcms, recipient, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
6585
6423
|
return _regenerator().w(function (_context3) {
|
|
6586
6424
|
while (1) switch (_context3.n) {
|
|
6587
6425
|
case 0:
|
|
6588
|
-
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency,
|
|
6426
|
+
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, asset = options.asset, currentAsset = options.currentAsset, forwardedXcms = options.forwardedXcms, recipient = options.recipient, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
6589
6427
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
6590
6428
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
6591
6429
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
6592
|
-
var
|
|
6430
|
+
var reverseFeeFor, swapAsset, _t2;
|
|
6593
6431
|
return _regenerator().w(function (_context2) {
|
|
6594
6432
|
while (1) switch (_context2.p = _context2.n) {
|
|
6595
6433
|
case 0:
|
|
@@ -6599,53 +6437,52 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6599
6437
|
}
|
|
6600
6438
|
return _context2.a(2, 0n);
|
|
6601
6439
|
case 1:
|
|
6602
|
-
|
|
6603
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(
|
|
6604
|
-
var
|
|
6440
|
+
reverseFeeFor = /*#__PURE__*/function () {
|
|
6441
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(assetInfo, amount) {
|
|
6442
|
+
var _t;
|
|
6605
6443
|
return _regenerator().w(function (_context) {
|
|
6606
6444
|
while (1) switch (_context.p = _context.n) {
|
|
6607
6445
|
case 0:
|
|
6608
|
-
|
|
6609
|
-
_context.
|
|
6610
|
-
_context.n = 2;
|
|
6446
|
+
_context.p = 0;
|
|
6447
|
+
_context.n = 1;
|
|
6611
6448
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
6612
6449
|
destination: destination
|
|
6613
6450
|
}), {
|
|
6614
6451
|
location: assetInfo.location,
|
|
6615
|
-
amount:
|
|
6452
|
+
amount: amount
|
|
6616
6453
|
});
|
|
6617
|
-
case
|
|
6454
|
+
case 1:
|
|
6618
6455
|
return _context.a(2, _context.v);
|
|
6619
|
-
case
|
|
6620
|
-
_context.p =
|
|
6456
|
+
case 2:
|
|
6457
|
+
_context.p = 2;
|
|
6621
6458
|
_t = _context.v;
|
|
6622
6459
|
if (!(_t instanceof InvalidCurrencyError)) {
|
|
6623
|
-
_context.n =
|
|
6460
|
+
_context.n = 4;
|
|
6624
6461
|
break;
|
|
6625
6462
|
}
|
|
6626
|
-
_context.n =
|
|
6463
|
+
_context.n = 3;
|
|
6627
6464
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
6628
6465
|
destination: destination
|
|
6629
6466
|
}), {
|
|
6630
6467
|
symbol: assetInfo.symbol,
|
|
6631
|
-
amount:
|
|
6468
|
+
amount: amount
|
|
6632
6469
|
});
|
|
6633
|
-
case
|
|
6470
|
+
case 3:
|
|
6634
6471
|
return _context.a(2, _context.v);
|
|
6635
|
-
case
|
|
6472
|
+
case 4:
|
|
6636
6473
|
throw _t;
|
|
6637
|
-
case
|
|
6474
|
+
case 5:
|
|
6638
6475
|
return _context.a(2);
|
|
6639
6476
|
}
|
|
6640
|
-
}, _callee, null, [[
|
|
6477
|
+
}, _callee, null, [[0, 2]]);
|
|
6641
6478
|
}));
|
|
6642
|
-
return function
|
|
6479
|
+
return function reverseFeeFor(_x2, _x3) {
|
|
6643
6480
|
return _ref3.apply(this, arguments);
|
|
6644
6481
|
};
|
|
6645
6482
|
}();
|
|
6646
6483
|
_context2.p = 2;
|
|
6647
6484
|
_context2.n = 3;
|
|
6648
|
-
return
|
|
6485
|
+
return reverseFeeFor(asset, asset.amount);
|
|
6649
6486
|
case 3:
|
|
6650
6487
|
return _context2.a(2, _context2.v);
|
|
6651
6488
|
case 4:
|
|
@@ -6657,8 +6494,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6657
6494
|
}
|
|
6658
6495
|
return _context2.a(2, 0n);
|
|
6659
6496
|
case 5:
|
|
6497
|
+
swapAsset = api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, destination);
|
|
6660
6498
|
_context2.n = 6;
|
|
6661
|
-
return
|
|
6499
|
+
return reverseFeeFor(swapAsset, swapConfig.amountOut);
|
|
6662
6500
|
case 6:
|
|
6663
6501
|
return _context2.a(2, _context2.v);
|
|
6664
6502
|
}
|
|
@@ -6677,14 +6515,14 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6677
6515
|
case 1:
|
|
6678
6516
|
_fee = _context3.v;
|
|
6679
6517
|
_context3.n = 2;
|
|
6680
|
-
return isSufficientDestination(api, destination, recipient,
|
|
6518
|
+
return isSufficientDestination(api, destination, recipient, currentAsset, _fee);
|
|
6681
6519
|
case 2:
|
|
6682
6520
|
sufficient = _context3.v;
|
|
6683
6521
|
return _context3.a(2, {
|
|
6684
6522
|
fee: _fee,
|
|
6685
6523
|
feeType: 'paymentInfo',
|
|
6686
6524
|
sufficient: sufficient,
|
|
6687
|
-
asset:
|
|
6525
|
+
asset: currentAsset
|
|
6688
6526
|
});
|
|
6689
6527
|
case 3:
|
|
6690
6528
|
_context3.n = 4;
|
|
@@ -6694,11 +6532,11 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6694
6532
|
xcm: forwardedXcms[1][0],
|
|
6695
6533
|
chain: destination,
|
|
6696
6534
|
origin: origin,
|
|
6697
|
-
asset:
|
|
6535
|
+
asset: currentAsset,
|
|
6698
6536
|
version: version,
|
|
6699
6537
|
originFee: originFee,
|
|
6700
6538
|
feeAsset: resolvedFeeAsset,
|
|
6701
|
-
amount: normalizeAmount(
|
|
6539
|
+
amount: normalizeAmount(currentAsset.amount)
|
|
6702
6540
|
});
|
|
6703
6541
|
case 4:
|
|
6704
6542
|
dryRunResult = _context3.v;
|
|
@@ -6725,7 +6563,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6725
6563
|
dryRunError: dryRunResult.failureReason,
|
|
6726
6564
|
dryRunSubError: dryRunResult.failureSubReason,
|
|
6727
6565
|
sufficient: false,
|
|
6728
|
-
asset:
|
|
6566
|
+
asset: currentAsset
|
|
6729
6567
|
});
|
|
6730
6568
|
case 7:
|
|
6731
6569
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
@@ -6735,7 +6573,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6735
6573
|
sufficient: true,
|
|
6736
6574
|
forwardedXcms: newForwardedXcms,
|
|
6737
6575
|
destParaId: destParaId,
|
|
6738
|
-
asset:
|
|
6576
|
+
asset: currentAsset
|
|
6739
6577
|
});
|
|
6740
6578
|
}
|
|
6741
6579
|
}, _callee3);
|
|
@@ -7492,15 +7330,14 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
7492
7330
|
|
|
7493
7331
|
var traverseXcmHops = /*#__PURE__*/function () {
|
|
7494
7332
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
7495
|
-
var api, origin, destination,
|
|
7333
|
+
var api, origin, destination, asset, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, currentOrigin, forwardedXcms, nextParaId, currentAsset, hasPassedExchange, hops, destinationResult, nextChain, hopApi, isDestination, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
7496
7334
|
return _regenerator().w(function (_context) {
|
|
7497
7335
|
while (1) switch (_context.p = _context.n) {
|
|
7498
7336
|
case 0:
|
|
7499
|
-
api = config.api, origin = config.origin, destination = config.destination,
|
|
7337
|
+
api = config.api, origin = config.origin, destination = config.destination, asset = config.asset, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
7500
7338
|
currentOrigin = origin;
|
|
7501
7339
|
forwardedXcms = initialForwardedXcms;
|
|
7502
7340
|
nextParaId = initialDestParaId;
|
|
7503
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
7504
7341
|
currentAsset = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain) ? api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo) : asset;
|
|
7505
7342
|
hasPassedExchange = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain);
|
|
7506
7343
|
hops = [];
|
|
@@ -7509,7 +7346,7 @@ var traverseXcmHops = /*#__PURE__*/function () {
|
|
|
7509
7346
|
_context.n = 10;
|
|
7510
7347
|
break;
|
|
7511
7348
|
}
|
|
7512
|
-
nextChain = getTChain(nextParaId,
|
|
7349
|
+
nextChain = getTChain(nextParaId, getRelayChainOfImpl(api, origin));
|
|
7513
7350
|
if (nextChain) {
|
|
7514
7351
|
_context.n = 2;
|
|
7515
7352
|
break;
|
|
@@ -7620,15 +7457,14 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
7620
7457
|
|
|
7621
7458
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
7622
7459
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
7623
|
-
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin,
|
|
7460
|
+
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
7624
7461
|
return _regenerator().w(function (_context2) {
|
|
7625
7462
|
while (1) switch (_context2.n) {
|
|
7626
7463
|
case 0:
|
|
7627
7464
|
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, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
7628
|
-
assertCurrencyCore(currency);
|
|
7629
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
7630
7465
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
7631
|
-
|
|
7466
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
7467
|
+
amount = asset.amount;
|
|
7632
7468
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
7633
7469
|
_context2.n = 1;
|
|
7634
7470
|
return api.getDryRunCall({
|
|
@@ -7639,6 +7475,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7639
7475
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
7640
7476
|
amount: amount
|
|
7641
7477
|
}),
|
|
7478
|
+
assets: assets,
|
|
7642
7479
|
feeAsset: resolvedFeeAsset,
|
|
7643
7480
|
version: resolvedVersion,
|
|
7644
7481
|
bypassOptions: bypassOptions,
|
|
@@ -7696,7 +7533,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7696
7533
|
originChain: origin,
|
|
7697
7534
|
currentChain: currentChain,
|
|
7698
7535
|
destination: destination,
|
|
7699
|
-
asset:
|
|
7536
|
+
asset: asset,
|
|
7537
|
+
currentAsset: currentAsset,
|
|
7700
7538
|
currency: currency,
|
|
7701
7539
|
swapConfig: swapConfig,
|
|
7702
7540
|
hasPassedExchange: hasPassedExchange
|
|
@@ -7714,7 +7552,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7714
7552
|
case 1:
|
|
7715
7553
|
_context.n = 2;
|
|
7716
7554
|
return hopApi.getDryRunXcm({
|
|
7717
|
-
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, currentChain, resolvedVersion), resolvedVersion),
|
|
7555
|
+
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, currentChain, resolvedVersion, api._customCtx), resolvedVersion),
|
|
7718
7556
|
tx: tx,
|
|
7719
7557
|
xcm: forwardedXcms[1][0],
|
|
7720
7558
|
chain: currentChain,
|
|
@@ -7742,7 +7580,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7742
7580
|
api: api,
|
|
7743
7581
|
origin: origin,
|
|
7744
7582
|
destination: destination,
|
|
7745
|
-
|
|
7583
|
+
asset: asset,
|
|
7746
7584
|
initialForwardedXcms: initialForwardedXcms,
|
|
7747
7585
|
initialDestParaId: initialDestParaId,
|
|
7748
7586
|
swapConfig: swapConfig,
|
|
@@ -7760,8 +7598,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7760
7598
|
case 6:
|
|
7761
7599
|
traversalResult = _context2.v;
|
|
7762
7600
|
// Process Ethereum bridge fees
|
|
7763
|
-
bridgeHubChain = "BridgeHub".concat(
|
|
7764
|
-
assetHubChain = "AssetHub".concat(
|
|
7601
|
+
bridgeHubChain = "BridgeHub".concat(getRelayChainOfImpl(api, origin));
|
|
7602
|
+
assetHubChain = "AssetHub".concat(getRelayChainOfImpl(api, origin));
|
|
7765
7603
|
bridgeHubHop = traversalResult.hops.find(function (hop) {
|
|
7766
7604
|
return hop.chain === bridgeHubChain;
|
|
7767
7605
|
}); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
|
|
@@ -7882,7 +7720,9 @@ var parseUnits = parseUnits$1;
|
|
|
7882
7720
|
var formatUnits = formatUnits$1;
|
|
7883
7721
|
|
|
7884
7722
|
var resolveBypassMintAmount = function resolveBypassMintAmount(chain) {
|
|
7885
|
-
return HIGH_BYPASS_MINT_CHAINS.
|
|
7723
|
+
return HIGH_BYPASS_MINT_CHAINS.some(function (c) {
|
|
7724
|
+
return c === chain;
|
|
7725
|
+
}) ? HIGH_BYPASS_MINT_AMOUNT : BYPASS_MINT_AMOUNT;
|
|
7886
7726
|
};
|
|
7887
7727
|
var pickOtherPallet = function pickOtherPallet(asset, pallets) {
|
|
7888
7728
|
if (!asset.isNative && (!asset.assetId || asset.assetId.startsWith('0x'))) {
|
|
@@ -7952,7 +7792,8 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
|
|
|
7952
7792
|
}) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
|
|
7953
7793
|
};
|
|
7954
7794
|
var wrapTxBypass = /*#__PURE__*/function () {
|
|
7955
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
7795
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dryRunOptions) {
|
|
7796
|
+
var _dryRunOptions$assets;
|
|
7956
7797
|
var options,
|
|
7957
7798
|
api,
|
|
7958
7799
|
chain,
|
|
@@ -7970,21 +7811,15 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
7970
7811
|
mintRelayAssetRes,
|
|
7971
7812
|
mintFeeAssetRes,
|
|
7972
7813
|
amount,
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
_calcPreviewMintAmoun,
|
|
7977
|
-
missing,
|
|
7978
|
-
total,
|
|
7979
|
-
mintAssetRes,
|
|
7980
|
-
_args = arguments,
|
|
7814
|
+
mintSentAsset,
|
|
7815
|
+
mintAssetResults,
|
|
7816
|
+
_args2 = arguments,
|
|
7981
7817
|
_t,
|
|
7982
|
-
_t2
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
while (1) switch (_context.n) {
|
|
7818
|
+
_t2;
|
|
7819
|
+
return _regenerator().w(function (_context2) {
|
|
7820
|
+
while (1) switch (_context2.n) {
|
|
7986
7821
|
case 0:
|
|
7987
|
-
options =
|
|
7822
|
+
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {
|
|
7988
7823
|
mintFeeAssets: true,
|
|
7989
7824
|
sentAssetMintMode: 'bypass'
|
|
7990
7825
|
};
|
|
@@ -8003,84 +7838,87 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
8003
7838
|
relayInfo = mintFeeAssets ? api.findAssetInfo(chain, relayCurrency) : null;
|
|
8004
7839
|
sameNativeRelay = !!(nativeInfo && relayInfo && isAssetXcEqual(nativeInfo, relayInfo));
|
|
8005
7840
|
if (!mintFeeAssets) {
|
|
8006
|
-
|
|
7841
|
+
_context2.n = 2;
|
|
8007
7842
|
break;
|
|
8008
7843
|
}
|
|
8009
|
-
|
|
7844
|
+
_context2.n = 1;
|
|
8010
7845
|
return createRequiredMintTxs(chain, api.findNativeAssetInfoOrThrow(chain), bypassMintAmount, 0n, address, api);
|
|
8011
7846
|
case 1:
|
|
8012
|
-
_t =
|
|
8013
|
-
|
|
7847
|
+
_t = _context2.v;
|
|
7848
|
+
_context2.n = 3;
|
|
8014
7849
|
break;
|
|
8015
7850
|
case 2:
|
|
8016
7851
|
_t = null;
|
|
8017
7852
|
case 3:
|
|
8018
7853
|
mintNativeAssetRes = _t;
|
|
8019
7854
|
if (!(mintFeeAssets && !sameNativeRelay)) {
|
|
8020
|
-
|
|
7855
|
+
_context2.n = 5;
|
|
8021
7856
|
break;
|
|
8022
7857
|
}
|
|
8023
|
-
|
|
7858
|
+
_context2.n = 4;
|
|
8024
7859
|
return createOptionalMintTxs(chain, relayCurrency, bypassMintAmount, 0n, address, api);
|
|
8025
7860
|
case 4:
|
|
8026
|
-
_t2 =
|
|
8027
|
-
|
|
7861
|
+
_t2 = _context2.v;
|
|
7862
|
+
_context2.n = 6;
|
|
8028
7863
|
break;
|
|
8029
7864
|
case 5:
|
|
8030
7865
|
_t2 = null;
|
|
8031
7866
|
case 6:
|
|
8032
7867
|
mintRelayAssetRes = _t2;
|
|
8033
7868
|
if (!(feeAsset && mintFeeAssets)) {
|
|
8034
|
-
|
|
7869
|
+
_context2.n = 8;
|
|
8035
7870
|
break;
|
|
8036
7871
|
}
|
|
8037
7872
|
amount = parseUnits(bypassMintAmount, feeAsset.decimals);
|
|
8038
|
-
|
|
7873
|
+
_context2.n = 7;
|
|
8039
7874
|
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
|
|
8040
7875
|
amount: amount
|
|
8041
7876
|
}), 0n, address, api);
|
|
8042
7877
|
case 7:
|
|
8043
|
-
mintFeeAssetRes =
|
|
7878
|
+
mintFeeAssetRes = _context2.v;
|
|
8044
7879
|
case 8:
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
7880
|
+
mintSentAsset = /*#__PURE__*/function () {
|
|
7881
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
|
|
7882
|
+
var balance, bonus, mintAmount, _calcPreviewMintAmoun, missing, total;
|
|
7883
|
+
return _regenerator().w(function (_context) {
|
|
7884
|
+
while (1) switch (_context.n) {
|
|
7885
|
+
case 0:
|
|
7886
|
+
_context.n = 1;
|
|
7887
|
+
return getAssetBalanceInternal({
|
|
7888
|
+
api: api,
|
|
7889
|
+
chain: chain,
|
|
7890
|
+
address: address,
|
|
7891
|
+
asset: sentAsset
|
|
7892
|
+
});
|
|
7893
|
+
case 1:
|
|
7894
|
+
balance = _context.v;
|
|
7895
|
+
bonus = mintBonusForSent(chain, sentAsset, feeAsset, !!mintFeeAssets, api);
|
|
7896
|
+
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
7897
|
+
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
|
|
7898
|
+
} else {
|
|
7899
|
+
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, sentAsset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
7900
|
+
total = missing + bonus;
|
|
7901
|
+
mintAmount = total > 0n ? total : null;
|
|
7902
|
+
}
|
|
7903
|
+
return _context.a(2, mintAmount !== null ? createMintTxs(chain, _objectSpread2(_objectSpread2({}, sentAsset), {}, {
|
|
7904
|
+
amount: mintAmount
|
|
7905
|
+
}), balance, address, api) : null);
|
|
7906
|
+
}
|
|
7907
|
+
}, _callee);
|
|
7908
|
+
}));
|
|
7909
|
+
return function mintSentAsset(_x2) {
|
|
7910
|
+
return _ref3.apply(this, arguments);
|
|
7911
|
+
};
|
|
7912
|
+
}(); // mint assets that are being sent
|
|
7913
|
+
_context2.n = 9;
|
|
7914
|
+
return Promise.all(((_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset]).map(mintSentAsset));
|
|
8052
7915
|
case 9:
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
8056
|
-
mintAmount = parseUnits(bypassMintAmount, asset.decimals) + asset.amount;
|
|
8057
|
-
} else {
|
|
8058
|
-
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
8059
|
-
total = missing + bonus;
|
|
8060
|
-
mintAmount = total > 0n ? total : null;
|
|
8061
|
-
}
|
|
8062
|
-
// mint asset that is being sent
|
|
8063
|
-
if (!(mintAmount !== null)) {
|
|
8064
|
-
_context.n = 11;
|
|
8065
|
-
break;
|
|
8066
|
-
}
|
|
8067
|
-
_context.n = 10;
|
|
8068
|
-
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
8069
|
-
amount: mintAmount
|
|
8070
|
-
}), balance, address, api);
|
|
8071
|
-
case 10:
|
|
8072
|
-
_t3 = _context.v;
|
|
8073
|
-
_context.n = 12;
|
|
8074
|
-
break;
|
|
8075
|
-
case 11:
|
|
8076
|
-
_t3 = null;
|
|
8077
|
-
case 12:
|
|
8078
|
-
mintAssetRes = _t3;
|
|
8079
|
-
return _context.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes, mintAssetRes].flatMap(function (tx) {
|
|
7916
|
+
mintAssetResults = _context2.v;
|
|
7917
|
+
return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
|
|
8080
7918
|
return tx ? resultToExtrinsics(api, address, tx) : [];
|
|
8081
7919
|
})), [api.callDispatchAsMethod(tx, address)]), BatchMode.BATCH_ALL));
|
|
8082
7920
|
}
|
|
8083
|
-
},
|
|
7921
|
+
}, _callee2);
|
|
8084
7922
|
}));
|
|
8085
7923
|
return function wrapTxBypass(_x) {
|
|
8086
7924
|
return _ref2.apply(this, arguments);
|
|
@@ -8302,14 +8140,13 @@ var getBypassResultWithRetries = /*#__PURE__*/function () {
|
|
|
8302
8140
|
|
|
8303
8141
|
var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
8304
8142
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
8305
|
-
var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin,
|
|
8143
|
+
var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, _yield$api$getPayment, rawFee, paddedFee, sufficient, resolvedVersion, dryRunResult, _yield$api$getPayment2, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight;
|
|
8306
8144
|
return _regenerator().w(function (_context) {
|
|
8307
8145
|
while (1) switch (_context.n) {
|
|
8308
8146
|
case 0:
|
|
8309
8147
|
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency, version = _ref.version, _ref$useRootOrigin = _ref.useRootOrigin, useRootOrigin = _ref$useRootOrigin === void 0 ? false : _ref$useRootOrigin;
|
|
8310
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
8311
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
8312
8148
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
8149
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
8313
8150
|
_context.n = 1;
|
|
8314
8151
|
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
8315
8152
|
case 1:
|
|
@@ -8324,9 +8161,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
8324
8161
|
rawFee = _yield$api$getPayment.partialFee;
|
|
8325
8162
|
paddedFee = padFee(rawFee, origin, destination, 'origin');
|
|
8326
8163
|
_context.n = 3;
|
|
8327
|
-
return isSufficientOrigin(api, origin, destination, sender, paddedFee,
|
|
8328
|
-
amount: amount
|
|
8329
|
-
}), asset, resolvedFeeAsset);
|
|
8164
|
+
return isSufficientOrigin(api, origin, destination, sender, paddedFee, asset, resolvedFeeAsset);
|
|
8330
8165
|
case 3:
|
|
8331
8166
|
sufficient = _context.v;
|
|
8332
8167
|
return _context.a(2, {
|
|
@@ -8343,9 +8178,8 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
8343
8178
|
chain: origin,
|
|
8344
8179
|
destination: destination,
|
|
8345
8180
|
address: sender,
|
|
8346
|
-
asset:
|
|
8347
|
-
|
|
8348
|
-
}),
|
|
8181
|
+
asset: asset,
|
|
8182
|
+
assets: assets,
|
|
8349
8183
|
version: resolvedVersion,
|
|
8350
8184
|
feeAsset: resolvedFeeAsset,
|
|
8351
8185
|
// Force dryRun pass
|
|
@@ -8486,13 +8320,13 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
|
8486
8320
|
};
|
|
8487
8321
|
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
8488
8322
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
8489
|
-
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation,
|
|
8323
|
+
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, _failureSubReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _inferFeeAsset2, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, failureSubReason, _t, _t2, _t3, _t4;
|
|
8490
8324
|
return _regenerator().w(function (_context2) {
|
|
8491
8325
|
while (1) switch (_context2.p = _context2.n) {
|
|
8492
8326
|
case 0:
|
|
8493
8327
|
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
8494
|
-
|
|
8495
|
-
|
|
8328
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
8329
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset;
|
|
8496
8330
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
8497
8331
|
_context2.n = 1;
|
|
8498
8332
|
return getOriginXcmFeeInternal({
|
|
@@ -8553,12 +8387,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8553
8387
|
origin: origin,
|
|
8554
8388
|
prevChain: origin,
|
|
8555
8389
|
destination: destination,
|
|
8556
|
-
currency:
|
|
8557
|
-
|
|
8558
|
-
|
|
8390
|
+
currency: currency,
|
|
8391
|
+
asset: asset,
|
|
8392
|
+
currentAsset: asset,
|
|
8559
8393
|
sender: sender,
|
|
8560
8394
|
recipient: recipient,
|
|
8561
|
-
asset: asset,
|
|
8562
8395
|
version: resolvedVersion,
|
|
8563
8396
|
tx: tx,
|
|
8564
8397
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -8625,7 +8458,8 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8625
8458
|
originChain: origin,
|
|
8626
8459
|
currentChain: currentChain,
|
|
8627
8460
|
destination: destination,
|
|
8628
|
-
asset:
|
|
8461
|
+
asset: asset,
|
|
8462
|
+
currentAsset: currentAsset,
|
|
8629
8463
|
currency: currency,
|
|
8630
8464
|
swapConfig: swapConfig,
|
|
8631
8465
|
hasPassedExchange: hasPassedExchange
|
|
@@ -8638,12 +8472,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8638
8472
|
origin: origin,
|
|
8639
8473
|
prevChain: currentOrigin,
|
|
8640
8474
|
destination: currentChain,
|
|
8641
|
-
currency:
|
|
8642
|
-
|
|
8475
|
+
currency: currency,
|
|
8476
|
+
asset: asset,
|
|
8477
|
+
currentAsset: _objectSpread2(_objectSpread2({}, hopAsset), {}, {
|
|
8478
|
+
amount: asset.amount
|
|
8643
8479
|
}),
|
|
8644
8480
|
sender: sender,
|
|
8645
8481
|
recipient: recipient,
|
|
8646
|
-
asset: hopAsset,
|
|
8647
8482
|
version: resolvedVersion,
|
|
8648
8483
|
feeAsset: feeAsset,
|
|
8649
8484
|
tx: tx,
|
|
@@ -8668,7 +8503,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8668
8503
|
api: api,
|
|
8669
8504
|
origin: origin,
|
|
8670
8505
|
destination: destination,
|
|
8671
|
-
|
|
8506
|
+
asset: asset,
|
|
8672
8507
|
initialForwardedXcms: initialForwardedXcm,
|
|
8673
8508
|
initialDestParaId: initialDestParaId,
|
|
8674
8509
|
swapConfig: swapConfig,
|
|
@@ -8715,12 +8550,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8715
8550
|
origin: origin,
|
|
8716
8551
|
prevChain: traversalResult.lastProcessedChain || origin,
|
|
8717
8552
|
destination: destination,
|
|
8718
|
-
currency:
|
|
8719
|
-
|
|
8553
|
+
currency: currency,
|
|
8554
|
+
asset: asset,
|
|
8555
|
+
currentAsset: _objectSpread2(_objectSpread2({}, (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset), {}, {
|
|
8556
|
+
amount: asset.amount
|
|
8720
8557
|
}),
|
|
8721
8558
|
sender: sender,
|
|
8722
8559
|
recipient: recipient,
|
|
8723
|
-
asset: (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset,
|
|
8724
8560
|
version: resolvedVersion,
|
|
8725
8561
|
tx: tx,
|
|
8726
8562
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -8743,8 +8579,8 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8743
8579
|
destAsset = api.findNativeAssetInfoOrThrow(destination);
|
|
8744
8580
|
case 16:
|
|
8745
8581
|
// Process Ethereum bridge fees
|
|
8746
|
-
bridgeHubChain = "BridgeHub".concat(
|
|
8747
|
-
assetHubChain = "AssetHub".concat(
|
|
8582
|
+
bridgeHubChain = "BridgeHub".concat(getRelayChainOfImpl(api, origin));
|
|
8583
|
+
assetHubChain = "AssetHub".concat(getRelayChainOfImpl(api, origin));
|
|
8748
8584
|
bridgeHubHop = traversalResult.hops.find(function (hop) {
|
|
8749
8585
|
return hop.chain === bridgeHubChain;
|
|
8750
8586
|
});
|
|
@@ -8764,7 +8600,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8764
8600
|
processedBridgeHub = _t4;
|
|
8765
8601
|
// Update bridge hub fee in hops if needed
|
|
8766
8602
|
if (processedBridgeHub && bridgeHubHop && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
|
|
8767
|
-
_bridgeHubChain = "BridgeHub".concat(
|
|
8603
|
+
_bridgeHubChain = "BridgeHub".concat(getRelayChainOfImpl(api, origin));
|
|
8768
8604
|
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
8769
8605
|
return hop.chain === _bridgeHubChain;
|
|
8770
8606
|
});
|
|
@@ -8948,11 +8784,11 @@ var aggregateHopFees = function aggregateHopFees(hops, matchAsset) {
|
|
|
8948
8784
|
|
|
8949
8785
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
8950
8786
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
8951
|
-
var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8787
|
+
var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, paysDestFee, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8952
8788
|
return _regenerator().w(function (_context) {
|
|
8953
8789
|
while (1) switch (_context.n) {
|
|
8954
8790
|
case 0:
|
|
8955
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
|
|
8791
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, paysDestFee = _ref.paysDestFee, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
|
|
8956
8792
|
destApi = api.clone();
|
|
8957
8793
|
_context.n = 1;
|
|
8958
8794
|
return destApi.init(destination);
|
|
@@ -8970,14 +8806,14 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
8970
8806
|
destBalance = _context.v;
|
|
8971
8807
|
destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
|
|
8972
8808
|
destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
|
|
8973
|
-
effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
8809
|
+
effectiveDestFee = paysDestFee && destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
8974
8810
|
effectiveAmountForBalance = destAmount - totalHopFee;
|
|
8975
8811
|
destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
|
|
8976
8812
|
destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
|
|
8977
8813
|
createUnableToComputeError = function createUnableToComputeError() {
|
|
8978
8814
|
return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
|
|
8979
8815
|
};
|
|
8980
|
-
isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
8816
|
+
isUnableToCompute = paysDestFee && destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
8981
8817
|
destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
|
|
8982
8818
|
destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
|
|
8983
8819
|
isSubBridge = isSubstrateBridge(origin, destination);
|
|
@@ -9096,24 +8932,49 @@ var buildHopInfo = /*#__PURE__*/function () {
|
|
|
9096
8932
|
};
|
|
9097
8933
|
}();
|
|
9098
8934
|
|
|
8935
|
+
var _excluded$1 = ["amount"];
|
|
9099
8936
|
var buildOriginInfo = /*#__PURE__*/function () {
|
|
9100
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9101
|
-
var api, origin, sender,
|
|
9102
|
-
return _regenerator().w(function (
|
|
9103
|
-
while (1) switch (
|
|
8937
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
8938
|
+
var api, origin, sender, assets, amount, originFee, originFeeAsset, isFeeAssetAh, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
|
|
8939
|
+
return _regenerator().w(function (_context2) {
|
|
8940
|
+
while (1) switch (_context2.n) {
|
|
9104
8941
|
case 0:
|
|
9105
|
-
api = _ref.api, origin = _ref.origin, sender = _ref.sender,
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
8942
|
+
api = _ref.api, origin = _ref.origin, sender = _ref.sender, assets = _ref.assets, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
|
|
8943
|
+
buildSelectedCurrency = /*#__PURE__*/function () {
|
|
8944
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref3) {
|
|
8945
|
+
var assetAmount, asset, balance, balanceAfter;
|
|
8946
|
+
return _regenerator().w(function (_context) {
|
|
8947
|
+
while (1) switch (_context.n) {
|
|
8948
|
+
case 0:
|
|
8949
|
+
assetAmount = _ref3.amount, asset = _objectWithoutProperties(_ref3, _excluded$1);
|
|
8950
|
+
_context.n = 1;
|
|
8951
|
+
return getAssetBalanceInternal({
|
|
8952
|
+
api: api,
|
|
8953
|
+
address: sender,
|
|
8954
|
+
chain: origin,
|
|
8955
|
+
asset: asset
|
|
8956
|
+
});
|
|
8957
|
+
case 1:
|
|
8958
|
+
balance = _context.v;
|
|
8959
|
+
balanceAfter = balance - assetAmount;
|
|
8960
|
+
return _context.a(2, {
|
|
8961
|
+
sufficient: balanceAfter >= getEdFromAssetOrThrow(asset),
|
|
8962
|
+
balance: balance,
|
|
8963
|
+
balanceAfter: balanceAfter,
|
|
8964
|
+
asset: asset
|
|
8965
|
+
});
|
|
8966
|
+
}
|
|
8967
|
+
}, _callee);
|
|
8968
|
+
}));
|
|
8969
|
+
return function buildSelectedCurrency(_x2) {
|
|
8970
|
+
return _ref4.apply(this, arguments);
|
|
8971
|
+
};
|
|
8972
|
+
}();
|
|
8973
|
+
_context2.n = 1;
|
|
8974
|
+
return Promise.all(assets.map(buildSelectedCurrency));
|
|
9113
8975
|
case 1:
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
_context.n = 2;
|
|
8976
|
+
selectedCurrency = _context2.v;
|
|
8977
|
+
_context2.n = 2;
|
|
9117
8978
|
return getAssetBalanceInternal({
|
|
9118
8979
|
api: api,
|
|
9119
8980
|
address: sender,
|
|
@@ -9121,20 +8982,12 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9121
8982
|
asset: originFeeAsset
|
|
9122
8983
|
});
|
|
9123
8984
|
case 2:
|
|
9124
|
-
originBalanceFee =
|
|
9125
|
-
originBalanceAfter = originBalance - amount;
|
|
8985
|
+
originBalanceFee = _context2.v;
|
|
9126
8986
|
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
return _context.a(2, {
|
|
9130
|
-
selectedCurrency: {
|
|
9131
|
-
sufficient: originBalanceSufficient,
|
|
9132
|
-
balance: originBalance,
|
|
9133
|
-
balanceAfter: originBalanceAfter,
|
|
9134
|
-
asset: originAsset
|
|
9135
|
-
},
|
|
8987
|
+
return _context2.a(2, {
|
|
8988
|
+
selectedCurrency: selectedCurrency,
|
|
9136
8989
|
xcmFee: {
|
|
9137
|
-
sufficient:
|
|
8990
|
+
sufficient: originBalanceFee >= originFee,
|
|
9138
8991
|
fee: originFee,
|
|
9139
8992
|
balance: originBalanceFee,
|
|
9140
8993
|
balanceAfter: originBalanceFeeAfter,
|
|
@@ -9142,7 +8995,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9142
8995
|
}
|
|
9143
8996
|
});
|
|
9144
8997
|
}
|
|
9145
|
-
},
|
|
8998
|
+
}, _callee2);
|
|
9146
8999
|
}));
|
|
9147
9000
|
return function buildOriginInfo(_x) {
|
|
9148
9001
|
return _ref2.apply(this, arguments);
|
|
@@ -9151,7 +9004,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9151
9004
|
|
|
9152
9005
|
var getTransferInfo = /*#__PURE__*/function () {
|
|
9153
9006
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
9154
|
-
var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh,
|
|
9007
|
+
var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, _resolveCurrency, assets, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, feeAssetIndex, feeCurrency, _yield$buildOriginInf, selectedCurrency, originXcmFee, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, buildDestInfoForAsset, destResults, feeResult, result, _t, _t2;
|
|
9155
9008
|
return _regenerator().w(function (_context2) {
|
|
9156
9009
|
while (1) switch (_context2.p = _context2.n) {
|
|
9157
9010
|
case 0:
|
|
@@ -9162,14 +9015,15 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9162
9015
|
}
|
|
9163
9016
|
throw new MissingParameterError('ahAddress', "ahAddress is required for EVM origin ".concat(origin, "."));
|
|
9164
9017
|
case 1:
|
|
9018
|
+
assertNotRawAssets(currency);
|
|
9165
9019
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
9166
9020
|
_context2.n = 2;
|
|
9167
9021
|
return api.init(origin);
|
|
9168
9022
|
case 2:
|
|
9169
9023
|
api.disconnectAllowed = false;
|
|
9170
9024
|
_context2.p = 3;
|
|
9171
|
-
|
|
9172
|
-
amount =
|
|
9025
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, originAsset = _resolveCurrency.asset;
|
|
9026
|
+
amount = originAsset.amount;
|
|
9173
9027
|
_context2.n = 4;
|
|
9174
9028
|
return getXcmFee({
|
|
9175
9029
|
api: api,
|
|
@@ -9191,20 +9045,25 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9191
9045
|
destFeeDetail = _yield$getXcmFeeInter.destination;
|
|
9192
9046
|
hops = _yield$getXcmFeeInter.hops;
|
|
9193
9047
|
isFeeAssetAh = origin === 'AssetHubPolkadot' && !!resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
|
|
9048
|
+
feeAssetIndex = assets.findIndex(function (asset) {
|
|
9049
|
+
return isAssetEqual(asset, originAsset);
|
|
9050
|
+
});
|
|
9051
|
+
feeCurrency = Array.isArray(currency) ? currency[feeAssetIndex] : currency;
|
|
9194
9052
|
_context2.n = 5;
|
|
9195
9053
|
return buildOriginInfo({
|
|
9196
9054
|
api: api,
|
|
9197
9055
|
origin: origin,
|
|
9198
9056
|
sender: sender,
|
|
9199
|
-
|
|
9200
|
-
originAsset: originAsset,
|
|
9057
|
+
assets: assets,
|
|
9201
9058
|
amount: amount,
|
|
9202
9059
|
originFee: originFee,
|
|
9203
9060
|
originFeeAsset: originFeeAsset,
|
|
9204
9061
|
isFeeAssetAh: isFeeAssetAh
|
|
9205
9062
|
});
|
|
9206
9063
|
case 5:
|
|
9207
|
-
|
|
9064
|
+
_yield$buildOriginInf = _context2.v;
|
|
9065
|
+
selectedCurrency = _yield$buildOriginInf.selectedCurrency;
|
|
9066
|
+
originXcmFee = _yield$buildOriginInf.xcmFee;
|
|
9208
9067
|
builtHops = [];
|
|
9209
9068
|
if (!(hops && hops.length > 0)) {
|
|
9210
9069
|
_context2.n = 7;
|
|
@@ -9223,7 +9082,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9223
9082
|
chain: hop.chain,
|
|
9224
9083
|
fee: hop.result.fee,
|
|
9225
9084
|
originChain: origin,
|
|
9226
|
-
currency:
|
|
9085
|
+
currency: feeCurrency,
|
|
9227
9086
|
asset: hop.result.asset,
|
|
9228
9087
|
sender: sender,
|
|
9229
9088
|
ahAddress: ahAddress
|
|
@@ -9245,44 +9104,76 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9245
9104
|
builtHops = _context2.v;
|
|
9246
9105
|
case 7:
|
|
9247
9106
|
_aggregateHopFees = aggregateHopFees(hops, originAsset), totalHopFee = _aggregateHopFees.totalHopFee, bridgeFee = _aggregateHopFees.bridgeFee;
|
|
9107
|
+
buildDestInfoForAsset = function buildDestInfoForAsset(item, isFeeElement) {
|
|
9108
|
+
return buildDestInfo({
|
|
9109
|
+
api: api,
|
|
9110
|
+
origin: origin,
|
|
9111
|
+
destination: destination,
|
|
9112
|
+
recipient: recipient,
|
|
9113
|
+
currency: item,
|
|
9114
|
+
originFee: originFee,
|
|
9115
|
+
isFeeAssetAh: isFeeAssetAh && isFeeElement,
|
|
9116
|
+
paysDestFee: isFeeElement,
|
|
9117
|
+
destFeeDetail: destFeeDetail,
|
|
9118
|
+
totalHopFee: isFeeElement ? totalHopFee : 0n,
|
|
9119
|
+
bridgeFee: bridgeFee
|
|
9120
|
+
});
|
|
9121
|
+
};
|
|
9122
|
+
if (!Array.isArray(currency)) {
|
|
9123
|
+
_context2.n = 9;
|
|
9124
|
+
break;
|
|
9125
|
+
}
|
|
9248
9126
|
_context2.n = 8;
|
|
9249
|
-
return
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9255
|
-
amount: amount
|
|
9256
|
-
}),
|
|
9257
|
-
originFee: originFee,
|
|
9258
|
-
isFeeAssetAh: isFeeAssetAh,
|
|
9259
|
-
destFeeDetail: destFeeDetail,
|
|
9260
|
-
totalHopFee: totalHopFee,
|
|
9261
|
-
bridgeFee: bridgeFee
|
|
9262
|
-
});
|
|
9127
|
+
return Promise.all(currency.map(function (item, index) {
|
|
9128
|
+
return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, item), {}, {
|
|
9129
|
+
amount: assets[index].amount
|
|
9130
|
+
}), index === feeAssetIndex);
|
|
9131
|
+
}));
|
|
9263
9132
|
case 8:
|
|
9264
|
-
|
|
9265
|
-
|
|
9133
|
+
_t = _context2.v;
|
|
9134
|
+
_context2.n = 11;
|
|
9135
|
+
break;
|
|
9136
|
+
case 9:
|
|
9137
|
+
_context2.n = 10;
|
|
9138
|
+
return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9139
|
+
amount: amount
|
|
9140
|
+
}), true);
|
|
9141
|
+
case 10:
|
|
9142
|
+
_t2 = _context2.v;
|
|
9143
|
+
_t = [_t2];
|
|
9144
|
+
case 11:
|
|
9145
|
+
destResults = _t;
|
|
9146
|
+
feeResult = destResults[Array.isArray(currency) ? feeAssetIndex : 0];
|
|
9147
|
+
result = {
|
|
9266
9148
|
chain: {
|
|
9267
9149
|
origin: origin,
|
|
9268
9150
|
destination: destination,
|
|
9269
9151
|
ecosystem: api.getRelayChainSymbol(origin)
|
|
9270
9152
|
},
|
|
9271
|
-
origin:
|
|
9153
|
+
origin: {
|
|
9154
|
+
selectedCurrency: Array.isArray(currency) ? selectedCurrency : selectedCurrency[0],
|
|
9155
|
+
xcmFee: originXcmFee
|
|
9156
|
+
},
|
|
9272
9157
|
hops: builtHops,
|
|
9273
|
-
destination:
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9158
|
+
destination: {
|
|
9159
|
+
receivedCurrency: Array.isArray(currency) ? destResults.map(function (result) {
|
|
9160
|
+
return result.receivedCurrency;
|
|
9161
|
+
}) : destResults[0].receivedCurrency,
|
|
9162
|
+
xcmFee: feeResult.xcmFee
|
|
9163
|
+
}
|
|
9164
|
+
};
|
|
9165
|
+
return _context2.a(2, result);
|
|
9166
|
+
case 12:
|
|
9167
|
+
_context2.p = 12;
|
|
9277
9168
|
api.disconnectAllowed = true;
|
|
9278
|
-
_context2.n =
|
|
9169
|
+
_context2.n = 13;
|
|
9279
9170
|
return api.disconnect();
|
|
9280
|
-
case
|
|
9281
|
-
return _context2.f(
|
|
9282
|
-
case
|
|
9171
|
+
case 13:
|
|
9172
|
+
return _context2.f(12);
|
|
9173
|
+
case 14:
|
|
9283
9174
|
return _context2.a(2);
|
|
9284
9175
|
}
|
|
9285
|
-
}, _callee2, null, [[3,,
|
|
9176
|
+
}, _callee2, null, [[3,, 12, 14]]);
|
|
9286
9177
|
}));
|
|
9287
9178
|
return function getTransferInfo(_x) {
|
|
9288
9179
|
return _ref2.apply(this, arguments);
|
|
@@ -9345,35 +9236,26 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
9345
9236
|
}();
|
|
9346
9237
|
|
|
9347
9238
|
var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
9348
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9349
|
-
var api, origin, sender, recipient,
|
|
9350
|
-
return _regenerator().w(function (
|
|
9351
|
-
while (1) switch (
|
|
9239
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref) {
|
|
9240
|
+
var api, origin, sender, recipient, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, _resolveCurrency, assets, selectors, toResult, destApi, nativeAssetInfo, result, minAmounts, buildMinCurrency, createTx, amounts, tx, dryRunResult, _t;
|
|
9241
|
+
return _regenerator().w(function (_context3) {
|
|
9242
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
9352
9243
|
case 0:
|
|
9353
|
-
api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient,
|
|
9354
|
-
validateAddress(api, sender,
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9244
|
+
api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder, version = _ref.version;
|
|
9245
|
+
validateAddress(api, sender, origin, false);
|
|
9246
|
+
assertNotRawAssets(currency);
|
|
9247
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
9248
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets;
|
|
9249
|
+
selectors = Array.isArray(currency) ? currency : [currency];
|
|
9250
|
+
toResult = function toResult(values) {
|
|
9251
|
+
return Array.isArray(currency) ? values : values[0];
|
|
9252
|
+
};
|
|
9358
9253
|
destApi = api.clone();
|
|
9359
|
-
|
|
9254
|
+
_context3.n = 1;
|
|
9360
9255
|
return destApi.init(destination);
|
|
9361
9256
|
case 1:
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
api: destApi,
|
|
9365
|
-
address: recipient,
|
|
9366
|
-
chain: destination,
|
|
9367
|
-
asset: destAsset
|
|
9368
|
-
});
|
|
9369
|
-
case 2:
|
|
9370
|
-
destBalance = _context2.v;
|
|
9371
|
-
destEd = getEdFromAssetOrThrow(destAsset);
|
|
9372
|
-
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
9373
|
-
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
9374
|
-
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9375
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9376
|
-
_context2.n = 3;
|
|
9257
|
+
nativeAssetInfo = api.findNativeAssetInfoOrThrow(origin);
|
|
9258
|
+
_context3.n = 2;
|
|
9377
9259
|
return getXcmFee({
|
|
9378
9260
|
api: api,
|
|
9379
9261
|
origin: origin,
|
|
@@ -9381,164 +9263,179 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
9381
9263
|
buildTx: buildTx,
|
|
9382
9264
|
sender: sender,
|
|
9383
9265
|
recipient: recipient,
|
|
9384
|
-
currency: _objectSpread2(_objectSpread2({},
|
|
9385
|
-
amount: amount
|
|
9266
|
+
currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
|
|
9267
|
+
amount: assets[0].amount
|
|
9386
9268
|
}),
|
|
9387
9269
|
feeAsset: feeAsset,
|
|
9388
9270
|
version: version,
|
|
9389
9271
|
disableFallback: false
|
|
9390
9272
|
});
|
|
9391
|
-
case
|
|
9392
|
-
result =
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
}, 0n);
|
|
9398
|
-
destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
|
|
9399
|
-
edComponent = destBalance === 0n ? destEd : 0n;
|
|
9400
|
-
minAmount = hopFeeTotal + destinationFee + originFee + edComponent + 1n;
|
|
9401
|
-
createTx = /*#__PURE__*/function () {
|
|
9402
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(amount) {
|
|
9403
|
-
var _yield$builder$curren, tx;
|
|
9273
|
+
case 2:
|
|
9274
|
+
result = _context3.v;
|
|
9275
|
+
_context3.n = 3;
|
|
9276
|
+
return Promise.all(assets.map(/*#__PURE__*/function () {
|
|
9277
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, index) {
|
|
9278
|
+
var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, hopFeeTotal, destinationFee, edComponent;
|
|
9404
9279
|
return _regenerator().w(function (_context) {
|
|
9405
9280
|
while (1) switch (_context.n) {
|
|
9406
9281
|
case 0:
|
|
9282
|
+
destAsset = api.findAssetOnDestOrThrow(origin, destination, selectors[index]);
|
|
9407
9283
|
_context.n = 1;
|
|
9408
|
-
return
|
|
9409
|
-
|
|
9410
|
-
|
|
9284
|
+
return getAssetBalanceInternal({
|
|
9285
|
+
api: destApi,
|
|
9286
|
+
address: recipient,
|
|
9287
|
+
chain: destination,
|
|
9288
|
+
asset: destAsset
|
|
9289
|
+
});
|
|
9411
9290
|
case 1:
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9291
|
+
destBalance = _context.v;
|
|
9292
|
+
destEd = getEdFromAssetOrThrow(destAsset);
|
|
9293
|
+
paysOriginInSendingAsset = !resolvedFeeAsset && isAssetEqual(nativeAssetInfo, asset) || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9294
|
+
originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
|
|
9295
|
+
hopFeeTotal = result.hops.reduce(function (acc, hop) {
|
|
9296
|
+
// only add if asset is equal
|
|
9297
|
+
return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
|
|
9298
|
+
}, 0n);
|
|
9299
|
+
destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
|
|
9300
|
+
edComponent = destBalance === 0n ? destEd : 0n;
|
|
9301
|
+
return _context.a(2, hopFeeTotal + destinationFee + originFee + edComponent + 1n);
|
|
9415
9302
|
}
|
|
9416
9303
|
}, _callee);
|
|
9417
9304
|
}));
|
|
9418
|
-
return function
|
|
9305
|
+
return function (_x2, _x3) {
|
|
9419
9306
|
return _ref3.apply(this, arguments);
|
|
9420
9307
|
};
|
|
9308
|
+
}()));
|
|
9309
|
+
case 3:
|
|
9310
|
+
minAmounts = _context3.v;
|
|
9311
|
+
buildMinCurrency = function buildMinCurrency(amounts) {
|
|
9312
|
+
assertNotRawAssets(currency);
|
|
9313
|
+
return Array.isArray(currency) ? currency.map(function (item, index) {
|
|
9314
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9315
|
+
amount: amounts[index]
|
|
9316
|
+
});
|
|
9317
|
+
}) : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
|
|
9318
|
+
amount: amounts[0]
|
|
9319
|
+
});
|
|
9320
|
+
};
|
|
9321
|
+
createTx = /*#__PURE__*/function () {
|
|
9322
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(amounts) {
|
|
9323
|
+
var _yield$builder$curren, tx;
|
|
9324
|
+
return _regenerator().w(function (_context2) {
|
|
9325
|
+
while (1) switch (_context2.n) {
|
|
9326
|
+
case 0:
|
|
9327
|
+
_context2.n = 1;
|
|
9328
|
+
return builder.currency(buildMinCurrency(amounts))['buildInternal']();
|
|
9329
|
+
case 1:
|
|
9330
|
+
_yield$builder$curren = _context2.v;
|
|
9331
|
+
tx = _yield$builder$curren.tx;
|
|
9332
|
+
return _context2.a(2, tx);
|
|
9333
|
+
}
|
|
9334
|
+
}, _callee2);
|
|
9335
|
+
}));
|
|
9336
|
+
return function createTx(_x4) {
|
|
9337
|
+
return _ref4.apply(this, arguments);
|
|
9338
|
+
};
|
|
9421
9339
|
}();
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9340
|
+
amounts = minAmounts;
|
|
9341
|
+
_context3.p = 4;
|
|
9342
|
+
_context3.n = 5;
|
|
9343
|
+
return createTx(amounts);
|
|
9425
9344
|
case 5:
|
|
9426
|
-
tx =
|
|
9427
|
-
|
|
9345
|
+
tx = _context3.v;
|
|
9346
|
+
_context3.n = 10;
|
|
9428
9347
|
break;
|
|
9429
9348
|
case 6:
|
|
9430
|
-
|
|
9431
|
-
_t =
|
|
9349
|
+
_context3.p = 6;
|
|
9350
|
+
_t = _context3.v;
|
|
9432
9351
|
if (!(_t instanceof AmountTooLowError)) {
|
|
9433
|
-
|
|
9352
|
+
_context3.n = 10;
|
|
9434
9353
|
break;
|
|
9435
9354
|
}
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9355
|
+
amounts = amounts.map(function (amount) {
|
|
9356
|
+
return padValueBy(amount, FEE_PADDING);
|
|
9357
|
+
});
|
|
9358
|
+
_context3.p = 7;
|
|
9359
|
+
_context3.n = 8;
|
|
9360
|
+
return createTx(amounts);
|
|
9440
9361
|
case 8:
|
|
9441
|
-
tx =
|
|
9442
|
-
|
|
9362
|
+
tx = _context3.v;
|
|
9363
|
+
_context3.n = 10;
|
|
9443
9364
|
break;
|
|
9444
9365
|
case 9:
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
}
|
|
9451
|
-
return _context2.a(2, 0n);
|
|
9366
|
+
_context3.p = 9;
|
|
9367
|
+
_context3.v;
|
|
9368
|
+
return _context3.a(2, toResult(amounts.map(function () {
|
|
9369
|
+
return 0n;
|
|
9370
|
+
})));
|
|
9452
9371
|
case 10:
|
|
9453
|
-
|
|
9372
|
+
_context3.n = 11;
|
|
9454
9373
|
return dryRunInternal({
|
|
9455
9374
|
api: api,
|
|
9456
9375
|
tx: tx,
|
|
9457
|
-
origin:
|
|
9376
|
+
origin: origin,
|
|
9458
9377
|
destination: destination,
|
|
9459
9378
|
sender: sender,
|
|
9460
9379
|
version: version,
|
|
9461
|
-
currency:
|
|
9462
|
-
amount: minAmount
|
|
9463
|
-
}),
|
|
9380
|
+
currency: buildMinCurrency(amounts),
|
|
9464
9381
|
feeAsset: feeAsset
|
|
9465
9382
|
});
|
|
9466
9383
|
case 11:
|
|
9467
|
-
dryRunResult =
|
|
9384
|
+
dryRunResult = _context3.v;
|
|
9468
9385
|
if (!dryRunResult.failureReason) {
|
|
9469
|
-
|
|
9386
|
+
_context3.n = 12;
|
|
9470
9387
|
break;
|
|
9471
9388
|
}
|
|
9472
|
-
return
|
|
9389
|
+
return _context3.a(2, toResult(amounts.map(function () {
|
|
9390
|
+
return 0n;
|
|
9391
|
+
})));
|
|
9473
9392
|
case 12:
|
|
9474
|
-
return
|
|
9393
|
+
return _context3.a(2, toResult(amounts));
|
|
9475
9394
|
}
|
|
9476
|
-
},
|
|
9395
|
+
}, _callee3, null, [[7, 9], [4, 6]]);
|
|
9477
9396
|
}));
|
|
9478
9397
|
return function getMinTransferableAmountInternal(_x) {
|
|
9479
9398
|
return _ref2.apply(this, arguments);
|
|
9480
9399
|
};
|
|
9481
9400
|
}();
|
|
9482
9401
|
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
9483
|
-
var
|
|
9402
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
9484
9403
|
var api;
|
|
9485
|
-
return _regenerator().w(function (
|
|
9486
|
-
while (1) switch (
|
|
9404
|
+
return _regenerator().w(function (_context4) {
|
|
9405
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
9487
9406
|
case 0:
|
|
9488
9407
|
api = options.api;
|
|
9489
9408
|
api.disconnectAllowed = false;
|
|
9490
|
-
|
|
9491
|
-
|
|
9409
|
+
_context4.p = 1;
|
|
9410
|
+
_context4.n = 2;
|
|
9492
9411
|
return getMinTransferableAmountInternal(options);
|
|
9493
9412
|
case 2:
|
|
9494
|
-
return
|
|
9413
|
+
return _context4.a(2, _context4.v);
|
|
9495
9414
|
case 3:
|
|
9496
|
-
|
|
9415
|
+
_context4.p = 3;
|
|
9497
9416
|
api.disconnectAllowed = true;
|
|
9498
|
-
|
|
9417
|
+
_context4.n = 4;
|
|
9499
9418
|
return api.disconnect();
|
|
9500
9419
|
case 4:
|
|
9501
|
-
return
|
|
9420
|
+
return _context4.f(3);
|
|
9502
9421
|
case 5:
|
|
9503
|
-
return
|
|
9422
|
+
return _context4.a(2);
|
|
9504
9423
|
}
|
|
9505
|
-
},
|
|
9424
|
+
}, _callee4, null, [[1,, 3, 5]]);
|
|
9506
9425
|
}));
|
|
9507
|
-
return function getMinTransferableAmount(
|
|
9508
|
-
return
|
|
9426
|
+
return function getMinTransferableAmount(_x5) {
|
|
9427
|
+
return _ref5.apply(this, arguments);
|
|
9509
9428
|
};
|
|
9510
9429
|
}();
|
|
9511
9430
|
|
|
9512
|
-
var
|
|
9513
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
9514
|
-
var api,
|
|
9431
|
+
var getOriginFeeOrThrow = /*#__PURE__*/function () {
|
|
9432
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
|
|
9433
|
+
var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
|
|
9515
9434
|
return _regenerator().w(function (_context) {
|
|
9516
9435
|
while (1) switch (_context.n) {
|
|
9517
9436
|
case 0:
|
|
9518
|
-
api = _ref.api,
|
|
9519
|
-
validateAddress(api, sender, chain, false);
|
|
9520
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
9521
|
-
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
9522
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9437
|
+
api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
|
|
9523
9438
|
_context.n = 1;
|
|
9524
|
-
return getAssetBalanceInternal({
|
|
9525
|
-
api: api,
|
|
9526
|
-
address: sender,
|
|
9527
|
-
chain: chain,
|
|
9528
|
-
asset: asset
|
|
9529
|
-
});
|
|
9530
|
-
case 1:
|
|
9531
|
-
balance = _context.v;
|
|
9532
|
-
ed = getEdFromAssetOrThrow(asset);
|
|
9533
|
-
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
9534
|
-
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
9535
|
-
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9536
|
-
feeToSubtract = 0n;
|
|
9537
|
-
if (!paysOriginInSendingAsset) {
|
|
9538
|
-
_context.n = 4;
|
|
9539
|
-
break;
|
|
9540
|
-
}
|
|
9541
|
-
_context.n = 2;
|
|
9542
9439
|
return getOriginXcmFee({
|
|
9543
9440
|
api: api,
|
|
9544
9441
|
buildTx: buildTx,
|
|
@@ -9547,58 +9444,157 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
9547
9444
|
sender: sender,
|
|
9548
9445
|
feeAsset: feeAsset,
|
|
9549
9446
|
version: version,
|
|
9550
|
-
currency:
|
|
9551
|
-
amount: amount
|
|
9552
|
-
}),
|
|
9447
|
+
currency: feeCurrency,
|
|
9553
9448
|
disableFallback: false
|
|
9554
9449
|
});
|
|
9555
|
-
case
|
|
9450
|
+
case 1:
|
|
9556
9451
|
_yield$getOriginXcmFe = _context.v;
|
|
9557
9452
|
fee = _yield$getOriginXcmFe.fee;
|
|
9558
9453
|
if (!(fee === undefined)) {
|
|
9559
|
-
_context.n =
|
|
9454
|
+
_context.n = 2;
|
|
9560
9455
|
break;
|
|
9561
9456
|
}
|
|
9562
9457
|
throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
|
|
9563
|
-
case
|
|
9564
|
-
|
|
9565
|
-
case 4:
|
|
9566
|
-
transferable = balance - ed - feeToSubtract;
|
|
9567
|
-
return _context.a(2, transferable > 0n ? transferable : 0n);
|
|
9458
|
+
case 2:
|
|
9459
|
+
return _context.a(2, fee);
|
|
9568
9460
|
}
|
|
9569
9461
|
}, _callee);
|
|
9570
9462
|
}));
|
|
9571
|
-
return function
|
|
9463
|
+
return function getOriginFeeOrThrow(_x, _x2) {
|
|
9572
9464
|
return _ref2.apply(this, arguments);
|
|
9573
9465
|
};
|
|
9574
9466
|
}();
|
|
9467
|
+
var computeTransferableAmount = /*#__PURE__*/function () {
|
|
9468
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
|
|
9469
|
+
var balance, transferable;
|
|
9470
|
+
return _regenerator().w(function (_context2) {
|
|
9471
|
+
while (1) switch (_context2.n) {
|
|
9472
|
+
case 0:
|
|
9473
|
+
_context2.n = 1;
|
|
9474
|
+
return getAssetBalanceInternal({
|
|
9475
|
+
api: api,
|
|
9476
|
+
address: sender,
|
|
9477
|
+
chain: chain,
|
|
9478
|
+
asset: asset
|
|
9479
|
+
});
|
|
9480
|
+
case 1:
|
|
9481
|
+
balance = _context2.v;
|
|
9482
|
+
transferable = balance - getEdFromAssetOrThrow(asset) - fee;
|
|
9483
|
+
return _context2.a(2, transferable > 0n ? transferable : 0n);
|
|
9484
|
+
}
|
|
9485
|
+
}, _callee2);
|
|
9486
|
+
}));
|
|
9487
|
+
return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
|
|
9488
|
+
return _ref3.apply(this, arguments);
|
|
9489
|
+
};
|
|
9490
|
+
}();
|
|
9491
|
+
var getTransferableAmountForAsset = /*#__PURE__*/function () {
|
|
9492
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
|
|
9493
|
+
var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
|
|
9494
|
+
return _regenerator().w(function (_context3) {
|
|
9495
|
+
while (1) switch (_context3.n) {
|
|
9496
|
+
case 0:
|
|
9497
|
+
api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
|
|
9498
|
+
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
9499
|
+
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9500
|
+
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
9501
|
+
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
9502
|
+
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9503
|
+
if (!paysOriginInSendingAsset) {
|
|
9504
|
+
_context3.n = 2;
|
|
9505
|
+
break;
|
|
9506
|
+
}
|
|
9507
|
+
_context3.n = 1;
|
|
9508
|
+
return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9509
|
+
amount: amount
|
|
9510
|
+
}));
|
|
9511
|
+
case 1:
|
|
9512
|
+
_t = _context3.v;
|
|
9513
|
+
_context3.n = 3;
|
|
9514
|
+
break;
|
|
9515
|
+
case 2:
|
|
9516
|
+
_t = 0n;
|
|
9517
|
+
case 3:
|
|
9518
|
+
fee = _t;
|
|
9519
|
+
return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
|
|
9520
|
+
}
|
|
9521
|
+
}, _callee3);
|
|
9522
|
+
}));
|
|
9523
|
+
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
9524
|
+
return _ref4.apply(this, arguments);
|
|
9525
|
+
};
|
|
9526
|
+
}();
|
|
9527
|
+
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
9528
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
9529
|
+
var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
|
|
9530
|
+
return _regenerator().w(function (_context4) {
|
|
9531
|
+
while (1) switch (_context4.n) {
|
|
9532
|
+
case 0:
|
|
9533
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
9534
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
9535
|
+
_context4.n = 1;
|
|
9536
|
+
return getOriginFeeOrThrow(options, currency);
|
|
9537
|
+
case 1:
|
|
9538
|
+
fee = _context4.v;
|
|
9539
|
+
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
9540
|
+
return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
|
|
9541
|
+
})));
|
|
9542
|
+
}
|
|
9543
|
+
}, _callee4);
|
|
9544
|
+
}));
|
|
9545
|
+
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
9546
|
+
return _ref5.apply(this, arguments);
|
|
9547
|
+
};
|
|
9548
|
+
}();
|
|
9549
|
+
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
9550
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
9551
|
+
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
9552
|
+
return _regenerator().w(function (_context5) {
|
|
9553
|
+
while (1) switch (_context5.n) {
|
|
9554
|
+
case 0:
|
|
9555
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
9556
|
+
validateAddress(api, sender, chain, false);
|
|
9557
|
+
assertNotRawAssets(currency);
|
|
9558
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
9559
|
+
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9560
|
+
currency: currency
|
|
9561
|
+
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9562
|
+
currency: currency
|
|
9563
|
+
}), resolvedFeeAsset));
|
|
9564
|
+
}
|
|
9565
|
+
}, _callee5);
|
|
9566
|
+
}));
|
|
9567
|
+
return function getTransferableAmountInternal(_x10) {
|
|
9568
|
+
return _ref6.apply(this, arguments);
|
|
9569
|
+
};
|
|
9570
|
+
}();
|
|
9575
9571
|
var getTransferableAmount = /*#__PURE__*/function () {
|
|
9576
|
-
var
|
|
9572
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
|
|
9577
9573
|
var api;
|
|
9578
|
-
return _regenerator().w(function (
|
|
9579
|
-
while (1) switch (
|
|
9574
|
+
return _regenerator().w(function (_context6) {
|
|
9575
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
9580
9576
|
case 0:
|
|
9581
9577
|
api = options.api;
|
|
9582
9578
|
api.disconnectAllowed = false;
|
|
9583
|
-
|
|
9584
|
-
|
|
9579
|
+
_context6.p = 1;
|
|
9580
|
+
_context6.n = 2;
|
|
9585
9581
|
return getTransferableAmountInternal(options);
|
|
9586
9582
|
case 2:
|
|
9587
|
-
return
|
|
9583
|
+
return _context6.a(2, _context6.v);
|
|
9588
9584
|
case 3:
|
|
9589
|
-
|
|
9585
|
+
_context6.p = 3;
|
|
9590
9586
|
api.disconnectAllowed = true;
|
|
9591
|
-
|
|
9587
|
+
_context6.n = 4;
|
|
9592
9588
|
return api.disconnect();
|
|
9593
9589
|
case 4:
|
|
9594
|
-
return
|
|
9590
|
+
return _context6.f(3);
|
|
9595
9591
|
case 5:
|
|
9596
|
-
return
|
|
9592
|
+
return _context6.a(2);
|
|
9597
9593
|
}
|
|
9598
|
-
},
|
|
9594
|
+
}, _callee6, null, [[1,, 3, 5]]);
|
|
9599
9595
|
}));
|
|
9600
|
-
return function getTransferableAmount(
|
|
9601
|
-
return
|
|
9596
|
+
return function getTransferableAmount(_x11) {
|
|
9597
|
+
return _ref7.apply(this, arguments);
|
|
9602
9598
|
};
|
|
9603
9599
|
}();
|
|
9604
9600
|
|
|
@@ -9791,6 +9787,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9791
9787
|
paraIdTo,
|
|
9792
9788
|
sender,
|
|
9793
9789
|
ahAddress,
|
|
9790
|
+
overriddenAsset,
|
|
9791
|
+
overriddenAssets,
|
|
9794
9792
|
buildRefundInstruction,
|
|
9795
9793
|
hopFees,
|
|
9796
9794
|
destFee,
|
|
@@ -9802,6 +9800,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9802
9800
|
asset,
|
|
9803
9801
|
allOfSelector,
|
|
9804
9802
|
depositInstruction,
|
|
9803
|
+
localizeFilterAsset,
|
|
9805
9804
|
assetsFilter,
|
|
9806
9805
|
isAssetEthereumNative,
|
|
9807
9806
|
buyExecutionAmount,
|
|
@@ -9822,7 +9821,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9822
9821
|
destFee: 0n
|
|
9823
9822
|
};
|
|
9824
9823
|
origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, options = context.options;
|
|
9825
|
-
destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress;
|
|
9824
|
+
destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, overriddenAsset = options.overriddenAsset;
|
|
9825
|
+
overriddenAssets = Array.isArray(overriddenAsset) ? overriddenAsset : null;
|
|
9826
9826
|
buildRefundInstruction = function buildRefundInstruction() {
|
|
9827
9827
|
if (!sender || isSubBridge) return null;
|
|
9828
9828
|
var resolveRefundAddress = function resolveRefundAddress() {
|
|
@@ -9869,8 +9869,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9869
9869
|
depositInstruction = {
|
|
9870
9870
|
DepositAsset: {
|
|
9871
9871
|
assets: {
|
|
9872
|
-
Wild: assetCount > 1 ? allOfSelector : {
|
|
9873
|
-
AllCounted:
|
|
9872
|
+
Wild: assetCount > 1 && !overriddenAssets ? allOfSelector : {
|
|
9873
|
+
AllCounted: assetCount
|
|
9874
9874
|
}
|
|
9875
9875
|
},
|
|
9876
9876
|
beneficiary: createBeneficiaryLocation({
|
|
@@ -9880,9 +9880,18 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9880
9880
|
})
|
|
9881
9881
|
}
|
|
9882
9882
|
};
|
|
9883
|
+
localizeFilterAsset = function localizeFilterAsset(amount, location) {
|
|
9884
|
+
return createAsset(version, amount, normalizeLocation(localizeLocationImpl(origin.api, reserve.chain, location), version));
|
|
9885
|
+
};
|
|
9883
9886
|
assetsFilter = [];
|
|
9884
|
-
if (
|
|
9885
|
-
|
|
9887
|
+
if (overriddenAssets) {
|
|
9888
|
+
assetsFilter.push.apply(assetsFilter, _toConsumableArray(overriddenAssets.map(function (asset) {
|
|
9889
|
+
return localizeFilterAsset(asset.fun.Fungible, extractAssetLocation(asset));
|
|
9890
|
+
})));
|
|
9891
|
+
} else {
|
|
9892
|
+
if (!isRelayAsset && !isExternalChain(dest.chain)) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocationImpl(origin.api, reserve.chain, RELAY_LOCATION)));
|
|
9893
|
+
assetsFilter.push(localizeFilterAsset(assetInfo.amount, assetInfo.location));
|
|
9894
|
+
}
|
|
9886
9895
|
isAssetEthereumNative = deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), getEthereumJunction(origin.api, origin.chain, false).GlobalConsensus);
|
|
9887
9896
|
if (!(isSubBridge || bridgeHopChain || origin.chain !== reserve.chain && dest.chain !== reserve.chain)) {
|
|
9888
9897
|
_context.n = 6;
|
|
@@ -10258,44 +10267,58 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
|
|
|
10258
10267
|
return totalHopFee + destFee;
|
|
10259
10268
|
};
|
|
10260
10269
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
10261
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
10262
|
-
var
|
|
10263
|
-
|
|
10264
|
-
|
|
10270
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
10271
|
+
var _destAssets$find;
|
|
10272
|
+
var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, isTypeAndThenMethod, verifyAsset, results;
|
|
10273
|
+
return _regenerator().w(function (_context2) {
|
|
10274
|
+
while (1) switch (_context2.n) {
|
|
10265
10275
|
case 0:
|
|
10266
10276
|
api = options.api, buildTx = options.buildTx, origin = options.origin, destination = options.destination, currency = options.currency, sender = options.sender, recipient = options.recipient, feeAsset = options.feeAsset, version = options.version;
|
|
10267
10277
|
if (!isExternalChain(destination)) {
|
|
10268
|
-
|
|
10278
|
+
_context2.n = 1;
|
|
10269
10279
|
break;
|
|
10270
10280
|
}
|
|
10271
|
-
return
|
|
10281
|
+
return _context2.a(2, true);
|
|
10272
10282
|
case 1:
|
|
10273
10283
|
validateAddress(api, recipient, destination, true);
|
|
10274
10284
|
isSubBridge = isSubstrateBridge(origin, destination);
|
|
10275
10285
|
if (!isSubBridge) {
|
|
10276
|
-
|
|
10286
|
+
_context2.n = 2;
|
|
10277
10287
|
break;
|
|
10278
10288
|
}
|
|
10279
10289
|
throw new ScenarioNotSupportedError('Unable to verify the existential deposit for substrate bridge scenarios');
|
|
10280
10290
|
case 2:
|
|
10291
|
+
assertNotRawAssets(currency);
|
|
10292
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
10281
10293
|
destApi = api.clone();
|
|
10282
|
-
|
|
10294
|
+
_context2.n = 3;
|
|
10283
10295
|
return destApi.init(destination);
|
|
10284
10296
|
case 3:
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10297
|
+
resolvedAssets = Array.isArray(currency) ? resolveCurrency(api, currency, resolvedFeeAsset, origin, destination).assets.map(function (asset, index) {
|
|
10298
|
+
return {
|
|
10299
|
+
selector: currency[index],
|
|
10300
|
+
paysDestFee: !!asset.isFeeAsset
|
|
10301
|
+
};
|
|
10302
|
+
}) : [{
|
|
10303
|
+
selector: currency,
|
|
10304
|
+
paysDestFee: true
|
|
10305
|
+
}];
|
|
10306
|
+
destAssets = resolvedAssets.map(function (_ref2) {
|
|
10307
|
+
var selector = _ref2.selector,
|
|
10308
|
+
paysDestFee = _ref2.paysDestFee;
|
|
10309
|
+
var destAsset = api.findAssetOnDestOrThrow(origin, destination, selector);
|
|
10310
|
+
return {
|
|
10311
|
+
destAsset: destAsset,
|
|
10312
|
+
amount: abstractDecimals(selector.amount, destAsset.decimals, api),
|
|
10313
|
+
paysDestFee: paysDestFee
|
|
10314
|
+
};
|
|
10295
10315
|
});
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10316
|
+
_destAssets = _slicedToArray(destAssets, 1), firstAsset = _destAssets[0];
|
|
10317
|
+
feeElement = (_destAssets$find = destAssets.find(function (_ref3) {
|
|
10318
|
+
var paysDestFee = _ref3.paysDestFee;
|
|
10319
|
+
return paysDestFee;
|
|
10320
|
+
})) !== null && _destAssets$find !== void 0 ? _destAssets$find : firstAsset;
|
|
10321
|
+
_context2.n = 4;
|
|
10299
10322
|
return getXcmFeeInternal({
|
|
10300
10323
|
api: api,
|
|
10301
10324
|
buildTx: buildTx,
|
|
@@ -10303,59 +10326,84 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
10303
10326
|
destination: destination,
|
|
10304
10327
|
sender: sender,
|
|
10305
10328
|
recipient: recipient,
|
|
10306
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
10307
|
-
amount: amount
|
|
10329
|
+
currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
10330
|
+
amount: feeElement.amount
|
|
10308
10331
|
}),
|
|
10309
10332
|
version: version,
|
|
10310
10333
|
feeAsset: feeAsset,
|
|
10311
10334
|
disableFallback: false
|
|
10312
10335
|
});
|
|
10313
|
-
case
|
|
10314
|
-
xcmFeeResult =
|
|
10336
|
+
case 4:
|
|
10337
|
+
xcmFeeResult = _context2.v;
|
|
10315
10338
|
dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
10316
10339
|
if (!dryRunError) {
|
|
10317
|
-
|
|
10340
|
+
_context2.n = 5;
|
|
10318
10341
|
break;
|
|
10319
10342
|
}
|
|
10320
10343
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
10321
|
-
case
|
|
10344
|
+
case 5:
|
|
10322
10345
|
erroredHop = hops.find(function (hop) {
|
|
10323
10346
|
return hop.result.dryRunError;
|
|
10324
10347
|
});
|
|
10325
10348
|
hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
|
|
10326
10349
|
if (!hopError) {
|
|
10327
|
-
|
|
10350
|
+
_context2.n = 6;
|
|
10328
10351
|
break;
|
|
10329
10352
|
}
|
|
10330
10353
|
throw new DryRunFailedError(hopError, erroredHop.chain);
|
|
10331
|
-
case
|
|
10354
|
+
case 6:
|
|
10332
10355
|
if (!destDryRunError) {
|
|
10333
|
-
|
|
10356
|
+
_context2.n = 7;
|
|
10334
10357
|
break;
|
|
10335
10358
|
}
|
|
10336
10359
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
10337
|
-
case
|
|
10338
|
-
isUnableToCompute = !isSymbolMatch(normalizeSymbol(destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
10360
|
+
case 7:
|
|
10361
|
+
isUnableToCompute = !isSymbolMatch(normalizeSymbol(feeElement.destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
10339
10362
|
if (!isUnableToCompute) {
|
|
10340
|
-
|
|
10363
|
+
_context2.n = 8;
|
|
10341
10364
|
break;
|
|
10342
10365
|
}
|
|
10343
10366
|
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
10344
|
-
case
|
|
10345
|
-
|
|
10367
|
+
case 8:
|
|
10368
|
+
_context2.n = 9;
|
|
10346
10369
|
return buildTx();
|
|
10347
|
-
case
|
|
10348
|
-
tx =
|
|
10349
|
-
totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
|
|
10370
|
+
case 9:
|
|
10371
|
+
tx = _context2.v;
|
|
10350
10372
|
method = api.getMethod(tx);
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10373
|
+
isTypeAndThenMethod = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen';
|
|
10374
|
+
verifyAsset = /*#__PURE__*/function () {
|
|
10375
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
|
|
10376
|
+
var destAsset, amount, paysDestFee, ed, balance, feeToSubtract;
|
|
10377
|
+
return _regenerator().w(function (_context) {
|
|
10378
|
+
while (1) switch (_context.n) {
|
|
10379
|
+
case 0:
|
|
10380
|
+
destAsset = _ref4.destAsset, amount = _ref4.amount, paysDestFee = _ref4.paysDestFee;
|
|
10381
|
+
ed = getEdFromAssetOrThrow(destAsset);
|
|
10382
|
+
_context.n = 1;
|
|
10383
|
+
return getAssetBalanceInternal({
|
|
10384
|
+
address: recipient,
|
|
10385
|
+
chain: destination,
|
|
10386
|
+
api: destApi,
|
|
10387
|
+
asset: destAsset
|
|
10388
|
+
});
|
|
10389
|
+
case 1:
|
|
10390
|
+
balance = _context.v;
|
|
10391
|
+
feeToSubtract = isTypeAndThenMethod ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee ? destFee : 0n;
|
|
10392
|
+
return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
|
|
10393
|
+
}
|
|
10394
|
+
}, _callee);
|
|
10395
|
+
}));
|
|
10396
|
+
return function verifyAsset(_x2) {
|
|
10397
|
+
return _ref5.apply(this, arguments);
|
|
10398
|
+
};
|
|
10399
|
+
}();
|
|
10400
|
+
_context2.n = 10;
|
|
10401
|
+
return Promise.all(destAssets.map(verifyAsset));
|
|
10402
|
+
case 10:
|
|
10403
|
+
results = _context2.v;
|
|
10404
|
+
return _context2.a(2, results.every(Boolean));
|
|
10357
10405
|
}
|
|
10358
|
-
},
|
|
10406
|
+
}, _callee2);
|
|
10359
10407
|
}));
|
|
10360
10408
|
return function verifyEdOnDestinationInternal(_x) {
|
|
10361
10409
|
return _ref.apply(this, arguments);
|
|
@@ -10499,22 +10547,23 @@ var createAssetsFilter = function createAssetsFilter(asset, version) {
|
|
|
10499
10547
|
};
|
|
10500
10548
|
|
|
10501
10549
|
var prepareExecuteContext = function prepareExecuteContext(_ref) {
|
|
10502
|
-
var
|
|
10550
|
+
var api = _ref.api,
|
|
10551
|
+
chain = _ref.chain,
|
|
10503
10552
|
destChain = _ref.destChain,
|
|
10504
10553
|
assetInfo = _ref.assetInfo,
|
|
10505
10554
|
feeAssetInfo = _ref.feeAssetInfo,
|
|
10506
10555
|
originFee = _ref.fees.originFee,
|
|
10507
10556
|
version = _ref.version;
|
|
10508
10557
|
var amount = assetInfo.amount;
|
|
10509
|
-
var reserveChain =
|
|
10558
|
+
var reserveChain = getAssetReserveChainImpl(api, chain, assetInfo.location);
|
|
10510
10559
|
var asset = createAsset(version, amount, assetInfo.location);
|
|
10511
|
-
var assetLocalized = createAsset(version, amount,
|
|
10560
|
+
var assetLocalized = createAsset(version, amount, localizeLocationImpl(api, chain, assetInfo.location));
|
|
10512
10561
|
var assetLocalizedToDest = createAsset(version, amount, localizeLocation(destChain, assetInfo.location));
|
|
10513
|
-
var assetLocalizedToReserve = createAsset(version, amount,
|
|
10562
|
+
var assetLocalizedToReserve = createAsset(version, amount, localizeLocationImpl(api, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, assetInfo.location));
|
|
10514
10563
|
var feeAsset = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, feeAssetInfo.location) : undefined;
|
|
10515
|
-
var feeAssetLocalized = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee,
|
|
10564
|
+
var feeAssetLocalized = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocationImpl(api, chain, feeAssetInfo.location)) : undefined;
|
|
10516
10565
|
var feeAssetLocalizedToDest = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocation(destChain, feeAssetInfo.location)) : undefined;
|
|
10517
|
-
var feeAssetLocalizedToReserve = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee,
|
|
10566
|
+
var feeAssetLocalizedToReserve = feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? createAsset(version, originFee, localizeLocationImpl(api, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, feeAssetInfo.location)) : undefined;
|
|
10518
10567
|
return {
|
|
10519
10568
|
amount: amount,
|
|
10520
10569
|
asset: asset,
|
|
@@ -10641,7 +10690,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
|
|
|
10641
10690
|
mainInstructions = [{
|
|
10642
10691
|
InitiateTeleport: {
|
|
10643
10692
|
assets: routingAssetsFilter,
|
|
10644
|
-
dest: getChainLocation(chain, reserveChain),
|
|
10693
|
+
dest: getChainLocation(chain, reserveChain, api._customCtx),
|
|
10645
10694
|
xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - originFeeDeduction), undefined, true, forceBuyExecution)), _toConsumableArray(resolvedDepositInstruction))
|
|
10646
10695
|
}
|
|
10647
10696
|
}];
|
|
@@ -10651,7 +10700,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
|
|
|
10651
10700
|
mainInstructions = [{
|
|
10652
10701
|
InitiateReserveWithdraw: {
|
|
10653
10702
|
assets: routingAssetsFilter,
|
|
10654
|
-
reserve: getChainLocation(chain, reserveChain),
|
|
10703
|
+
reserve: getChainLocation(chain, reserveChain, api._customCtx),
|
|
10655
10704
|
xcm: [].concat(_toConsumableArray(createPayFees(version, // Decrease amount by 2 units because for some reason polkadot withdraws 2 units less
|
|
10656
10705
|
// than requested, so we need to account for that
|
|
10657
10706
|
hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - 2n), undefined, true, forceBuyExecution)), _toConsumableArray(resolvedDepositInstruction))
|
|
@@ -11744,34 +11793,28 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Chain) {
|
|
|
11744
11793
|
while (1) switch (_context.n) {
|
|
11745
11794
|
case 0:
|
|
11746
11795
|
api = options.api, assetInfo = options.assetInfo, feeAssetInfo = options.feeAssetInfo, overriddenAsset = options.overriddenAsset;
|
|
11747
|
-
if (!feeAssetInfo) {
|
|
11748
|
-
_context.n =
|
|
11749
|
-
break;
|
|
11750
|
-
}
|
|
11751
|
-
if (!overriddenAsset) {
|
|
11752
|
-
_context.n = 1;
|
|
11796
|
+
if (!(feeAssetInfo && !overriddenAsset)) {
|
|
11797
|
+
_context.n = 3;
|
|
11753
11798
|
break;
|
|
11754
11799
|
}
|
|
11755
|
-
throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
|
|
11756
|
-
case 1:
|
|
11757
11800
|
if (!isSymbolMatch(assetInfo.symbol, 'KSM')) {
|
|
11758
|
-
_context.n =
|
|
11801
|
+
_context.n = 1;
|
|
11759
11802
|
break;
|
|
11760
11803
|
}
|
|
11761
11804
|
return _context.a(2, transferPolkadotXcm(options));
|
|
11762
|
-
case
|
|
11805
|
+
case 1:
|
|
11763
11806
|
isNativeAsset = isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol(api));
|
|
11764
11807
|
isNativeFeeAsset = isSymbolMatch(feeAssetInfo.symbol, this.getNativeAssetSymbol(api));
|
|
11765
11808
|
if (!(!isNativeAsset || !isNativeFeeAsset)) {
|
|
11766
|
-
_context.n =
|
|
11809
|
+
_context.n = 3;
|
|
11767
11810
|
break;
|
|
11768
11811
|
}
|
|
11769
11812
|
_t = api;
|
|
11770
|
-
_context.n =
|
|
11813
|
+
_context.n = 2;
|
|
11771
11814
|
return handleExecuteTransfer(options);
|
|
11772
|
-
case
|
|
11815
|
+
case 2:
|
|
11773
11816
|
return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
|
|
11774
|
-
case
|
|
11817
|
+
case 3:
|
|
11775
11818
|
return _context.a(2, transferPolkadotXcm(options));
|
|
11776
11819
|
}
|
|
11777
11820
|
}, _callee, this);
|
|
@@ -11947,34 +11990,28 @@ var Hydration = /*#__PURE__*/function (_Chain) {
|
|
|
11947
11990
|
while (1) switch (_context.n) {
|
|
11948
11991
|
case 0:
|
|
11949
11992
|
destination = input.destination, asset = input.assetInfo, feeAsset = input.feeAssetInfo, overriddenAsset = input.overriddenAsset, api = input.api;
|
|
11950
|
-
if (!feeAsset) {
|
|
11951
|
-
_context.n =
|
|
11952
|
-
break;
|
|
11953
|
-
}
|
|
11954
|
-
if (!overriddenAsset) {
|
|
11955
|
-
_context.n = 1;
|
|
11993
|
+
if (!(feeAsset && !overriddenAsset)) {
|
|
11994
|
+
_context.n = 2;
|
|
11956
11995
|
break;
|
|
11957
11996
|
}
|
|
11958
|
-
throw new InvalidCurrencyError('Cannot use overridden assets with XCM execute');
|
|
11959
|
-
case 1:
|
|
11960
11997
|
isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol(api));
|
|
11961
11998
|
isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol(api));
|
|
11962
11999
|
if (!(!isNativeAsset || !isNativeFeeAsset)) {
|
|
11963
|
-
_context.n =
|
|
12000
|
+
_context.n = 2;
|
|
11964
12001
|
break;
|
|
11965
12002
|
}
|
|
11966
12003
|
_t = api;
|
|
11967
|
-
_context.n =
|
|
12004
|
+
_context.n = 1;
|
|
11968
12005
|
return handleExecuteTransfer(input);
|
|
11969
|
-
case
|
|
12006
|
+
case 1:
|
|
11970
12007
|
return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
|
|
11971
|
-
case
|
|
12008
|
+
case 2:
|
|
11972
12009
|
if (!(isMoonbeamWhAsset(asset.location) && destination === 'Moonbeam')) {
|
|
11973
|
-
_context.n =
|
|
12010
|
+
_context.n = 3;
|
|
11974
12011
|
break;
|
|
11975
12012
|
}
|
|
11976
12013
|
return _context.a(2, this.transferMoonbeamWhAsset(input));
|
|
11977
|
-
case
|
|
12014
|
+
case 3:
|
|
11978
12015
|
return _context.a(2, transferPolkadotXcm(input));
|
|
11979
12016
|
}
|
|
11980
12017
|
}, _callee, this);
|
|
@@ -13750,12 +13787,17 @@ var getAssetReserveChainImpl = function getAssetReserveChainImpl(api, chain, ass
|
|
|
13750
13787
|
};
|
|
13751
13788
|
|
|
13752
13789
|
var getChainVersion = function getChainVersion(api, chain) {
|
|
13753
|
-
var _api$_customCtx$custo;
|
|
13754
13790
|
if (isRelayChain(chain) || isExternalChain(chain)) {
|
|
13755
13791
|
return Version.V5;
|
|
13756
13792
|
}
|
|
13757
|
-
|
|
13758
|
-
|
|
13793
|
+
if (isCustomChain(chain)) {
|
|
13794
|
+
var _api$_customCtx$custo;
|
|
13795
|
+
var entry = (_api$_customCtx$custo = api._customCtx.customChains) === null || _api$_customCtx$custo === void 0 ? void 0 : _api$_customCtx$custo[chain];
|
|
13796
|
+
if (!entry) {
|
|
13797
|
+
throw new CustomChainInvalidError("Custom chain '".concat(chain, "' is not registered."));
|
|
13798
|
+
}
|
|
13799
|
+
return entry.xcmVersion;
|
|
13800
|
+
}
|
|
13759
13801
|
return getChain(chain).version;
|
|
13760
13802
|
};
|
|
13761
13803
|
|
|
@@ -13994,12 +14036,23 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
|
|
|
13994
14036
|
};
|
|
13995
14037
|
var overrideTxAmount = /*#__PURE__*/function () {
|
|
13996
14038
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount, relative) {
|
|
13997
|
-
var modifiedBuilder, _yield$modifiedBuilde, tx;
|
|
14039
|
+
var currency, overrideAmount, modifiedBuilder, _yield$modifiedBuilde, tx;
|
|
13998
14040
|
return _regenerator().w(function (_context) {
|
|
13999
14041
|
while (1) switch (_context.n) {
|
|
14000
14042
|
case 0:
|
|
14001
|
-
|
|
14002
|
-
|
|
14043
|
+
currency = options.currency;
|
|
14044
|
+
assertNotRawAssets(currency);
|
|
14045
|
+
overrideAmount = function overrideAmount(item) {
|
|
14046
|
+
return computeOverridenAmount(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
14047
|
+
currency: item
|
|
14048
|
+
}), amount, relative);
|
|
14049
|
+
};
|
|
14050
|
+
modifiedBuilder = builder.currency(Array.isArray(currency) ? currency.map(function (item) {
|
|
14051
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
14052
|
+
amount: overrideAmount(item)
|
|
14053
|
+
});
|
|
14054
|
+
}) : _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
14055
|
+
amount: overrideAmount(currency)
|
|
14003
14056
|
}));
|
|
14004
14057
|
_context.n = 1;
|
|
14005
14058
|
return modifiedBuilder['buildInternal']();
|
|
@@ -14860,4 +14913,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
|
|
|
14860
14913
|
};
|
|
14861
14914
|
};
|
|
14862
14915
|
|
|
14863
|
-
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
|
|
14916
|
+
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertNotRawAssets, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
|