@paraspell/sdk-core 12.8.3 → 12.8.4
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 +298 -176
- package/dist/index.mjs +1724 -1314
- package/package.json +12 -4
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow,
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isTAsset, findAssetInfoOrThrow, findAssetInfo, findNativeAssetInfoOrThrow, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isOverrideLocationSpecifier, extractAssetLocation, getRelayChainSymbol, isSymbolSpecifier, normalizeLocation, getExistentialDepositOrThrow, isSymbolMatch, getNativeAssetSymbol, getEdFromAssetOrThrow, hasDryRunSupport, findNativeAssetInfo, isAssetXcEqual, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, isHex, getContract, createPublicClient, http, parseUnits as parseUnits$1, formatUnits as formatUnits$1, pad, toHex, getAddress, concat, keccak256 } from 'viem';
|
|
6
|
-
import { isTLocation, replaceBigInt, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, Version, isExternalChain, isSnowbridge, isBridge,
|
|
6
|
+
import { isTLocation, replaceBigInt, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, Version, isExternalChain, isSnowbridge, isBridge, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isTrustedChain } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { mainnet, sepolia, moonbeam, moonriver } from 'viem/chains';
|
|
9
9
|
import { getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets, getSupportedPalletsDetails } from '@paraspell/pallets';
|
|
@@ -227,6 +227,26 @@ function _objectSpread2(e) {
|
|
|
227
227
|
}
|
|
228
228
|
return e;
|
|
229
229
|
}
|
|
230
|
+
function _objectWithoutProperties(e, t) {
|
|
231
|
+
if (null == e) return {};
|
|
232
|
+
var o,
|
|
233
|
+
r,
|
|
234
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
235
|
+
if (Object.getOwnPropertySymbols) {
|
|
236
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
237
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
238
|
+
}
|
|
239
|
+
return i;
|
|
240
|
+
}
|
|
241
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
242
|
+
if (null == r) return {};
|
|
243
|
+
var t = {};
|
|
244
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
245
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
246
|
+
t[n] = r[n];
|
|
247
|
+
}
|
|
248
|
+
return t;
|
|
249
|
+
}
|
|
230
250
|
function _possibleConstructorReturn(t, e) {
|
|
231
251
|
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
232
252
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
@@ -488,6 +508,26 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
|
|
|
488
508
|
return _createClass(DryRunFailedError);
|
|
489
509
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
490
510
|
|
|
511
|
+
/**
|
|
512
|
+
* Error thrown when an extension is not installed.
|
|
513
|
+
*/
|
|
514
|
+
var ExtensionNotInstalledError = /*#__PURE__*/function (_Error) {
|
|
515
|
+
/**
|
|
516
|
+
* Constructs a new ExtensionNotInstalledError.
|
|
517
|
+
*
|
|
518
|
+
* @param message - The error message.
|
|
519
|
+
*/
|
|
520
|
+
function ExtensionNotInstalledError(message) {
|
|
521
|
+
var _this;
|
|
522
|
+
_classCallCheck(this, ExtensionNotInstalledError);
|
|
523
|
+
_this = _callSuper(this, ExtensionNotInstalledError, [message]);
|
|
524
|
+
_this.name = 'ExtensionNotInstalledError';
|
|
525
|
+
return _this;
|
|
526
|
+
}
|
|
527
|
+
_inherits(ExtensionNotInstalledError, _Error);
|
|
528
|
+
return _createClass(ExtensionNotInstalledError);
|
|
529
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
530
|
+
|
|
491
531
|
/**
|
|
492
532
|
* Error thrown when a feature or route is temporarily disabled via configuration or governance.
|
|
493
533
|
*/
|
|
@@ -1110,6 +1150,11 @@ var assertSender = function assertSender(sender) {
|
|
|
1110
1150
|
var isSenderSigner = function isSenderSigner(sender) {
|
|
1111
1151
|
return typeof sender !== 'string';
|
|
1112
1152
|
};
|
|
1153
|
+
var assertSwapSupport = function assertSwapSupport(options) {
|
|
1154
|
+
if (options) {
|
|
1155
|
+
throw new UnsupportedOperationError('Swap options are not supported by this operation. Please open an issue if you would like to see this supported.');
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1113
1158
|
|
|
1114
1159
|
var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
|
|
1115
1160
|
var hasGlobalConsensusJunction = hasJunction(assetLocation, 'GlobalConsensus');
|
|
@@ -1390,352 +1435,707 @@ var claimAssets = /*#__PURE__*/function () {
|
|
|
1390
1435
|
};
|
|
1391
1436
|
}();
|
|
1392
1437
|
|
|
1393
|
-
var
|
|
1394
|
-
return
|
|
1395
|
-
};
|
|
1396
|
-
var isBridgeHub = function isBridgeHub(chain) {
|
|
1397
|
-
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
1398
|
-
};
|
|
1399
|
-
var isPeople = function isPeople(chain) {
|
|
1400
|
-
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
1401
|
-
};
|
|
1402
|
-
var isSystemPara = function isSystemPara(chain) {
|
|
1403
|
-
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
1404
|
-
};
|
|
1405
|
-
var mul = function mul(v, num) {
|
|
1406
|
-
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
1407
|
-
return v * num / den;
|
|
1438
|
+
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
1439
|
+
return assetCheckEnabled ? findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null) : null;
|
|
1408
1440
|
};
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
var sysParaDest = isSystemPara(dest);
|
|
1414
|
-
var relayToPara = relayOrigin && !relayDest;
|
|
1415
|
-
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
1416
|
-
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
1417
|
-
if (sysParaToPara) return raw * 40n;
|
|
1418
|
-
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
1419
|
-
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
1420
|
-
return 150000000000000000n;
|
|
1441
|
+
|
|
1442
|
+
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
1443
|
+
if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
1444
|
+
throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
|
|
1421
1445
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1446
|
+
var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
|
|
1447
|
+
var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
|
|
1448
|
+
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
1449
|
+
throwUnsupportedCurrency(feeAsset, origin);
|
|
1450
|
+
}
|
|
1451
|
+
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
1425
1452
|
};
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1453
|
+
|
|
1454
|
+
var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
1455
|
+
var _findAssetInfoOnDest;
|
|
1456
|
+
var api = _ref.api,
|
|
1457
|
+
tx = _ref.tx,
|
|
1458
|
+
originChain = _ref.originChain,
|
|
1459
|
+
currentChain = _ref.currentChain,
|
|
1460
|
+
destination = _ref.destination,
|
|
1461
|
+
swapConfig = _ref.swapConfig,
|
|
1462
|
+
asset = _ref.asset,
|
|
1463
|
+
hasPassedExchange = _ref.hasPassedExchange,
|
|
1464
|
+
currency = _ref.currency;
|
|
1465
|
+
var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
|
|
1466
|
+
var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
|
|
1467
|
+
if (useRelayAssetAsFee) {
|
|
1468
|
+
return findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
1469
|
+
}
|
|
1470
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
1471
|
+
return findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
1472
|
+
}
|
|
1473
|
+
return (_findAssetInfoOnDest = findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
|
|
1429
1474
|
};
|
|
1430
1475
|
|
|
1431
|
-
var
|
|
1432
|
-
var
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
case 1:
|
|
1441
|
-
_context.n = 2;
|
|
1442
|
-
return getParaEthTransferFees(ahApi, false);
|
|
1443
|
-
case 2:
|
|
1444
|
-
_yield$getParaEthTran = _context.v;
|
|
1445
|
-
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
1446
|
-
bridgeFee = _yield$getParaEthTran2[0];
|
|
1447
|
-
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
1448
|
-
nativeAsset = findNativeAssetInfoOrThrow('Mythos');
|
|
1449
|
-
_context.n = 3;
|
|
1450
|
-
return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
|
|
1451
|
-
case 3:
|
|
1452
|
-
feeConverted = _context.v;
|
|
1453
|
-
_context.n = 4;
|
|
1454
|
-
return ahApi.disconnect();
|
|
1455
|
-
case 4:
|
|
1456
|
-
if (feeConverted) {
|
|
1457
|
-
_context.n = 5;
|
|
1458
|
-
break;
|
|
1459
|
-
}
|
|
1460
|
-
throw new UnableToComputeError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
|
|
1461
|
-
case 5:
|
|
1462
|
-
return _context.a(2, padValueBy(feeConverted, 10));
|
|
1476
|
+
var getEthereumJunction = function getEthereumJunction(chain) {
|
|
1477
|
+
var useBigInt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1478
|
+
var relayChain = getRelayChainOf(chain);
|
|
1479
|
+
var isTestnet = relayChain === 'Westend' || relayChain === 'Paseo';
|
|
1480
|
+
var chainId = isTestnet ? ETH_TESTNET_PARA_ID : ETH_MAINNET_PARA_ID;
|
|
1481
|
+
return {
|
|
1482
|
+
GlobalConsensus: {
|
|
1483
|
+
Ethereum: {
|
|
1484
|
+
chainId: useBigInt ? BigInt(chainId) : chainId
|
|
1463
1485
|
}
|
|
1464
|
-
}
|
|
1465
|
-
}));
|
|
1466
|
-
return function getMythosOriginFee(_x) {
|
|
1467
|
-
return _ref.apply(this, arguments);
|
|
1486
|
+
}
|
|
1468
1487
|
};
|
|
1469
|
-
}();
|
|
1470
|
-
|
|
1471
|
-
var AssetHubPolkadot$1 = {
|
|
1472
|
-
name: "Asset Hub",
|
|
1473
|
-
info: "PolkadotAssetHub",
|
|
1474
|
-
paraId: 1000,
|
|
1475
|
-
providers: [
|
|
1476
|
-
{
|
|
1477
|
-
name: "Dwellir",
|
|
1478
|
-
endpoint: "wss://asset-hub-polkadot-rpc.n.dwellir.com"
|
|
1479
|
-
},
|
|
1480
|
-
{
|
|
1481
|
-
name: "Dwellir Tunisia",
|
|
1482
|
-
endpoint: "wss://statemint-rpc-tn.dwellir.com"
|
|
1483
|
-
},
|
|
1484
|
-
{
|
|
1485
|
-
name: "IBP1",
|
|
1486
|
-
endpoint: "wss://asset-hub-polkadot.ibp.network"
|
|
1487
|
-
},
|
|
1488
|
-
{
|
|
1489
|
-
name: "IBP2",
|
|
1490
|
-
endpoint: "wss://asset-hub-polkadot.dotters.network"
|
|
1491
|
-
},
|
|
1492
|
-
{
|
|
1493
|
-
name: "LuckyFriday",
|
|
1494
|
-
endpoint: "wss://rpc-asset-hub-polkadot.luckyfriday.io"
|
|
1495
|
-
},
|
|
1496
|
-
{
|
|
1497
|
-
name: "OnFinality",
|
|
1498
|
-
endpoint: "wss://statemint.api.onfinality.io/public-ws"
|
|
1499
|
-
},
|
|
1500
|
-
{
|
|
1501
|
-
name: "Parity",
|
|
1502
|
-
endpoint: "wss://polkadot-asset-hub-rpc.polkadot.io"
|
|
1503
|
-
},
|
|
1504
|
-
{
|
|
1505
|
-
name: "Permanence DAO EU",
|
|
1506
|
-
endpoint: "wss://asset-hub-polkadot.rpc.permanence.io"
|
|
1507
|
-
},
|
|
1508
|
-
{
|
|
1509
|
-
name: "RadiumBlock",
|
|
1510
|
-
endpoint: "wss://statemint.public.curie.radiumblock.co/ws"
|
|
1511
|
-
}
|
|
1512
|
-
]
|
|
1513
1488
|
};
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
endpoint: "wss://acala-rpc-1.aca-api.network"
|
|
1526
|
-
},
|
|
1527
|
-
{
|
|
1528
|
-
name: "Acala Foundation 3",
|
|
1529
|
-
endpoint: "wss://acala-rpc-3.aca-api.network/ws"
|
|
1530
|
-
},
|
|
1531
|
-
{
|
|
1532
|
-
name: "Dwellir",
|
|
1533
|
-
endpoint: "wss://acala-rpc.n.dwellir.com"
|
|
1534
|
-
},
|
|
1535
|
-
{
|
|
1536
|
-
name: "IBP1",
|
|
1537
|
-
endpoint: "wss://acala.ibp.network"
|
|
1538
|
-
},
|
|
1539
|
-
{
|
|
1540
|
-
name: "IBP2",
|
|
1541
|
-
endpoint: "wss://acala.dotters.network"
|
|
1542
|
-
}
|
|
1543
|
-
]
|
|
1489
|
+
|
|
1490
|
+
var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge) {
|
|
1491
|
+
if (!asset || isTLocation(destination) || isExternalChain(destination) || !isBridge) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
var nativeAsset = findNativeAssetInfoOrThrow(origin);
|
|
1495
|
+
var isNativeAsset = isAssetEqual(asset, nativeAsset);
|
|
1496
|
+
var isBridgedStablecoin = isStableCoinAsset(asset);
|
|
1497
|
+
if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
|
|
1498
|
+
throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
1499
|
+
}
|
|
1544
1500
|
};
|
|
1545
|
-
var
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
},
|
|
1558
|
-
{
|
|
1559
|
-
name: "IBP2",
|
|
1560
|
-
endpoint: "wss://ajuna.dotters.network"
|
|
1561
|
-
}
|
|
1562
|
-
]
|
|
1501
|
+
var validateEcosystems = function validateEcosystems(origin, destination) {
|
|
1502
|
+
if (isTLocation(destination)) return;
|
|
1503
|
+
var relayChain = getRelayChainOf(origin);
|
|
1504
|
+
var destinationToRelayChains = {
|
|
1505
|
+
Ethereum: ['Polkadot'],
|
|
1506
|
+
EthereumTestnet: ['Westend', 'Paseo']
|
|
1507
|
+
};
|
|
1508
|
+
var allowedRelayChains = destinationToRelayChains[destination];
|
|
1509
|
+
if (!allowedRelayChains) return;
|
|
1510
|
+
if (!allowedRelayChains.includes(relayChain)) {
|
|
1511
|
+
throw new InvalidCurrencyError("Destination ".concat(destination, " is only supported from following ecosystems: ").concat(allowedRelayChains.join(', '), "."));
|
|
1512
|
+
}
|
|
1563
1513
|
};
|
|
1564
|
-
var
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
]
|
|
1586
|
-
};
|
|
1587
|
-
var BifrostPolkadot$1 = {
|
|
1588
|
-
name: "Bifrost",
|
|
1589
|
-
info: "bifrost",
|
|
1590
|
-
paraId: 2030,
|
|
1591
|
-
providers: [
|
|
1592
|
-
{
|
|
1593
|
-
name: "IBP1",
|
|
1594
|
-
endpoint: "wss://bifrost-polkadot.ibp.network"
|
|
1595
|
-
},
|
|
1596
|
-
{
|
|
1597
|
-
name: "IBP2",
|
|
1598
|
-
endpoint: "wss://bifrost-polkadot.dotters.network"
|
|
1599
|
-
},
|
|
1600
|
-
{
|
|
1601
|
-
name: "Liebi",
|
|
1602
|
-
endpoint: "wss://hk.p.bifrost-rpc.liebi.com/ws"
|
|
1603
|
-
},
|
|
1604
|
-
{
|
|
1605
|
-
name: "LiebiEU",
|
|
1606
|
-
endpoint: "wss://eu.bifrost-polkadot-rpc.liebi.com/ws"
|
|
1607
|
-
}
|
|
1608
|
-
]
|
|
1609
|
-
};
|
|
1610
|
-
var BridgeHubPolkadot$1 = {
|
|
1611
|
-
name: "Bridge Hub",
|
|
1612
|
-
info: "polkadotBridgeHub",
|
|
1613
|
-
paraId: 1002,
|
|
1614
|
-
providers: [
|
|
1615
|
-
{
|
|
1616
|
-
name: "Dwellir",
|
|
1617
|
-
endpoint: "wss://bridge-hub-polkadot-rpc.n.dwellir.com"
|
|
1618
|
-
},
|
|
1619
|
-
{
|
|
1620
|
-
name: "Dwellir Tunisia",
|
|
1621
|
-
endpoint: "wss://polkadot-bridge-hub-rpc-tn.dwellir.com"
|
|
1622
|
-
},
|
|
1623
|
-
{
|
|
1624
|
-
name: "IBP1",
|
|
1625
|
-
endpoint: "wss://bridge-hub-polkadot.ibp.network"
|
|
1626
|
-
},
|
|
1627
|
-
{
|
|
1628
|
-
name: "IBP2",
|
|
1629
|
-
endpoint: "wss://bridge-hub-polkadot.dotters.network"
|
|
1630
|
-
},
|
|
1631
|
-
{
|
|
1632
|
-
name: "LuckyFriday",
|
|
1633
|
-
endpoint: "wss://rpc-bridge-hub-polkadot.luckyfriday.io"
|
|
1634
|
-
},
|
|
1635
|
-
{
|
|
1636
|
-
name: "OnFinality",
|
|
1637
|
-
endpoint: "wss://bridgehub-polkadot.api.onfinality.io/public-ws"
|
|
1638
|
-
},
|
|
1639
|
-
{
|
|
1640
|
-
name: "Parity",
|
|
1641
|
-
endpoint: "wss://polkadot-bridge-hub-rpc.polkadot.io"
|
|
1642
|
-
},
|
|
1643
|
-
{
|
|
1644
|
-
name: "RadiumBlock",
|
|
1645
|
-
endpoint: "wss://bridgehub-polkadot.public.curie.radiumblock.co/ws"
|
|
1646
|
-
}
|
|
1647
|
-
]
|
|
1514
|
+
var validateEthereumAsset = function validateEthereumAsset(origin, destination, asset) {
|
|
1515
|
+
if (!asset || !isTLocation(destination) && !isSnowbridge(origin, destination) || origin === 'Mythos') {
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
validateEcosystems(origin, destination);
|
|
1519
|
+
var ADDITIONAL_ALLOWED_LOCATIONS = [RELAY_LOCATION, {
|
|
1520
|
+
parents: 2,
|
|
1521
|
+
interior: {
|
|
1522
|
+
X1: [{
|
|
1523
|
+
GlobalConsensus: {
|
|
1524
|
+
Kusama: null
|
|
1525
|
+
}
|
|
1526
|
+
}]
|
|
1527
|
+
}
|
|
1528
|
+
}];
|
|
1529
|
+
var isEthCompatibleAsset = asset.location.parents === Parents.TWO && deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(origin, false).GlobalConsensus) || ADDITIONAL_ALLOWED_LOCATIONS.some(function (loc) {
|
|
1530
|
+
return deepEqual(asset.location, loc);
|
|
1531
|
+
});
|
|
1532
|
+
if (!isEthCompatibleAsset) {
|
|
1533
|
+
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(asset, replaceBigInt), " is not transferable to Ethereum."));
|
|
1534
|
+
}
|
|
1648
1535
|
};
|
|
1649
|
-
var
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
]
|
|
1536
|
+
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
1537
|
+
var origin = _ref.from,
|
|
1538
|
+
destination = _ref.to,
|
|
1539
|
+
currency = _ref.currency;
|
|
1540
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
1541
|
+
if (asset === null && assetCheckEnabled) {
|
|
1542
|
+
throwUnsupportedCurrency(currency, origin);
|
|
1543
|
+
}
|
|
1544
|
+
if (!isLocationDestination && assetCheckEnabled && !findAssetInfoOnDest(origin, destination, currency, asset)) {
|
|
1545
|
+
throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
1546
|
+
}
|
|
1547
|
+
validateBridgeAsset(origin, destination, asset, currency, isBridge);
|
|
1548
|
+
validateEthereumAsset(origin, destination, asset);
|
|
1663
1549
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1550
|
+
|
|
1551
|
+
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
1552
|
+
var api = options.api,
|
|
1553
|
+
currency = options.currency,
|
|
1554
|
+
feeAsset = options.feeAsset,
|
|
1555
|
+
origin = options.from,
|
|
1556
|
+
destination = options.to;
|
|
1557
|
+
if ('location' in currency && isOverrideLocationSpecifier(currency.location)) {
|
|
1558
|
+
return currency.location.value;
|
|
1559
|
+
}
|
|
1560
|
+
if (Array.isArray(currency)) {
|
|
1561
|
+
if (!feeAsset) {
|
|
1562
|
+
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
1563
|
+
}
|
|
1564
|
+
if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
|
|
1565
|
+
throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
1566
|
+
}
|
|
1567
|
+
if (currency.every(function (asset) {
|
|
1568
|
+
return isTAsset(asset);
|
|
1569
|
+
})) {
|
|
1570
|
+
if (!feeAsset) {
|
|
1571
|
+
throw new InvalidCurrencyError('Fee asset not provided');
|
|
1572
|
+
}
|
|
1573
|
+
if (!('location' in feeAsset)) {
|
|
1574
|
+
throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
1575
|
+
}
|
|
1576
|
+
return currency.map(function (asset) {
|
|
1577
|
+
var ml = extractAssetLocation(asset);
|
|
1578
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
1579
|
+
fun: {
|
|
1580
|
+
Fungible: BigInt(asset.fun.Fungible)
|
|
1581
|
+
},
|
|
1582
|
+
isFeeAsset: deepEqual(ml, feeAsset.location)
|
|
1583
|
+
});
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
1587
|
+
var assets = currency.map(function (currency) {
|
|
1588
|
+
if (currency.amount === AMOUNT_ALL) {
|
|
1589
|
+
throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
1590
|
+
}
|
|
1591
|
+
var asset = findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
|
|
1592
|
+
if (!asset) {
|
|
1593
|
+
throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
1594
|
+
}
|
|
1595
|
+
if (!resolvedFeeAsset) {
|
|
1596
|
+
throw new InvalidCurrencyError('Fee asset not found');
|
|
1597
|
+
}
|
|
1598
|
+
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
1599
|
+
var version = getChainVersion(origin);
|
|
1600
|
+
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
1601
|
+
return _objectSpread2({
|
|
1602
|
+
isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
|
|
1603
|
+
}, createAsset(version, abstractedAmount, asset.location));
|
|
1604
|
+
});
|
|
1605
|
+
if (assets.filter(function (asset) {
|
|
1606
|
+
return asset.isFeeAsset;
|
|
1607
|
+
}).length > 1) {
|
|
1608
|
+
throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
1609
|
+
}
|
|
1610
|
+
if (assets.filter(function (asset) {
|
|
1611
|
+
return asset.isFeeAsset;
|
|
1612
|
+
}).length === 0) {
|
|
1613
|
+
throw new InvalidCurrencyError("Fee asset not found in multiassets");
|
|
1614
|
+
}
|
|
1615
|
+
return assets;
|
|
1616
|
+
}
|
|
1617
|
+
return undefined;
|
|
1678
1618
|
};
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
name: "Energy Web",
|
|
1686
|
-
endpoint: "wss://wnp-rpc.mainnet.energywebx.com/"
|
|
1687
|
-
}
|
|
1688
|
-
]
|
|
1619
|
+
|
|
1620
|
+
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
1621
|
+
if (isRelayChain(origin)) return true;
|
|
1622
|
+
var isMultipleAssets = Array.isArray(currency);
|
|
1623
|
+
var hasOverriddenLocation = 'location' in currency && isOverrideLocationSpecifier(currency.location);
|
|
1624
|
+
return !(isMultipleAssets || hasOverriddenLocation);
|
|
1689
1625
|
};
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
endpoint: "wss://hydration.dotters.network"
|
|
1706
|
-
}
|
|
1707
|
-
]
|
|
1626
|
+
|
|
1627
|
+
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
1628
|
+
if (Array.isArray(currency)) {
|
|
1629
|
+
if (currency.length === 0) {
|
|
1630
|
+
throw new InvalidCurrencyError('Overridden assets cannot be empty');
|
|
1631
|
+
}
|
|
1632
|
+
if (currency.length === 1) {
|
|
1633
|
+
throw new InvalidCurrencyError('Please provide more than one asset');
|
|
1634
|
+
}
|
|
1635
|
+
if (currency.length > 1 && !currency.every(function (asset) {
|
|
1636
|
+
return isTAsset(asset);
|
|
1637
|
+
}) && !feeAsset) {
|
|
1638
|
+
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1708
1641
|
};
|
|
1709
|
-
var
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1642
|
+
var validateDestination = function validateDestination(origin, destination) {
|
|
1643
|
+
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
1644
|
+
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
1645
|
+
}
|
|
1646
|
+
var allowedChainsToEthereum = ['AssetHubPolkadot', 'AssetHubPaseo', 'AssetHubWestend', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
1647
|
+
if (typeof destination === 'string' && isExternalChain(destination) && !allowedChainsToEthereum.includes(origin)) {
|
|
1648
|
+
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
1649
|
+
}
|
|
1650
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
1651
|
+
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
1652
|
+
var isRelayDestination = !isTLocation(destination) && isRelayChain(destination);
|
|
1653
|
+
if (!isRelayDestination && !isLocationDestination) {
|
|
1654
|
+
var originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
1655
|
+
var destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
1656
|
+
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
1657
|
+
throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
|
|
1661
|
+
var chain = getChain(destination);
|
|
1662
|
+
if (!chain.isRelayToParaEnabled()) {
|
|
1663
|
+
throw new ScenarioNotSupportedError({
|
|
1664
|
+
chain: destination,
|
|
1665
|
+
scenario: 'RelayToPara'
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
1671
|
+
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
1672
|
+
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
1673
|
+
}
|
|
1674
|
+
if (!assetCheckEnabled && 'id' in currency) {
|
|
1675
|
+
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
var validateTransact = function validateTransact(_ref) {
|
|
1679
|
+
var api = _ref.api,
|
|
1680
|
+
from = _ref.from,
|
|
1681
|
+
to = _ref.to,
|
|
1682
|
+
senderAddress = _ref.senderAddress,
|
|
1683
|
+
address = _ref.address,
|
|
1684
|
+
transactOptions = _ref.transactOptions;
|
|
1685
|
+
var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
|
|
1686
|
+
if (!call) return;
|
|
1687
|
+
if (from === to) {
|
|
1688
|
+
throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
|
|
1689
|
+
}
|
|
1690
|
+
if (typeof call === 'string' && !isHex(call)) {
|
|
1691
|
+
throw new ValidationError('Transact call hex must be a valid hex string.');
|
|
1692
|
+
}
|
|
1693
|
+
if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
|
|
1694
|
+
throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
|
|
1695
|
+
}
|
|
1696
|
+
if (typeof address === 'string' && senderAddress && !compareAddresses(api, address, senderAddress)) {
|
|
1697
|
+
return new ValidationError('Sender address must match the destination address for transact to work.');
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
var resolveTransferParams = function resolveTransferParams(options) {
|
|
1702
|
+
var api = options.api,
|
|
1703
|
+
origin = options.from,
|
|
1704
|
+
currency = options.currency,
|
|
1705
|
+
feeAsset = options.feeAsset,
|
|
1706
|
+
address = options.address,
|
|
1707
|
+
destination = options.to,
|
|
1708
|
+
version = options.version,
|
|
1709
|
+
senderAddress = options.senderAddress;
|
|
1710
|
+
validateCurrency(currency, feeAsset);
|
|
1711
|
+
validateDestination(origin, destination);
|
|
1712
|
+
validateTransact(options);
|
|
1713
|
+
validateDestinationAddress(address, destination, api);
|
|
1714
|
+
if (senderAddress) validateAddress(api, senderAddress, origin, false);
|
|
1715
|
+
var isBridge = !isTLocation(destination) && isSubstrateBridge(origin, destination);
|
|
1716
|
+
var assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
|
|
1717
|
+
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
1718
|
+
var asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
1719
|
+
var resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
1720
|
+
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
1721
|
+
var amount = Array.isArray(currency) ? 0n : abstractDecimals(currency.amount, asset === null || asset === void 0 ? void 0 : asset.decimals, api);
|
|
1722
|
+
// Ensure amount is at least 2 to avoid Rust panic (only for non-array currencies)
|
|
1723
|
+
var finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
|
|
1724
|
+
var resolvedVersion = pickCompatibleXcmVersion(origin, destination, version);
|
|
1725
|
+
var overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset);
|
|
1726
|
+
// In case asset check is disabled, we create asset object from currency symbol
|
|
1727
|
+
var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
1728
|
+
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
1729
|
+
};
|
|
1730
|
+
var finalAsset = Array.isArray(currency) ? // TODO: Refactor this
|
|
1731
|
+
// We use a dummy values when overriding with multi-assets
|
|
1732
|
+
// since these values won't be used but need to pass checks
|
|
1733
|
+
_objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
1734
|
+
amount: 0n,
|
|
1735
|
+
assetId: '1',
|
|
1736
|
+
location: {
|
|
1737
|
+
parents: Parents.ZERO,
|
|
1738
|
+
interior: {
|
|
1739
|
+
Here: null
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
1743
|
+
amount: finalAmount
|
|
1744
|
+
});
|
|
1745
|
+
var normalizedAsset = finalAsset.location ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
|
|
1746
|
+
location: normalizeLocation(finalAsset.location, resolvedVersion)
|
|
1747
|
+
}) : finalAsset;
|
|
1748
|
+
return {
|
|
1749
|
+
resolvedFeeAsset: resolvedFeeAsset,
|
|
1750
|
+
resolvedVersion: resolvedVersion,
|
|
1751
|
+
overriddenAsset: overriddenAsset,
|
|
1752
|
+
normalizedAsset: normalizedAsset
|
|
1753
|
+
};
|
|
1754
|
+
};
|
|
1755
|
+
var createTransfer = /*#__PURE__*/function () {
|
|
1756
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
1757
|
+
var api, origin, currency, feeAsset, address, destination, paraIdTo, senderAddress, ahAddress, pallet, method, transactOptions, isAmountAll, keepAlive, _resolveTransferParam, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset;
|
|
1758
|
+
return _regenerator().w(function (_context) {
|
|
1759
|
+
while (1) switch (_context.n) {
|
|
1760
|
+
case 0:
|
|
1761
|
+
api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
1762
|
+
_resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
|
|
1763
|
+
_context.n = 1;
|
|
1764
|
+
return api.init(origin, TX_CLIENT_TIMEOUT_MS);
|
|
1765
|
+
case 1:
|
|
1766
|
+
return _context.a(2, getChain(origin).transfer({
|
|
1767
|
+
api: api,
|
|
1768
|
+
assetInfo: normalizedAsset,
|
|
1769
|
+
currency: currency,
|
|
1770
|
+
feeAsset: resolvedFeeAsset,
|
|
1771
|
+
feeCurrency: feeAsset,
|
|
1772
|
+
address: address,
|
|
1773
|
+
to: destination,
|
|
1774
|
+
paraIdTo: paraIdTo,
|
|
1775
|
+
overriddenAsset: overriddenAsset,
|
|
1776
|
+
version: resolvedVersion,
|
|
1777
|
+
senderAddress: senderAddress,
|
|
1778
|
+
ahAddress: ahAddress,
|
|
1779
|
+
pallet: pallet,
|
|
1780
|
+
method: method,
|
|
1781
|
+
transactOptions: transactOptions,
|
|
1782
|
+
isAmountAll: isAmountAll,
|
|
1783
|
+
keepAlive: keepAlive
|
|
1784
|
+
}));
|
|
1785
|
+
}
|
|
1786
|
+
}, _callee);
|
|
1787
|
+
}));
|
|
1788
|
+
return function createTransfer(_x) {
|
|
1789
|
+
return _ref.apply(this, arguments);
|
|
1790
|
+
};
|
|
1791
|
+
}();
|
|
1792
|
+
|
|
1793
|
+
var isAssetHub = function isAssetHub(chain) {
|
|
1794
|
+
return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
|
|
1795
|
+
};
|
|
1796
|
+
var isBridgeHub = function isBridgeHub(chain) {
|
|
1797
|
+
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
1798
|
+
};
|
|
1799
|
+
var isPeople = function isPeople(chain) {
|
|
1800
|
+
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
1801
|
+
};
|
|
1802
|
+
var isSystemPara = function isSystemPara(chain) {
|
|
1803
|
+
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
1804
|
+
};
|
|
1805
|
+
var mul = function mul(v, num) {
|
|
1806
|
+
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
1807
|
+
return v * num / den;
|
|
1808
|
+
};
|
|
1809
|
+
var padFee = function padFee(raw, origin, dest, side) {
|
|
1810
|
+
var relayOrigin = isRelayChain(origin);
|
|
1811
|
+
var relayDest = isRelayChain(dest);
|
|
1812
|
+
var sysParaOrigin = isSystemPara(origin);
|
|
1813
|
+
var sysParaDest = isSystemPara(dest);
|
|
1814
|
+
var relayToPara = relayOrigin && !relayDest;
|
|
1815
|
+
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
1816
|
+
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
1817
|
+
if (sysParaToPara) return raw * 40n;
|
|
1818
|
+
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
1819
|
+
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
1820
|
+
return 150000000000000000n;
|
|
1821
|
+
}
|
|
1822
|
+
if (paraToPara) return mul(raw, 130n, 100n);
|
|
1823
|
+
// apply default 30% padding
|
|
1824
|
+
return mul(raw, 130n, 100n);
|
|
1825
|
+
};
|
|
1826
|
+
var padValueBy = function padValueBy(amount, percent) {
|
|
1827
|
+
var scaled = BigInt(Math.round(percent * 100)); // 2 decimal precision
|
|
1828
|
+
return amount * (BigInt(10000) + scaled) / BigInt(10000);
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1831
|
+
var getMythosOriginFee = /*#__PURE__*/function () {
|
|
1832
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
|
|
1833
|
+
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
|
|
1834
|
+
return _regenerator().w(function (_context) {
|
|
1835
|
+
while (1) switch (_context.n) {
|
|
1836
|
+
case 0:
|
|
1837
|
+
ahApi = api.clone();
|
|
1838
|
+
_context.n = 1;
|
|
1839
|
+
return ahApi.init('AssetHubPolkadot');
|
|
1840
|
+
case 1:
|
|
1841
|
+
_context.n = 2;
|
|
1842
|
+
return getParaEthTransferFees(ahApi, false);
|
|
1843
|
+
case 2:
|
|
1844
|
+
_yield$getParaEthTran = _context.v;
|
|
1845
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
1846
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
1847
|
+
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
1848
|
+
nativeAsset = findNativeAssetInfoOrThrow('Mythos');
|
|
1849
|
+
_context.n = 3;
|
|
1850
|
+
return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
|
|
1851
|
+
case 3:
|
|
1852
|
+
feeConverted = _context.v;
|
|
1853
|
+
_context.n = 4;
|
|
1854
|
+
return ahApi.disconnect();
|
|
1855
|
+
case 4:
|
|
1856
|
+
if (feeConverted) {
|
|
1857
|
+
_context.n = 5;
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
throw new UnableToComputeError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
|
|
1861
|
+
case 5:
|
|
1862
|
+
return _context.a(2, padValueBy(feeConverted, 10));
|
|
1863
|
+
}
|
|
1864
|
+
}, _callee);
|
|
1865
|
+
}));
|
|
1866
|
+
return function getMythosOriginFee(_x) {
|
|
1867
|
+
return _ref.apply(this, arguments);
|
|
1868
|
+
};
|
|
1869
|
+
}();
|
|
1870
|
+
|
|
1871
|
+
var AssetHubPolkadot$1 = {
|
|
1872
|
+
name: "Asset Hub",
|
|
1873
|
+
info: "PolkadotAssetHub",
|
|
1874
|
+
paraId: 1000,
|
|
1713
1875
|
providers: [
|
|
1714
1876
|
{
|
|
1715
|
-
name: "
|
|
1716
|
-
endpoint: "wss://
|
|
1877
|
+
name: "Dwellir",
|
|
1878
|
+
endpoint: "wss://asset-hub-polkadot-rpc.n.dwellir.com"
|
|
1717
1879
|
},
|
|
1718
1880
|
{
|
|
1719
|
-
name: "
|
|
1720
|
-
endpoint: "wss://rpc-
|
|
1721
|
-
}
|
|
1722
|
-
]
|
|
1723
|
-
};
|
|
1724
|
-
var Heima$1 = {
|
|
1725
|
-
name: "Heima",
|
|
1726
|
-
info: "heima",
|
|
1727
|
-
paraId: 2013,
|
|
1728
|
-
providers: [
|
|
1881
|
+
name: "Dwellir Tunisia",
|
|
1882
|
+
endpoint: "wss://statemint-rpc-tn.dwellir.com"
|
|
1883
|
+
},
|
|
1729
1884
|
{
|
|
1730
|
-
name: "
|
|
1731
|
-
endpoint: "wss://
|
|
1885
|
+
name: "IBP1",
|
|
1886
|
+
endpoint: "wss://asset-hub-polkadot.ibp.network"
|
|
1732
1887
|
},
|
|
1733
1888
|
{
|
|
1734
|
-
name: "
|
|
1735
|
-
endpoint: "wss://
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1889
|
+
name: "IBP2",
|
|
1890
|
+
endpoint: "wss://asset-hub-polkadot.dotters.network"
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
name: "LuckyFriday",
|
|
1894
|
+
endpoint: "wss://rpc-asset-hub-polkadot.luckyfriday.io"
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
name: "OnFinality",
|
|
1898
|
+
endpoint: "wss://statemint.api.onfinality.io/public-ws"
|
|
1899
|
+
},
|
|
1900
|
+
{
|
|
1901
|
+
name: "Parity",
|
|
1902
|
+
endpoint: "wss://polkadot-asset-hub-rpc.polkadot.io"
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
name: "Permanence DAO EU",
|
|
1906
|
+
endpoint: "wss://asset-hub-polkadot.rpc.permanence.io"
|
|
1907
|
+
},
|
|
1908
|
+
{
|
|
1909
|
+
name: "RadiumBlock",
|
|
1910
|
+
endpoint: "wss://statemint.public.curie.radiumblock.co/ws"
|
|
1911
|
+
}
|
|
1912
|
+
]
|
|
1913
|
+
};
|
|
1914
|
+
var Acala$1 = {
|
|
1915
|
+
name: "Acala",
|
|
1916
|
+
info: "acala",
|
|
1917
|
+
paraId: 2000,
|
|
1918
|
+
providers: [
|
|
1919
|
+
{
|
|
1920
|
+
name: "Acala Foundation 0",
|
|
1921
|
+
endpoint: "wss://acala-rpc-0.aca-api.network"
|
|
1922
|
+
},
|
|
1923
|
+
{
|
|
1924
|
+
name: "Acala Foundation 1",
|
|
1925
|
+
endpoint: "wss://acala-rpc-1.aca-api.network"
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
name: "Acala Foundation 3",
|
|
1929
|
+
endpoint: "wss://acala-rpc-3.aca-api.network/ws"
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
name: "Dwellir",
|
|
1933
|
+
endpoint: "wss://acala-rpc.n.dwellir.com"
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
name: "IBP1",
|
|
1937
|
+
endpoint: "wss://acala.ibp.network"
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
name: "IBP2",
|
|
1941
|
+
endpoint: "wss://acala.dotters.network"
|
|
1942
|
+
}
|
|
1943
|
+
]
|
|
1944
|
+
};
|
|
1945
|
+
var Ajuna$1 = {
|
|
1946
|
+
name: "Ajuna Network",
|
|
1947
|
+
info: "ajuna",
|
|
1948
|
+
paraId: 2051,
|
|
1949
|
+
providers: [
|
|
1950
|
+
{
|
|
1951
|
+
name: "AjunaNetwork",
|
|
1952
|
+
endpoint: "wss://rpc-para.ajuna.network"
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
name: "IBP1",
|
|
1956
|
+
endpoint: "wss://ajuna.ibp.network"
|
|
1957
|
+
},
|
|
1958
|
+
{
|
|
1959
|
+
name: "IBP2",
|
|
1960
|
+
endpoint: "wss://ajuna.dotters.network"
|
|
1961
|
+
}
|
|
1962
|
+
]
|
|
1963
|
+
};
|
|
1964
|
+
var Astar$1 = {
|
|
1965
|
+
name: "Astar",
|
|
1966
|
+
info: "astar",
|
|
1967
|
+
paraId: 2006,
|
|
1968
|
+
providers: [
|
|
1969
|
+
{
|
|
1970
|
+
name: "Astar",
|
|
1971
|
+
endpoint: "wss://rpc.astar.network"
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
name: "Dwellir",
|
|
1975
|
+
endpoint: "wss://astar-rpc.n.dwellir.com"
|
|
1976
|
+
},
|
|
1977
|
+
{
|
|
1978
|
+
name: "OnFinality",
|
|
1979
|
+
endpoint: "wss://astar.api.onfinality.io/public-ws"
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
name: "RadiumBlock",
|
|
1983
|
+
endpoint: "wss://astar.public.curie.radiumblock.co/ws"
|
|
1984
|
+
}
|
|
1985
|
+
]
|
|
1986
|
+
};
|
|
1987
|
+
var BifrostPolkadot$1 = {
|
|
1988
|
+
name: "Bifrost",
|
|
1989
|
+
info: "bifrost",
|
|
1990
|
+
paraId: 2030,
|
|
1991
|
+
providers: [
|
|
1992
|
+
{
|
|
1993
|
+
name: "IBP1",
|
|
1994
|
+
endpoint: "wss://bifrost-polkadot.ibp.network"
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
name: "IBP2",
|
|
1998
|
+
endpoint: "wss://bifrost-polkadot.dotters.network"
|
|
1999
|
+
},
|
|
2000
|
+
{
|
|
2001
|
+
name: "Liebi",
|
|
2002
|
+
endpoint: "wss://hk.p.bifrost-rpc.liebi.com/ws"
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
name: "LiebiEU",
|
|
2006
|
+
endpoint: "wss://eu.bifrost-polkadot-rpc.liebi.com/ws"
|
|
2007
|
+
}
|
|
2008
|
+
]
|
|
2009
|
+
};
|
|
2010
|
+
var BridgeHubPolkadot$1 = {
|
|
2011
|
+
name: "Bridge Hub",
|
|
2012
|
+
info: "polkadotBridgeHub",
|
|
2013
|
+
paraId: 1002,
|
|
2014
|
+
providers: [
|
|
2015
|
+
{
|
|
2016
|
+
name: "Dwellir",
|
|
2017
|
+
endpoint: "wss://bridge-hub-polkadot-rpc.n.dwellir.com"
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
name: "Dwellir Tunisia",
|
|
2021
|
+
endpoint: "wss://polkadot-bridge-hub-rpc-tn.dwellir.com"
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
name: "IBP1",
|
|
2025
|
+
endpoint: "wss://bridge-hub-polkadot.ibp.network"
|
|
2026
|
+
},
|
|
2027
|
+
{
|
|
2028
|
+
name: "IBP2",
|
|
2029
|
+
endpoint: "wss://bridge-hub-polkadot.dotters.network"
|
|
2030
|
+
},
|
|
2031
|
+
{
|
|
2032
|
+
name: "LuckyFriday",
|
|
2033
|
+
endpoint: "wss://rpc-bridge-hub-polkadot.luckyfriday.io"
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
name: "OnFinality",
|
|
2037
|
+
endpoint: "wss://bridgehub-polkadot.api.onfinality.io/public-ws"
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
name: "Parity",
|
|
2041
|
+
endpoint: "wss://polkadot-bridge-hub-rpc.polkadot.io"
|
|
2042
|
+
},
|
|
2043
|
+
{
|
|
2044
|
+
name: "RadiumBlock",
|
|
2045
|
+
endpoint: "wss://bridgehub-polkadot.public.curie.radiumblock.co/ws"
|
|
2046
|
+
}
|
|
2047
|
+
]
|
|
2048
|
+
};
|
|
2049
|
+
var Centrifuge$1 = {
|
|
2050
|
+
name: "Centrifuge",
|
|
2051
|
+
info: "centrifuge",
|
|
2052
|
+
paraId: 2031,
|
|
2053
|
+
providers: [
|
|
2054
|
+
{
|
|
2055
|
+
name: "LuckyFriday",
|
|
2056
|
+
endpoint: "wss://rpc-centrifuge.luckyfriday.io"
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
name: "OnFinality",
|
|
2060
|
+
endpoint: "wss://centrifuge-parachain.api.onfinality.io/public-ws"
|
|
2061
|
+
}
|
|
2062
|
+
]
|
|
2063
|
+
};
|
|
2064
|
+
var Darwinia$1 = {
|
|
2065
|
+
name: "Darwinia",
|
|
2066
|
+
info: "darwinia",
|
|
2067
|
+
paraId: 2046,
|
|
2068
|
+
providers: [
|
|
2069
|
+
{
|
|
2070
|
+
name: "Darwinia",
|
|
2071
|
+
endpoint: "wss://rpc.darwinia.network"
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
name: "Subquery",
|
|
2075
|
+
endpoint: "wss://darwinia.rpc.subquery.network/public/ws"
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2078
|
+
};
|
|
2079
|
+
var EnergyWebX$1 = {
|
|
2080
|
+
name: "Energy Web X",
|
|
2081
|
+
info: "ewx",
|
|
2082
|
+
paraId: 3345,
|
|
2083
|
+
providers: [
|
|
2084
|
+
{
|
|
2085
|
+
name: "Energy Web",
|
|
2086
|
+
endpoint: "wss://wnp-rpc.mainnet.energywebx.com/"
|
|
2087
|
+
}
|
|
2088
|
+
]
|
|
2089
|
+
};
|
|
2090
|
+
var Hydration$1 = {
|
|
2091
|
+
name: "Hydration",
|
|
2092
|
+
info: "hydradx",
|
|
2093
|
+
paraId: 2034,
|
|
2094
|
+
providers: [
|
|
2095
|
+
{
|
|
2096
|
+
name: "Helikon",
|
|
2097
|
+
endpoint: "wss://rpc.helikon.io/hydradx"
|
|
2098
|
+
},
|
|
2099
|
+
{
|
|
2100
|
+
name: "IBP1",
|
|
2101
|
+
endpoint: "wss://hydration.ibp.network"
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
name: "IBP2",
|
|
2105
|
+
endpoint: "wss://hydration.dotters.network"
|
|
2106
|
+
}
|
|
2107
|
+
]
|
|
2108
|
+
};
|
|
2109
|
+
var Interlay$1 = {
|
|
2110
|
+
name: "Interlay",
|
|
2111
|
+
info: "interlay",
|
|
2112
|
+
paraId: 2032,
|
|
2113
|
+
providers: [
|
|
2114
|
+
{
|
|
2115
|
+
name: "Kintsugi Labs",
|
|
2116
|
+
endpoint: "wss://api.interlay.io/parachain"
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
name: "LuckyFriday",
|
|
2120
|
+
endpoint: "wss://rpc-interlay.luckyfriday.io/"
|
|
2121
|
+
}
|
|
2122
|
+
]
|
|
2123
|
+
};
|
|
2124
|
+
var Heima$1 = {
|
|
2125
|
+
name: "Heima",
|
|
2126
|
+
info: "heima",
|
|
2127
|
+
paraId: 2013,
|
|
2128
|
+
providers: [
|
|
2129
|
+
{
|
|
2130
|
+
name: "Dwellir",
|
|
2131
|
+
endpoint: "wss://heima-rpc.n.dwellir.com"
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
name: "Heima",
|
|
2135
|
+
endpoint: "wss://rpc.heima-parachain.heima.network"
|
|
2136
|
+
}
|
|
2137
|
+
]
|
|
2138
|
+
};
|
|
1739
2139
|
var Jamton$1 = {
|
|
1740
2140
|
name: "JAMTON",
|
|
1741
2141
|
info: "jamton",
|
|
@@ -2894,18 +3294,6 @@ var getParaId = function getParaId(chain) {
|
|
|
2894
3294
|
return getChainConfig(chain).paraId;
|
|
2895
3295
|
};
|
|
2896
3296
|
|
|
2897
|
-
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
2898
|
-
if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
2899
|
-
throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
|
|
2900
|
-
}
|
|
2901
|
-
var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
|
|
2902
|
-
var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
|
|
2903
|
-
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
2904
|
-
throwUnsupportedCurrency(feeAsset, origin);
|
|
2905
|
-
}
|
|
2906
|
-
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
2907
|
-
};
|
|
2908
|
-
|
|
2909
3297
|
/**
|
|
2910
3298
|
* Builder class for constructing asset claim transactions.
|
|
2911
3299
|
*/
|
|
@@ -3151,11 +3539,11 @@ var PolkadotXcmExecutionError;
|
|
|
3151
3539
|
|
|
3152
3540
|
var normalizeAmountAll = /*#__PURE__*/function () {
|
|
3153
3541
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, builder, options) {
|
|
3154
|
-
var currency, isAmountAll, builderWithMinAmount, buildTx, transferable, finalBuildTx;
|
|
3542
|
+
var currency, swapOptions, isAmountAll, builderWithMinAmount, buildTx, transferable, finalBuildTx, _t;
|
|
3155
3543
|
return _regenerator().w(function (_context) {
|
|
3156
3544
|
while (1) switch (_context.n) {
|
|
3157
3545
|
case 0:
|
|
3158
|
-
currency = options.currency;
|
|
3546
|
+
currency = options.currency, swapOptions = options.swapOptions;
|
|
3159
3547
|
isAmountAll = !Array.isArray(currency) && currency.amount === AMOUNT_ALL;
|
|
3160
3548
|
if (isAmountAll) {
|
|
3161
3549
|
_context.n = 1;
|
|
@@ -3175,7 +3563,23 @@ var normalizeAmountAll = /*#__PURE__*/function () {
|
|
|
3175
3563
|
buildTx = builderWithMinAmount['createTxFactory']();
|
|
3176
3564
|
assertToIsString(options.to);
|
|
3177
3565
|
assertSenderAddress(options.senderAddress);
|
|
3566
|
+
if (!swapOptions) {
|
|
3567
|
+
_context.n = 3;
|
|
3568
|
+
break;
|
|
3569
|
+
}
|
|
3178
3570
|
_context.n = 2;
|
|
3571
|
+
return executeWithRouter(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
3572
|
+
api: api,
|
|
3573
|
+
swapOptions: swapOptions
|
|
3574
|
+
}), function (builder) {
|
|
3575
|
+
return builder.getTransferableAmount();
|
|
3576
|
+
});
|
|
3577
|
+
case 2:
|
|
3578
|
+
_t = _context.v;
|
|
3579
|
+
_context.n = 5;
|
|
3580
|
+
break;
|
|
3581
|
+
case 3:
|
|
3582
|
+
_context.n = 4;
|
|
3179
3583
|
return getTransferableAmountInternal({
|
|
3180
3584
|
api: api,
|
|
3181
3585
|
buildTx: buildTx,
|
|
@@ -3188,8 +3592,10 @@ var normalizeAmountAll = /*#__PURE__*/function () {
|
|
|
3188
3592
|
amount: MIN_AMOUNT
|
|
3189
3593
|
})
|
|
3190
3594
|
});
|
|
3191
|
-
case
|
|
3192
|
-
|
|
3595
|
+
case 4:
|
|
3596
|
+
_t = _context.v;
|
|
3597
|
+
case 5:
|
|
3598
|
+
transferable = _t;
|
|
3193
3599
|
finalBuildTx = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
|
|
3194
3600
|
amount: transferable
|
|
3195
3601
|
}))['createTxFactory']();
|
|
@@ -3282,7 +3688,7 @@ var BatchTransactionManager = /*#__PURE__*/function () {
|
|
|
3282
3688
|
_context2.n = 5;
|
|
3283
3689
|
return Promise.all(normalized.map(function (_ref2) {
|
|
3284
3690
|
var options = _ref2.options;
|
|
3285
|
-
return
|
|
3691
|
+
return createTransferOrSwap(options);
|
|
3286
3692
|
}));
|
|
3287
3693
|
case 5:
|
|
3288
3694
|
txs = _context2.v;
|
|
@@ -3510,6 +3916,19 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3510
3916
|
})
|
|
3511
3917
|
}));
|
|
3512
3918
|
}
|
|
3919
|
+
/**
|
|
3920
|
+
* Performs a token swap as part of the transfer, using the specified exchange and destination currency.
|
|
3921
|
+
*
|
|
3922
|
+
* @param options - The swap options.
|
|
3923
|
+
* @returns An instance of the Builder.
|
|
3924
|
+
*/
|
|
3925
|
+
}, {
|
|
3926
|
+
key: "swap",
|
|
3927
|
+
value: function swap(options) {
|
|
3928
|
+
return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
3929
|
+
swapOptions: options
|
|
3930
|
+
}));
|
|
3931
|
+
}
|
|
3513
3932
|
/**
|
|
3514
3933
|
* Adds the transfer transaction to the batch.
|
|
3515
3934
|
*
|
|
@@ -3606,82 +4025,147 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3606
4025
|
return _build.apply(this, arguments);
|
|
3607
4026
|
}
|
|
3608
4027
|
return build;
|
|
4028
|
+
}()
|
|
4029
|
+
/**
|
|
4030
|
+
* Builds and returns multiple transfer or swap extrinsics
|
|
4031
|
+
*
|
|
4032
|
+
* @returns A Promise that resolves to the transfer extrinsic contexts
|
|
4033
|
+
*/
|
|
4034
|
+
)
|
|
4035
|
+
}, {
|
|
4036
|
+
key: "buildAll",
|
|
4037
|
+
value: (function () {
|
|
4038
|
+
var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
4039
|
+
var _yield$this$buildComm2, txContexts;
|
|
4040
|
+
return _regenerator().w(function (_context4) {
|
|
4041
|
+
while (1) switch (_context4.n) {
|
|
4042
|
+
case 0:
|
|
4043
|
+
_context4.n = 1;
|
|
4044
|
+
return this.buildCommonAll();
|
|
4045
|
+
case 1:
|
|
4046
|
+
_yield$this$buildComm2 = _context4.v;
|
|
4047
|
+
txContexts = _yield$this$buildComm2.txContexts;
|
|
4048
|
+
return _context4.a(2, txContexts);
|
|
4049
|
+
}
|
|
4050
|
+
}, _callee4, this);
|
|
4051
|
+
}));
|
|
4052
|
+
function buildAll() {
|
|
4053
|
+
return _buildAll.apply(this, arguments);
|
|
4054
|
+
}
|
|
4055
|
+
return buildAll;
|
|
3609
4056
|
}())
|
|
4057
|
+
}, {
|
|
4058
|
+
key: "validateBatchState",
|
|
4059
|
+
value: function validateBatchState(isCalledInternally) {
|
|
4060
|
+
if (!this.batchManager.isEmpty() && !isCalledInternally) {
|
|
4061
|
+
throw new BatchValidationError('Transaction manager contains batched items. Use buildBatch() to process them.');
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
3610
4064
|
}, {
|
|
3611
4065
|
key: "buildCommon",
|
|
3612
4066
|
value: function () {
|
|
3613
|
-
var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4067
|
+
var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
3614
4068
|
var isCalledInternally,
|
|
3615
4069
|
_yield$this$prepareNo,
|
|
3616
4070
|
normalizedOptions,
|
|
3617
4071
|
tx,
|
|
3618
|
-
|
|
3619
|
-
return _regenerator().w(function (
|
|
3620
|
-
while (1) switch (
|
|
4072
|
+
_args5 = arguments;
|
|
4073
|
+
return _regenerator().w(function (_context5) {
|
|
4074
|
+
while (1) switch (_context5.n) {
|
|
3621
4075
|
case 0:
|
|
3622
|
-
isCalledInternally =
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
break;
|
|
3626
|
-
}
|
|
3627
|
-
throw new BatchValidationError('Transaction manager contains batched items. Use buildBatch() to process them.');
|
|
3628
|
-
case 1:
|
|
3629
|
-
_context4.n = 2;
|
|
4076
|
+
isCalledInternally = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : false;
|
|
4077
|
+
this.validateBatchState(isCalledInternally);
|
|
4078
|
+
_context5.n = 1;
|
|
3630
4079
|
return this.prepareNormalizedOptions(this._options);
|
|
3631
|
-
case
|
|
3632
|
-
_yield$this$prepareNo =
|
|
4080
|
+
case 1:
|
|
4081
|
+
_yield$this$prepareNo = _context5.v;
|
|
3633
4082
|
normalizedOptions = _yield$this$prepareNo.normalizedOptions;
|
|
3634
|
-
|
|
3635
|
-
return
|
|
3636
|
-
case
|
|
3637
|
-
tx =
|
|
3638
|
-
|
|
4083
|
+
_context5.n = 2;
|
|
4084
|
+
return createTransferOrSwap(normalizedOptions);
|
|
4085
|
+
case 2:
|
|
4086
|
+
tx = _context5.v;
|
|
4087
|
+
_context5.n = 3;
|
|
3639
4088
|
return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
|
|
3640
|
-
case
|
|
3641
|
-
return
|
|
4089
|
+
case 3:
|
|
4090
|
+
return _context5.a(2, {
|
|
3642
4091
|
tx: tx,
|
|
3643
4092
|
options: normalizedOptions
|
|
3644
4093
|
});
|
|
3645
4094
|
}
|
|
3646
|
-
},
|
|
4095
|
+
}, _callee5, this);
|
|
3647
4096
|
}));
|
|
3648
4097
|
function buildCommon() {
|
|
3649
4098
|
return _buildCommon.apply(this, arguments);
|
|
3650
4099
|
}
|
|
3651
4100
|
return buildCommon;
|
|
3652
4101
|
}()
|
|
4102
|
+
}, {
|
|
4103
|
+
key: "buildCommonAll",
|
|
4104
|
+
value: function () {
|
|
4105
|
+
var _buildCommonAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
4106
|
+
var isCalledInternally,
|
|
4107
|
+
_yield$this$prepareNo2,
|
|
4108
|
+
normalizedOptions,
|
|
4109
|
+
txContexts,
|
|
4110
|
+
_args6 = arguments;
|
|
4111
|
+
return _regenerator().w(function (_context6) {
|
|
4112
|
+
while (1) switch (_context6.n) {
|
|
4113
|
+
case 0:
|
|
4114
|
+
isCalledInternally = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : false;
|
|
4115
|
+
this.validateBatchState(isCalledInternally);
|
|
4116
|
+
_context6.n = 1;
|
|
4117
|
+
return this.prepareNormalizedOptions(this._options);
|
|
4118
|
+
case 1:
|
|
4119
|
+
_yield$this$prepareNo2 = _context6.v;
|
|
4120
|
+
normalizedOptions = _yield$this$prepareNo2.normalizedOptions;
|
|
4121
|
+
_context6.n = 2;
|
|
4122
|
+
return createTransferOrSwapAll(normalizedOptions);
|
|
4123
|
+
case 2:
|
|
4124
|
+
txContexts = _context6.v;
|
|
4125
|
+
return _context6.a(2, {
|
|
4126
|
+
txContexts: txContexts,
|
|
4127
|
+
options: normalizedOptions
|
|
4128
|
+
});
|
|
4129
|
+
}
|
|
4130
|
+
}, _callee6, this);
|
|
4131
|
+
}));
|
|
4132
|
+
function buildCommonAll() {
|
|
4133
|
+
return _buildCommonAll.apply(this, arguments);
|
|
4134
|
+
}
|
|
4135
|
+
return buildCommonAll;
|
|
4136
|
+
}()
|
|
3653
4137
|
}, {
|
|
3654
4138
|
key: "maybePerformXcmFormatCheck",
|
|
3655
4139
|
value: function () {
|
|
3656
|
-
var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4140
|
+
var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(tx, options, isCalledInternally) {
|
|
3657
4141
|
var senderAddress, config, dryRunResult;
|
|
3658
|
-
return _regenerator().w(function (
|
|
3659
|
-
while (1) switch (
|
|
4142
|
+
return _regenerator().w(function (_context7) {
|
|
4143
|
+
while (1) switch (_context7.n) {
|
|
3660
4144
|
case 0:
|
|
3661
4145
|
senderAddress = options.senderAddress;
|
|
3662
4146
|
config = this.api.getConfig();
|
|
3663
4147
|
if (!(isConfig(config) && config.xcmFormatCheck && !isCalledInternally)) {
|
|
3664
|
-
|
|
4148
|
+
_context7.n = 2;
|
|
3665
4149
|
break;
|
|
3666
4150
|
}
|
|
3667
4151
|
assertSenderAddress(senderAddress);
|
|
3668
|
-
|
|
4152
|
+
_context7.n = 1;
|
|
3669
4153
|
return buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
3670
4154
|
senderAddress: senderAddress
|
|
3671
4155
|
}), {
|
|
3672
4156
|
sentAssetMintMode: 'bypass'
|
|
3673
4157
|
});
|
|
3674
4158
|
case 1:
|
|
3675
|
-
dryRunResult =
|
|
4159
|
+
dryRunResult = _context7.v;
|
|
3676
4160
|
if (!dryRunResult.failureReason) {
|
|
3677
|
-
|
|
4161
|
+
_context7.n = 2;
|
|
3678
4162
|
break;
|
|
3679
4163
|
}
|
|
3680
4164
|
throw new DryRunFailedError(dryRunResult.failureReason, dryRunResult.failureChain);
|
|
3681
4165
|
case 2:
|
|
3682
|
-
return
|
|
4166
|
+
return _context7.a(2);
|
|
3683
4167
|
}
|
|
3684
|
-
},
|
|
4168
|
+
}, _callee7, this);
|
|
3685
4169
|
}));
|
|
3686
4170
|
function maybePerformXcmFormatCheck(_x3, _x4, _x5) {
|
|
3687
4171
|
return _maybePerformXcmFormatCheck.apply(this, arguments);
|
|
@@ -3691,20 +4175,32 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3691
4175
|
}, {
|
|
3692
4176
|
key: "dryRun",
|
|
3693
4177
|
value: function () {
|
|
3694
|
-
var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3695
|
-
var _yield$this$buildInte, tx, options;
|
|
3696
|
-
return _regenerator().w(function (
|
|
3697
|
-
while (1) switch (
|
|
4178
|
+
var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
4179
|
+
var swapOptions, _yield$this$buildInte, tx, options;
|
|
4180
|
+
return _regenerator().w(function (_context8) {
|
|
4181
|
+
while (1) switch (_context8.n) {
|
|
3698
4182
|
case 0:
|
|
3699
|
-
|
|
3700
|
-
|
|
4183
|
+
swapOptions = this._options.swapOptions;
|
|
4184
|
+
if (!swapOptions) {
|
|
4185
|
+
_context8.n = 1;
|
|
4186
|
+
break;
|
|
4187
|
+
}
|
|
4188
|
+
return _context8.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
4189
|
+
api: this.api,
|
|
4190
|
+
swapOptions: swapOptions
|
|
4191
|
+
}), function (builder) {
|
|
4192
|
+
return builder.dryRun();
|
|
4193
|
+
}));
|
|
3701
4194
|
case 1:
|
|
3702
|
-
|
|
4195
|
+
_context8.n = 2;
|
|
4196
|
+
return this.buildInternal();
|
|
4197
|
+
case 2:
|
|
4198
|
+
_yield$this$buildInte = _context8.v;
|
|
3703
4199
|
tx = _yield$this$buildInte.tx;
|
|
3704
4200
|
options = _yield$this$buildInte.options;
|
|
3705
|
-
return
|
|
4201
|
+
return _context8.a(2, buildDryRun(this.api, tx, options));
|
|
3706
4202
|
}
|
|
3707
|
-
},
|
|
4203
|
+
}, _callee8, this);
|
|
3708
4204
|
}));
|
|
3709
4205
|
function dryRun() {
|
|
3710
4206
|
return _dryRun.apply(this, arguments);
|
|
@@ -3714,23 +4210,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3714
4210
|
}, {
|
|
3715
4211
|
key: "dryRunPreview",
|
|
3716
4212
|
value: function () {
|
|
3717
|
-
var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3718
|
-
var _yield$this$buildInte2, tx, options;
|
|
3719
|
-
return _regenerator().w(function (
|
|
3720
|
-
while (1) switch (
|
|
4213
|
+
var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(dryRunOptions) {
|
|
4214
|
+
var swapOptions, _yield$this$buildInte2, tx, options;
|
|
4215
|
+
return _regenerator().w(function (_context9) {
|
|
4216
|
+
while (1) switch (_context9.n) {
|
|
3721
4217
|
case 0:
|
|
3722
|
-
|
|
4218
|
+
swapOptions = this._options.swapOptions;
|
|
4219
|
+
assertSwapSupport(swapOptions);
|
|
4220
|
+
_context9.n = 1;
|
|
3723
4221
|
return this.buildInternal();
|
|
3724
4222
|
case 1:
|
|
3725
|
-
_yield$this$buildInte2 =
|
|
4223
|
+
_yield$this$buildInte2 = _context9.v;
|
|
3726
4224
|
tx = _yield$this$buildInte2.tx;
|
|
3727
4225
|
options = _yield$this$buildInte2.options;
|
|
3728
|
-
return
|
|
4226
|
+
return _context9.a(2, buildDryRun(this.api, tx, options, {
|
|
3729
4227
|
sentAssetMintMode: 'preview',
|
|
3730
4228
|
mintFeeAssets: dryRunOptions === null || dryRunOptions === void 0 ? void 0 : dryRunOptions.mintFeeAssets
|
|
3731
4229
|
}));
|
|
3732
4230
|
}
|
|
3733
|
-
},
|
|
4231
|
+
}, _callee9, this);
|
|
3734
4232
|
}));
|
|
3735
4233
|
function dryRunPreview(_x6) {
|
|
3736
4234
|
return _dryRunPreview.apply(this, arguments);
|
|
@@ -3742,7 +4240,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3742
4240
|
value: function createTxFactory() {
|
|
3743
4241
|
var _this = this;
|
|
3744
4242
|
return function (amount, relative) {
|
|
3745
|
-
return
|
|
4243
|
+
return createTxOverrideAmount(_objectSpread2(_objectSpread2({}, _this._options), {}, {
|
|
3746
4244
|
api: _this.api
|
|
3747
4245
|
}), _this, amount, relative);
|
|
3748
4246
|
};
|
|
@@ -3755,23 +4253,33 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3755
4253
|
}, {
|
|
3756
4254
|
key: "getXcmFee",
|
|
3757
4255
|
value: (function () {
|
|
3758
|
-
var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4256
|
+
var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
|
|
3759
4257
|
var _options$disableFallb;
|
|
3760
|
-
var disableFallback, _yield$this$
|
|
3761
|
-
return _regenerator().w(function (
|
|
3762
|
-
while (1) switch (
|
|
4258
|
+
var disableFallback, _yield$this$prepareNo3, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset, version, swapOptions;
|
|
4259
|
+
return _regenerator().w(function (_context0) {
|
|
4260
|
+
while (1) switch (_context0.n) {
|
|
3763
4261
|
case 0:
|
|
3764
4262
|
disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
|
|
3765
|
-
|
|
4263
|
+
_context0.n = 1;
|
|
3766
4264
|
return this.prepareNormalizedOptions(this._options);
|
|
3767
4265
|
case 1:
|
|
3768
|
-
_yield$this$
|
|
3769
|
-
normalizedOptions = _yield$this$
|
|
3770
|
-
buildTx = _yield$this$
|
|
3771
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version;
|
|
4266
|
+
_yield$this$prepareNo3 = _context0.v;
|
|
4267
|
+
normalizedOptions = _yield$this$prepareNo3.normalizedOptions;
|
|
4268
|
+
buildTx = _yield$this$prepareNo3.buildTx;
|
|
4269
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
3772
4270
|
assertToIsString(to);
|
|
3773
4271
|
assertAddressIsString(address);
|
|
3774
|
-
|
|
4272
|
+
if (!swapOptions) {
|
|
4273
|
+
_context0.n = 2;
|
|
4274
|
+
break;
|
|
4275
|
+
}
|
|
4276
|
+
return _context0.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
|
|
4277
|
+
swapOptions: swapOptions
|
|
4278
|
+
}), function (builder) {
|
|
4279
|
+
return builder.getXcmFees(options);
|
|
4280
|
+
}));
|
|
4281
|
+
case 2:
|
|
4282
|
+
return _context0.a(2, getXcmFee({
|
|
3775
4283
|
api: api,
|
|
3776
4284
|
buildTx: buildTx,
|
|
3777
4285
|
origin: from,
|
|
@@ -3784,7 +4292,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3784
4292
|
disableFallback: disableFallback
|
|
3785
4293
|
}));
|
|
3786
4294
|
}
|
|
3787
|
-
},
|
|
4295
|
+
}, _callee0, this);
|
|
3788
4296
|
}));
|
|
3789
4297
|
function getXcmFee$1(_x7) {
|
|
3790
4298
|
return _getXcmFee2.apply(this, arguments);
|
|
@@ -3800,10 +4308,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3800
4308
|
}, {
|
|
3801
4309
|
key: "getOriginXcmFee",
|
|
3802
4310
|
value: (function () {
|
|
3803
|
-
var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4311
|
+
var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
3804
4312
|
var _ref,
|
|
3805
4313
|
disableFallback,
|
|
3806
|
-
_yield$this$
|
|
4314
|
+
_yield$this$prepareNo4,
|
|
3807
4315
|
normalizedOptions,
|
|
3808
4316
|
buildTx,
|
|
3809
4317
|
api,
|
|
@@ -3813,23 +4321,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3813
4321
|
currency,
|
|
3814
4322
|
feeAsset,
|
|
3815
4323
|
version,
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
4324
|
+
swapOptions,
|
|
4325
|
+
_args1 = arguments;
|
|
4326
|
+
return _regenerator().w(function (_context1) {
|
|
4327
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
3819
4328
|
case 0:
|
|
3820
|
-
_ref =
|
|
4329
|
+
_ref = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : {
|
|
3821
4330
|
disableFallback: false
|
|
3822
4331
|
}, disableFallback = _ref.disableFallback;
|
|
3823
|
-
|
|
4332
|
+
_context1.n = 1;
|
|
3824
4333
|
return this.prepareNormalizedOptions(this._options);
|
|
3825
4334
|
case 1:
|
|
3826
|
-
_yield$this$
|
|
3827
|
-
normalizedOptions = _yield$this$
|
|
3828
|
-
buildTx = _yield$this$
|
|
3829
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version;
|
|
4335
|
+
_yield$this$prepareNo4 = _context1.v;
|
|
4336
|
+
normalizedOptions = _yield$this$prepareNo4.normalizedOptions;
|
|
4337
|
+
buildTx = _yield$this$prepareNo4.buildTx;
|
|
4338
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
3830
4339
|
assertToIsString(to);
|
|
3831
|
-
|
|
3832
|
-
|
|
4340
|
+
assertSwapSupport(swapOptions);
|
|
4341
|
+
_context1.p = 2;
|
|
4342
|
+
_context1.n = 3;
|
|
3833
4343
|
return getOriginXcmFee({
|
|
3834
4344
|
api: api,
|
|
3835
4345
|
buildTx: buildTx,
|
|
@@ -3842,17 +4352,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3842
4352
|
disableFallback: disableFallback
|
|
3843
4353
|
});
|
|
3844
4354
|
case 3:
|
|
3845
|
-
return
|
|
4355
|
+
return _context1.a(2, _context1.v);
|
|
3846
4356
|
case 4:
|
|
3847
|
-
|
|
3848
|
-
|
|
4357
|
+
_context1.p = 4;
|
|
4358
|
+
_context1.n = 5;
|
|
3849
4359
|
return this.api.disconnect();
|
|
3850
4360
|
case 5:
|
|
3851
|
-
return
|
|
4361
|
+
return _context1.f(4);
|
|
3852
4362
|
case 6:
|
|
3853
|
-
return
|
|
4363
|
+
return _context1.a(2);
|
|
3854
4364
|
}
|
|
3855
|
-
},
|
|
4365
|
+
}, _callee1, this, [[2,, 4, 6]]);
|
|
3856
4366
|
}));
|
|
3857
4367
|
function getOriginXcmFee$1() {
|
|
3858
4368
|
return _getOriginXcmFee2.apply(this, arguments);
|
|
@@ -3874,26 +4384,27 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3874
4384
|
}, {
|
|
3875
4385
|
key: "getXcmFeeEstimate",
|
|
3876
4386
|
value: (function () {
|
|
3877
|
-
var _getXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3878
|
-
var _yield$this$
|
|
3879
|
-
return _regenerator().w(function (
|
|
3880
|
-
while (1) switch (
|
|
4387
|
+
var _getXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
4388
|
+
var _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, address, senderAddress, currency, swapOptions, tx;
|
|
4389
|
+
return _regenerator().w(function (_context10) {
|
|
4390
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
3881
4391
|
case 0:
|
|
3882
|
-
|
|
4392
|
+
_context10.n = 1;
|
|
3883
4393
|
return this.prepareNormalizedOptions(this._options);
|
|
3884
4394
|
case 1:
|
|
3885
|
-
_yield$this$
|
|
3886
|
-
normalizedOptions = _yield$this$
|
|
3887
|
-
buildTx = _yield$this$
|
|
3888
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency;
|
|
4395
|
+
_yield$this$prepareNo5 = _context10.v;
|
|
4396
|
+
normalizedOptions = _yield$this$prepareNo5.normalizedOptions;
|
|
4397
|
+
buildTx = _yield$this$prepareNo5.buildTx;
|
|
4398
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, swapOptions = normalizedOptions.swapOptions;
|
|
3889
4399
|
assertToIsString(to);
|
|
3890
4400
|
assertAddressIsString(address);
|
|
3891
|
-
|
|
4401
|
+
assertSwapSupport(swapOptions);
|
|
4402
|
+
_context10.n = 2;
|
|
3892
4403
|
return buildTx();
|
|
3893
4404
|
case 2:
|
|
3894
|
-
tx =
|
|
3895
|
-
|
|
3896
|
-
|
|
4405
|
+
tx = _context10.v;
|
|
4406
|
+
_context10.p = 3;
|
|
4407
|
+
_context10.n = 4;
|
|
3897
4408
|
return getXcmFeeEstimate({
|
|
3898
4409
|
api: api,
|
|
3899
4410
|
tx: tx,
|
|
@@ -3904,17 +4415,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3904
4415
|
currency: currency
|
|
3905
4416
|
});
|
|
3906
4417
|
case 4:
|
|
3907
|
-
return
|
|
4418
|
+
return _context10.a(2, _context10.v);
|
|
3908
4419
|
case 5:
|
|
3909
|
-
|
|
3910
|
-
|
|
4420
|
+
_context10.p = 5;
|
|
4421
|
+
_context10.n = 6;
|
|
3911
4422
|
return this.api.disconnect();
|
|
3912
4423
|
case 6:
|
|
3913
|
-
return
|
|
4424
|
+
return _context10.f(5);
|
|
3914
4425
|
case 7:
|
|
3915
|
-
return
|
|
4426
|
+
return _context10.a(2);
|
|
3916
4427
|
}
|
|
3917
|
-
},
|
|
4428
|
+
}, _callee10, this, [[3,, 5, 7]]);
|
|
3918
4429
|
}));
|
|
3919
4430
|
function getXcmFeeEstimate$1() {
|
|
3920
4431
|
return _getXcmFeeEstimate2.apply(this, arguments);
|
|
@@ -3936,25 +4447,26 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3936
4447
|
}, {
|
|
3937
4448
|
key: "getOriginXcmFeeEstimate",
|
|
3938
4449
|
value: (function () {
|
|
3939
|
-
var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3940
|
-
var _yield$this$
|
|
3941
|
-
return _regenerator().w(function (
|
|
3942
|
-
while (1) switch (
|
|
4450
|
+
var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
4451
|
+
var _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, senderAddress, currency, swapOptions, tx;
|
|
4452
|
+
return _regenerator().w(function (_context11) {
|
|
4453
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
3943
4454
|
case 0:
|
|
3944
|
-
|
|
4455
|
+
_context11.n = 1;
|
|
3945
4456
|
return this.prepareNormalizedOptions(this._options);
|
|
3946
4457
|
case 1:
|
|
3947
|
-
_yield$this$
|
|
3948
|
-
normalizedOptions = _yield$this$
|
|
3949
|
-
buildTx = _yield$this$
|
|
3950
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency;
|
|
4458
|
+
_yield$this$prepareNo6 = _context11.v;
|
|
4459
|
+
normalizedOptions = _yield$this$prepareNo6.normalizedOptions;
|
|
4460
|
+
buildTx = _yield$this$prepareNo6.buildTx;
|
|
4461
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, swapOptions = normalizedOptions.swapOptions;
|
|
3951
4462
|
assertToIsString(to);
|
|
3952
|
-
|
|
4463
|
+
assertSwapSupport(swapOptions);
|
|
4464
|
+
_context11.n = 2;
|
|
3953
4465
|
return buildTx();
|
|
3954
4466
|
case 2:
|
|
3955
|
-
tx =
|
|
3956
|
-
|
|
3957
|
-
|
|
4467
|
+
tx = _context11.v;
|
|
4468
|
+
_context11.p = 3;
|
|
4469
|
+
_context11.n = 4;
|
|
3958
4470
|
return getOriginXcmFeeEstimate({
|
|
3959
4471
|
api: api,
|
|
3960
4472
|
tx: tx,
|
|
@@ -3964,17 +4476,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3964
4476
|
senderAddress: senderAddress
|
|
3965
4477
|
});
|
|
3966
4478
|
case 4:
|
|
3967
|
-
return
|
|
4479
|
+
return _context11.a(2, _context11.v);
|
|
3968
4480
|
case 5:
|
|
3969
|
-
|
|
3970
|
-
|
|
4481
|
+
_context11.p = 5;
|
|
4482
|
+
_context11.n = 6;
|
|
3971
4483
|
return this.api.disconnect();
|
|
3972
4484
|
case 6:
|
|
3973
|
-
return
|
|
4485
|
+
return _context11.f(5);
|
|
3974
4486
|
case 7:
|
|
3975
|
-
return
|
|
4487
|
+
return _context11.a(2);
|
|
3976
4488
|
}
|
|
3977
|
-
},
|
|
4489
|
+
}, _callee11, this, [[3,, 5, 7]]);
|
|
3978
4490
|
}));
|
|
3979
4491
|
function getOriginXcmFeeEstimate$1() {
|
|
3980
4492
|
return _getOriginXcmFeeEstimate2.apply(this, arguments);
|
|
@@ -3990,20 +4502,30 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
3990
4502
|
}, {
|
|
3991
4503
|
key: "getTransferableAmount",
|
|
3992
4504
|
value: (function () {
|
|
3993
|
-
var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3994
|
-
var _yield$this$
|
|
3995
|
-
return _regenerator().w(function (
|
|
3996
|
-
while (1) switch (
|
|
4505
|
+
var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
4506
|
+
var _yield$this$prepareNo7, normalizedOptions, buildTx, api, from, to, senderAddress, currency, feeAsset, version, swapOptions;
|
|
4507
|
+
return _regenerator().w(function (_context12) {
|
|
4508
|
+
while (1) switch (_context12.n) {
|
|
3997
4509
|
case 0:
|
|
3998
|
-
|
|
4510
|
+
_context12.n = 1;
|
|
3999
4511
|
return this.prepareNormalizedOptions(this._options);
|
|
4000
4512
|
case 1:
|
|
4001
|
-
_yield$this$
|
|
4002
|
-
normalizedOptions = _yield$this$
|
|
4003
|
-
buildTx = _yield$this$
|
|
4004
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version;
|
|
4513
|
+
_yield$this$prepareNo7 = _context12.v;
|
|
4514
|
+
normalizedOptions = _yield$this$prepareNo7.normalizedOptions;
|
|
4515
|
+
buildTx = _yield$this$prepareNo7.buildTx;
|
|
4516
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
4005
4517
|
assertToIsString(to);
|
|
4006
|
-
|
|
4518
|
+
if (!swapOptions) {
|
|
4519
|
+
_context12.n = 2;
|
|
4520
|
+
break;
|
|
4521
|
+
}
|
|
4522
|
+
return _context12.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
|
|
4523
|
+
swapOptions: swapOptions
|
|
4524
|
+
}), function (builder) {
|
|
4525
|
+
return builder.getTransferableAmount();
|
|
4526
|
+
}));
|
|
4527
|
+
case 2:
|
|
4528
|
+
return _context12.a(2, getTransferableAmount({
|
|
4007
4529
|
api: api,
|
|
4008
4530
|
buildTx: buildTx,
|
|
4009
4531
|
origin: from,
|
|
@@ -4014,7 +4536,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4014
4536
|
currency: currency
|
|
4015
4537
|
}));
|
|
4016
4538
|
}
|
|
4017
|
-
},
|
|
4539
|
+
}, _callee12, this);
|
|
4018
4540
|
}));
|
|
4019
4541
|
function getTransferableAmount$1() {
|
|
4020
4542
|
return _getTransferableAmount2.apply(this, arguments);
|
|
@@ -4030,771 +4552,580 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4030
4552
|
}, {
|
|
4031
4553
|
key: "getMinTransferableAmount",
|
|
4032
4554
|
value: (function () {
|
|
4033
|
-
var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4034
|
-
var _yield$this$
|
|
4035
|
-
return _regenerator().w(function (_context11) {
|
|
4036
|
-
while (1) switch (_context11.n) {
|
|
4037
|
-
case 0:
|
|
4038
|
-
_context11.n = 1;
|
|
4039
|
-
return this.prepareNormalizedOptions(this._options);
|
|
4040
|
-
case 1:
|
|
4041
|
-
_yield$this$prepareNo7 = _context11.v;
|
|
4042
|
-
normalizedOptions = _yield$this$prepareNo7.normalizedOptions;
|
|
4043
|
-
buildTx = _yield$this$prepareNo7.buildTx;
|
|
4044
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version;
|
|
4045
|
-
assertToIsString(to);
|
|
4046
|
-
assertAddressIsString(address);
|
|
4047
|
-
return _context11.a(2, getMinTransferableAmount({
|
|
4048
|
-
api: api,
|
|
4049
|
-
buildTx: buildTx,
|
|
4050
|
-
origin: from,
|
|
4051
|
-
destination: to,
|
|
4052
|
-
senderAddress: senderAddress,
|
|
4053
|
-
address: address,
|
|
4054
|
-
feeAsset: feeAsset,
|
|
4055
|
-
version: version,
|
|
4056
|
-
currency: currency,
|
|
4057
|
-
builder: this
|
|
4058
|
-
}));
|
|
4059
|
-
}
|
|
4060
|
-
}, _callee11, this);
|
|
4061
|
-
}));
|
|
4062
|
-
function getMinTransferableAmount$1() {
|
|
4063
|
-
return _getMinTransferableAmount2.apply(this, arguments);
|
|
4064
|
-
}
|
|
4065
|
-
return getMinTransferableAmount$1;
|
|
4066
|
-
}()
|
|
4067
|
-
/**
|
|
4068
|
-
* Returns the max transferable amount for the transfer
|
|
4069
|
-
*
|
|
4070
|
-
* @returns The max transferable amount.
|
|
4071
|
-
*/
|
|
4072
|
-
)
|
|
4073
|
-
}, {
|
|
4074
|
-
key: "verifyEdOnDestination",
|
|
4075
|
-
value: (function () {
|
|
4076
|
-
var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
4077
|
-
var _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, address, currency, senderAddress, feeAsset, version;
|
|
4078
|
-
return _regenerator().w(function (_context12) {
|
|
4079
|
-
while (1) switch (_context12.n) {
|
|
4080
|
-
case 0:
|
|
4081
|
-
_context12.n = 1;
|
|
4082
|
-
return this.prepareNormalizedOptions(this._options);
|
|
4083
|
-
case 1:
|
|
4084
|
-
_yield$this$prepareNo8 = _context12.v;
|
|
4085
|
-
normalizedOptions = _yield$this$prepareNo8.normalizedOptions;
|
|
4086
|
-
buildTx = _yield$this$prepareNo8.buildTx;
|
|
4087
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, currency = normalizedOptions.currency, senderAddress = normalizedOptions.senderAddress, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version;
|
|
4088
|
-
assertToIsString(to);
|
|
4089
|
-
assertAddressIsString(address);
|
|
4090
|
-
return _context12.a(2, verifyEdOnDestination({
|
|
4091
|
-
api: api,
|
|
4092
|
-
buildTx: buildTx,
|
|
4093
|
-
origin: from,
|
|
4094
|
-
destination: to,
|
|
4095
|
-
address: address,
|
|
4096
|
-
version: version,
|
|
4097
|
-
senderAddress: senderAddress,
|
|
4098
|
-
feeAsset: feeAsset,
|
|
4099
|
-
currency: currency
|
|
4100
|
-
}));
|
|
4101
|
-
}
|
|
4102
|
-
}, _callee12, this);
|
|
4103
|
-
}));
|
|
4104
|
-
function verifyEdOnDestination$1() {
|
|
4105
|
-
return _verifyEdOnDestination2.apply(this, arguments);
|
|
4106
|
-
}
|
|
4107
|
-
return verifyEdOnDestination$1;
|
|
4108
|
-
}()
|
|
4109
|
-
/**
|
|
4110
|
-
* Returns the transfer info for the transfer
|
|
4111
|
-
*
|
|
4112
|
-
* @returns The transfer info.
|
|
4113
|
-
*/
|
|
4114
|
-
)
|
|
4115
|
-
}, {
|
|
4116
|
-
key: "getTransferInfo",
|
|
4117
|
-
value: (function () {
|
|
4118
|
-
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
4119
|
-
var _yield$this$prepareNo9, normalizedOptions, buildTx, api, from, to, address, currency, ahAddress, senderAddress, feeAsset, version;
|
|
4555
|
+
var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
4556
|
+
var _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset, version, swapOptions;
|
|
4120
4557
|
return _regenerator().w(function (_context13) {
|
|
4121
4558
|
while (1) switch (_context13.n) {
|
|
4122
4559
|
case 0:
|
|
4123
4560
|
_context13.n = 1;
|
|
4124
4561
|
return this.prepareNormalizedOptions(this._options);
|
|
4125
4562
|
case 1:
|
|
4126
|
-
_yield$this$
|
|
4127
|
-
normalizedOptions = _yield$this$
|
|
4128
|
-
buildTx = _yield$this$
|
|
4129
|
-
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to,
|
|
4130
|
-
assertToIsString(to);
|
|
4131
|
-
assertAddressIsString(address);
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
}, {
|
|
4160
|
-
key: "getReceivableAmount",
|
|
4161
|
-
value: (function () {
|
|
4162
|
-
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
4163
|
-
var _yield$this$getTransf, receivedAmount;
|
|
4164
|
-
return _regenerator().w(function (_context14) {
|
|
4165
|
-
while (1) switch (_context14.n) {
|
|
4166
|
-
case 0:
|
|
4167
|
-
_context14.n = 1;
|
|
4168
|
-
return this.getTransferInfo();
|
|
4169
|
-
case 1:
|
|
4170
|
-
_yield$this$getTransf = _context14.v;
|
|
4171
|
-
receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
|
|
4172
|
-
if (!(receivedAmount instanceof UnableToComputeError)) {
|
|
4173
|
-
_context14.n = 2;
|
|
4174
|
-
break;
|
|
4175
|
-
}
|
|
4176
|
-
throw receivedAmount;
|
|
4177
|
-
case 2:
|
|
4178
|
-
return _context14.a(2, receivedAmount);
|
|
4179
|
-
}
|
|
4180
|
-
}, _callee14, this);
|
|
4181
|
-
}));
|
|
4182
|
-
function getReceivableAmount() {
|
|
4183
|
-
return _getReceivableAmount.apply(this, arguments);
|
|
4184
|
-
}
|
|
4185
|
-
return getReceivableAmount;
|
|
4186
|
-
}())
|
|
4187
|
-
}, {
|
|
4188
|
-
key: "signAndSubmit",
|
|
4189
|
-
value: function () {
|
|
4190
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
4191
|
-
var sender, _yield$this$buildInte3, tx;
|
|
4192
|
-
return _regenerator().w(function (_context15) {
|
|
4193
|
-
while (1) switch (_context15.n) {
|
|
4194
|
-
case 0:
|
|
4195
|
-
sender = this._options.sender;
|
|
4196
|
-
assertSender(sender);
|
|
4197
|
-
_context15.n = 1;
|
|
4198
|
-
return this.buildInternal();
|
|
4199
|
-
case 1:
|
|
4200
|
-
_yield$this$buildInte3 = _context15.v;
|
|
4201
|
-
tx = _yield$this$buildInte3.tx;
|
|
4202
|
-
return _context15.a(2, this.api.signAndSubmit(tx, sender));
|
|
4203
|
-
}
|
|
4204
|
-
}, _callee15, this);
|
|
4205
|
-
}));
|
|
4206
|
-
function signAndSubmit() {
|
|
4207
|
-
return _signAndSubmit.apply(this, arguments);
|
|
4208
|
-
}
|
|
4209
|
-
return signAndSubmit;
|
|
4210
|
-
}()
|
|
4211
|
-
/**
|
|
4212
|
-
* Returns the API instance used by the builder.
|
|
4213
|
-
*
|
|
4214
|
-
* @returns The API instance.
|
|
4215
|
-
*/
|
|
4216
|
-
}, {
|
|
4217
|
-
key: "getApi",
|
|
4218
|
-
value: function getApi() {
|
|
4219
|
-
return this.api.getApi();
|
|
4220
|
-
}
|
|
4221
|
-
/**
|
|
4222
|
-
* Disconnects the API.
|
|
4223
|
-
*
|
|
4224
|
-
* @returns A Promise that resolves when the API is disconnected.
|
|
4225
|
-
*/
|
|
4226
|
-
}, {
|
|
4227
|
-
key: "disconnect",
|
|
4228
|
-
value: function disconnect() {
|
|
4229
|
-
return this.api.disconnect();
|
|
4230
|
-
}
|
|
4231
|
-
}]);
|
|
4232
|
-
}();
|
|
4233
|
-
/**
|
|
4234
|
-
* Creates a new Builder instance.
|
|
4235
|
-
*
|
|
4236
|
-
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
4237
|
-
* @returns A new Builder instance.
|
|
4238
|
-
*/
|
|
4239
|
-
var Builder = function Builder(api) {
|
|
4240
|
-
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
4241
|
-
};
|
|
4242
|
-
|
|
4243
|
-
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
4244
|
-
if (isChainEvm(chain)) {
|
|
4245
|
-
return isAddress(address) ? address : senderAddress;
|
|
4246
|
-
}
|
|
4247
|
-
return isAddress(address) ? senderAddress : address;
|
|
4248
|
-
};
|
|
4249
|
-
var getReverseTxFee = /*#__PURE__*/function () {
|
|
4250
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
4251
|
-
var api, origin, destination, senderAddress, address, skipReverseFeeCalculation, toAddress, fromAddress, _yield$Builder$from$t, tx, _yield$api$getPayment, partialFee;
|
|
4252
|
-
return _regenerator().w(function (_context) {
|
|
4253
|
-
while (1) switch (_context.n) {
|
|
4254
|
-
case 0:
|
|
4255
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
4256
|
-
if (!skipReverseFeeCalculation) {
|
|
4257
|
-
_context.n = 1;
|
|
4258
|
-
break;
|
|
4259
|
-
}
|
|
4260
|
-
return _context.a(2, 0n);
|
|
4261
|
-
case 1:
|
|
4262
|
-
toAddress = determineAddress(origin, address, senderAddress);
|
|
4263
|
-
fromAddress = determineAddress(destination, address, senderAddress);
|
|
4264
|
-
_context.n = 2;
|
|
4265
|
-
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
|
|
4266
|
-
case 2:
|
|
4267
|
-
_yield$Builder$from$t = _context.v;
|
|
4268
|
-
tx = _yield$Builder$from$t.tx;
|
|
4269
|
-
_context.n = 3;
|
|
4270
|
-
return api.getPaymentInfo(tx, fromAddress);
|
|
4271
|
-
case 3:
|
|
4272
|
-
_yield$api$getPayment = _context.v;
|
|
4273
|
-
partialFee = _yield$api$getPayment.partialFee;
|
|
4274
|
-
return _context.a(2, padFee(partialFee, origin, destination, 'destination'));
|
|
4275
|
-
}
|
|
4276
|
-
}, _callee);
|
|
4277
|
-
}));
|
|
4278
|
-
return function getReverseTxFee(_x, _x2) {
|
|
4279
|
-
return _ref2.apply(this, arguments);
|
|
4280
|
-
};
|
|
4281
|
-
}();
|
|
4282
|
-
|
|
4283
|
-
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4284
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
4285
|
-
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
4286
|
-
return _regenerator().w(function (_context) {
|
|
4287
|
-
while (1) switch (_context.n) {
|
|
4288
|
-
case 0:
|
|
4289
|
-
if (!feeAsset) {
|
|
4290
|
-
_context.n = 1;
|
|
4291
|
-
break;
|
|
4292
|
-
}
|
|
4293
|
-
return _context.a(2, undefined);
|
|
4294
|
-
case 1:
|
|
4295
|
-
edNative = getExistentialDepositOrThrow(origin);
|
|
4296
|
-
_context.n = 2;
|
|
4297
|
-
return getBalanceInternal({
|
|
4298
|
-
api: api,
|
|
4299
|
-
chain: origin,
|
|
4300
|
-
address: senderAddress
|
|
4301
|
-
});
|
|
4302
|
-
case 2:
|
|
4303
|
-
balanceNative = _context.v;
|
|
4304
|
-
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
|
|
4305
|
-
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4306
|
-
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
4307
|
-
_context.n = 3;
|
|
4308
|
-
break;
|
|
4309
|
-
}
|
|
4310
|
-
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4311
|
-
case 3:
|
|
4312
|
-
if (isNativeAssetToOrigin) {
|
|
4313
|
-
_context.n = 5;
|
|
4314
|
-
break;
|
|
4315
|
-
}
|
|
4316
|
-
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
4317
|
-
_context.n = 4;
|
|
4318
|
-
return getAssetBalanceInternal({
|
|
4319
|
-
api: api,
|
|
4320
|
-
chain: origin,
|
|
4321
|
-
address: senderAddress,
|
|
4322
|
-
asset: asset
|
|
4323
|
-
});
|
|
4324
|
-
case 4:
|
|
4325
|
-
balanceAsset = _context.v;
|
|
4326
|
-
edAsset = getEdFromAssetOrThrow(asset);
|
|
4327
|
-
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
4328
|
-
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
4329
|
-
case 5:
|
|
4330
|
-
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4331
|
-
case 6:
|
|
4332
|
-
return _context.a(2);
|
|
4333
|
-
}
|
|
4334
|
-
}, _callee);
|
|
4335
|
-
}));
|
|
4336
|
-
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
4337
|
-
return _ref.apply(this, arguments);
|
|
4338
|
-
};
|
|
4339
|
-
}();
|
|
4340
|
-
var isSufficientDestination = /*#__PURE__*/function () {
|
|
4341
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
|
|
4342
|
-
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
4343
|
-
return _regenerator().w(function (_context2) {
|
|
4344
|
-
while (1) switch (_context2.n) {
|
|
4345
|
-
case 0:
|
|
4346
|
-
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4347
|
-
if (isNativeAsset) {
|
|
4348
|
-
_context2.n = 1;
|
|
4349
|
-
break;
|
|
4350
|
-
}
|
|
4351
|
-
return _context2.a(2, undefined);
|
|
4352
|
-
case 1:
|
|
4353
|
-
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
4354
|
-
_context2.n = 2;
|
|
4355
|
-
return getBalanceInternal({
|
|
4356
|
-
api: api,
|
|
4357
|
-
chain: destination,
|
|
4358
|
-
address: address
|
|
4359
|
-
});
|
|
4360
|
-
case 2:
|
|
4361
|
-
nativeBalance = _context2.v;
|
|
4362
|
-
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
4363
|
-
}
|
|
4364
|
-
}, _callee2);
|
|
4365
|
-
}));
|
|
4366
|
-
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
4367
|
-
return _ref2.apply(this, arguments);
|
|
4368
|
-
};
|
|
4369
|
-
}();
|
|
4370
|
-
|
|
4371
|
-
var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
4372
|
-
if (isRelayChain(origin)) return DOT_LOCATION;
|
|
4373
|
-
return {
|
|
4374
|
-
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
4375
|
-
interior: {
|
|
4376
|
-
X1: [{
|
|
4377
|
-
Parachain: getParaId(origin)
|
|
4378
|
-
}]
|
|
4379
|
-
}
|
|
4380
|
-
};
|
|
4381
|
-
};
|
|
4382
|
-
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4383
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
4384
|
-
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4385
|
-
return _regenerator().w(function (_context3) {
|
|
4386
|
-
while (1) switch (_context3.n) {
|
|
4387
|
-
case 0:
|
|
4388
|
-
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
4389
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4390
|
-
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4391
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
4392
|
-
var attempt, _t2;
|
|
4393
|
-
return _regenerator().w(function (_context2) {
|
|
4394
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
4395
|
-
case 0:
|
|
4396
|
-
if (!isExternalChain(destination)) {
|
|
4397
|
-
_context2.n = 1;
|
|
4398
|
-
break;
|
|
4399
|
-
}
|
|
4400
|
-
return _context2.a(2, 0n);
|
|
4401
|
-
case 1:
|
|
4402
|
-
attempt = /*#__PURE__*/function () {
|
|
4403
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
|
|
4404
|
-
var assetInfo, _t;
|
|
4405
|
-
return _regenerator().w(function (_context) {
|
|
4406
|
-
while (1) switch (_context.p = _context.n) {
|
|
4407
|
-
case 0:
|
|
4408
|
-
assetInfo = findAssetInfoOrThrow(chain, curr, destination);
|
|
4409
|
-
_context.p = 1;
|
|
4410
|
-
_context.n = 2;
|
|
4411
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4412
|
-
destination: destination
|
|
4413
|
-
}), {
|
|
4414
|
-
location: assetInfo.location,
|
|
4415
|
-
amount: amt
|
|
4416
|
-
});
|
|
4417
|
-
case 2:
|
|
4418
|
-
return _context.a(2, _context.v);
|
|
4419
|
-
case 3:
|
|
4420
|
-
_context.p = 3;
|
|
4421
|
-
_t = _context.v;
|
|
4422
|
-
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4423
|
-
_context.n = 5;
|
|
4424
|
-
break;
|
|
4425
|
-
}
|
|
4426
|
-
_context.n = 4;
|
|
4427
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4428
|
-
destination: destination
|
|
4429
|
-
}), {
|
|
4430
|
-
symbol: assetInfo.symbol,
|
|
4431
|
-
amount: amt
|
|
4432
|
-
});
|
|
4433
|
-
case 4:
|
|
4434
|
-
return _context.a(2, _context.v);
|
|
4435
|
-
case 5:
|
|
4436
|
-
throw _t;
|
|
4437
|
-
case 6:
|
|
4438
|
-
return _context.a(2);
|
|
4439
|
-
}
|
|
4440
|
-
}, _callee, null, [[1, 3]]);
|
|
4441
|
-
}));
|
|
4442
|
-
return function attempt(_x2, _x3, _x4) {
|
|
4443
|
-
return _ref3.apply(this, arguments);
|
|
4444
|
-
};
|
|
4445
|
-
}();
|
|
4446
|
-
_context2.p = 2;
|
|
4447
|
-
_context2.n = 3;
|
|
4448
|
-
return attempt(origin, currency, currency.amount);
|
|
4449
|
-
case 3:
|
|
4450
|
-
return _context2.a(2, _context2.v);
|
|
4451
|
-
case 4:
|
|
4452
|
-
_context2.p = 4;
|
|
4453
|
-
_t2 = _context2.v;
|
|
4454
|
-
if (!(!(_t2 instanceof InvalidCurrencyError) || !swapConfig)) {
|
|
4455
|
-
_context2.n = 5;
|
|
4456
|
-
break;
|
|
4457
|
-
}
|
|
4458
|
-
return _context2.a(2, 0n);
|
|
4459
|
-
case 5:
|
|
4460
|
-
_context2.n = 6;
|
|
4461
|
-
return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
|
|
4462
|
-
case 6:
|
|
4463
|
-
return _context2.a(2, _context2.v);
|
|
4464
|
-
}
|
|
4465
|
-
}, _callee2, null, [[2, 4]]);
|
|
4466
|
-
}));
|
|
4467
|
-
return function calcPaymentInfoFee() {
|
|
4468
|
-
return _ref2.apply(this, arguments);
|
|
4469
|
-
};
|
|
4470
|
-
}();
|
|
4471
|
-
if (!(!hasDryRunSupport(destination) || !forwardedXcms || isExternalChain(destination))) {
|
|
4472
|
-
_context3.n = 3;
|
|
4473
|
-
break;
|
|
4474
|
-
}
|
|
4475
|
-
_context3.n = 1;
|
|
4476
|
-
return calcPaymentInfoFee();
|
|
4477
|
-
case 1:
|
|
4478
|
-
_fee = _context3.v;
|
|
4479
|
-
_context3.n = 2;
|
|
4480
|
-
return isSufficientDestination(api, destination, address, currency.amount, asset, _fee);
|
|
4481
|
-
case 2:
|
|
4482
|
-
sufficient = _context3.v;
|
|
4483
|
-
return _context3.a(2, {
|
|
4484
|
-
fee: _fee,
|
|
4485
|
-
feeType: 'paymentInfo',
|
|
4486
|
-
sufficient: sufficient,
|
|
4487
|
-
asset: asset
|
|
4488
|
-
});
|
|
4489
|
-
case 3:
|
|
4490
|
-
_context3.n = 4;
|
|
4491
|
-
return api.getDryRunXcm({
|
|
4492
|
-
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
|
|
4493
|
-
tx: tx,
|
|
4494
|
-
xcm: forwardedXcms[1][0],
|
|
4495
|
-
chain: destination,
|
|
4496
|
-
origin: origin,
|
|
4497
|
-
asset: asset,
|
|
4498
|
-
version: version,
|
|
4499
|
-
originFee: originFee,
|
|
4500
|
-
feeAsset: resolvedFeeAsset,
|
|
4501
|
-
amount: normalizeAmount(currency.amount)
|
|
4502
|
-
});
|
|
4503
|
-
case 4:
|
|
4504
|
-
dryRunResult = _context3.v;
|
|
4505
|
-
if (dryRunResult.success) {
|
|
4506
|
-
_context3.n = 7;
|
|
4507
|
-
break;
|
|
4508
|
-
}
|
|
4509
|
-
if (!disableFallback) {
|
|
4510
|
-
_context3.n = 5;
|
|
4511
|
-
break;
|
|
4512
|
-
}
|
|
4513
|
-
return _context3.a(2, {
|
|
4514
|
-
dryRunError: dryRunResult.failureReason,
|
|
4515
|
-
dryRunSubError: dryRunResult.failureSubReason
|
|
4516
|
-
});
|
|
4517
|
-
case 5:
|
|
4518
|
-
_context3.n = 6;
|
|
4519
|
-
return calcPaymentInfoFee();
|
|
4520
|
-
case 6:
|
|
4521
|
-
_fee2 = _context3.v;
|
|
4522
|
-
return _context3.a(2, {
|
|
4523
|
-
fee: _fee2,
|
|
4524
|
-
feeType: 'paymentInfo',
|
|
4525
|
-
dryRunError: dryRunResult.failureReason,
|
|
4526
|
-
dryRunSubError: dryRunResult.failureSubReason,
|
|
4527
|
-
sufficient: false,
|
|
4528
|
-
asset: asset
|
|
4529
|
-
});
|
|
4530
|
-
case 7:
|
|
4531
|
-
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4532
|
-
return _context3.a(2, {
|
|
4533
|
-
fee: fee,
|
|
4534
|
-
feeType: 'dryRun',
|
|
4535
|
-
sufficient: true,
|
|
4536
|
-
forwardedXcms: newForwardedXcms,
|
|
4537
|
-
destParaId: destParaId,
|
|
4538
|
-
asset: asset
|
|
4539
|
-
});
|
|
4540
|
-
}
|
|
4541
|
-
}, _callee3);
|
|
4542
|
-
}));
|
|
4543
|
-
return function getDestXcmFee(_x) {
|
|
4544
|
-
return _ref.apply(this, arguments);
|
|
4545
|
-
};
|
|
4546
|
-
}();
|
|
4547
|
-
|
|
4548
|
-
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
4549
|
-
return assetCheckEnabled ? findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null) : null;
|
|
4550
|
-
};
|
|
4551
|
-
|
|
4552
|
-
var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
4553
|
-
var _findAssetInfoOnDest;
|
|
4554
|
-
var api = _ref.api,
|
|
4555
|
-
tx = _ref.tx,
|
|
4556
|
-
originChain = _ref.originChain,
|
|
4557
|
-
currentChain = _ref.currentChain,
|
|
4558
|
-
destination = _ref.destination,
|
|
4559
|
-
swapConfig = _ref.swapConfig,
|
|
4560
|
-
asset = _ref.asset,
|
|
4561
|
-
hasPassedExchange = _ref.hasPassedExchange,
|
|
4562
|
-
currency = _ref.currency;
|
|
4563
|
-
var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
|
|
4564
|
-
var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
|
|
4565
|
-
if (useRelayAssetAsFee) {
|
|
4566
|
-
return findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
4567
|
-
}
|
|
4568
|
-
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
4569
|
-
return findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
4570
|
-
}
|
|
4571
|
-
return (_findAssetInfoOnDest = findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
|
|
4572
|
-
};
|
|
4573
|
-
|
|
4574
|
-
var getEthereumJunction = function getEthereumJunction(chain) {
|
|
4575
|
-
var useBigInt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
4576
|
-
var relayChain = getRelayChainOf(chain);
|
|
4577
|
-
var isTestnet = relayChain === 'Westend' || relayChain === 'Paseo';
|
|
4578
|
-
var chainId = isTestnet ? ETH_TESTNET_PARA_ID : ETH_MAINNET_PARA_ID;
|
|
4579
|
-
return {
|
|
4580
|
-
GlobalConsensus: {
|
|
4581
|
-
Ethereum: {
|
|
4582
|
-
chainId: useBigInt ? BigInt(chainId) : chainId
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
};
|
|
4586
|
-
};
|
|
4587
|
-
|
|
4588
|
-
var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge) {
|
|
4589
|
-
if (!asset || isTLocation(destination) || isExternalChain(destination) || !isBridge) {
|
|
4590
|
-
return;
|
|
4591
|
-
}
|
|
4592
|
-
var nativeAsset = findNativeAssetInfoOrThrow(origin);
|
|
4593
|
-
var isNativeAsset = isAssetEqual(asset, nativeAsset);
|
|
4594
|
-
var isBridgedStablecoin = isStableCoinAsset(asset);
|
|
4595
|
-
if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
|
|
4596
|
-
throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
4597
|
-
}
|
|
4598
|
-
};
|
|
4599
|
-
var validateEcosystems = function validateEcosystems(origin, destination) {
|
|
4600
|
-
if (isTLocation(destination)) return;
|
|
4601
|
-
var relayChain = getRelayChainOf(origin);
|
|
4602
|
-
var destinationToRelayChains = {
|
|
4603
|
-
Ethereum: ['Polkadot'],
|
|
4604
|
-
EthereumTestnet: ['Westend', 'Paseo']
|
|
4605
|
-
};
|
|
4606
|
-
var allowedRelayChains = destinationToRelayChains[destination];
|
|
4607
|
-
if (!allowedRelayChains) return;
|
|
4608
|
-
if (!allowedRelayChains.includes(relayChain)) {
|
|
4609
|
-
throw new InvalidCurrencyError("Destination ".concat(destination, " is only supported from following ecosystems: ").concat(allowedRelayChains.join(', '), "."));
|
|
4610
|
-
}
|
|
4611
|
-
};
|
|
4612
|
-
var validateEthereumAsset = function validateEthereumAsset(origin, destination, asset) {
|
|
4613
|
-
if (!asset || !isTLocation(destination) && !isSnowbridge(origin, destination) || origin === 'Mythos') {
|
|
4614
|
-
return;
|
|
4615
|
-
}
|
|
4616
|
-
validateEcosystems(origin, destination);
|
|
4617
|
-
var ADDITIONAL_ALLOWED_LOCATIONS = [RELAY_LOCATION, {
|
|
4618
|
-
parents: 2,
|
|
4619
|
-
interior: {
|
|
4620
|
-
X1: [{
|
|
4621
|
-
GlobalConsensus: {
|
|
4622
|
-
Kusama: null
|
|
4623
|
-
}
|
|
4624
|
-
}]
|
|
4625
|
-
}
|
|
4626
|
-
}];
|
|
4627
|
-
var isEthCompatibleAsset = asset.location.parents === Parents.TWO && deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(origin, false).GlobalConsensus) || ADDITIONAL_ALLOWED_LOCATIONS.some(function (loc) {
|
|
4628
|
-
return deepEqual(asset.location, loc);
|
|
4629
|
-
});
|
|
4630
|
-
if (!isEthCompatibleAsset) {
|
|
4631
|
-
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(asset, replaceBigInt), " is not transferable to Ethereum."));
|
|
4632
|
-
}
|
|
4633
|
-
};
|
|
4634
|
-
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
4635
|
-
var origin = _ref.from,
|
|
4636
|
-
destination = _ref.to,
|
|
4637
|
-
currency = _ref.currency;
|
|
4638
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
4639
|
-
if (asset === null && assetCheckEnabled) {
|
|
4640
|
-
throwUnsupportedCurrency(currency, origin);
|
|
4641
|
-
}
|
|
4642
|
-
if (!isLocationDestination && assetCheckEnabled && !findAssetInfoOnDest(origin, destination, currency, asset)) {
|
|
4643
|
-
throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
4644
|
-
}
|
|
4645
|
-
validateBridgeAsset(origin, destination, asset, currency, isBridge);
|
|
4646
|
-
validateEthereumAsset(origin, destination, asset);
|
|
4647
|
-
};
|
|
4648
|
-
|
|
4649
|
-
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
4650
|
-
var api = options.api,
|
|
4651
|
-
currency = options.currency,
|
|
4652
|
-
feeAsset = options.feeAsset,
|
|
4653
|
-
origin = options.from,
|
|
4654
|
-
destination = options.to;
|
|
4655
|
-
if ('location' in currency && isOverrideLocationSpecifier(currency.location)) {
|
|
4656
|
-
return currency.location.value;
|
|
4657
|
-
}
|
|
4658
|
-
if (Array.isArray(currency)) {
|
|
4659
|
-
if (!feeAsset) {
|
|
4660
|
-
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
4661
|
-
}
|
|
4662
|
-
if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
|
|
4663
|
-
throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
4664
|
-
}
|
|
4665
|
-
if (currency.every(function (asset) {
|
|
4666
|
-
return isTAsset(asset);
|
|
4667
|
-
})) {
|
|
4668
|
-
if (!feeAsset) {
|
|
4669
|
-
throw new InvalidCurrencyError('Fee asset not provided');
|
|
4563
|
+
_yield$this$prepareNo8 = _context13.v;
|
|
4564
|
+
normalizedOptions = _yield$this$prepareNo8.normalizedOptions;
|
|
4565
|
+
buildTx = _yield$this$prepareNo8.buildTx;
|
|
4566
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
4567
|
+
assertToIsString(to);
|
|
4568
|
+
assertAddressIsString(address);
|
|
4569
|
+
if (!swapOptions) {
|
|
4570
|
+
_context13.n = 2;
|
|
4571
|
+
break;
|
|
4572
|
+
}
|
|
4573
|
+
return _context13.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
|
|
4574
|
+
swapOptions: swapOptions
|
|
4575
|
+
}), function (builder) {
|
|
4576
|
+
return builder.getMinTransferableAmount();
|
|
4577
|
+
}));
|
|
4578
|
+
case 2:
|
|
4579
|
+
return _context13.a(2, getMinTransferableAmount({
|
|
4580
|
+
api: api,
|
|
4581
|
+
buildTx: buildTx,
|
|
4582
|
+
origin: from,
|
|
4583
|
+
destination: to,
|
|
4584
|
+
senderAddress: senderAddress,
|
|
4585
|
+
address: address,
|
|
4586
|
+
feeAsset: feeAsset,
|
|
4587
|
+
version: version,
|
|
4588
|
+
currency: currency,
|
|
4589
|
+
builder: this
|
|
4590
|
+
}));
|
|
4591
|
+
}
|
|
4592
|
+
}, _callee13, this);
|
|
4593
|
+
}));
|
|
4594
|
+
function getMinTransferableAmount$1() {
|
|
4595
|
+
return _getMinTransferableAmount2.apply(this, arguments);
|
|
4670
4596
|
}
|
|
4671
|
-
|
|
4672
|
-
|
|
4597
|
+
return getMinTransferableAmount$1;
|
|
4598
|
+
}()
|
|
4599
|
+
/**
|
|
4600
|
+
* Returns the max transferable amount for the transfer
|
|
4601
|
+
*
|
|
4602
|
+
* @returns The max transferable amount.
|
|
4603
|
+
*/
|
|
4604
|
+
)
|
|
4605
|
+
}, {
|
|
4606
|
+
key: "verifyEdOnDestination",
|
|
4607
|
+
value: (function () {
|
|
4608
|
+
var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
4609
|
+
var _yield$this$prepareNo9, normalizedOptions, buildTx, api, from, to, address, currency, senderAddress, feeAsset, version, swapOptions;
|
|
4610
|
+
return _regenerator().w(function (_context14) {
|
|
4611
|
+
while (1) switch (_context14.n) {
|
|
4612
|
+
case 0:
|
|
4613
|
+
_context14.n = 1;
|
|
4614
|
+
return this.prepareNormalizedOptions(this._options);
|
|
4615
|
+
case 1:
|
|
4616
|
+
_yield$this$prepareNo9 = _context14.v;
|
|
4617
|
+
normalizedOptions = _yield$this$prepareNo9.normalizedOptions;
|
|
4618
|
+
buildTx = _yield$this$prepareNo9.buildTx;
|
|
4619
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, currency = normalizedOptions.currency, senderAddress = normalizedOptions.senderAddress, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
4620
|
+
assertToIsString(to);
|
|
4621
|
+
assertAddressIsString(address);
|
|
4622
|
+
assertSwapSupport(swapOptions);
|
|
4623
|
+
return _context14.a(2, verifyEdOnDestination({
|
|
4624
|
+
api: api,
|
|
4625
|
+
buildTx: buildTx,
|
|
4626
|
+
origin: from,
|
|
4627
|
+
destination: to,
|
|
4628
|
+
address: address,
|
|
4629
|
+
version: version,
|
|
4630
|
+
senderAddress: senderAddress,
|
|
4631
|
+
feeAsset: feeAsset,
|
|
4632
|
+
currency: currency
|
|
4633
|
+
}));
|
|
4634
|
+
}
|
|
4635
|
+
}, _callee14, this);
|
|
4636
|
+
}));
|
|
4637
|
+
function verifyEdOnDestination$1() {
|
|
4638
|
+
return _verifyEdOnDestination2.apply(this, arguments);
|
|
4673
4639
|
}
|
|
4674
|
-
return
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4640
|
+
return verifyEdOnDestination$1;
|
|
4641
|
+
}()
|
|
4642
|
+
/**
|
|
4643
|
+
* Returns the transfer info for the transfer
|
|
4644
|
+
*
|
|
4645
|
+
* @returns The transfer info.
|
|
4646
|
+
*/
|
|
4647
|
+
)
|
|
4648
|
+
}, {
|
|
4649
|
+
key: "getTransferInfo",
|
|
4650
|
+
value: (function () {
|
|
4651
|
+
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
4652
|
+
var _yield$this$prepareNo0, normalizedOptions, buildTx, api, from, to, address, currency, ahAddress, senderAddress, feeAsset, version, swapOptions;
|
|
4653
|
+
return _regenerator().w(function (_context15) {
|
|
4654
|
+
while (1) switch (_context15.n) {
|
|
4655
|
+
case 0:
|
|
4656
|
+
_context15.n = 1;
|
|
4657
|
+
return this.prepareNormalizedOptions(this._options);
|
|
4658
|
+
case 1:
|
|
4659
|
+
_yield$this$prepareNo0 = _context15.v;
|
|
4660
|
+
normalizedOptions = _yield$this$prepareNo0.normalizedOptions;
|
|
4661
|
+
buildTx = _yield$this$prepareNo0.buildTx;
|
|
4662
|
+
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, address = normalizedOptions.address, currency = normalizedOptions.currency, ahAddress = normalizedOptions.ahAddress, senderAddress = normalizedOptions.senderAddress, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
|
|
4663
|
+
assertToIsString(to);
|
|
4664
|
+
assertAddressIsString(address);
|
|
4665
|
+
assertSwapSupport(swapOptions);
|
|
4666
|
+
return _context15.a(2, getTransferInfo({
|
|
4667
|
+
api: api,
|
|
4668
|
+
buildTx: buildTx,
|
|
4669
|
+
origin: from,
|
|
4670
|
+
destination: to,
|
|
4671
|
+
address: address,
|
|
4672
|
+
senderAddress: senderAddress,
|
|
4673
|
+
ahAddress: ahAddress,
|
|
4674
|
+
version: version,
|
|
4675
|
+
currency: currency,
|
|
4676
|
+
feeAsset: feeAsset
|
|
4677
|
+
}));
|
|
4678
|
+
}
|
|
4679
|
+
}, _callee15, this);
|
|
4680
|
+
}));
|
|
4681
|
+
function getTransferInfo$1() {
|
|
4682
|
+
return _getTransferInfo2.apply(this, arguments);
|
|
4688
4683
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4684
|
+
return getTransferInfo$1;
|
|
4685
|
+
}()
|
|
4686
|
+
/**
|
|
4687
|
+
* Returns the receivable amount on the destination after the transfer
|
|
4688
|
+
*
|
|
4689
|
+
* @returns The computed receivable amount.
|
|
4690
|
+
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
4691
|
+
*/
|
|
4692
|
+
)
|
|
4693
|
+
}, {
|
|
4694
|
+
key: "getReceivableAmount",
|
|
4695
|
+
value: (function () {
|
|
4696
|
+
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
4697
|
+
var _yield$this$getTransf, receivedAmount;
|
|
4698
|
+
return _regenerator().w(function (_context16) {
|
|
4699
|
+
while (1) switch (_context16.n) {
|
|
4700
|
+
case 0:
|
|
4701
|
+
_context16.n = 1;
|
|
4702
|
+
return this.getTransferInfo();
|
|
4703
|
+
case 1:
|
|
4704
|
+
_yield$this$getTransf = _context16.v;
|
|
4705
|
+
receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
|
|
4706
|
+
if (!(receivedAmount instanceof UnableToComputeError)) {
|
|
4707
|
+
_context16.n = 2;
|
|
4708
|
+
break;
|
|
4709
|
+
}
|
|
4710
|
+
throw receivedAmount;
|
|
4711
|
+
case 2:
|
|
4712
|
+
return _context16.a(2, receivedAmount);
|
|
4713
|
+
}
|
|
4714
|
+
}, _callee16, this);
|
|
4715
|
+
}));
|
|
4716
|
+
function getReceivableAmount() {
|
|
4717
|
+
return _getReceivableAmount.apply(this, arguments);
|
|
4692
4718
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4719
|
+
return getReceivableAmount;
|
|
4720
|
+
}())
|
|
4721
|
+
}, {
|
|
4722
|
+
key: "getBestAmountOut",
|
|
4723
|
+
value: function () {
|
|
4724
|
+
var _getBestAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
4725
|
+
var swapOptions;
|
|
4726
|
+
return _regenerator().w(function (_context17) {
|
|
4727
|
+
while (1) switch (_context17.n) {
|
|
4728
|
+
case 0:
|
|
4729
|
+
swapOptions = this._options.swapOptions;
|
|
4730
|
+
return _context17.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
4731
|
+
api: this.api,
|
|
4732
|
+
swapOptions: swapOptions
|
|
4733
|
+
}), function (builder) {
|
|
4734
|
+
return builder.getBestAmountOut();
|
|
4735
|
+
}));
|
|
4736
|
+
}
|
|
4737
|
+
}, _callee17, this);
|
|
4738
|
+
}));
|
|
4739
|
+
function getBestAmountOut() {
|
|
4740
|
+
return _getBestAmountOut.apply(this, arguments);
|
|
4695
4741
|
}
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
}
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4742
|
+
return getBestAmountOut;
|
|
4743
|
+
}()
|
|
4744
|
+
}, {
|
|
4745
|
+
key: "signAndSubmit",
|
|
4746
|
+
value: function () {
|
|
4747
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
4748
|
+
var _this$_options, sender, swapOptions, _yield$this$buildInte3, tx;
|
|
4749
|
+
return _regenerator().w(function (_context18) {
|
|
4750
|
+
while (1) switch (_context18.n) {
|
|
4751
|
+
case 0:
|
|
4752
|
+
_this$_options = this._options, sender = _this$_options.sender, swapOptions = _this$_options.swapOptions;
|
|
4753
|
+
assertSender(sender);
|
|
4754
|
+
if (!swapOptions) {
|
|
4755
|
+
_context18.n = 3;
|
|
4756
|
+
break;
|
|
4757
|
+
}
|
|
4758
|
+
if (isSenderSigner(sender)) {
|
|
4759
|
+
_context18.n = 1;
|
|
4760
|
+
break;
|
|
4761
|
+
}
|
|
4762
|
+
throw new UnsupportedOperationError('Swap operations do not support local accounts yet. Please provider a signer');
|
|
4763
|
+
case 1:
|
|
4764
|
+
_context18.n = 2;
|
|
4765
|
+
return executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
4766
|
+
swapOptions: swapOptions,
|
|
4767
|
+
api: this.api
|
|
4768
|
+
}), function (builder) {
|
|
4769
|
+
return (
|
|
4770
|
+
// We need to cast this sender because RouterBuilder expects a PAPI signer but this part of sdk-core is generic
|
|
4771
|
+
// Will be removed in the future when we gradually move parts of xcm-router to sdk-core
|
|
4772
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
4773
|
+
builder.signer(sender).build()
|
|
4774
|
+
);
|
|
4775
|
+
});
|
|
4776
|
+
case 2:
|
|
4777
|
+
return _context18.a(2, '');
|
|
4778
|
+
case 3:
|
|
4779
|
+
_context18.n = 4;
|
|
4780
|
+
return this.buildInternal();
|
|
4781
|
+
case 4:
|
|
4782
|
+
_yield$this$buildInte3 = _context18.v;
|
|
4783
|
+
tx = _yield$this$buildInte3.tx;
|
|
4784
|
+
return _context18.a(2, this.api.signAndSubmit(tx, sender));
|
|
4785
|
+
}
|
|
4786
|
+
}, _callee18, this);
|
|
4787
|
+
}));
|
|
4788
|
+
function signAndSubmit() {
|
|
4789
|
+
return _signAndSubmit.apply(this, arguments);
|
|
4790
|
+
}
|
|
4791
|
+
return signAndSubmit;
|
|
4792
|
+
}()
|
|
4793
|
+
/**
|
|
4794
|
+
* Returns the API instance used by the builder.
|
|
4795
|
+
*
|
|
4796
|
+
* @returns The API instance.
|
|
4797
|
+
*/
|
|
4798
|
+
}, {
|
|
4799
|
+
key: "getApi",
|
|
4800
|
+
value: function getApi() {
|
|
4801
|
+
return this.api.getApi();
|
|
4756
4802
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4803
|
+
/**
|
|
4804
|
+
* Disconnects the API.
|
|
4805
|
+
*
|
|
4806
|
+
* @returns A Promise that resolves when the API is disconnected.
|
|
4807
|
+
*/
|
|
4808
|
+
}, {
|
|
4809
|
+
key: "disconnect",
|
|
4810
|
+
value: function disconnect() {
|
|
4811
|
+
return this.api.disconnect();
|
|
4765
4812
|
}
|
|
4766
|
-
}
|
|
4813
|
+
}]);
|
|
4814
|
+
}();
|
|
4815
|
+
/**
|
|
4816
|
+
* Creates a new Builder instance.
|
|
4817
|
+
*
|
|
4818
|
+
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
4819
|
+
* @returns A new Builder instance.
|
|
4820
|
+
*/
|
|
4821
|
+
var Builder = function Builder(api) {
|
|
4822
|
+
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
4767
4823
|
};
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
4773
|
-
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4824
|
+
|
|
4825
|
+
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
4826
|
+
if (isChainEvm(chain)) {
|
|
4827
|
+
return isAddress(address) ? address : senderAddress;
|
|
4774
4828
|
}
|
|
4829
|
+
return isAddress(address) ? senderAddress : address;
|
|
4775
4830
|
};
|
|
4776
|
-
var
|
|
4777
|
-
var
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4831
|
+
var getReverseTxFee = /*#__PURE__*/function () {
|
|
4832
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
4833
|
+
var api, origin, destination, senderAddress, address, skipReverseFeeCalculation, toAddress, fromAddress, _yield$Builder$from$t, tx, _yield$api$getPayment, partialFee;
|
|
4834
|
+
return _regenerator().w(function (_context) {
|
|
4835
|
+
while (1) switch (_context.n) {
|
|
4836
|
+
case 0:
|
|
4837
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
4838
|
+
if (!skipReverseFeeCalculation) {
|
|
4839
|
+
_context.n = 1;
|
|
4840
|
+
break;
|
|
4841
|
+
}
|
|
4842
|
+
return _context.a(2, 0n);
|
|
4843
|
+
case 1:
|
|
4844
|
+
toAddress = determineAddress(origin, address, senderAddress);
|
|
4845
|
+
fromAddress = determineAddress(destination, address, senderAddress);
|
|
4846
|
+
_context.n = 2;
|
|
4847
|
+
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
|
|
4848
|
+
case 2:
|
|
4849
|
+
_yield$Builder$from$t = _context.v;
|
|
4850
|
+
tx = _yield$Builder$from$t.tx;
|
|
4851
|
+
_context.n = 3;
|
|
4852
|
+
return api.getPaymentInfo(tx, fromAddress);
|
|
4853
|
+
case 3:
|
|
4854
|
+
_yield$api$getPayment = _context.v;
|
|
4855
|
+
partialFee = _yield$api$getPayment.partialFee;
|
|
4856
|
+
return _context.a(2, padFee(partialFee, origin, destination, 'destination'));
|
|
4857
|
+
}
|
|
4858
|
+
}, _callee);
|
|
4859
|
+
}));
|
|
4860
|
+
return function getReverseTxFee(_x, _x2) {
|
|
4861
|
+
return _ref2.apply(this, arguments);
|
|
4862
|
+
};
|
|
4863
|
+
}();
|
|
4864
|
+
|
|
4865
|
+
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4866
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
4867
|
+
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
4868
|
+
return _regenerator().w(function (_context) {
|
|
4869
|
+
while (1) switch (_context.n) {
|
|
4870
|
+
case 0:
|
|
4871
|
+
if (!feeAsset) {
|
|
4872
|
+
_context.n = 1;
|
|
4873
|
+
break;
|
|
4874
|
+
}
|
|
4875
|
+
return _context.a(2, undefined);
|
|
4876
|
+
case 1:
|
|
4877
|
+
edNative = getExistentialDepositOrThrow(origin);
|
|
4878
|
+
_context.n = 2;
|
|
4879
|
+
return getBalanceInternal({
|
|
4880
|
+
api: api,
|
|
4881
|
+
chain: origin,
|
|
4882
|
+
address: senderAddress
|
|
4883
|
+
});
|
|
4884
|
+
case 2:
|
|
4885
|
+
balanceNative = _context.v;
|
|
4886
|
+
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
|
|
4887
|
+
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4888
|
+
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
4889
|
+
_context.n = 3;
|
|
4890
|
+
break;
|
|
4891
|
+
}
|
|
4892
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4893
|
+
case 3:
|
|
4894
|
+
if (isNativeAssetToOrigin) {
|
|
4895
|
+
_context.n = 5;
|
|
4896
|
+
break;
|
|
4897
|
+
}
|
|
4898
|
+
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
4899
|
+
_context.n = 4;
|
|
4900
|
+
return getAssetBalanceInternal({
|
|
4901
|
+
api: api,
|
|
4902
|
+
chain: origin,
|
|
4903
|
+
address: senderAddress,
|
|
4904
|
+
asset: asset
|
|
4905
|
+
});
|
|
4906
|
+
case 4:
|
|
4907
|
+
balanceAsset = _context.v;
|
|
4908
|
+
edAsset = getEdFromAssetOrThrow(asset);
|
|
4909
|
+
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
4910
|
+
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
4911
|
+
case 5:
|
|
4912
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4913
|
+
case 6:
|
|
4914
|
+
return _context.a(2);
|
|
4915
|
+
}
|
|
4916
|
+
}, _callee);
|
|
4917
|
+
}));
|
|
4918
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
4919
|
+
return _ref.apply(this, arguments);
|
|
4920
|
+
};
|
|
4921
|
+
}();
|
|
4922
|
+
var isSufficientDestination = /*#__PURE__*/function () {
|
|
4923
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
|
|
4924
|
+
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
4925
|
+
return _regenerator().w(function (_context2) {
|
|
4926
|
+
while (1) switch (_context2.n) {
|
|
4927
|
+
case 0:
|
|
4928
|
+
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4929
|
+
if (isNativeAsset) {
|
|
4930
|
+
_context2.n = 1;
|
|
4931
|
+
break;
|
|
4932
|
+
}
|
|
4933
|
+
return _context2.a(2, undefined);
|
|
4934
|
+
case 1:
|
|
4935
|
+
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
4936
|
+
_context2.n = 2;
|
|
4937
|
+
return getBalanceInternal({
|
|
4938
|
+
api: api,
|
|
4939
|
+
chain: destination,
|
|
4940
|
+
address: address
|
|
4941
|
+
});
|
|
4942
|
+
case 2:
|
|
4943
|
+
nativeBalance = _context2.v;
|
|
4944
|
+
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
4945
|
+
}
|
|
4946
|
+
}, _callee2);
|
|
4947
|
+
}));
|
|
4948
|
+
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
4949
|
+
return _ref2.apply(this, arguments);
|
|
4950
|
+
};
|
|
4951
|
+
}();
|
|
4952
|
+
|
|
4953
|
+
var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
4954
|
+
if (isRelayChain(origin)) return DOT_LOCATION;
|
|
4955
|
+
return {
|
|
4956
|
+
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
4957
|
+
interior: {
|
|
4958
|
+
X1: [{
|
|
4959
|
+
Parachain: getParaId(origin)
|
|
4960
|
+
}]
|
|
4961
|
+
}
|
|
4962
|
+
};
|
|
4797
4963
|
};
|
|
4964
|
+
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4965
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
4966
|
+
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4967
|
+
return _regenerator().w(function (_context3) {
|
|
4968
|
+
while (1) switch (_context3.n) {
|
|
4969
|
+
case 0:
|
|
4970
|
+
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
4971
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4972
|
+
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4973
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
4974
|
+
var attempt, _t2;
|
|
4975
|
+
return _regenerator().w(function (_context2) {
|
|
4976
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
4977
|
+
case 0:
|
|
4978
|
+
if (!isExternalChain(destination)) {
|
|
4979
|
+
_context2.n = 1;
|
|
4980
|
+
break;
|
|
4981
|
+
}
|
|
4982
|
+
return _context2.a(2, 0n);
|
|
4983
|
+
case 1:
|
|
4984
|
+
attempt = /*#__PURE__*/function () {
|
|
4985
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
|
|
4986
|
+
var assetInfo, _t;
|
|
4987
|
+
return _regenerator().w(function (_context) {
|
|
4988
|
+
while (1) switch (_context.p = _context.n) {
|
|
4989
|
+
case 0:
|
|
4990
|
+
assetInfo = findAssetInfoOrThrow(chain, curr, destination);
|
|
4991
|
+
_context.p = 1;
|
|
4992
|
+
_context.n = 2;
|
|
4993
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4994
|
+
destination: destination
|
|
4995
|
+
}), {
|
|
4996
|
+
location: assetInfo.location,
|
|
4997
|
+
amount: amt
|
|
4998
|
+
});
|
|
4999
|
+
case 2:
|
|
5000
|
+
return _context.a(2, _context.v);
|
|
5001
|
+
case 3:
|
|
5002
|
+
_context.p = 3;
|
|
5003
|
+
_t = _context.v;
|
|
5004
|
+
if (!(_t instanceof InvalidCurrencyError)) {
|
|
5005
|
+
_context.n = 5;
|
|
5006
|
+
break;
|
|
5007
|
+
}
|
|
5008
|
+
_context.n = 4;
|
|
5009
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
5010
|
+
destination: destination
|
|
5011
|
+
}), {
|
|
5012
|
+
symbol: assetInfo.symbol,
|
|
5013
|
+
amount: amt
|
|
5014
|
+
});
|
|
5015
|
+
case 4:
|
|
5016
|
+
return _context.a(2, _context.v);
|
|
5017
|
+
case 5:
|
|
5018
|
+
throw _t;
|
|
5019
|
+
case 6:
|
|
5020
|
+
return _context.a(2);
|
|
5021
|
+
}
|
|
5022
|
+
}, _callee, null, [[1, 3]]);
|
|
5023
|
+
}));
|
|
5024
|
+
return function attempt(_x2, _x3, _x4) {
|
|
5025
|
+
return _ref3.apply(this, arguments);
|
|
5026
|
+
};
|
|
5027
|
+
}();
|
|
5028
|
+
_context2.p = 2;
|
|
5029
|
+
_context2.n = 3;
|
|
5030
|
+
return attempt(origin, currency, currency.amount);
|
|
5031
|
+
case 3:
|
|
5032
|
+
return _context2.a(2, _context2.v);
|
|
5033
|
+
case 4:
|
|
5034
|
+
_context2.p = 4;
|
|
5035
|
+
_t2 = _context2.v;
|
|
5036
|
+
if (!(!(_t2 instanceof InvalidCurrencyError) || !swapConfig)) {
|
|
5037
|
+
_context2.n = 5;
|
|
5038
|
+
break;
|
|
5039
|
+
}
|
|
5040
|
+
return _context2.a(2, 0n);
|
|
5041
|
+
case 5:
|
|
5042
|
+
_context2.n = 6;
|
|
5043
|
+
return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
|
|
5044
|
+
case 6:
|
|
5045
|
+
return _context2.a(2, _context2.v);
|
|
5046
|
+
}
|
|
5047
|
+
}, _callee2, null, [[2, 4]]);
|
|
5048
|
+
}));
|
|
5049
|
+
return function calcPaymentInfoFee() {
|
|
5050
|
+
return _ref2.apply(this, arguments);
|
|
5051
|
+
};
|
|
5052
|
+
}();
|
|
5053
|
+
if (!(!hasDryRunSupport(destination) || !forwardedXcms || isExternalChain(destination))) {
|
|
5054
|
+
_context3.n = 3;
|
|
5055
|
+
break;
|
|
5056
|
+
}
|
|
5057
|
+
_context3.n = 1;
|
|
5058
|
+
return calcPaymentInfoFee();
|
|
5059
|
+
case 1:
|
|
5060
|
+
_fee = _context3.v;
|
|
5061
|
+
_context3.n = 2;
|
|
5062
|
+
return isSufficientDestination(api, destination, address, currency.amount, asset, _fee);
|
|
5063
|
+
case 2:
|
|
5064
|
+
sufficient = _context3.v;
|
|
5065
|
+
return _context3.a(2, {
|
|
5066
|
+
fee: _fee,
|
|
5067
|
+
feeType: 'paymentInfo',
|
|
5068
|
+
sufficient: sufficient,
|
|
5069
|
+
asset: asset
|
|
5070
|
+
});
|
|
5071
|
+
case 3:
|
|
5072
|
+
_context3.n = 4;
|
|
5073
|
+
return api.getDryRunXcm({
|
|
5074
|
+
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
|
|
5075
|
+
tx: tx,
|
|
5076
|
+
xcm: forwardedXcms[1][0],
|
|
5077
|
+
chain: destination,
|
|
5078
|
+
origin: origin,
|
|
5079
|
+
asset: asset,
|
|
5080
|
+
version: version,
|
|
5081
|
+
originFee: originFee,
|
|
5082
|
+
feeAsset: resolvedFeeAsset,
|
|
5083
|
+
amount: normalizeAmount(currency.amount)
|
|
5084
|
+
});
|
|
5085
|
+
case 4:
|
|
5086
|
+
dryRunResult = _context3.v;
|
|
5087
|
+
if (dryRunResult.success) {
|
|
5088
|
+
_context3.n = 7;
|
|
5089
|
+
break;
|
|
5090
|
+
}
|
|
5091
|
+
if (!disableFallback) {
|
|
5092
|
+
_context3.n = 5;
|
|
5093
|
+
break;
|
|
5094
|
+
}
|
|
5095
|
+
return _context3.a(2, {
|
|
5096
|
+
dryRunError: dryRunResult.failureReason,
|
|
5097
|
+
dryRunSubError: dryRunResult.failureSubReason
|
|
5098
|
+
});
|
|
5099
|
+
case 5:
|
|
5100
|
+
_context3.n = 6;
|
|
5101
|
+
return calcPaymentInfoFee();
|
|
5102
|
+
case 6:
|
|
5103
|
+
_fee2 = _context3.v;
|
|
5104
|
+
return _context3.a(2, {
|
|
5105
|
+
fee: _fee2,
|
|
5106
|
+
feeType: 'paymentInfo',
|
|
5107
|
+
dryRunError: dryRunResult.failureReason,
|
|
5108
|
+
dryRunSubError: dryRunResult.failureSubReason,
|
|
5109
|
+
sufficient: false,
|
|
5110
|
+
asset: asset
|
|
5111
|
+
});
|
|
5112
|
+
case 7:
|
|
5113
|
+
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
5114
|
+
return _context3.a(2, {
|
|
5115
|
+
fee: fee,
|
|
5116
|
+
feeType: 'dryRun',
|
|
5117
|
+
sufficient: true,
|
|
5118
|
+
forwardedXcms: newForwardedXcms,
|
|
5119
|
+
destParaId: destParaId,
|
|
5120
|
+
asset: asset
|
|
5121
|
+
});
|
|
5122
|
+
}
|
|
5123
|
+
}, _callee3);
|
|
5124
|
+
}));
|
|
5125
|
+
return function getDestXcmFee(_x) {
|
|
5126
|
+
return _ref.apply(this, arguments);
|
|
5127
|
+
};
|
|
5128
|
+
}();
|
|
4798
5129
|
|
|
4799
5130
|
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
4800
5131
|
var orderedChecks = [{
|
|
@@ -7368,98 +7699,6 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
7368
7699
|
};
|
|
7369
7700
|
}();
|
|
7370
7701
|
|
|
7371
|
-
var resolveSendParams = function resolveSendParams(options) {
|
|
7372
|
-
var api = options.api,
|
|
7373
|
-
origin = options.from,
|
|
7374
|
-
currency = options.currency,
|
|
7375
|
-
feeAsset = options.feeAsset,
|
|
7376
|
-
address = options.address,
|
|
7377
|
-
destination = options.to,
|
|
7378
|
-
version = options.version,
|
|
7379
|
-
senderAddress = options.senderAddress;
|
|
7380
|
-
validateCurrency(currency, feeAsset);
|
|
7381
|
-
validateDestination(origin, destination);
|
|
7382
|
-
validateTransact(options);
|
|
7383
|
-
validateDestinationAddress(address, destination, api);
|
|
7384
|
-
if (senderAddress) validateAddress(api, senderAddress, origin, false);
|
|
7385
|
-
var isBridge = !isTLocation(destination) && isSubstrateBridge(origin, destination);
|
|
7386
|
-
var assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
|
|
7387
|
-
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
7388
|
-
var asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
7389
|
-
var resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
7390
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
7391
|
-
var amount = Array.isArray(currency) ? 0n : abstractDecimals(currency.amount, asset === null || asset === void 0 ? void 0 : asset.decimals, api);
|
|
7392
|
-
// Ensure amount is at least 2 to avoid Rust panic (only for non-array currencies)
|
|
7393
|
-
var finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
|
|
7394
|
-
var resolvedVersion = pickCompatibleXcmVersion(origin, destination, version);
|
|
7395
|
-
var overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset);
|
|
7396
|
-
// In case asset check is disabled, we create asset object from currency symbol
|
|
7397
|
-
var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
7398
|
-
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
7399
|
-
};
|
|
7400
|
-
var finalAsset = Array.isArray(currency) ? // TODO: Refactor this
|
|
7401
|
-
// We use a dummy values when overriding with multi-assets
|
|
7402
|
-
// since these values won't be used but need to pass checks
|
|
7403
|
-
_objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
7404
|
-
amount: 0n,
|
|
7405
|
-
assetId: '1',
|
|
7406
|
-
location: {
|
|
7407
|
-
parents: Parents.ZERO,
|
|
7408
|
-
interior: {
|
|
7409
|
-
Here: null
|
|
7410
|
-
}
|
|
7411
|
-
}
|
|
7412
|
-
}) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
7413
|
-
amount: finalAmount
|
|
7414
|
-
});
|
|
7415
|
-
var normalizedAsset = finalAsset.location ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
|
|
7416
|
-
location: normalizeLocation(finalAsset.location, resolvedVersion)
|
|
7417
|
-
}) : finalAsset;
|
|
7418
|
-
return {
|
|
7419
|
-
resolvedFeeAsset: resolvedFeeAsset,
|
|
7420
|
-
resolvedVersion: resolvedVersion,
|
|
7421
|
-
overriddenAsset: overriddenAsset,
|
|
7422
|
-
normalizedAsset: normalizedAsset
|
|
7423
|
-
};
|
|
7424
|
-
};
|
|
7425
|
-
var send = /*#__PURE__*/function () {
|
|
7426
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
7427
|
-
var api, origin, currency, feeAsset, address, destination, paraIdTo, senderAddress, ahAddress, pallet, method, transactOptions, isAmountAll, keepAlive, _resolveSendParams, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset;
|
|
7428
|
-
return _regenerator().w(function (_context) {
|
|
7429
|
-
while (1) switch (_context.n) {
|
|
7430
|
-
case 0:
|
|
7431
|
-
api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
7432
|
-
_resolveSendParams = resolveSendParams(options), resolvedFeeAsset = _resolveSendParams.resolvedFeeAsset, resolvedVersion = _resolveSendParams.resolvedVersion, overriddenAsset = _resolveSendParams.overriddenAsset, normalizedAsset = _resolveSendParams.normalizedAsset;
|
|
7433
|
-
_context.n = 1;
|
|
7434
|
-
return api.init(origin, TX_CLIENT_TIMEOUT_MS);
|
|
7435
|
-
case 1:
|
|
7436
|
-
return _context.a(2, getChain(origin).transfer({
|
|
7437
|
-
api: api,
|
|
7438
|
-
assetInfo: normalizedAsset,
|
|
7439
|
-
currency: currency,
|
|
7440
|
-
feeAsset: resolvedFeeAsset,
|
|
7441
|
-
feeCurrency: feeAsset,
|
|
7442
|
-
address: address,
|
|
7443
|
-
to: destination,
|
|
7444
|
-
paraIdTo: paraIdTo,
|
|
7445
|
-
overriddenAsset: overriddenAsset,
|
|
7446
|
-
version: resolvedVersion,
|
|
7447
|
-
senderAddress: senderAddress,
|
|
7448
|
-
ahAddress: ahAddress,
|
|
7449
|
-
pallet: pallet,
|
|
7450
|
-
method: method,
|
|
7451
|
-
transactOptions: transactOptions,
|
|
7452
|
-
isAmountAll: isAmountAll,
|
|
7453
|
-
keepAlive: keepAlive
|
|
7454
|
-
}));
|
|
7455
|
-
}
|
|
7456
|
-
}, _callee);
|
|
7457
|
-
}));
|
|
7458
|
-
return function send(_x) {
|
|
7459
|
-
return _ref.apply(this, arguments);
|
|
7460
|
-
};
|
|
7461
|
-
}();
|
|
7462
|
-
|
|
7463
7702
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
7464
7703
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
7465
7704
|
var api, origin, destination, address, 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;
|
|
@@ -12991,6 +13230,10 @@ var MIN_AMOUNT = 2n;
|
|
|
12991
13230
|
var AMOUNT_ALL = 'ALL';
|
|
12992
13231
|
var TRANSACT_ORIGINS = ['Native', 'SovereignAccount', 'Superuser', 'Xcm'];
|
|
12993
13232
|
var ERR_LOCATION_DEST_NOT_SUPPORTED = 'XCM Location destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens pallet, try using address location instead (for both destination and address in same location set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.';
|
|
13233
|
+
/**
|
|
13234
|
+
* Supported exchange chains
|
|
13235
|
+
*/
|
|
13236
|
+
var EXCHANGE_CHAINS = ['AssetHubPolkadotDex', 'AssetHubKusamaDex', 'AssetHubPaseoDex', 'AssetHubWestendDex', 'HydrationDex', 'KaruraDex', 'AcalaDex', 'BifrostKusamaDex', 'BifrostPolkadotDex'];
|
|
12994
13237
|
|
|
12995
13238
|
var EVM_DEV_PRIVATE_KEYS = {
|
|
12996
13239
|
alith: '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133',
|
|
@@ -13137,6 +13380,108 @@ var sortAssets = function sortAssets(assets) {
|
|
|
13137
13380
|
});
|
|
13138
13381
|
};
|
|
13139
13382
|
|
|
13383
|
+
var _excluded = ["apiOverrides"];
|
|
13384
|
+
var isUrl = function isUrl(value) {
|
|
13385
|
+
return typeof value === 'string' || Array.isArray(value);
|
|
13386
|
+
};
|
|
13387
|
+
var convertBuilderConfig = function convertBuilderConfig(config) {
|
|
13388
|
+
if (!config) return undefined;
|
|
13389
|
+
if (isConfig(config)) {
|
|
13390
|
+
var apiOverrides = config.apiOverrides,
|
|
13391
|
+
rest = _objectWithoutProperties(config, _excluded);
|
|
13392
|
+
if (!apiOverrides) {
|
|
13393
|
+
return rest;
|
|
13394
|
+
}
|
|
13395
|
+
if (config.apiOverrides && Object.values(config.apiOverrides).some(function (url) {
|
|
13396
|
+
return _typeof(url) === 'object';
|
|
13397
|
+
})) {
|
|
13398
|
+
throw new UnsupportedOperationError('XCM Router does not support API client override with non-string values');
|
|
13399
|
+
}
|
|
13400
|
+
var filteredApiOverrides = Object.fromEntries(Object.entries(apiOverrides).filter(function (_ref) {
|
|
13401
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
13402
|
+
value = _ref2[1];
|
|
13403
|
+
return isUrl(value);
|
|
13404
|
+
}));
|
|
13405
|
+
return _objectSpread2(_objectSpread2({}, config), {}, {
|
|
13406
|
+
apiOverrides: filteredApiOverrides
|
|
13407
|
+
});
|
|
13408
|
+
}
|
|
13409
|
+
var isWsUrl = typeof config === 'string' && Array.isArray(config);
|
|
13410
|
+
if (!isWsUrl) {
|
|
13411
|
+
throw new UnsupportedOperationError('XCM Router does not support API client override');
|
|
13412
|
+
}
|
|
13413
|
+
};
|
|
13414
|
+
var createRouterBuilder = /*#__PURE__*/function () {
|
|
13415
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
13416
|
+
var _slippage$toString;
|
|
13417
|
+
var api, _yield$import, RouterBuilder, from, to, currency, _options$swapOptions, currencyTo, evmSenderAddress, exchange, slippage, onStatusChange, senderAddress, address, config, routerConfig, builder;
|
|
13418
|
+
return _regenerator().w(function (_context) {
|
|
13419
|
+
while (1) switch (_context.n) {
|
|
13420
|
+
case 0:
|
|
13421
|
+
api = options.api;
|
|
13422
|
+
if (!(api.getType() !== 'PAPI')) {
|
|
13423
|
+
_context.n = 1;
|
|
13424
|
+
break;
|
|
13425
|
+
}
|
|
13426
|
+
throw new UnsupportedOperationError('Swaps are only supported when using PAPI SDK.');
|
|
13427
|
+
case 1:
|
|
13428
|
+
_context.n = 2;
|
|
13429
|
+
return import('@paraspell/xcm-router');
|
|
13430
|
+
case 2:
|
|
13431
|
+
_yield$import = _context.v;
|
|
13432
|
+
RouterBuilder = _yield$import.RouterBuilder;
|
|
13433
|
+
if (RouterBuilder) {
|
|
13434
|
+
_context.n = 3;
|
|
13435
|
+
break;
|
|
13436
|
+
}
|
|
13437
|
+
throw new ExtensionNotInstalledError('XCM Router package is required for swaps. Please install @paraspell/xcm-router.');
|
|
13438
|
+
case 3:
|
|
13439
|
+
from = options.from, to = options.to, currency = options.currency, _options$swapOptions = options.swapOptions, currencyTo = _options$swapOptions.currencyTo, evmSenderAddress = _options$swapOptions.evmSenderAddress, exchange = _options$swapOptions.exchange, slippage = _options$swapOptions.slippage, onStatusChange = _options$swapOptions.onStatusChange, senderAddress = options.senderAddress, address = options.address;
|
|
13440
|
+
assertToIsString(to);
|
|
13441
|
+
assertAddressIsString(address);
|
|
13442
|
+
assertSenderAddress(senderAddress);
|
|
13443
|
+
if (!Array.isArray(currency)) {
|
|
13444
|
+
_context.n = 4;
|
|
13445
|
+
break;
|
|
13446
|
+
}
|
|
13447
|
+
throw new UnsupportedOperationError('Swaps with multiple currencies are not supported.');
|
|
13448
|
+
case 4:
|
|
13449
|
+
config = api.getConfig();
|
|
13450
|
+
routerConfig = convertBuilderConfig(config);
|
|
13451
|
+
builder = RouterBuilder(routerConfig).from(from).exchange(exchange).to(to).currencyFrom(currency).currencyTo(currencyTo).amount(currency.amount).senderAddress(senderAddress).evmSenderAddress(evmSenderAddress).recipientAddress(address).slippagePct((_slippage$toString = slippage.toString()) !== null && _slippage$toString !== void 0 ? _slippage$toString : '1');
|
|
13452
|
+
if (onStatusChange) {
|
|
13453
|
+
// We cast because router types are bind to specific PAPI types
|
|
13454
|
+
// Will be resolved when we make RouterBuilder generic
|
|
13455
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
13456
|
+
builder = builder.onStatusChange(onStatusChange);
|
|
13457
|
+
}
|
|
13458
|
+
return _context.a(2, builder);
|
|
13459
|
+
}
|
|
13460
|
+
}, _callee);
|
|
13461
|
+
}));
|
|
13462
|
+
return function createRouterBuilder(_x) {
|
|
13463
|
+
return _ref3.apply(this, arguments);
|
|
13464
|
+
};
|
|
13465
|
+
}();
|
|
13466
|
+
var executeWithRouter = /*#__PURE__*/function () {
|
|
13467
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, executor) {
|
|
13468
|
+
var routerBuilder;
|
|
13469
|
+
return _regenerator().w(function (_context2) {
|
|
13470
|
+
while (1) switch (_context2.n) {
|
|
13471
|
+
case 0:
|
|
13472
|
+
_context2.n = 1;
|
|
13473
|
+
return createRouterBuilder(options);
|
|
13474
|
+
case 1:
|
|
13475
|
+
routerBuilder = _context2.v;
|
|
13476
|
+
return _context2.a(2, executor(routerBuilder));
|
|
13477
|
+
}
|
|
13478
|
+
}, _callee2);
|
|
13479
|
+
}));
|
|
13480
|
+
return function executeWithRouter(_x2, _x3) {
|
|
13481
|
+
return _ref4.apply(this, arguments);
|
|
13482
|
+
};
|
|
13483
|
+
}();
|
|
13484
|
+
|
|
13140
13485
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13141
13486
|
var isConfig = function isConfig(value) {
|
|
13142
13487
|
return _typeof(value) === 'object' && value !== null && !Array.isArray(value) && (
|
|
@@ -13184,7 +13529,7 @@ var overrideTxAmount = /*#__PURE__*/function () {
|
|
|
13184
13529
|
return _ref.apply(this, arguments);
|
|
13185
13530
|
};
|
|
13186
13531
|
}();
|
|
13187
|
-
var
|
|
13532
|
+
var createTxOverrideAmount = /*#__PURE__*/function () {
|
|
13188
13533
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options, builder, amount, relative) {
|
|
13189
13534
|
var _yield$builder$buildI, tx;
|
|
13190
13535
|
return _regenerator().w(function (_context2) {
|
|
@@ -13208,10 +13553,75 @@ var createTx = /*#__PURE__*/function () {
|
|
|
13208
13553
|
}
|
|
13209
13554
|
}, _callee2);
|
|
13210
13555
|
}));
|
|
13211
|
-
return function
|
|
13556
|
+
return function createTxOverrideAmount(_x5, _x6, _x7, _x8) {
|
|
13212
13557
|
return _ref2.apply(this, arguments);
|
|
13213
13558
|
};
|
|
13214
13559
|
}();
|
|
13560
|
+
var createTransferOrSwapAll = /*#__PURE__*/function () {
|
|
13561
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
13562
|
+
var api, from, swapOptions, transactions, _t, _t2, _t3, _t4;
|
|
13563
|
+
return _regenerator().w(function (_context3) {
|
|
13564
|
+
while (1) switch (_context3.n) {
|
|
13565
|
+
case 0:
|
|
13566
|
+
api = options.api, from = options.from, swapOptions = options.swapOptions;
|
|
13567
|
+
if (!swapOptions) {
|
|
13568
|
+
_context3.n = 2;
|
|
13569
|
+
break;
|
|
13570
|
+
}
|
|
13571
|
+
_context3.n = 1;
|
|
13572
|
+
return executeWithRouter(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
13573
|
+
swapOptions: swapOptions
|
|
13574
|
+
}), function (builder) {
|
|
13575
|
+
return builder.buildTransactions();
|
|
13576
|
+
});
|
|
13577
|
+
case 1:
|
|
13578
|
+
transactions = _context3.v;
|
|
13579
|
+
return _context3.a(2, transactions);
|
|
13580
|
+
case 2:
|
|
13581
|
+
_t = api.getApi();
|
|
13582
|
+
_t2 = from;
|
|
13583
|
+
_context3.n = 3;
|
|
13584
|
+
return createTransfer(options);
|
|
13585
|
+
case 3:
|
|
13586
|
+
_t3 = _context3.v;
|
|
13587
|
+
_t4 = {
|
|
13588
|
+
type: 'TRANSFER',
|
|
13589
|
+
api: _t,
|
|
13590
|
+
chain: _t2,
|
|
13591
|
+
tx: _t3
|
|
13592
|
+
};
|
|
13593
|
+
return _context3.a(2, [_t4]);
|
|
13594
|
+
}
|
|
13595
|
+
}, _callee3);
|
|
13596
|
+
}));
|
|
13597
|
+
return function createTransferOrSwapAll(_x9) {
|
|
13598
|
+
return _ref3.apply(this, arguments);
|
|
13599
|
+
};
|
|
13600
|
+
}();
|
|
13601
|
+
var createTransferOrSwap = /*#__PURE__*/function () {
|
|
13602
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
13603
|
+
var res;
|
|
13604
|
+
return _regenerator().w(function (_context4) {
|
|
13605
|
+
while (1) switch (_context4.n) {
|
|
13606
|
+
case 0:
|
|
13607
|
+
_context4.n = 1;
|
|
13608
|
+
return createTransferOrSwapAll(options);
|
|
13609
|
+
case 1:
|
|
13610
|
+
res = _context4.v;
|
|
13611
|
+
if (!(res.length > 1)) {
|
|
13612
|
+
_context4.n = 2;
|
|
13613
|
+
break;
|
|
13614
|
+
}
|
|
13615
|
+
throw new UnsupportedOperationError('This operation produces multiple transactions, but .build() only supports a single transaction. Use .buildAll() instead.');
|
|
13616
|
+
case 2:
|
|
13617
|
+
return _context4.a(2, res[0].tx);
|
|
13618
|
+
}
|
|
13619
|
+
}, _callee4);
|
|
13620
|
+
}));
|
|
13621
|
+
return function createTransferOrSwap(_x0) {
|
|
13622
|
+
return _ref4.apply(this, arguments);
|
|
13623
|
+
};
|
|
13624
|
+
}();
|
|
13215
13625
|
|
|
13216
13626
|
var createChainClient = /*#__PURE__*/function () {
|
|
13217
13627
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain) {
|
|
@@ -14115,4 +14525,4 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
|
|
|
14115
14525
|
};
|
|
14116
14526
|
}();
|
|
14117
14527
|
|
|
14118
|
-
export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId,
|
|
14528
|
+
export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderAddress, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
|