@paraspell/sdk-core 14.4.3 → 14.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +78 -40
- package/dist/index.mjs +1137 -949
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,13 @@ import { blake2b } from '@noble/hashes/blake2.js';
|
|
|
2
2
|
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
|
-
import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1, numberToBytes } from 'viem';
|
|
5
|
+
import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1, stringToHex, numberToBytes } from 'viem';
|
|
6
6
|
import { ParaSpellError, isTLocation, replaceBigInt, isExternalChain, CHAINS, Version, isRelayChain, isSubstrateBridge, Parents, deepEqual, isTrustedChain, isCustomChain, isSnowbridge, getJunctionValue, hasJunction, ETHEREUM_BRIDGE_ORIGINS, isBridge, isSubstrateChain, flattenJunctions, RELAYCHAINS, DEFAULT_SS58_PREFIX } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
|
-
import { getOtherAssetsPallets, getNativeAssetsPallet, BRIDGE_PALLETS, getPalletIndex,
|
|
8
|
+
import { getOtherAssetsPallets, getNativeAssetsPallet, BRIDGE_PALLETS, getPalletIndex, getSupportedPalletsDetails, getXcmPallet, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY, hasPalletImpl, getXcmPalletImpl } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
10
10
|
import { mainnet, sepolia } from 'viem/chains';
|
|
11
|
-
import {
|
|
11
|
+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
|
|
12
12
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
13
13
|
|
|
14
14
|
function _arrayLikeToArray(r, a) {
|
|
@@ -1041,13 +1041,13 @@ var Centrifuge$1 = {
|
|
|
1041
1041
|
info: "centrifuge",
|
|
1042
1042
|
paraId: 2031,
|
|
1043
1043
|
providers: [
|
|
1044
|
-
{
|
|
1045
|
-
name: "LuckyFriday",
|
|
1046
|
-
endpoint: "wss://rpc-centrifuge.luckyfriday.io"
|
|
1047
|
-
},
|
|
1048
1044
|
{
|
|
1049
1045
|
name: "OnFinality",
|
|
1050
1046
|
endpoint: "wss://centrifuge-parachain.api.onfinality.io/public-ws"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
name: "Centrifuge",
|
|
1050
|
+
endpoint: "wss://fullnode.centrifuge.io"
|
|
1051
1051
|
}
|
|
1052
1052
|
]
|
|
1053
1053
|
};
|
|
@@ -1679,6 +1679,17 @@ var PeoplePaseo$1 = {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
]
|
|
1681
1681
|
};
|
|
1682
|
+
var Shibuya$1 = {
|
|
1683
|
+
name: "Shibuya Testnet (Astar)",
|
|
1684
|
+
info: "PaseoShibuyaChain",
|
|
1685
|
+
paraId: 2000,
|
|
1686
|
+
providers: [
|
|
1687
|
+
{
|
|
1688
|
+
name: "Astar",
|
|
1689
|
+
endpoint: "wss://rpc.shibuya.astar.network"
|
|
1690
|
+
}
|
|
1691
|
+
]
|
|
1692
|
+
};
|
|
1682
1693
|
var Polkadot$1 = {
|
|
1683
1694
|
name: "Polkadot Relay",
|
|
1684
1695
|
info: "polkadot",
|
|
@@ -1843,6 +1854,7 @@ var configs = {
|
|
|
1843
1854
|
HeimaPaseo: HeimaPaseo$1,
|
|
1844
1855
|
HydrationPaseo: HydrationPaseo$1,
|
|
1845
1856
|
PeoplePaseo: PeoplePaseo$1,
|
|
1857
|
+
Shibuya: Shibuya$1,
|
|
1846
1858
|
Polkadot: Polkadot$1,
|
|
1847
1859
|
Kusama: Kusama$1,
|
|
1848
1860
|
Westend: Westend$1,
|
|
@@ -2099,10 +2111,18 @@ var createTransactInstructions = /*#__PURE__*/function () {
|
|
|
2099
2111
|
};
|
|
2100
2112
|
}();
|
|
2101
2113
|
|
|
2102
|
-
var BaseAssetsPallet = /*#__PURE__*/
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2114
|
+
var BaseAssetsPallet = /*#__PURE__*/function () {
|
|
2115
|
+
function BaseAssetsPallet(palletName) {
|
|
2116
|
+
_classCallCheck(this, BaseAssetsPallet);
|
|
2117
|
+
this.palletName = palletName;
|
|
2118
|
+
}
|
|
2119
|
+
return _createClass(BaseAssetsPallet, [{
|
|
2120
|
+
key: "getAssetState",
|
|
2121
|
+
value: function getAssetState(_api, _asset) {
|
|
2122
|
+
throw new UnsupportedOperationError("getAssetState is not implemented for ".concat(this.palletName, " pallet"));
|
|
2123
|
+
}
|
|
2124
|
+
}]);
|
|
2125
|
+
}();
|
|
2106
2126
|
|
|
2107
2127
|
var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
2108
2128
|
function AssetManagerPallet() {
|
|
@@ -2140,11 +2160,6 @@ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2140
2160
|
}]);
|
|
2141
2161
|
}(BaseAssetsPallet);
|
|
2142
2162
|
|
|
2143
|
-
var resolveAssetId = function resolveAssetId(asset, config) {
|
|
2144
|
-
if (config.useLocationId) return asset.location;
|
|
2145
|
-
assertHasId(asset);
|
|
2146
|
-
return config.useBigIntId ? BigInt(asset.assetId) : Number(asset.assetId);
|
|
2147
|
-
};
|
|
2148
2163
|
var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
2149
2164
|
function AssetsPallet() {
|
|
2150
2165
|
_classCallCheck(this, AssetsPallet);
|
|
@@ -2152,11 +2167,53 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2152
2167
|
}
|
|
2153
2168
|
_inherits(AssetsPallet, _BaseAssetsPallet);
|
|
2154
2169
|
return _createClass(AssetsPallet, [{
|
|
2170
|
+
key: "resolveMintId",
|
|
2171
|
+
value: function resolveMintId(asset, api, chain, config) {
|
|
2172
|
+
if (config.useLocationId) return api.localizeLocation(chain.chain, asset.location);
|
|
2173
|
+
assertHasId(asset);
|
|
2174
|
+
return config.useBigIntId ? BigInt(asset.assetId) : Number(asset.assetId);
|
|
2175
|
+
}
|
|
2176
|
+
}, {
|
|
2177
|
+
key: "queryWithAssetId",
|
|
2178
|
+
value: function () {
|
|
2179
|
+
var _queryWithAssetId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, query) {
|
|
2180
|
+
var _t;
|
|
2181
|
+
return _regenerator().w(function (_context) {
|
|
2182
|
+
while (1) switch (_context.p = _context.n) {
|
|
2183
|
+
case 0:
|
|
2184
|
+
assertHasId(asset);
|
|
2185
|
+
// Try with number ID first, if it fails, try with bigint ID
|
|
2186
|
+
_context.p = 1;
|
|
2187
|
+
_context.n = 2;
|
|
2188
|
+
return query(Number(asset.assetId));
|
|
2189
|
+
case 2:
|
|
2190
|
+
return _context.a(2, _context.v);
|
|
2191
|
+
case 3:
|
|
2192
|
+
_context.p = 3;
|
|
2193
|
+
_t = _context.v;
|
|
2194
|
+
if (!(_t instanceof Error && (_t.message.includes('Incompatible runtime entry') || _t.message.includes('API Compatibility Error') || _t.message.includes('Number needs to be an integer')))) {
|
|
2195
|
+
_context.n = 4;
|
|
2196
|
+
break;
|
|
2197
|
+
}
|
|
2198
|
+
return _context.a(2, query(BigInt(asset.assetId)));
|
|
2199
|
+
case 4:
|
|
2200
|
+
throw _t;
|
|
2201
|
+
case 5:
|
|
2202
|
+
return _context.a(2);
|
|
2203
|
+
}
|
|
2204
|
+
}, _callee, null, [[1, 3]]);
|
|
2205
|
+
}));
|
|
2206
|
+
function queryWithAssetId(_x, _x2) {
|
|
2207
|
+
return _queryWithAssetId.apply(this, arguments);
|
|
2208
|
+
}
|
|
2209
|
+
return queryWithAssetId;
|
|
2210
|
+
}()
|
|
2211
|
+
}, {
|
|
2155
2212
|
key: "mint",
|
|
2156
2213
|
value: function mint(api, address, asset, _balance, chain) {
|
|
2157
2214
|
var amount = asset.amount;
|
|
2158
2215
|
var config = chain.resolveMintConfig(api);
|
|
2159
|
-
var id =
|
|
2216
|
+
var id = this.resolveMintId(asset, api, chain, config);
|
|
2160
2217
|
var addr = config.useIdPrefix ? {
|
|
2161
2218
|
Id: address
|
|
2162
2219
|
} : address;
|
|
@@ -2189,55 +2246,64 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2189
2246
|
}, {
|
|
2190
2247
|
key: "getBalance",
|
|
2191
2248
|
value: function () {
|
|
2192
|
-
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2193
|
-
var _this = this
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
while (1) switch (_context.p = _context.n) {
|
|
2249
|
+
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, address, asset) {
|
|
2250
|
+
var _this = this;
|
|
2251
|
+
var balance, value;
|
|
2252
|
+
return _regenerator().w(function (_context2) {
|
|
2253
|
+
while (1) switch (_context2.n) {
|
|
2198
2254
|
case 0:
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
var useBigInt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2255
|
+
_context2.n = 1;
|
|
2256
|
+
return this.queryWithAssetId(asset, function (id) {
|
|
2202
2257
|
return api.queryState({
|
|
2203
2258
|
module: _this.palletName,
|
|
2204
2259
|
method: 'Account',
|
|
2205
|
-
params: [
|
|
2260
|
+
params: [id, address]
|
|
2206
2261
|
});
|
|
2207
|
-
};
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
balance = _context.v;
|
|
2213
|
-
_context.n = 6;
|
|
2214
|
-
break;
|
|
2215
|
-
case 3:
|
|
2216
|
-
_context.p = 3;
|
|
2217
|
-
_t = _context.v;
|
|
2218
|
-
if (!(_t instanceof Error && (_t.message.includes('Incompatible runtime entry') || _t.message.includes('API Compatibility Error') || _t.message.includes('Number needs to be an integer')))) {
|
|
2219
|
-
_context.n = 5;
|
|
2220
|
-
break;
|
|
2221
|
-
}
|
|
2222
|
-
_context.n = 4;
|
|
2223
|
-
return fetchBalance(true);
|
|
2224
|
-
case 4:
|
|
2225
|
-
balance = _context.v;
|
|
2226
|
-
_context.n = 6;
|
|
2227
|
-
break;
|
|
2228
|
-
case 5:
|
|
2229
|
-
throw _t;
|
|
2230
|
-
case 6:
|
|
2231
|
-
value = (_balance2 = balance) === null || _balance2 === void 0 ? void 0 : _balance2.balance;
|
|
2232
|
-
return _context.a(2, value !== undefined ? BigInt(value) : 0n);
|
|
2262
|
+
});
|
|
2263
|
+
case 1:
|
|
2264
|
+
balance = _context2.v;
|
|
2265
|
+
value = balance === null || balance === void 0 ? void 0 : balance.balance;
|
|
2266
|
+
return _context2.a(2, value !== undefined ? BigInt(value) : 0n);
|
|
2233
2267
|
}
|
|
2234
|
-
},
|
|
2268
|
+
}, _callee2, this);
|
|
2235
2269
|
}));
|
|
2236
|
-
function getBalance(
|
|
2270
|
+
function getBalance(_x3, _x4, _x5) {
|
|
2237
2271
|
return _getBalance.apply(this, arguments);
|
|
2238
2272
|
}
|
|
2239
2273
|
return getBalance;
|
|
2240
2274
|
}()
|
|
2275
|
+
}, {
|
|
2276
|
+
key: "getAssetState",
|
|
2277
|
+
value: function () {
|
|
2278
|
+
var _getAssetState = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api, asset) {
|
|
2279
|
+
var _this2 = this,
|
|
2280
|
+
_ref,
|
|
2281
|
+
_details$is_sufficien;
|
|
2282
|
+
var details;
|
|
2283
|
+
return _regenerator().w(function (_context3) {
|
|
2284
|
+
while (1) switch (_context3.n) {
|
|
2285
|
+
case 0:
|
|
2286
|
+
_context3.n = 1;
|
|
2287
|
+
return this.queryWithAssetId(asset, function (id) {
|
|
2288
|
+
return api.queryState({
|
|
2289
|
+
module: _this2.palletName,
|
|
2290
|
+
method: 'Asset',
|
|
2291
|
+
params: [id]
|
|
2292
|
+
});
|
|
2293
|
+
});
|
|
2294
|
+
case 1:
|
|
2295
|
+
details = _context3.v;
|
|
2296
|
+
return _context3.a(2, details ? {
|
|
2297
|
+
isSufficient: (_ref = (_details$is_sufficien = details.is_sufficient) !== null && _details$is_sufficien !== void 0 ? _details$is_sufficien : details.isSufficient) !== null && _ref !== void 0 ? _ref : false
|
|
2298
|
+
} : undefined);
|
|
2299
|
+
}
|
|
2300
|
+
}, _callee3, this);
|
|
2301
|
+
}));
|
|
2302
|
+
function getAssetState(_x6, _x7) {
|
|
2303
|
+
return _getAssetState.apply(this, arguments);
|
|
2304
|
+
}
|
|
2305
|
+
return getAssetState;
|
|
2306
|
+
}()
|
|
2241
2307
|
}]);
|
|
2242
2308
|
}(BaseAssetsPallet);
|
|
2243
2309
|
|
|
@@ -2354,76 +2420,24 @@ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
2354
2420
|
}]);
|
|
2355
2421
|
}(BaseAssetsPallet);
|
|
2356
2422
|
|
|
2357
|
-
var ForeignAssetsPallet = /*#__PURE__*/function (
|
|
2423
|
+
var ForeignAssetsPallet = /*#__PURE__*/function (_AssetsPallet) {
|
|
2358
2424
|
function ForeignAssetsPallet() {
|
|
2359
2425
|
_classCallCheck(this, ForeignAssetsPallet);
|
|
2360
2426
|
return _callSuper(this, ForeignAssetsPallet, arguments);
|
|
2361
2427
|
}
|
|
2362
|
-
_inherits(ForeignAssetsPallet,
|
|
2428
|
+
_inherits(ForeignAssetsPallet, _AssetsPallet);
|
|
2363
2429
|
return _createClass(ForeignAssetsPallet, [{
|
|
2364
|
-
key: "
|
|
2365
|
-
value: function
|
|
2366
|
-
|
|
2367
|
-
amount = asset.amount;
|
|
2368
|
-
var _chain$resolveMintCon = chain.resolveMintConfig(api),
|
|
2369
|
-
useIdPrefix = _chain$resolveMintCon.useIdPrefix;
|
|
2370
|
-
var addr = useIdPrefix ? {
|
|
2371
|
-
Id: address
|
|
2372
|
-
} : address;
|
|
2373
|
-
return Promise.resolve({
|
|
2374
|
-
assetStatusTx: {
|
|
2375
|
-
module: this.palletName,
|
|
2376
|
-
method: 'force_asset_status',
|
|
2377
|
-
params: {
|
|
2378
|
-
id: location,
|
|
2379
|
-
owner: addr,
|
|
2380
|
-
issuer: addr,
|
|
2381
|
-
admin: addr,
|
|
2382
|
-
freezer: addr,
|
|
2383
|
-
min_balance: 0n,
|
|
2384
|
-
is_sufficient: true,
|
|
2385
|
-
is_frozen: false
|
|
2386
|
-
}
|
|
2387
|
-
},
|
|
2388
|
-
balanceTx: {
|
|
2389
|
-
module: this.palletName,
|
|
2390
|
-
method: 'mint',
|
|
2391
|
-
params: {
|
|
2392
|
-
id: location,
|
|
2393
|
-
beneficiary: addr,
|
|
2394
|
-
amount: amount
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
});
|
|
2430
|
+
key: "resolveMintId",
|
|
2431
|
+
value: function resolveMintId(asset) {
|
|
2432
|
+
return asset.location;
|
|
2398
2433
|
}
|
|
2399
2434
|
}, {
|
|
2400
|
-
key: "
|
|
2401
|
-
value: function () {
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
return _regenerator().w(function (_context) {
|
|
2405
|
-
while (1) switch (_context.n) {
|
|
2406
|
-
case 0:
|
|
2407
|
-
_context.n = 1;
|
|
2408
|
-
return api.queryState({
|
|
2409
|
-
module: this.palletName,
|
|
2410
|
-
method: 'Account',
|
|
2411
|
-
params: [asset.location, address]
|
|
2412
|
-
});
|
|
2413
|
-
case 1:
|
|
2414
|
-
balance = _context.v;
|
|
2415
|
-
value = balance === null || balance === void 0 ? void 0 : balance.balance;
|
|
2416
|
-
return _context.a(2, value !== undefined ? BigInt(value) : 0n);
|
|
2417
|
-
}
|
|
2418
|
-
}, _callee, this);
|
|
2419
|
-
}));
|
|
2420
|
-
function getBalance(_x, _x2, _x3) {
|
|
2421
|
-
return _getBalance.apply(this, arguments);
|
|
2422
|
-
}
|
|
2423
|
-
return getBalance;
|
|
2424
|
-
}()
|
|
2435
|
+
key: "queryWithAssetId",
|
|
2436
|
+
value: function queryWithAssetId(asset, query) {
|
|
2437
|
+
return query(asset.location);
|
|
2438
|
+
}
|
|
2425
2439
|
}]);
|
|
2426
|
-
}(
|
|
2440
|
+
}(AssetsPallet);
|
|
2427
2441
|
|
|
2428
2442
|
var FungiblesPallet = /*#__PURE__*/function (_AssetsPallet) {
|
|
2429
2443
|
function FungiblesPallet() {
|
|
@@ -2432,31 +2446,10 @@ var FungiblesPallet = /*#__PURE__*/function (_AssetsPallet) {
|
|
|
2432
2446
|
}
|
|
2433
2447
|
_inherits(FungiblesPallet, _AssetsPallet);
|
|
2434
2448
|
return _createClass(FungiblesPallet, [{
|
|
2435
|
-
key: "
|
|
2436
|
-
value: function () {
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
var balance;
|
|
2440
|
-
return _regenerator().w(function (_context) {
|
|
2441
|
-
while (1) switch (_context.n) {
|
|
2442
|
-
case 0:
|
|
2443
|
-
_context.n = 1;
|
|
2444
|
-
return api.queryState({
|
|
2445
|
-
module: this.palletName,
|
|
2446
|
-
method: 'Account',
|
|
2447
|
-
params: [asset.location, address]
|
|
2448
|
-
});
|
|
2449
|
-
case 1:
|
|
2450
|
-
balance = _context.v;
|
|
2451
|
-
return _context.a(2, (_balance$balance = balance === null || balance === void 0 ? void 0 : balance.balance) !== null && _balance$balance !== void 0 ? _balance$balance : 0n);
|
|
2452
|
-
}
|
|
2453
|
-
}, _callee, this);
|
|
2454
|
-
}));
|
|
2455
|
-
function getBalance(_x, _x2, _x3) {
|
|
2456
|
-
return _getBalance.apply(this, arguments);
|
|
2457
|
-
}
|
|
2458
|
-
return getBalance;
|
|
2459
|
-
}()
|
|
2449
|
+
key: "queryWithAssetId",
|
|
2450
|
+
value: function queryWithAssetId(asset, query) {
|
|
2451
|
+
return query(asset.location);
|
|
2452
|
+
}
|
|
2460
2453
|
}]);
|
|
2461
2454
|
}(AssetsPallet);
|
|
2462
2455
|
|
|
@@ -2912,11 +2905,11 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2912
2905
|
key: "transferLocal",
|
|
2913
2906
|
value: function () {
|
|
2914
2907
|
var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
2915
|
-
var api, asset, feeAsset, recipient, sender, isAmountAll, keepAlive, validatedOptions, isNativeAsset, balance, localOptions;
|
|
2908
|
+
var api, asset, feeAsset, recipient, sender, isAmountAll, isDryRunBypass, keepAlive, validatedOptions, isNativeAsset, balance, localOptions;
|
|
2916
2909
|
return _regenerator().w(function (_context2) {
|
|
2917
2910
|
while (1) switch (_context2.n) {
|
|
2918
2911
|
case 0:
|
|
2919
|
-
api = options.api, asset = options.assetInfo, feeAsset = options.feeAsset, recipient = options.recipient, sender = options.sender, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
2912
|
+
api = options.api, asset = options.assetInfo, feeAsset = options.feeAsset, recipient = options.recipient, sender = options.sender, isAmountAll = options.isAmountAll, isDryRunBypass = options.isDryRunBypass, keepAlive = options.keepAlive;
|
|
2920
2913
|
if (!isTLocation(recipient)) {
|
|
2921
2914
|
_context2.n = 1;
|
|
2922
2915
|
break;
|
|
@@ -2942,6 +2935,9 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
2942
2935
|
return this.getBalance(api, sender, asset);
|
|
2943
2936
|
case 3:
|
|
2944
2937
|
balance = _context2.v;
|
|
2938
|
+
if (isDryRunBypass && !isAmountAll) {
|
|
2939
|
+
balance += calcSentAssetPreviewMint(asset, balance, keepAlive);
|
|
2940
|
+
}
|
|
2945
2941
|
_context2.n = 5;
|
|
2946
2942
|
break;
|
|
2947
2943
|
case 4:
|
|
@@ -3531,11 +3527,11 @@ var resolveTransferParams = function resolveTransferParams(options) {
|
|
|
3531
3527
|
};
|
|
3532
3528
|
var createTransfer = /*#__PURE__*/function () {
|
|
3533
3529
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
3534
|
-
var api, origin, currency, feeAsset, recipient, destination, paraIdTo, sender, ahAddress, pallet, method, transactOptions, isAmountAll, keepAlive, _resolveTransferParam, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset, customCtx, chainInstance;
|
|
3530
|
+
var api, origin, currency, feeAsset, recipient, destination, paraIdTo, sender, ahAddress, pallet, method, transactOptions, isAmountAll, isDryRunBypass, keepAlive, _resolveTransferParam, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset, customCtx, chainInstance;
|
|
3535
3531
|
return _regenerator().w(function (_context) {
|
|
3536
3532
|
while (1) switch (_context.n) {
|
|
3537
3533
|
case 0:
|
|
3538
|
-
api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, recipient = options.recipient, destination = options.to, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
3534
|
+
api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, recipient = options.recipient, destination = options.to, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, isDryRunBypass = options.isDryRunBypass, keepAlive = options.keepAlive;
|
|
3539
3535
|
validateCurrency(currency, feeAsset);
|
|
3540
3536
|
_context.n = 1;
|
|
3541
3537
|
return api.init(origin, TX_CLIENT_TIMEOUT_MS, destination);
|
|
@@ -3560,6 +3556,7 @@ var createTransfer = /*#__PURE__*/function () {
|
|
|
3560
3556
|
method: method,
|
|
3561
3557
|
transactOptions: transactOptions,
|
|
3562
3558
|
isAmountAll: isAmountAll,
|
|
3559
|
+
isDryRunBypass: isDryRunBypass,
|
|
3563
3560
|
keepAlive: keepAlive
|
|
3564
3561
|
}));
|
|
3565
3562
|
}
|
|
@@ -4532,7 +4529,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4532
4529
|
key: "dryRunPreview",
|
|
4533
4530
|
value: function () {
|
|
4534
4531
|
var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(dryRunOptions) {
|
|
4535
|
-
var _this$_options6, from, senderSource, swapOptions, _yield$
|
|
4532
|
+
var _this$_options6, from, senderSource, swapOptions, _yield$GeneralBuilder, tx, options;
|
|
4536
4533
|
return _regenerator().w(function (_context0) {
|
|
4537
4534
|
while (1) switch (_context0.n) {
|
|
4538
4535
|
case 0:
|
|
@@ -4551,11 +4548,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4551
4548
|
}));
|
|
4552
4549
|
case 1:
|
|
4553
4550
|
_context0.n = 2;
|
|
4554
|
-
return this.
|
|
4551
|
+
return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
4552
|
+
isDryRunBypass: true
|
|
4553
|
+
})).buildInternal();
|
|
4555
4554
|
case 2:
|
|
4556
|
-
_yield$
|
|
4557
|
-
tx = _yield$
|
|
4558
|
-
options = _yield$
|
|
4555
|
+
_yield$GeneralBuilder = _context0.v;
|
|
4556
|
+
tx = _yield$GeneralBuilder.tx;
|
|
4557
|
+
options = _yield$GeneralBuilder.options;
|
|
4559
4558
|
return _context0.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
4560
4559
|
from: from
|
|
4561
4560
|
}), {
|
|
@@ -4574,10 +4573,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4574
4573
|
key: "createTxFactory",
|
|
4575
4574
|
value: function createTxFactory() {
|
|
4576
4575
|
var _this = this;
|
|
4577
|
-
return function (amount, relative) {
|
|
4576
|
+
return function (amount, relative, isDryRunBypass) {
|
|
4577
|
+
var builder = isDryRunBypass ? new GeneralBuilder(_this.api, _this.batchManager, _objectSpread2(_objectSpread2({}, _this._options), {}, {
|
|
4578
|
+
isDryRunBypass: isDryRunBypass
|
|
4579
|
+
})) : _this;
|
|
4578
4580
|
return createTxOverrideAmount(_objectSpread2(_objectSpread2({}, _this._options), {}, {
|
|
4579
4581
|
api: _this.api
|
|
4580
|
-
}),
|
|
4582
|
+
}), builder, amount, relative);
|
|
4581
4583
|
};
|
|
4582
4584
|
}
|
|
4583
4585
|
/**
|
|
@@ -4955,7 +4957,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4955
4957
|
key: "signAndSubmit",
|
|
4956
4958
|
value: function () {
|
|
4957
4959
|
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
4958
|
-
var _this$_options8, from, senderSource, swapOptions, txHashes, _yield$this$
|
|
4960
|
+
var _this$_options8, from, senderSource, swapOptions, txHashes, _yield$this$buildInte2, tx;
|
|
4959
4961
|
return _regenerator().w(function (_context17) {
|
|
4960
4962
|
while (1) switch (_context17.n) {
|
|
4961
4963
|
case 0:
|
|
@@ -4993,8 +4995,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
4993
4995
|
_context17.n = 5;
|
|
4994
4996
|
return this.buildInternal();
|
|
4995
4997
|
case 5:
|
|
4996
|
-
_yield$this$
|
|
4997
|
-
tx = _yield$this$
|
|
4998
|
+
_yield$this$buildInte2 = _context17.v;
|
|
4999
|
+
tx = _yield$this$buildInte2.tx;
|
|
4998
5000
|
return _context17.a(2, this.api.signAndSubmit(tx, senderSource));
|
|
4999
5001
|
}
|
|
5000
5002
|
}, _callee17, this);
|
|
@@ -5008,7 +5010,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5008
5010
|
key: "signAndSubmitAll",
|
|
5009
5011
|
value: function () {
|
|
5010
5012
|
var _signAndSubmitAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
5011
|
-
var _this$_options9, from, senderSource, swapOptions, hash, _yield$this$
|
|
5013
|
+
var _this$_options9, from, senderSource, swapOptions, hash, _yield$this$buildInte3, tx, txHash;
|
|
5012
5014
|
return _regenerator().w(function (_context18) {
|
|
5013
5015
|
while (1) switch (_context18.n) {
|
|
5014
5016
|
case 0:
|
|
@@ -5046,8 +5048,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5046
5048
|
_context18.n = 5;
|
|
5047
5049
|
return this.buildInternal();
|
|
5048
5050
|
case 5:
|
|
5049
|
-
_yield$this$
|
|
5050
|
-
tx = _yield$this$
|
|
5051
|
+
_yield$this$buildInte3 = _context18.v;
|
|
5052
|
+
tx = _yield$this$buildInte3.tx;
|
|
5051
5053
|
_context18.n = 6;
|
|
5052
5054
|
return this.api.signAndSubmit(tx, senderSource);
|
|
5053
5055
|
case 6:
|
|
@@ -6080,81 +6082,420 @@ var dryRunOrigin = /*#__PURE__*/function () {
|
|
|
6080
6082
|
};
|
|
6081
6083
|
}();
|
|
6082
6084
|
|
|
6083
|
-
var parseUnits = parseUnits$1;
|
|
6084
|
-
var formatUnits = formatUnits$1;
|
|
6085
|
-
|
|
6086
|
-
var resolveBypassMintAmount = function resolveBypassMintAmount(chain) {
|
|
6087
|
-
return HIGH_BYPASS_MINT_CHAINS.some(function (c) {
|
|
6088
|
-
return c === chain;
|
|
6089
|
-
}) ? HIGH_BYPASS_MINT_AMOUNT : BYPASS_MINT_AMOUNT;
|
|
6090
|
-
};
|
|
6091
|
-
var createMintTxs = function createMintTxs(chain, asset, balance, address, api) {
|
|
6092
|
-
return getSubstrateChainImpl(chain, api._customCtx).mint(api, address, asset, balance);
|
|
6093
|
-
};
|
|
6094
|
-
var createRequiredMintTxs = function createRequiredMintTxs(chain, asset, amountHuman, balance, address, api) {
|
|
6095
|
-
var amount = parseUnits(amountHuman, asset.decimals);
|
|
6096
|
-
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
6097
|
-
amount: amount
|
|
6098
|
-
}), balance, address, api);
|
|
6099
|
-
};
|
|
6100
|
-
var createOptionalMintTxs = function createOptionalMintTxs(chain, currency, amountHuman, balance, address, api) {
|
|
6101
|
-
var asset = api.findAssetInfo(chain, currency);
|
|
6102
|
-
if (!asset) return null;
|
|
6103
|
-
var amount = parseUnits(amountHuman, asset.decimals);
|
|
6104
|
-
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
6105
|
-
amount: amount
|
|
6106
|
-
}), balance, address, api);
|
|
6107
|
-
};
|
|
6108
|
-
var resultToExtrinsics = function resultToExtrinsics(api, address, _ref) {
|
|
6109
|
-
var assetStatusTx = _ref.assetStatusTx,
|
|
6110
|
-
balanceTx = _ref.balanceTx;
|
|
6111
|
-
return [].concat(_toConsumableArray(assetStatusTx ? [api.deserializeExtrinsics(assetStatusTx)] : []), _toConsumableArray(assetStatusTx ? [api.callDispatchAsMethod(api.deserializeExtrinsics(balanceTx), address)] : [api.deserializeExtrinsics(balanceTx)]));
|
|
6112
|
-
};
|
|
6113
6085
|
var calcPreviewMintAmount = function calcPreviewMintAmount(balance, desired) {
|
|
6114
|
-
// Ensure mint amount is at least 2 to avoid Rust panic
|
|
6115
6086
|
if (desired <= 0n) return null;
|
|
6116
6087
|
var missing = desired - balance;
|
|
6117
6088
|
return missing > 0n ? missing : null;
|
|
6118
6089
|
};
|
|
6119
|
-
var
|
|
6120
|
-
|
|
6121
|
-
var
|
|
6122
|
-
var
|
|
6123
|
-
|
|
6124
|
-
parents: Parents.ONE,
|
|
6125
|
-
interior: {
|
|
6126
|
-
Here: null
|
|
6127
|
-
}
|
|
6128
|
-
}
|
|
6129
|
-
}, null);
|
|
6130
|
-
var seen = new Set();
|
|
6131
|
-
var preminted = [_native, relay, feeAsset].filter(function (a) {
|
|
6132
|
-
return !!a;
|
|
6133
|
-
}).filter(function (a) {
|
|
6134
|
-
var k = JSON.stringify(a.location, replaceBigInt);
|
|
6135
|
-
if (seen.has(k)) return false;
|
|
6136
|
-
seen.add(k);
|
|
6137
|
-
return true;
|
|
6138
|
-
});
|
|
6139
|
-
return preminted.some(function (a) {
|
|
6140
|
-
return isAssetEqual(a, sent);
|
|
6141
|
-
}) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
|
|
6090
|
+
var calcSentAssetPreviewMint = function calcSentAssetPreviewMint(asset, balance) {
|
|
6091
|
+
var _calcPreviewMintAmoun;
|
|
6092
|
+
var keepAlive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
6093
|
+
var keepAliveBuffer = keepAlive ? BigInt(asset.existentialDeposit) : 0n;
|
|
6094
|
+
return (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount + keepAliveBuffer)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
6142
6095
|
};
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6096
|
+
|
|
6097
|
+
var createX1Payload = function createX1Payload(version, junction) {
|
|
6098
|
+
return version === Version.V3 ? {
|
|
6099
|
+
X1: junction
|
|
6100
|
+
} : {
|
|
6101
|
+
X1: [junction]
|
|
6102
|
+
};
|
|
6103
|
+
};
|
|
6104
|
+
|
|
6105
|
+
var createAccountPayload = function createAccountPayload(api, address) {
|
|
6106
|
+
return isAddress(address) ? {
|
|
6107
|
+
AccountKey20: {
|
|
6108
|
+
key: address
|
|
6109
|
+
}
|
|
6110
|
+
} : {
|
|
6111
|
+
AccountId32: {
|
|
6112
|
+
id: api.accountToHex(address)
|
|
6113
|
+
}
|
|
6114
|
+
};
|
|
6115
|
+
};
|
|
6116
|
+
var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
|
|
6117
|
+
var api = _ref.api,
|
|
6118
|
+
recipient = _ref.recipient,
|
|
6119
|
+
origin = _ref.origin,
|
|
6120
|
+
destination = _ref.destination,
|
|
6121
|
+
version = _ref.version,
|
|
6122
|
+
paraId = _ref.paraId;
|
|
6123
|
+
if (isTLocation(recipient)) {
|
|
6124
|
+
return recipient;
|
|
6125
|
+
}
|
|
6126
|
+
var scenario = resolveScenario(origin, destination);
|
|
6127
|
+
var accountPayload = createAccountPayload(api, recipient);
|
|
6128
|
+
if (scenario === 'ParaToRelay') {
|
|
6129
|
+
return {
|
|
6130
|
+
parents: Parents.ONE,
|
|
6131
|
+
interior: createX1Payload(version, {
|
|
6132
|
+
AccountId32: {
|
|
6133
|
+
id: api.accountToHex(recipient)
|
|
6134
|
+
}
|
|
6135
|
+
})
|
|
6136
|
+
};
|
|
6137
|
+
} else if (scenario === 'ParaToPara') {
|
|
6138
|
+
return {
|
|
6139
|
+
parents: Parents.ONE,
|
|
6140
|
+
interior: {
|
|
6141
|
+
X2: [{
|
|
6142
|
+
Parachain: paraId
|
|
6143
|
+
}, accountPayload]
|
|
6144
|
+
}
|
|
6145
|
+
};
|
|
6146
|
+
}
|
|
6147
|
+
return {
|
|
6148
|
+
parents: Parents.ZERO,
|
|
6149
|
+
interior: createX1Payload(version, accountPayload)
|
|
6150
|
+
};
|
|
6151
|
+
};
|
|
6152
|
+
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
6153
|
+
var api = _ref2.api,
|
|
6154
|
+
address = _ref2.address,
|
|
6155
|
+
version = _ref2.version;
|
|
6156
|
+
if (isTLocation(address)) return address;
|
|
6157
|
+
var accountPayload = createAccountPayload(api, address);
|
|
6158
|
+
return {
|
|
6159
|
+
parents: Parents.ZERO,
|
|
6160
|
+
interior: createX1Payload(version, accountPayload)
|
|
6161
|
+
};
|
|
6162
|
+
};
|
|
6163
|
+
|
|
6164
|
+
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
6165
|
+
var isLocDestination = isTLocation(destination);
|
|
6166
|
+
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
6167
|
+
if (isSubBridge) {
|
|
6168
|
+
return {
|
|
6169
|
+
parents: Parents.TWO,
|
|
6170
|
+
interior: {
|
|
6171
|
+
X2: [{
|
|
6172
|
+
GlobalConsensus: api.getRelayChainOf(destination)
|
|
6173
|
+
}, {
|
|
6174
|
+
Parachain: chainId
|
|
6175
|
+
}]
|
|
6176
|
+
}
|
|
6177
|
+
};
|
|
6178
|
+
}
|
|
6179
|
+
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
6180
|
+
if (isExternalDestination) {
|
|
6181
|
+
return {
|
|
6182
|
+
parents: Parents.TWO,
|
|
6183
|
+
interior: {
|
|
6184
|
+
X1: [getEthereumJunction(api, origin)]
|
|
6185
|
+
}
|
|
6186
|
+
};
|
|
6187
|
+
}
|
|
6188
|
+
var scenario = resolveScenario(origin, destination);
|
|
6189
|
+
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
6190
|
+
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
6191
|
+
Parachain: chainId
|
|
6192
|
+
});
|
|
6193
|
+
return isLocDestination ? destination : {
|
|
6194
|
+
parents: parentsResolved,
|
|
6195
|
+
interior: interior
|
|
6196
|
+
};
|
|
6197
|
+
};
|
|
6198
|
+
var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
6199
|
+
var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
|
|
6200
|
+
return addXcmVersionHeader(plainDestination, version);
|
|
6201
|
+
};
|
|
6202
|
+
|
|
6203
|
+
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
6204
|
+
var fromRelay = isRelayChain(chain);
|
|
6205
|
+
var toRelay = isRelayChain(destChain);
|
|
6206
|
+
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
6207
|
+
var interior = toRelay ? 'Here' : {
|
|
6208
|
+
X1: [{
|
|
6209
|
+
Parachain: getParaIdImpl(destChain, customCtx)
|
|
6210
|
+
}]
|
|
6211
|
+
};
|
|
6212
|
+
return {
|
|
6213
|
+
parents: parents,
|
|
6214
|
+
interior: interior
|
|
6215
|
+
};
|
|
6216
|
+
};
|
|
6217
|
+
|
|
6218
|
+
/**
|
|
6219
|
+
* This function localizes a location by removing the `Parachain` junction
|
|
6220
|
+
* if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
|
|
6221
|
+
* or if the resulting interior is `'Here'` and the chain is a relay chain.
|
|
6222
|
+
*
|
|
6223
|
+
* @param chain - The current chain
|
|
6224
|
+
* @param location - The location to localize
|
|
6225
|
+
* @returns The localized location
|
|
6226
|
+
*/
|
|
6227
|
+
var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
|
|
6228
|
+
var _Object$keys$;
|
|
6229
|
+
var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
|
|
6230
|
+
var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
|
|
6231
|
+
var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
6232
|
+
var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
|
|
6233
|
+
var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
|
|
6234
|
+
var junctions = location.interior === 'Here' ? [] : flattenJunctions(location.interior);
|
|
6235
|
+
var junctionCount = junctions.length;
|
|
6236
|
+
var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
|
|
6237
|
+
// Check if target is an external chain and location's GlobalConsensus matches it
|
|
6238
|
+
var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
|
|
6239
|
+
var isConsensusAnchored = junctions.findIndex(function (junction) {
|
|
6240
|
+
return 'GlobalConsensus' in junction;
|
|
6241
|
+
}) === 0;
|
|
6242
|
+
if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
|
|
6243
|
+
return location;
|
|
6244
|
+
}
|
|
6245
|
+
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
6246
|
+
return RELAY_LOCATION;
|
|
6247
|
+
}
|
|
6248
|
+
var newInterior = location.interior === 'Here' ? {
|
|
6249
|
+
Here: null
|
|
6250
|
+
} : location.interior;
|
|
6251
|
+
var parachainRemoved = false;
|
|
6252
|
+
if (location.interior !== 'Here') {
|
|
6253
|
+
var paraId = resolveParaId(chain);
|
|
6254
|
+
var filteredJunctions = junctions.filter(function (junction) {
|
|
6255
|
+
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
6256
|
+
return false;
|
|
6257
|
+
}
|
|
6258
|
+
if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
|
|
6259
|
+
var paraJunctionId = getJunctionValue(location, 'Parachain');
|
|
6260
|
+
if (paraJunctionId === paraId) {
|
|
6261
|
+
parachainRemoved = true;
|
|
6262
|
+
return false;
|
|
6263
|
+
}
|
|
6264
|
+
}
|
|
6265
|
+
return true;
|
|
6266
|
+
});
|
|
6267
|
+
if (filteredJunctions.length === 0) {
|
|
6268
|
+
newInterior = {
|
|
6269
|
+
Here: null
|
|
6270
|
+
};
|
|
6271
|
+
} else {
|
|
6272
|
+
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
6273
|
+
}
|
|
6274
|
+
}
|
|
6275
|
+
var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
|
|
6276
|
+
var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
|
|
6277
|
+
if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
|
|
6278
|
+
return {
|
|
6279
|
+
parents: Parents.ONE,
|
|
6280
|
+
interior: {
|
|
6281
|
+
X1: [{
|
|
6282
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
6283
|
+
}]
|
|
6284
|
+
}
|
|
6285
|
+
};
|
|
6286
|
+
}
|
|
6287
|
+
if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
|
|
6288
|
+
return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
|
|
6289
|
+
})) {
|
|
6290
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
6291
|
+
parents: Parents.ONE
|
|
6292
|
+
});
|
|
6293
|
+
}
|
|
6294
|
+
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
6295
|
+
return {
|
|
6296
|
+
parents: Parents.TWO,
|
|
6297
|
+
interior: {
|
|
6298
|
+
X1: [{
|
|
6299
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
6300
|
+
}]
|
|
6301
|
+
}
|
|
6302
|
+
};
|
|
6303
|
+
}
|
|
6304
|
+
if (origin && ecosystemDiffers && newInterior.Here === undefined && !hasGlobalConsensus && originRelay !== undefined) {
|
|
6305
|
+
var _junctions = flattenJunctions(newInterior);
|
|
6306
|
+
var updatedJunctions = [{
|
|
6307
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
6308
|
+
}].concat(_toConsumableArray(_junctions));
|
|
6309
|
+
return {
|
|
6310
|
+
parents: Parents.TWO,
|
|
6311
|
+
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
6312
|
+
};
|
|
6313
|
+
}
|
|
6314
|
+
var shouldSetParentsToZero = parachainRemoved || newInterior.Here !== undefined && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
6315
|
+
return {
|
|
6316
|
+
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
6317
|
+
interior: newInterior
|
|
6318
|
+
};
|
|
6319
|
+
};
|
|
6320
|
+
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
6321
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
6322
|
+
return getRelayChainOf(c);
|
|
6323
|
+
}, function (c) {
|
|
6324
|
+
return getParaId(c);
|
|
6325
|
+
});
|
|
6326
|
+
};
|
|
6327
|
+
var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
|
|
6328
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
6329
|
+
return getRelayChainOfImpl(api, c);
|
|
6330
|
+
}, function (c) {
|
|
6331
|
+
return getParaIdImpl(c, api._customCtx);
|
|
6332
|
+
});
|
|
6333
|
+
};
|
|
6334
|
+
|
|
6335
|
+
var reverseTransformLocation = function reverseTransformLocation(location) {
|
|
6336
|
+
var parachainJunction = {
|
|
6337
|
+
Parachain: 1000
|
|
6338
|
+
};
|
|
6339
|
+
var alreadyHasP1000 = location.interior !== 'Here' && Object.values(location.interior).flat().some(function (j) {
|
|
6340
|
+
return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
|
|
6341
|
+
});
|
|
6342
|
+
if (alreadyHasP1000) {
|
|
6343
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
6344
|
+
parents: Parents.ONE
|
|
6345
|
+
});
|
|
6346
|
+
}
|
|
6347
|
+
var existingJunctions = location.interior === 'Here' ? [] // no other junctions
|
|
6348
|
+
: Object.values(location.interior).flat();
|
|
6349
|
+
var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
|
|
6350
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
6351
|
+
parents: Parents.ONE,
|
|
6352
|
+
interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
|
|
6353
|
+
});
|
|
6354
|
+
};
|
|
6355
|
+
|
|
6356
|
+
var createBridgedXcmPrefix = function createBridgedXcmPrefix(version, _ref) {
|
|
6357
|
+
var palletIndex = _ref.palletIndex,
|
|
6358
|
+
relay = _ref.relay,
|
|
6359
|
+
paraId = _ref.paraId;
|
|
6360
|
+
return [{
|
|
6361
|
+
DescendOrigin: createX1Payload(version, {
|
|
6362
|
+
PalletInstance: palletIndex
|
|
6363
|
+
})
|
|
6364
|
+
}, {
|
|
6365
|
+
UniversalOrigin: {
|
|
6366
|
+
GlobalConsensus: _defineProperty({}, relay.toLowerCase(), null)
|
|
6367
|
+
}
|
|
6368
|
+
}, {
|
|
6369
|
+
DescendOrigin: createX1Payload(version, {
|
|
6370
|
+
Parachain: paraId
|
|
6371
|
+
})
|
|
6372
|
+
}];
|
|
6373
|
+
};
|
|
6374
|
+
|
|
6375
|
+
var getErrorInstruction = function getErrorInstruction(message, index) {
|
|
6376
|
+
if (index === undefined || _typeof(message) !== 'object' || message === null) {
|
|
6377
|
+
return undefined;
|
|
6378
|
+
}
|
|
6379
|
+
var instructions = message;
|
|
6380
|
+
if (!Array.isArray(instructions)) {
|
|
6381
|
+
instructions = 'value' in message && Array.isArray(message.value) ? message.value : Object.values(message)[0];
|
|
6382
|
+
}
|
|
6383
|
+
if (!Array.isArray(instructions)) return undefined;
|
|
6384
|
+
var instruction = instructions[index];
|
|
6385
|
+
return _typeof(instruction) === 'object' && instruction !== null ? instruction : undefined;
|
|
6386
|
+
};
|
|
6387
|
+
var buildDryRunError = function buildDryRunError(error, message) {
|
|
6388
|
+
return _objectSpread2(_objectSpread2({}, error), {}, {
|
|
6389
|
+
instruction: getErrorInstruction(message, error.instructionIndex)
|
|
6390
|
+
});
|
|
6391
|
+
};
|
|
6392
|
+
|
|
6393
|
+
var resolveModuleError = function resolveModuleError(chain, error) {
|
|
6394
|
+
var palletDetails = getSupportedPalletsDetails(chain).find(function (p) {
|
|
6395
|
+
return p.index === Number(error.index);
|
|
6396
|
+
});
|
|
6397
|
+
if (!palletDetails) {
|
|
6398
|
+
throw new RoutingResolutionError("Pallet with index ".concat(error.index, " not found"));
|
|
6399
|
+
}
|
|
6400
|
+
// Use only the first byte of the error to get the error index
|
|
6401
|
+
// Including 0x prefix
|
|
6402
|
+
var errorIndex = Number(error.error.slice(0, 4));
|
|
6403
|
+
var name = palletDetails.name;
|
|
6404
|
+
if (name !== 'XTokens' && name !== 'PolkadotXcm' && name !== 'XcmPallet') {
|
|
6405
|
+
throw new UnsupportedOperationError("Pallet ".concat(name, " is not supported"));
|
|
6406
|
+
}
|
|
6407
|
+
var reason = name === 'XTokens' ? Object.values(XTokensError)[errorIndex] : Object.values(PolkadotXcmError)[errorIndex];
|
|
6408
|
+
if (!reason) {
|
|
6409
|
+
throw new RoutingResolutionError("Error index ".concat(errorIndex, " not found in ").concat(name, " pallet"));
|
|
6410
|
+
}
|
|
6411
|
+
if (reason === PolkadotXcmError.LocalExecutionIncompleteWithError) {
|
|
6412
|
+
// Byte layout: [pallet error variant][instruction index][xcm sub-error]
|
|
6413
|
+
var instructionIndex = Number("0x".concat(error.error.slice(4, 6)));
|
|
6414
|
+
var subErrorIndex = Number("0x".concat(error.error.slice(6, 8)));
|
|
6415
|
+
var subReason = Object.values(PolkadotXcmExecutionError)[subErrorIndex];
|
|
6416
|
+
if (!subReason) {
|
|
6417
|
+
throw new RoutingResolutionError("Sub-error index ".concat(subErrorIndex, " not found in PolkadotXcm pallet"));
|
|
6418
|
+
}
|
|
6419
|
+
return {
|
|
6420
|
+
reason: reason,
|
|
6421
|
+
subReason: subReason,
|
|
6422
|
+
instructionIndex: instructionIndex
|
|
6423
|
+
};
|
|
6424
|
+
}
|
|
6425
|
+
return {
|
|
6426
|
+
reason: reason
|
|
6427
|
+
};
|
|
6428
|
+
};
|
|
6429
|
+
|
|
6430
|
+
var parseUnits = parseUnits$1;
|
|
6431
|
+
var formatUnits = formatUnits$1;
|
|
6432
|
+
|
|
6433
|
+
var resolveBypassMintAmount = function resolveBypassMintAmount(chain) {
|
|
6434
|
+
return HIGH_BYPASS_MINT_CHAINS.some(function (c) {
|
|
6435
|
+
return c === chain;
|
|
6436
|
+
}) ? HIGH_BYPASS_MINT_AMOUNT : BYPASS_MINT_AMOUNT;
|
|
6437
|
+
};
|
|
6438
|
+
var createMintTxs = function createMintTxs(chain, asset, balance, address, api) {
|
|
6439
|
+
return getSubstrateChainImpl(chain, api._customCtx).mint(api, address, asset, balance);
|
|
6440
|
+
};
|
|
6441
|
+
var createRequiredMintTxs = function createRequiredMintTxs(chain, asset, amountHuman, balance, address, api) {
|
|
6442
|
+
var amount = parseUnits(amountHuman, asset.decimals);
|
|
6443
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
6444
|
+
amount: amount
|
|
6445
|
+
}), balance, address, api);
|
|
6446
|
+
};
|
|
6447
|
+
var createOptionalMintTxs = function createOptionalMintTxs(chain, currency, amountHuman, balance, address, api) {
|
|
6448
|
+
var asset = api.findAssetInfo(chain, currency);
|
|
6449
|
+
if (!asset) return null;
|
|
6450
|
+
var amount = parseUnits(amountHuman, asset.decimals);
|
|
6451
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
6452
|
+
amount: amount
|
|
6453
|
+
}), balance, address, api);
|
|
6454
|
+
};
|
|
6455
|
+
var resultToExtrinsics = function resultToExtrinsics(api, address, _ref) {
|
|
6456
|
+
var assetStatusTx = _ref.assetStatusTx,
|
|
6457
|
+
balanceTx = _ref.balanceTx;
|
|
6458
|
+
return [].concat(_toConsumableArray(assetStatusTx ? [api.deserializeExtrinsics(assetStatusTx)] : []), _toConsumableArray(assetStatusTx ? [api.callDispatchAsMethod(api.deserializeExtrinsics(balanceTx), address)] : [api.deserializeExtrinsics(balanceTx)]));
|
|
6459
|
+
};
|
|
6460
|
+
var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeAssets, api) {
|
|
6461
|
+
if (!mintFeeAssets) return 0n;
|
|
6462
|
+
var _native = api.findNativeAssetInfo(chain);
|
|
6463
|
+
var relay = api.findAssetInfo(chain, {
|
|
6464
|
+
location: {
|
|
6465
|
+
parents: Parents.ONE,
|
|
6466
|
+
interior: {
|
|
6467
|
+
Here: null
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
}, null);
|
|
6471
|
+
var seen = new Set();
|
|
6472
|
+
var preminted = [_native, relay, feeAsset].filter(function (a) {
|
|
6473
|
+
return !!a;
|
|
6474
|
+
}).filter(function (a) {
|
|
6475
|
+
var k = JSON.stringify(a.location, replaceBigInt);
|
|
6476
|
+
if (seen.has(k)) return false;
|
|
6477
|
+
seen.add(k);
|
|
6478
|
+
return true;
|
|
6479
|
+
});
|
|
6480
|
+
return preminted.some(function (a) {
|
|
6481
|
+
return isAssetEqual(a, sent);
|
|
6482
|
+
}) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
|
|
6483
|
+
};
|
|
6484
|
+
var wrapTxBypass = /*#__PURE__*/function () {
|
|
6485
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dryRunOptions) {
|
|
6486
|
+
var _dryRunOptions$assets;
|
|
6487
|
+
var options,
|
|
6488
|
+
api,
|
|
6489
|
+
chain,
|
|
6490
|
+
address,
|
|
6491
|
+
asset,
|
|
6492
|
+
feeAsset,
|
|
6493
|
+
tx,
|
|
6494
|
+
mintFeeAssets,
|
|
6495
|
+
bypassMintAmount,
|
|
6496
|
+
relayCurrency,
|
|
6497
|
+
nativeInfo,
|
|
6498
|
+
relayInfo,
|
|
6158
6499
|
sameNativeRelay,
|
|
6159
6500
|
mintNativeAssetRes,
|
|
6160
6501
|
mintRelayAssetRes,
|
|
@@ -6229,7 +6570,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6229
6570
|
case 8:
|
|
6230
6571
|
mintSentAsset = /*#__PURE__*/function () {
|
|
6231
6572
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
|
|
6232
|
-
var balance, bonus, mintAmount,
|
|
6573
|
+
var balance, bonus, mintAmount, missing, total;
|
|
6233
6574
|
return _regenerator().w(function (_context) {
|
|
6234
6575
|
while (1) switch (_context.n) {
|
|
6235
6576
|
case 0:
|
|
@@ -6244,11 +6585,9 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6244
6585
|
balance = _context.v;
|
|
6245
6586
|
bonus = mintBonusForSent(chain, sentAsset, feeAsset, !!mintFeeAssets, api);
|
|
6246
6587
|
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
6247
|
-
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
|
|
6588
|
+
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount + BigInt(sentAsset.existentialDeposit);
|
|
6248
6589
|
} else {
|
|
6249
|
-
|
|
6250
|
-
desiredBalance = sentAsset.amount + keepAliveBuffer;
|
|
6251
|
-
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, desiredBalance)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
6590
|
+
missing = calcSentAssetPreviewMint(sentAsset, balance, dryRunOptions.keepAlive);
|
|
6252
6591
|
total = missing + bonus;
|
|
6253
6592
|
mintAmount = total > 0n ? total : null;
|
|
6254
6593
|
}
|
|
@@ -6325,7 +6664,7 @@ var getBypassResultWithRetries = /*#__PURE__*/function () {
|
|
|
6325
6664
|
while (1) switch (_context.n) {
|
|
6326
6665
|
case 0:
|
|
6327
6666
|
_context.n = 1;
|
|
6328
|
-
return options.buildTx(amount, relative);
|
|
6667
|
+
return options.buildTx(amount, relative, true);
|
|
6329
6668
|
case 1:
|
|
6330
6669
|
tx = _context.v;
|
|
6331
6670
|
return _context.a(2, internalFn(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -7549,11 +7888,11 @@ var sumHopFees = function sumHopFees(result, _ref) {
|
|
|
7549
7888
|
};
|
|
7550
7889
|
var computeAllFees = /*#__PURE__*/function () {
|
|
7551
7890
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
|
|
7552
|
-
var origin, dest, feeAssetInfo, _context$options, sender, recipient, currency, feeCurrency, version, overriddenAsset, result, hopFees, destFee;
|
|
7891
|
+
var origin, dest, feeAssetInfo, edDeposit, _context$options, sender, recipient, currency, feeCurrency, version, overriddenAsset, result, hopFees, destFee;
|
|
7553
7892
|
return _regenerator().w(function (_context) {
|
|
7554
7893
|
while (1) switch (_context.n) {
|
|
7555
7894
|
case 0:
|
|
7556
|
-
origin = context.origin, dest = context.dest, feeAssetInfo = context.feeAssetInfo, _context$options = context.options, sender = _context$options.sender, recipient = _context$options.recipient, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency, version = _context$options.version, overriddenAsset = _context$options.overriddenAsset;
|
|
7895
|
+
origin = context.origin, dest = context.dest, feeAssetInfo = context.feeAssetInfo, edDeposit = context.edDeposit, _context$options = context.options, sender = _context$options.sender, recipient = _context$options.recipient, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency, version = _context$options.version, overriddenAsset = _context$options.overriddenAsset;
|
|
7557
7896
|
assertSender(sender);
|
|
7558
7897
|
assertAddressIsString(recipient);
|
|
7559
7898
|
if (origin.api.hasDryRunSupport(context.origin.chain)) {
|
|
@@ -7588,7 +7927,7 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
7588
7927
|
destFee = result.destination.fee;
|
|
7589
7928
|
return _context.a(2, {
|
|
7590
7929
|
hopFees: padValueBy(hopFees, FEE_PADDING),
|
|
7591
|
-
destFee: padValueBy(destFee, FEE_PADDING)
|
|
7930
|
+
destFee: padValueBy(destFee, FEE_PADDING) + (edDeposit !== null && edDeposit !== void 0 ? edDeposit : 0n)
|
|
7592
7931
|
});
|
|
7593
7932
|
}
|
|
7594
7933
|
}, _callee);
|
|
@@ -7641,7 +7980,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7641
7980
|
_context3.n = 3;
|
|
7642
7981
|
return Promise.all(assets.map(/*#__PURE__*/function () {
|
|
7643
7982
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, index) {
|
|
7644
|
-
var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, hopFeeTotal, destinationFee, edComponent;
|
|
7983
|
+
var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, originChainAsset, hopFeeTotal, destinationFee, edComponent;
|
|
7645
7984
|
return _regenerator().w(function (_context) {
|
|
7646
7985
|
while (1) switch (_context.n) {
|
|
7647
7986
|
case 0:
|
|
@@ -7658,11 +7997,24 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7658
7997
|
destEd = BigInt(destAsset.existentialDeposit);
|
|
7659
7998
|
paysOriginInSendingAsset = !resolvedFeeAsset && isAssetEqual(nativeAssetInfo, asset) || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
7660
7999
|
originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
8000
|
+
originChainAsset = {
|
|
8001
|
+
chain: origin,
|
|
8002
|
+
asset: asset
|
|
8003
|
+
};
|
|
8004
|
+
hopFeeTotal = result.hops.reduce(function (acc, _ref4) {
|
|
8005
|
+
var chain = _ref4.chain,
|
|
8006
|
+
_ref4$result = _ref4.result,
|
|
8007
|
+
hopAsset = _ref4$result.asset,
|
|
8008
|
+
fee = _ref4$result.fee;
|
|
8009
|
+
return api.isAssetXcEqual(originChainAsset, {
|
|
8010
|
+
chain: chain,
|
|
8011
|
+
asset: hopAsset
|
|
8012
|
+
}) ? acc + fee : acc;
|
|
7664
8013
|
}, 0n);
|
|
7665
|
-
destinationFee = result.destination &&
|
|
8014
|
+
destinationFee = result.destination && api.isAssetXcEqual(originChainAsset, {
|
|
8015
|
+
chain: destination,
|
|
8016
|
+
asset: result.destination.asset
|
|
8017
|
+
}) ? result.destination.fee : 0n;
|
|
7666
8018
|
edComponent = destBalance === 0n ? destEd : 0n;
|
|
7667
8019
|
return _context.a(2, hopFeeTotal + destinationFee + originFee + edComponent + 1n);
|
|
7668
8020
|
}
|
|
@@ -7684,7 +8036,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7684
8036
|
});
|
|
7685
8037
|
};
|
|
7686
8038
|
createTx = /*#__PURE__*/function () {
|
|
7687
|
-
var
|
|
8039
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(amounts) {
|
|
7688
8040
|
var _yield$builder$curren, tx;
|
|
7689
8041
|
return _regenerator().w(function (_context2) {
|
|
7690
8042
|
while (1) switch (_context2.n) {
|
|
@@ -7699,7 +8051,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7699
8051
|
}, _callee2);
|
|
7700
8052
|
}));
|
|
7701
8053
|
return function createTx(_x4) {
|
|
7702
|
-
return
|
|
8054
|
+
return _ref5.apply(this, arguments);
|
|
7703
8055
|
};
|
|
7704
8056
|
}();
|
|
7705
8057
|
amounts = minAmounts;
|
|
@@ -7764,7 +8116,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7764
8116
|
};
|
|
7765
8117
|
}();
|
|
7766
8118
|
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
7767
|
-
var
|
|
8119
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
7768
8120
|
var api;
|
|
7769
8121
|
return _regenerator().w(function (_context4) {
|
|
7770
8122
|
while (1) switch (_context4.p = _context4.n) {
|
|
@@ -7789,7 +8141,7 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
|
7789
8141
|
}, _callee4, null, [[1,, 3, 5]]);
|
|
7790
8142
|
}));
|
|
7791
8143
|
return function getMinTransferableAmount(_x5) {
|
|
7792
|
-
return
|
|
8144
|
+
return _ref6.apply(this, arguments);
|
|
7793
8145
|
};
|
|
7794
8146
|
}();
|
|
7795
8147
|
|
|
@@ -7883,339 +8235,197 @@ var getTransferableAmountForAsset = /*#__PURE__*/function () {
|
|
|
7883
8235
|
fee = originFee && isAssetEqual(originFee.asset, asset) ? originFee.fee : 0n;
|
|
7884
8236
|
return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
|
|
7885
8237
|
}
|
|
7886
|
-
}, _callee3);
|
|
7887
|
-
}));
|
|
7888
|
-
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
7889
|
-
return _ref4.apply(this, arguments);
|
|
7890
|
-
};
|
|
7891
|
-
}();
|
|
7892
|
-
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
7893
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
7894
|
-
var api, sender, chain, destination, currency, _resolveCurrency, assets, originFee;
|
|
7895
|
-
return _regenerator().w(function (_context4) {
|
|
7896
|
-
while (1) switch (_context4.n) {
|
|
7897
|
-
case 0:
|
|
7898
|
-
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
7899
|
-
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
7900
|
-
_context4.n = 1;
|
|
7901
|
-
return getOriginFeeOrThrow(options, currency);
|
|
7902
|
-
case 1:
|
|
7903
|
-
originFee = _context4.v;
|
|
7904
|
-
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
7905
|
-
return computeTransferableAmount(api, sender, chain, asset, isAssetEqual(originFee.asset, asset) ? originFee.fee : 0n);
|
|
7906
|
-
})));
|
|
7907
|
-
}
|
|
7908
|
-
}, _callee4);
|
|
7909
|
-
}));
|
|
7910
|
-
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
7911
|
-
return _ref5.apply(this, arguments);
|
|
7912
|
-
};
|
|
7913
|
-
}();
|
|
7914
|
-
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
7915
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
7916
|
-
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
7917
|
-
return _regenerator().w(function (_context5) {
|
|
7918
|
-
while (1) switch (_context5.n) {
|
|
7919
|
-
case 0:
|
|
7920
|
-
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
7921
|
-
validateAddress(api, sender, chain, false);
|
|
7922
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
7923
|
-
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7924
|
-
currency: currency
|
|
7925
|
-
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7926
|
-
currency: currency
|
|
7927
|
-
}), resolvedFeeAsset));
|
|
7928
|
-
}
|
|
7929
|
-
}, _callee5);
|
|
7930
|
-
}));
|
|
7931
|
-
return function getTransferableAmountInternal(_x10) {
|
|
7932
|
-
return _ref6.apply(this, arguments);
|
|
7933
|
-
};
|
|
7934
|
-
}();
|
|
7935
|
-
var getTransferableAmount = /*#__PURE__*/function () {
|
|
7936
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
|
|
7937
|
-
var api;
|
|
7938
|
-
return _regenerator().w(function (_context6) {
|
|
7939
|
-
while (1) switch (_context6.p = _context6.n) {
|
|
7940
|
-
case 0:
|
|
7941
|
-
api = options.api;
|
|
7942
|
-
api.disconnectAllowed = false;
|
|
7943
|
-
_context6.p = 1;
|
|
7944
|
-
_context6.n = 2;
|
|
7945
|
-
return getTransferableAmountInternal(options);
|
|
7946
|
-
case 2:
|
|
7947
|
-
return _context6.a(2, _context6.v);
|
|
7948
|
-
case 3:
|
|
7949
|
-
_context6.p = 3;
|
|
7950
|
-
api.disconnectAllowed = true;
|
|
7951
|
-
_context6.n = 4;
|
|
7952
|
-
return api.disconnect();
|
|
7953
|
-
case 4:
|
|
7954
|
-
return _context6.f(3);
|
|
7955
|
-
case 5:
|
|
7956
|
-
return _context6.a(2);
|
|
7957
|
-
}
|
|
7958
|
-
}, _callee6, null, [[1,, 3, 5]]);
|
|
7959
|
-
}));
|
|
7960
|
-
return function getTransferableAmount(_x11) {
|
|
7961
|
-
return _ref7.apply(this, arguments);
|
|
7962
|
-
};
|
|
7963
|
-
}();
|
|
7964
|
-
|
|
7965
|
-
var createX1Payload = function createX1Payload(version, junction) {
|
|
7966
|
-
return version === Version.V3 ? {
|
|
7967
|
-
X1: junction
|
|
7968
|
-
} : {
|
|
7969
|
-
X1: [junction]
|
|
7970
|
-
};
|
|
7971
|
-
};
|
|
7972
|
-
|
|
7973
|
-
var createAccountPayload = function createAccountPayload(api, address) {
|
|
7974
|
-
return isAddress(address) ? {
|
|
7975
|
-
AccountKey20: {
|
|
7976
|
-
key: address
|
|
7977
|
-
}
|
|
7978
|
-
} : {
|
|
7979
|
-
AccountId32: {
|
|
7980
|
-
id: api.accountToHex(address)
|
|
7981
|
-
}
|
|
7982
|
-
};
|
|
7983
|
-
};
|
|
7984
|
-
var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
|
|
7985
|
-
var api = _ref.api,
|
|
7986
|
-
recipient = _ref.recipient,
|
|
7987
|
-
origin = _ref.origin,
|
|
7988
|
-
destination = _ref.destination,
|
|
7989
|
-
version = _ref.version,
|
|
7990
|
-
paraId = _ref.paraId;
|
|
7991
|
-
if (isTLocation(recipient)) {
|
|
7992
|
-
return recipient;
|
|
7993
|
-
}
|
|
7994
|
-
var scenario = resolveScenario(origin, destination);
|
|
7995
|
-
var accountPayload = createAccountPayload(api, recipient);
|
|
7996
|
-
if (scenario === 'ParaToRelay') {
|
|
7997
|
-
return {
|
|
7998
|
-
parents: Parents.ONE,
|
|
7999
|
-
interior: createX1Payload(version, {
|
|
8000
|
-
AccountId32: {
|
|
8001
|
-
id: api.accountToHex(recipient)
|
|
8002
|
-
}
|
|
8003
|
-
})
|
|
8004
|
-
};
|
|
8005
|
-
} else if (scenario === 'ParaToPara') {
|
|
8006
|
-
return {
|
|
8007
|
-
parents: Parents.ONE,
|
|
8008
|
-
interior: {
|
|
8009
|
-
X2: [{
|
|
8010
|
-
Parachain: paraId
|
|
8011
|
-
}, accountPayload]
|
|
8012
|
-
}
|
|
8013
|
-
};
|
|
8014
|
-
}
|
|
8015
|
-
return {
|
|
8016
|
-
parents: Parents.ZERO,
|
|
8017
|
-
interior: createX1Payload(version, accountPayload)
|
|
8018
|
-
};
|
|
8019
|
-
};
|
|
8020
|
-
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
8021
|
-
var api = _ref2.api,
|
|
8022
|
-
address = _ref2.address,
|
|
8023
|
-
version = _ref2.version;
|
|
8024
|
-
if (isTLocation(address)) return address;
|
|
8025
|
-
var accountPayload = createAccountPayload(api, address);
|
|
8026
|
-
return {
|
|
8027
|
-
parents: Parents.ZERO,
|
|
8028
|
-
interior: createX1Payload(version, accountPayload)
|
|
8029
|
-
};
|
|
8030
|
-
};
|
|
8031
|
-
|
|
8032
|
-
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
8033
|
-
var isLocDestination = isTLocation(destination);
|
|
8034
|
-
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
8035
|
-
if (isSubBridge) {
|
|
8036
|
-
return {
|
|
8037
|
-
parents: Parents.TWO,
|
|
8038
|
-
interior: {
|
|
8039
|
-
X2: [{
|
|
8040
|
-
GlobalConsensus: api.getRelayChainOf(destination)
|
|
8041
|
-
}, {
|
|
8042
|
-
Parachain: chainId
|
|
8043
|
-
}]
|
|
8044
|
-
}
|
|
8045
|
-
};
|
|
8046
|
-
}
|
|
8047
|
-
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
8048
|
-
if (isExternalDestination) {
|
|
8049
|
-
return {
|
|
8050
|
-
parents: Parents.TWO,
|
|
8051
|
-
interior: {
|
|
8052
|
-
X1: [getEthereumJunction(api, origin)]
|
|
8238
|
+
}, _callee3);
|
|
8239
|
+
}));
|
|
8240
|
+
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
8241
|
+
return _ref4.apply(this, arguments);
|
|
8242
|
+
};
|
|
8243
|
+
}();
|
|
8244
|
+
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
8245
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
8246
|
+
var api, sender, chain, destination, currency, _resolveCurrency, assets, originFee;
|
|
8247
|
+
return _regenerator().w(function (_context4) {
|
|
8248
|
+
while (1) switch (_context4.n) {
|
|
8249
|
+
case 0:
|
|
8250
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
8251
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
8252
|
+
_context4.n = 1;
|
|
8253
|
+
return getOriginFeeOrThrow(options, currency);
|
|
8254
|
+
case 1:
|
|
8255
|
+
originFee = _context4.v;
|
|
8256
|
+
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
8257
|
+
return computeTransferableAmount(api, sender, chain, asset, isAssetEqual(originFee.asset, asset) ? originFee.fee : 0n);
|
|
8258
|
+
})));
|
|
8053
8259
|
}
|
|
8054
|
-
};
|
|
8055
|
-
}
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
8059
|
-
Parachain: chainId
|
|
8060
|
-
});
|
|
8061
|
-
return isLocDestination ? destination : {
|
|
8062
|
-
parents: parentsResolved,
|
|
8063
|
-
interior: interior
|
|
8260
|
+
}, _callee4);
|
|
8261
|
+
}));
|
|
8262
|
+
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
8263
|
+
return _ref5.apply(this, arguments);
|
|
8064
8264
|
};
|
|
8065
|
-
};
|
|
8066
|
-
var
|
|
8067
|
-
var
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8265
|
+
}();
|
|
8266
|
+
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
8267
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
8268
|
+
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
8269
|
+
return _regenerator().w(function (_context5) {
|
|
8270
|
+
while (1) switch (_context5.n) {
|
|
8271
|
+
case 0:
|
|
8272
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
8273
|
+
validateAddress(api, sender, chain, false);
|
|
8274
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
8275
|
+
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8276
|
+
currency: currency
|
|
8277
|
+
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8278
|
+
currency: currency
|
|
8279
|
+
}), resolvedFeeAsset));
|
|
8280
|
+
}
|
|
8281
|
+
}, _callee5);
|
|
8282
|
+
}));
|
|
8283
|
+
return function getTransferableAmountInternal(_x10) {
|
|
8284
|
+
return _ref6.apply(this, arguments);
|
|
8079
8285
|
};
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8286
|
+
}();
|
|
8287
|
+
var getTransferableAmount = /*#__PURE__*/function () {
|
|
8288
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
|
|
8289
|
+
var api;
|
|
8290
|
+
return _regenerator().w(function (_context6) {
|
|
8291
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
8292
|
+
case 0:
|
|
8293
|
+
api = options.api;
|
|
8294
|
+
api.disconnectAllowed = false;
|
|
8295
|
+
_context6.p = 1;
|
|
8296
|
+
_context6.n = 2;
|
|
8297
|
+
return getTransferableAmountInternal(options);
|
|
8298
|
+
case 2:
|
|
8299
|
+
return _context6.a(2, _context6.v);
|
|
8300
|
+
case 3:
|
|
8301
|
+
_context6.p = 3;
|
|
8302
|
+
api.disconnectAllowed = true;
|
|
8303
|
+
_context6.n = 4;
|
|
8304
|
+
return api.disconnect();
|
|
8305
|
+
case 4:
|
|
8306
|
+
return _context6.f(3);
|
|
8307
|
+
case 5:
|
|
8308
|
+
return _context6.a(2);
|
|
8309
|
+
}
|
|
8310
|
+
}, _callee6, null, [[1,, 3, 5]]);
|
|
8311
|
+
}));
|
|
8312
|
+
return function getTransferableAmount(_x11) {
|
|
8313
|
+
return _ref7.apply(this, arguments);
|
|
8083
8314
|
};
|
|
8084
|
-
};
|
|
8315
|
+
}();
|
|
8085
8316
|
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
}) === 0;
|
|
8110
|
-
if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
|
|
8111
|
-
return location;
|
|
8112
|
-
}
|
|
8113
|
-
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
8114
|
-
return RELAY_LOCATION;
|
|
8115
|
-
}
|
|
8116
|
-
var newInterior = location.interior;
|
|
8117
|
-
var parachainRemoved = false;
|
|
8118
|
-
if (location.interior !== 'Here') {
|
|
8119
|
-
var paraId = resolveParaId(chain);
|
|
8120
|
-
var filteredJunctions = junctions.filter(function (junction) {
|
|
8121
|
-
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
8122
|
-
return false;
|
|
8123
|
-
}
|
|
8124
|
-
if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
|
|
8125
|
-
var paraJunctionId = getJunctionValue(location, 'Parachain');
|
|
8126
|
-
if (paraJunctionId === paraId) {
|
|
8127
|
-
parachainRemoved = true;
|
|
8128
|
-
return false;
|
|
8129
|
-
}
|
|
8130
|
-
}
|
|
8131
|
-
return true;
|
|
8132
|
-
});
|
|
8133
|
-
if (filteredJunctions.length === 0) {
|
|
8134
|
-
newInterior = 'Here';
|
|
8135
|
-
} else {
|
|
8136
|
-
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
8137
|
-
}
|
|
8138
|
-
}
|
|
8139
|
-
var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
|
|
8140
|
-
var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
|
|
8141
|
-
if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
|
|
8142
|
-
return {
|
|
8143
|
-
parents: Parents.ONE,
|
|
8144
|
-
interior: {
|
|
8145
|
-
X1: [{
|
|
8146
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8147
|
-
}]
|
|
8148
|
-
}
|
|
8149
|
-
};
|
|
8150
|
-
}
|
|
8151
|
-
if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
|
|
8152
|
-
return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
|
|
8153
|
-
})) {
|
|
8154
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8155
|
-
parents: Parents.ONE
|
|
8156
|
-
});
|
|
8157
|
-
}
|
|
8158
|
-
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
8159
|
-
return {
|
|
8160
|
-
parents: Parents.TWO,
|
|
8161
|
-
interior: {
|
|
8162
|
-
X1: [{
|
|
8163
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8164
|
-
}]
|
|
8317
|
+
var isAssetSufficient = /*#__PURE__*/function () {
|
|
8318
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain, asset) {
|
|
8319
|
+
var pallets, _state$isSufficient, state;
|
|
8320
|
+
return _regenerator().w(function (_context) {
|
|
8321
|
+
while (1) switch (_context.p = _context.n) {
|
|
8322
|
+
case 0:
|
|
8323
|
+
pallets = getOtherAssetsPallets(chain, api._customCtx);
|
|
8324
|
+
if (!(asset.isNative || pallets.length === 0)) {
|
|
8325
|
+
_context.n = 1;
|
|
8326
|
+
break;
|
|
8327
|
+
}
|
|
8328
|
+
return _context.a(2, true);
|
|
8329
|
+
case 1:
|
|
8330
|
+
_context.p = 1;
|
|
8331
|
+
_context.n = 2;
|
|
8332
|
+
return getPalletInstance(pickOtherMintPallet(asset, pallets)).getAssetState(api, asset);
|
|
8333
|
+
case 2:
|
|
8334
|
+
state = _context.v;
|
|
8335
|
+
return _context.a(2, (_state$isSufficient = state === null || state === void 0 ? void 0 : state.isSufficient) !== null && _state$isSufficient !== void 0 ? _state$isSufficient : true);
|
|
8336
|
+
case 3:
|
|
8337
|
+
_context.p = 3;
|
|
8338
|
+
_context.v;
|
|
8339
|
+
return _context.a(2, true);
|
|
8165
8340
|
}
|
|
8166
|
-
};
|
|
8167
|
-
}
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
var updatedJunctions = [{
|
|
8171
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8172
|
-
}].concat(_toConsumableArray(_junctions));
|
|
8173
|
-
return {
|
|
8174
|
-
parents: Parents.TWO,
|
|
8175
|
-
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
8176
|
-
};
|
|
8177
|
-
}
|
|
8178
|
-
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
8179
|
-
return {
|
|
8180
|
-
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
8181
|
-
interior: newInterior
|
|
8341
|
+
}, _callee, null, [[1, 3]]);
|
|
8342
|
+
}));
|
|
8343
|
+
return function isAssetSufficient(_x, _x2, _x3) {
|
|
8344
|
+
return _ref.apply(this, arguments);
|
|
8182
8345
|
};
|
|
8183
|
-
};
|
|
8184
|
-
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
8185
|
-
return localizeLocationInner(chain, location, origin, function (c) {
|
|
8186
|
-
return getRelayChainOf(c);
|
|
8187
|
-
}, function (c) {
|
|
8188
|
-
return getParaId(c);
|
|
8189
|
-
});
|
|
8190
|
-
};
|
|
8191
|
-
var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
|
|
8192
|
-
return localizeLocationInner(chain, location, origin, function (c) {
|
|
8193
|
-
return getRelayChainOfImpl(api, c);
|
|
8194
|
-
}, function (c) {
|
|
8195
|
-
return getParaIdImpl(c, api._customCtx);
|
|
8196
|
-
});
|
|
8197
|
-
};
|
|
8346
|
+
}();
|
|
8198
8347
|
|
|
8199
|
-
var
|
|
8200
|
-
var
|
|
8201
|
-
|
|
8348
|
+
var resolveEdDeposit = /*#__PURE__*/function () {
|
|
8349
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
8350
|
+
var _overriddenAsset$map;
|
|
8351
|
+
var origin, _ref$dest, destApi, destChain, assetInfo, overriddenAsset, feeAssetLocation, recipient, nativeAsset, nativeLocation, feeLocation, isFeeNative, _yield$destApi$queryS, providers, destAssets, sufficiency, ed, feeAmount;
|
|
8352
|
+
return _regenerator().w(function (_context) {
|
|
8353
|
+
while (1) switch (_context.n) {
|
|
8354
|
+
case 0:
|
|
8355
|
+
origin = _ref.origin, _ref$dest = _ref.dest, destApi = _ref$dest.api, destChain = _ref$dest.chain, assetInfo = _ref.assetInfo, overriddenAsset = _ref.overriddenAsset, feeAssetLocation = _ref.feeAssetLocation, recipient = _ref.recipient;
|
|
8356
|
+
if (!(isExternalChain(destChain) || typeof recipient !== 'string')) {
|
|
8357
|
+
_context.n = 1;
|
|
8358
|
+
break;
|
|
8359
|
+
}
|
|
8360
|
+
return _context.a(2, undefined);
|
|
8361
|
+
case 1:
|
|
8362
|
+
nativeAsset = destApi.findNativeAssetInfoOrThrow(destChain);
|
|
8363
|
+
nativeLocation = origin.api.localizeLocation(destChain, nativeAsset.location);
|
|
8364
|
+
feeLocation = origin.api.localizeLocation(destChain, feeAssetLocation, origin.chain);
|
|
8365
|
+
isFeeNative = deepEqual(feeLocation, nativeLocation);
|
|
8366
|
+
if (!(!isFeeNative && !destChain.startsWith('AssetHub'))) {
|
|
8367
|
+
_context.n = 2;
|
|
8368
|
+
break;
|
|
8369
|
+
}
|
|
8370
|
+
return _context.a(2, undefined);
|
|
8371
|
+
case 2:
|
|
8372
|
+
_context.n = 3;
|
|
8373
|
+
return destApi.queryState({
|
|
8374
|
+
module: 'System',
|
|
8375
|
+
method: 'Account',
|
|
8376
|
+
params: [recipient]
|
|
8377
|
+
});
|
|
8378
|
+
case 3:
|
|
8379
|
+
_yield$destApi$queryS = _context.v;
|
|
8380
|
+
providers = _yield$destApi$queryS.providers;
|
|
8381
|
+
if (!(providers > 0)) {
|
|
8382
|
+
_context.n = 4;
|
|
8383
|
+
break;
|
|
8384
|
+
}
|
|
8385
|
+
return _context.a(2, undefined);
|
|
8386
|
+
case 4:
|
|
8387
|
+
destAssets = ((_overriddenAsset$map = overriddenAsset === null || overriddenAsset === void 0 ? void 0 : overriddenAsset.map(function (asset) {
|
|
8388
|
+
return extractAssetLocation(asset);
|
|
8389
|
+
})) !== null && _overriddenAsset$map !== void 0 ? _overriddenAsset$map : [assetInfo.location]).map(function (location) {
|
|
8390
|
+
return origin.api.findAssetOnDestOrThrow(origin.chain, destChain, {
|
|
8391
|
+
location: location
|
|
8392
|
+
});
|
|
8393
|
+
});
|
|
8394
|
+
_context.n = 5;
|
|
8395
|
+
return Promise.all(destAssets.map(function (asset) {
|
|
8396
|
+
return isAssetSufficient(destApi, destChain, asset);
|
|
8397
|
+
}));
|
|
8398
|
+
case 5:
|
|
8399
|
+
sufficiency = _context.v;
|
|
8400
|
+
if (!sufficiency.every(Boolean)) {
|
|
8401
|
+
_context.n = 6;
|
|
8402
|
+
break;
|
|
8403
|
+
}
|
|
8404
|
+
return _context.a(2, undefined);
|
|
8405
|
+
case 6:
|
|
8406
|
+
ed = BigInt(nativeAsset.existentialDeposit);
|
|
8407
|
+
if (!isFeeNative) {
|
|
8408
|
+
_context.n = 7;
|
|
8409
|
+
break;
|
|
8410
|
+
}
|
|
8411
|
+
return _context.a(2, ed);
|
|
8412
|
+
case 7:
|
|
8413
|
+
_context.n = 8;
|
|
8414
|
+
return destApi.queryRuntimeApi({
|
|
8415
|
+
module: 'AssetConversionApi',
|
|
8416
|
+
method: 'quote_price_tokens_for_exact_tokens',
|
|
8417
|
+
params: [feeLocation, nativeLocation, ed, true]
|
|
8418
|
+
});
|
|
8419
|
+
case 8:
|
|
8420
|
+
feeAmount = _context.v;
|
|
8421
|
+
return _context.a(2, feeAmount == null ? undefined : padValueBy(BigInt(feeAmount), FEE_PADDING));
|
|
8422
|
+
}
|
|
8423
|
+
}, _callee);
|
|
8424
|
+
}));
|
|
8425
|
+
return function resolveEdDeposit(_x) {
|
|
8426
|
+
return _ref2.apply(this, arguments);
|
|
8202
8427
|
};
|
|
8203
|
-
|
|
8204
|
-
return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
|
|
8205
|
-
});
|
|
8206
|
-
if (alreadyHasP1000) {
|
|
8207
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8208
|
-
parents: Parents.ONE
|
|
8209
|
-
});
|
|
8210
|
-
}
|
|
8211
|
-
var existingJunctions = location.interior === 'Here' ? [] // no other junctions
|
|
8212
|
-
: Object.values(location.interior).flat();
|
|
8213
|
-
var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
|
|
8214
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8215
|
-
parents: Parents.ONE,
|
|
8216
|
-
interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
|
|
8217
|
-
});
|
|
8218
|
-
};
|
|
8428
|
+
}();
|
|
8219
8429
|
|
|
8220
8430
|
var PINK_LOCATION = {
|
|
8221
8431
|
parents: 1,
|
|
@@ -8241,8 +8451,9 @@ var getFeeAssetLocation = function getFeeAssetLocation(_ref) {
|
|
|
8241
8451
|
var _feeAssetInfo$locatio;
|
|
8242
8452
|
var feeAssetInfo = _ref.feeAssetInfo,
|
|
8243
8453
|
isRelayAsset = _ref.isRelayAsset,
|
|
8244
|
-
assetInfo = _ref.assetInfo
|
|
8245
|
-
|
|
8454
|
+
assetInfo = _ref.assetInfo,
|
|
8455
|
+
overriddenAsset = _ref.options.overriddenAsset;
|
|
8456
|
+
return (_feeAssetInfo$locatio = feeAssetInfo === null || feeAssetInfo === void 0 ? void 0 : feeAssetInfo.location) !== null && _feeAssetInfo$locatio !== void 0 ? _feeAssetInfo$locatio : isRelayAsset || overriddenAsset ? assetInfo.location : RELAY_LOCATION;
|
|
8246
8457
|
};
|
|
8247
8458
|
var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
|
|
8248
8459
|
var assetConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
@@ -8265,7 +8476,7 @@ var resolveReserveChain = function resolveReserveChain(api, chain, destination,
|
|
|
8265
8476
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
8266
8477
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, overrides) {
|
|
8267
8478
|
var _overrides$noFeeAsset;
|
|
8268
|
-
var api, chain, destination, assetInfo, overriddenAsset, isSubBridge, isSb, transferredAsset, reserveChain, feeAssetInfo, feeAssetLocation, feeReserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isExternalDestination, isSnowbridgeAsset, requiresSystemAsset, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, assetHubChain, bridgeHopChain, routedChain, destApi, reserveApi;
|
|
8479
|
+
var api, chain, destination, assetInfo, overriddenAsset, isSubBridge, isSb, transferredAsset, reserveChain, feeAssetInfo, feeAssetLocation, feeReserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isExternalDestination, isSnowbridgeAsset, requiresSystemAsset, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, assetHubChain, bridgeHopChain, routedChain, destApi, reserveApi, context, edDeposit;
|
|
8269
8480
|
return _regenerator().w(function (_context) {
|
|
8270
8481
|
while (1) switch (_context.n) {
|
|
8271
8482
|
case 0:
|
|
@@ -8336,7 +8547,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
8336
8547
|
_context.n = 3;
|
|
8337
8548
|
return reserveApi.init(reserveChain);
|
|
8338
8549
|
case 3:
|
|
8339
|
-
|
|
8550
|
+
context = {
|
|
8340
8551
|
origin: {
|
|
8341
8552
|
api: api,
|
|
8342
8553
|
chain: chain
|
|
@@ -8358,7 +8569,21 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
8358
8569
|
options: options,
|
|
8359
8570
|
systemAsset: systemAsset,
|
|
8360
8571
|
bridgeHopChain: bridgeHopChain
|
|
8572
|
+
};
|
|
8573
|
+
_context.n = 4;
|
|
8574
|
+
return resolveEdDeposit({
|
|
8575
|
+
origin: context.origin,
|
|
8576
|
+
dest: context.dest,
|
|
8577
|
+
assetInfo: assetInfo,
|
|
8578
|
+
overriddenAsset: overriddenAsset,
|
|
8579
|
+
feeAssetLocation: getFeeAssetLocation(context),
|
|
8580
|
+
recipient: options.recipient
|
|
8361
8581
|
});
|
|
8582
|
+
case 4:
|
|
8583
|
+
edDeposit = _context.v;
|
|
8584
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, context), {}, {
|
|
8585
|
+
edDeposit: edDeposit
|
|
8586
|
+
}));
|
|
8362
8587
|
}
|
|
8363
8588
|
}, _callee);
|
|
8364
8589
|
}));
|
|
@@ -8448,6 +8673,28 @@ var generateMessageId = /*#__PURE__*/function () {
|
|
|
8448
8673
|
};
|
|
8449
8674
|
}();
|
|
8450
8675
|
|
|
8676
|
+
var createEdExchangeInstructions = function createEdExchangeInstructions(api, destChain, version, feeLocation, isFeeTransferred) {
|
|
8677
|
+
var _api$findNativeAssetI = api.findNativeAssetInfoOrThrow(destChain),
|
|
8678
|
+
location = _api$findNativeAssetI.location,
|
|
8679
|
+
existentialDeposit = _api$findNativeAssetI.existentialDeposit;
|
|
8680
|
+
var nativeLocation = api.localizeLocation(destChain, location);
|
|
8681
|
+
if (deepEqual(feeLocation, nativeLocation)) return [];
|
|
8682
|
+
return [{
|
|
8683
|
+
ExchangeAsset: {
|
|
8684
|
+
give: {
|
|
8685
|
+
Wild: {
|
|
8686
|
+
AllOf: {
|
|
8687
|
+
id: createAssetId(version, feeLocation),
|
|
8688
|
+
fun: 'Fungible'
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
},
|
|
8692
|
+
want: [createAsset(version, BigInt(existentialDeposit), nativeLocation)],
|
|
8693
|
+
maximal: !isFeeTransferred
|
|
8694
|
+
}
|
|
8695
|
+
}];
|
|
8696
|
+
};
|
|
8697
|
+
|
|
8451
8698
|
var resolveBuyExecutionAmount = function resolveBuyExecutionAmount(_ref, isForFeeCalc, _ref2, systemAssetAmount) {
|
|
8452
8699
|
var isRelayAsset = _ref.isRelayAsset,
|
|
8453
8700
|
assetInfo = _ref.assetInfo;
|
|
@@ -8469,7 +8716,7 @@ var resolveSnowbridgeMessageId = function resolveSnowbridgeMessageId(_ref3) {
|
|
|
8469
8716
|
recipient = _ref3$options.recipient;
|
|
8470
8717
|
if (!isSnowbridge) return Promise.resolve(null);
|
|
8471
8718
|
assertSender(sender);
|
|
8472
|
-
return generateMessageId(origin.api, sender, origin.api.getParaId(origin.chain), JSON.stringify(assetInfo.location, replaceBigInt), JSON.stringify(recipient), assetInfo.amount);
|
|
8719
|
+
return generateMessageId(origin.api, sender, origin.api.getParaId(origin.chain), stringToHex(JSON.stringify(assetInfo.location, replaceBigInt)), JSON.stringify(recipient), assetInfo.amount);
|
|
8473
8720
|
};
|
|
8474
8721
|
var createCustomXcm = /*#__PURE__*/function () {
|
|
8475
8722
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, assetCount, isForFeeCalc, systemAssetAmount) {
|
|
@@ -8481,6 +8728,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8481
8728
|
isRelayAsset,
|
|
8482
8729
|
assetInfo,
|
|
8483
8730
|
bridgeHopChain,
|
|
8731
|
+
edDeposit,
|
|
8484
8732
|
options,
|
|
8485
8733
|
destination,
|
|
8486
8734
|
version,
|
|
@@ -8499,11 +8747,12 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8499
8747
|
assetLocLocalized,
|
|
8500
8748
|
transferredAsset,
|
|
8501
8749
|
depositLocLocalized,
|
|
8502
|
-
|
|
8503
|
-
allOfSelector,
|
|
8750
|
+
createAllOf,
|
|
8504
8751
|
isFeeLeftoverAboveEd,
|
|
8505
|
-
|
|
8752
|
+
isFeeTransferred,
|
|
8753
|
+
resolveDepositAssets,
|
|
8506
8754
|
depositInstruction,
|
|
8755
|
+
depositInstructions,
|
|
8507
8756
|
localizeFilterAsset,
|
|
8508
8757
|
assetsFilter,
|
|
8509
8758
|
isAssetEthereumNative,
|
|
@@ -8524,7 +8773,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8524
8773
|
hopFees: 0n,
|
|
8525
8774
|
destFee: 0n
|
|
8526
8775
|
};
|
|
8527
|
-
origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, options = context.options;
|
|
8776
|
+
origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, edDeposit = context.edDeposit, options = context.options;
|
|
8528
8777
|
destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, overriddenAsset = options.overriddenAsset;
|
|
8529
8778
|
buildRefundInstruction = function buildRefundInstruction() {
|
|
8530
8779
|
if (!sender || isSubBridge) return null;
|
|
@@ -8566,12 +8815,15 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8566
8815
|
return !asset.isFeeAsset;
|
|
8567
8816
|
});
|
|
8568
8817
|
depositLocLocalized = transferredAsset ? origin.api.localizeLocation(dest.chain, extractAssetLocation(transferredAsset), origin.chain) : assetLocLocalized;
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8818
|
+
createAllOf = function createAllOf(location) {
|
|
8819
|
+
return {
|
|
8820
|
+
Wild: {
|
|
8821
|
+
AllOf: {
|
|
8822
|
+
id: createAssetId(version, location),
|
|
8823
|
+
fun: 'Fungible'
|
|
8824
|
+
}
|
|
8825
|
+
}
|
|
8826
|
+
};
|
|
8575
8827
|
};
|
|
8576
8828
|
isFeeLeftoverAboveEd = function isFeeLeftoverAboveEd() {
|
|
8577
8829
|
var destFeeAsset = origin.api.findAssetInfoOnDest(origin.chain, dest.chain, {
|
|
@@ -8579,14 +8831,25 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8579
8831
|
}, assetInfo);
|
|
8580
8832
|
return destFeeAsset !== null && assetInfo.amount - hopFees - destFee >= BigInt(destFeeAsset.existentialDeposit);
|
|
8581
8833
|
};
|
|
8582
|
-
|
|
8834
|
+
isFeeTransferred = deepEqual(feeLocLocalized, depositLocLocalized);
|
|
8835
|
+
resolveDepositAssets = function resolveDepositAssets() {
|
|
8836
|
+
if (edDeposit !== undefined) {
|
|
8837
|
+
return {
|
|
8838
|
+
Wild: {
|
|
8839
|
+
AllCounted: isFeeTransferred ? assetCount + 1 : assetCount
|
|
8840
|
+
}
|
|
8841
|
+
};
|
|
8842
|
+
}
|
|
8843
|
+
var depositsFeeAsset = overriddenAsset !== undefined && (isForFeeCalc || isExternalChain(dest.chain) || isFeeLeftoverAboveEd());
|
|
8844
|
+
return assetCount > 1 && !depositsFeeAsset ? createAllOf(depositLocLocalized) : {
|
|
8845
|
+
Wild: {
|
|
8846
|
+
AllCounted: assetCount
|
|
8847
|
+
}
|
|
8848
|
+
};
|
|
8849
|
+
};
|
|
8583
8850
|
depositInstruction = {
|
|
8584
8851
|
DepositAsset: {
|
|
8585
|
-
assets:
|
|
8586
|
-
Wild: assetCount > 1 && !depositsFeeAsset ? allOfSelector : {
|
|
8587
|
-
AllCounted: assetCount
|
|
8588
|
-
}
|
|
8589
|
-
},
|
|
8852
|
+
assets: resolveDepositAssets(),
|
|
8590
8853
|
beneficiary: createBeneficiaryLocation({
|
|
8591
8854
|
api: isSubBridge ? dest.api : origin.api,
|
|
8592
8855
|
address: recipient,
|
|
@@ -8594,6 +8857,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8594
8857
|
})
|
|
8595
8858
|
}
|
|
8596
8859
|
};
|
|
8860
|
+
depositInstructions = [].concat(_toConsumableArray(edDeposit === undefined ? [] : createEdExchangeInstructions(origin.api, dest.chain, version, feeLocLocalized, isFeeTransferred)), [depositInstruction]);
|
|
8597
8861
|
localizeFilterAsset = function localizeFilterAsset(amount, location) {
|
|
8598
8862
|
return createAsset(version, amount, normalizeLocation(origin.api.localizeLocation(reserve.chain, location), version));
|
|
8599
8863
|
};
|
|
@@ -8636,7 +8900,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8636
8900
|
_context.n = 3;
|
|
8637
8901
|
break;
|
|
8638
8902
|
}
|
|
8639
|
-
return _context.a(2, [buyExecution
|
|
8903
|
+
return _context.a(2, [buyExecution].concat(_toConsumableArray(depositInstructions)));
|
|
8640
8904
|
case 3:
|
|
8641
8905
|
destLoc = createDestination(origin.api, version, origin.chain, destination, paraIdTo); // If both reserve (B) and destination (C) are trusted chains,
|
|
8642
8906
|
// use teleport instead of DepositReserveAsset
|
|
@@ -8649,7 +8913,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8649
8913
|
InitiateTeleport: {
|
|
8650
8914
|
assets: filter,
|
|
8651
8915
|
dest: destLoc,
|
|
8652
|
-
xcm: [buyExecution
|
|
8916
|
+
xcm: [buyExecution].concat(_toConsumableArray(depositInstructions), setTopic)
|
|
8653
8917
|
}
|
|
8654
8918
|
}], setTopic));
|
|
8655
8919
|
case 4:
|
|
@@ -8684,11 +8948,11 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
8684
8948
|
DepositReserveAsset: {
|
|
8685
8949
|
assets: filter,
|
|
8686
8950
|
dest: destLoc,
|
|
8687
|
-
xcm: [buyExecution
|
|
8951
|
+
xcm: [buyExecution].concat(_toConsumableArray(depositInstructions), setTopic)
|
|
8688
8952
|
}
|
|
8689
8953
|
}], setTopic));
|
|
8690
8954
|
case 6:
|
|
8691
|
-
return _context.a(2, [
|
|
8955
|
+
return _context.a(2, [].concat(_toConsumableArray(depositInstructions), setTopic));
|
|
8692
8956
|
}
|
|
8693
8957
|
}, _callee);
|
|
8694
8958
|
}));
|
|
@@ -9262,27 +9526,38 @@ var abstractDecimals = function abstractDecimals(amount, decimals, api) {
|
|
|
9262
9526
|
var abstractDecimals = !(isConfig(config) && config.abstractDecimals === false);
|
|
9263
9527
|
return applyDecimalAbstraction(amount, decimals, abstractDecimals);
|
|
9264
9528
|
};
|
|
9529
|
+
var toDecimalString = function toDecimalString(amount) {
|
|
9530
|
+
if (typeof amount !== 'number') return amount.toString();
|
|
9531
|
+
var _amount$toString$spli = amount.toString().split('e'),
|
|
9532
|
+
_amount$toString$spli2 = _slicedToArray(_amount$toString$spli, 2),
|
|
9533
|
+
mantissa = _amount$toString$spli2[0],
|
|
9534
|
+
exponent = _amount$toString$spli2[1];
|
|
9535
|
+
if (exponent === undefined) return mantissa;
|
|
9536
|
+
var sign = amount < 0 ? '-' : '';
|
|
9537
|
+
var digits = mantissa.replace(/[-.]/g, '');
|
|
9538
|
+
var point = Number(exponent) + 1;
|
|
9539
|
+
return sign + (point > 0 ? digits.padEnd(point, '0') : "0.".concat('0'.repeat(-point)).concat(digits));
|
|
9540
|
+
};
|
|
9265
9541
|
var applyDecimalAbstraction = function applyDecimalAbstraction(amount, decimals, shouldAbstract) {
|
|
9266
9542
|
// If amount is already bigint, return as-is
|
|
9267
9543
|
if (typeof amount === 'bigint') {
|
|
9268
9544
|
return amount;
|
|
9269
9545
|
}
|
|
9546
|
+
var strAmount = toDecimalString(amount);
|
|
9270
9547
|
if (!shouldAbstract) {
|
|
9271
|
-
var strAmount = amount.toString();
|
|
9272
9548
|
if (strAmount.includes('.')) {
|
|
9273
9549
|
throw new NumberFormatError("Non-abstracted amount cannot have decimals: ".concat(strAmount));
|
|
9274
9550
|
}
|
|
9275
9551
|
return BigInt(strAmount);
|
|
9276
9552
|
}
|
|
9277
9553
|
if (decimals === undefined) {
|
|
9278
|
-
|
|
9279
|
-
if (_strAmount.includes('.')) {
|
|
9554
|
+
if (strAmount.includes('.')) {
|
|
9280
9555
|
// Return integer part only as fallback
|
|
9281
|
-
return BigInt(
|
|
9556
|
+
return BigInt(strAmount.split('.')[0]);
|
|
9282
9557
|
}
|
|
9283
|
-
return BigInt(
|
|
9558
|
+
return BigInt(strAmount);
|
|
9284
9559
|
}
|
|
9285
|
-
return parseUnits(
|
|
9560
|
+
return parseUnits(strAmount, decimals);
|
|
9286
9561
|
};
|
|
9287
9562
|
|
|
9288
9563
|
var createAllCountedFilter = function createAllCountedFilter(count) {
|
|
@@ -9527,101 +9802,13 @@ xcm, maxWeight) {
|
|
|
9527
9802
|
};
|
|
9528
9803
|
};
|
|
9529
9804
|
|
|
9530
|
-
var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, origin, weight, originExecutionFee, destExecutionFee) {
|
|
9531
|
-
var api = input.api,
|
|
9532
|
-
version = input.version,
|
|
9533
|
-
asset = input.assetInfo,
|
|
9534
|
-
destination = input.destination,
|
|
9535
|
-
paraIdTo = input.paraIdTo,
|
|
9536
|
-
recipient = input.recipient;
|
|
9537
|
-
var dest = createDestination(api, version, origin, destination, paraIdTo);
|
|
9538
|
-
var beneficiary = createBeneficiaryLocation({
|
|
9539
|
-
api: api,
|
|
9540
|
-
address: recipient,
|
|
9541
|
-
version: version
|
|
9542
|
-
});
|
|
9543
|
-
var transformedLocation = localizeLocation(origin, asset.location);
|
|
9544
|
-
var call = {
|
|
9545
|
-
module: 'PolkadotXcm',
|
|
9546
|
-
method: 'execute',
|
|
9547
|
-
params: {
|
|
9548
|
-
message: _defineProperty({}, version, [{
|
|
9549
|
-
WithdrawAsset: [{
|
|
9550
|
-
id: transformedLocation,
|
|
9551
|
-
fun: {
|
|
9552
|
-
Fungible: asset.amount
|
|
9553
|
-
}
|
|
9554
|
-
}]
|
|
9555
|
-
}, {
|
|
9556
|
-
BuyExecution: {
|
|
9557
|
-
fees: {
|
|
9558
|
-
id: transformedLocation,
|
|
9559
|
-
fun: {
|
|
9560
|
-
Fungible: originExecutionFee
|
|
9561
|
-
}
|
|
9562
|
-
},
|
|
9563
|
-
weight_limit: 'Unlimited'
|
|
9564
|
-
}
|
|
9565
|
-
}, {
|
|
9566
|
-
InitiateTeleport: {
|
|
9567
|
-
assets: {
|
|
9568
|
-
Wild: {
|
|
9569
|
-
AllCounted: 1
|
|
9570
|
-
}
|
|
9571
|
-
},
|
|
9572
|
-
dest: dest,
|
|
9573
|
-
xcm: [{
|
|
9574
|
-
BuyExecution: {
|
|
9575
|
-
fees: {
|
|
9576
|
-
id: asset.location,
|
|
9577
|
-
fun: {
|
|
9578
|
-
Fungible: destExecutionFee
|
|
9579
|
-
}
|
|
9580
|
-
},
|
|
9581
|
-
weight_limit: 'Unlimited'
|
|
9582
|
-
}
|
|
9583
|
-
}, {
|
|
9584
|
-
ExchangeAsset: {
|
|
9585
|
-
give: {
|
|
9586
|
-
Wild: {
|
|
9587
|
-
AllCounted: 1
|
|
9588
|
-
}
|
|
9589
|
-
},
|
|
9590
|
-
want: [{
|
|
9591
|
-
id: DOT_LOCATION,
|
|
9592
|
-
fun: {
|
|
9593
|
-
Fungible: 100000000n
|
|
9594
|
-
} // 0.01 DOT
|
|
9595
|
-
}],
|
|
9596
|
-
maximal: false
|
|
9597
|
-
}
|
|
9598
|
-
}, {
|
|
9599
|
-
DepositAsset: {
|
|
9600
|
-
assets: {
|
|
9601
|
-
Wild: {
|
|
9602
|
-
AllCounted: 2
|
|
9603
|
-
}
|
|
9604
|
-
},
|
|
9605
|
-
beneficiary: beneficiary
|
|
9606
|
-
}
|
|
9607
|
-
}]
|
|
9608
|
-
}
|
|
9609
|
-
}]),
|
|
9610
|
-
max_weight: {
|
|
9611
|
-
ref_time: weight.refTime,
|
|
9612
|
-
proof_size: weight.proofSize
|
|
9613
|
-
}
|
|
9614
|
-
}
|
|
9615
|
-
};
|
|
9616
|
-
return api.deserializeExtrinsics(call);
|
|
9617
|
-
};
|
|
9618
|
-
|
|
9619
9805
|
var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToDeposit) {
|
|
9620
9806
|
var depositFeeAsset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
9621
9807
|
var api = options.api,
|
|
9622
9808
|
useJitWithdraw = options.useJitWithdraw,
|
|
9623
9809
|
recipient = options.recipient,
|
|
9624
|
-
version = options.version
|
|
9810
|
+
version = options.version,
|
|
9811
|
+
edDeposit = options.edDeposit;
|
|
9625
9812
|
var context = prepareExecuteContext(options);
|
|
9626
9813
|
var assetLocalized = context.assetLocalized,
|
|
9627
9814
|
assetLocalizedToDest = context.assetLocalizedToDest,
|
|
@@ -9647,7 +9834,7 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
|
|
|
9647
9834
|
});
|
|
9648
9835
|
var depositInstruction = {
|
|
9649
9836
|
DepositAsset: {
|
|
9650
|
-
assets: depositFeeAsset ? createAllCountedFilter(2) : createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest, version),
|
|
9837
|
+
assets: depositFeeAsset || edDeposit !== undefined ? createAllCountedFilter(2) : createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest, version),
|
|
9651
9838
|
beneficiary: beneficiary
|
|
9652
9839
|
}
|
|
9653
9840
|
};
|
|
@@ -9659,11 +9846,11 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
|
|
|
9659
9846
|
|
|
9660
9847
|
var createDirectExecuteXcm = /*#__PURE__*/function () {
|
|
9661
9848
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
9662
|
-
var api, version, transactOptions, destChain, recipient, _prepareCommonExecute, prefix, depositInstruction, transact, baseXcm, fullXcm, _t;
|
|
9849
|
+
var api, version, transactOptions, destChain, recipient, assetInfo, feeAssetInfo, edDeposit, _prepareCommonExecute, prefix, depositInstruction, transact, resolvedFeeAssetInfo, edExchangeInstructions, baseXcm, fullXcm, _t;
|
|
9663
9850
|
return _regenerator().w(function (_context) {
|
|
9664
9851
|
while (1) switch (_context.n) {
|
|
9665
9852
|
case 0:
|
|
9666
|
-
api = options.api, version = options.version, transactOptions = options.transactOptions, destChain = options.destChain, recipient = options.recipient;
|
|
9853
|
+
api = options.api, version = options.version, transactOptions = options.transactOptions, destChain = options.destChain, recipient = options.recipient, assetInfo = options.assetInfo, feeAssetInfo = options.feeAssetInfo, edDeposit = options.edDeposit;
|
|
9667
9854
|
_prepareCommonExecute = prepareCommonExecuteXcm(options), prefix = _prepareCommonExecute.prefix, depositInstruction = _prepareCommonExecute.depositInstruction;
|
|
9668
9855
|
if (!(transactOptions !== null && transactOptions !== void 0 && transactOptions.call)) {
|
|
9669
9856
|
_context.n = 2;
|
|
@@ -9679,8 +9866,10 @@ var createDirectExecuteXcm = /*#__PURE__*/function () {
|
|
|
9679
9866
|
_t = [];
|
|
9680
9867
|
case 3:
|
|
9681
9868
|
transact = _t;
|
|
9869
|
+
resolvedFeeAssetInfo = getFeeAssetInfo(assetInfo, feeAssetInfo);
|
|
9870
|
+
edExchangeInstructions = edDeposit === undefined ? [] : createEdExchangeInstructions(api, destChain, version, api.localizeLocation(destChain, (resolvedFeeAssetInfo !== null && resolvedFeeAssetInfo !== void 0 ? resolvedFeeAssetInfo : assetInfo).location), !resolvedFeeAssetInfo);
|
|
9682
9871
|
baseXcm = createBaseExecuteXcm(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9683
|
-
suffixXcm:
|
|
9872
|
+
suffixXcm: [].concat(_toConsumableArray(transact), _toConsumableArray(edExchangeInstructions), [depositInstruction])
|
|
9684
9873
|
}));
|
|
9685
9874
|
fullXcm = [].concat(_toConsumableArray(prefix), _toConsumableArray(baseXcm));
|
|
9686
9875
|
return _context.a(2, addXcmVersionHeader(fullXcm, version));
|
|
@@ -9699,7 +9888,7 @@ var FEE_PADDING_PERCENTAGE$1 = 40;
|
|
|
9699
9888
|
var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
9700
9889
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
9701
9890
|
var _dryRunResult$hops$at;
|
|
9702
|
-
var api, chain, sender, paraIdTo, destChain, assetInfo, currency, feeCurrency, recipient, feeAssetInfo, version, transactOptions, checkAmount, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount,
|
|
9891
|
+
var api, chain, sender, paraIdTo, destChain, assetInfo, currency, feeCurrency, recipient, feeAssetInfo, version, transactOptions, checkAmount, resolvedFeeAssetInfo, destApi, edDeposit, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, hopFeeAmount, call, dryRunResult, originFee, reserveFee, destFee, xcm, weight, _t, _t2;
|
|
9703
9892
|
return _regenerator().w(function (_context) {
|
|
9704
9893
|
while (1) switch (_context.n) {
|
|
9705
9894
|
case 0:
|
|
@@ -9722,6 +9911,30 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
9722
9911
|
}
|
|
9723
9912
|
throw new RoutingResolutionError('Could not determine destination chain for execute transfer');
|
|
9724
9913
|
case 2:
|
|
9914
|
+
resolvedFeeAssetInfo = getFeeAssetInfo(assetInfo, feeAssetInfo);
|
|
9915
|
+
destApi = api.clone();
|
|
9916
|
+
_context.n = 3;
|
|
9917
|
+
return destApi.init(destChain);
|
|
9918
|
+
case 3:
|
|
9919
|
+
_context.n = 4;
|
|
9920
|
+
return resolveEdDeposit({
|
|
9921
|
+
origin: {
|
|
9922
|
+
api: api,
|
|
9923
|
+
chain: chain
|
|
9924
|
+
},
|
|
9925
|
+
dest: {
|
|
9926
|
+
api: destApi,
|
|
9927
|
+
chain: destChain
|
|
9928
|
+
},
|
|
9929
|
+
assetInfo: assetInfo,
|
|
9930
|
+
feeAssetLocation: (resolvedFeeAssetInfo !== null && resolvedFeeAssetInfo !== void 0 ? resolvedFeeAssetInfo : assetInfo).location,
|
|
9931
|
+
recipient: recipient
|
|
9932
|
+
});
|
|
9933
|
+
case 4:
|
|
9934
|
+
edDeposit = _context.v;
|
|
9935
|
+
_context.n = 5;
|
|
9936
|
+
return destApi.disconnect();
|
|
9937
|
+
case 5:
|
|
9725
9938
|
internalOptions = {
|
|
9726
9939
|
api: api,
|
|
9727
9940
|
chain: chain,
|
|
@@ -9734,15 +9947,15 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
9734
9947
|
recipient: recipient,
|
|
9735
9948
|
version: version,
|
|
9736
9949
|
paraIdTo: paraIdTo,
|
|
9737
|
-
transactOptions: transactOptions
|
|
9950
|
+
transactOptions: transactOptions,
|
|
9951
|
+
edDeposit: edDeposit
|
|
9738
9952
|
}; // We mint 1000 units of feeAsset and use 100
|
|
9739
9953
|
FEE_ASSET_AMOUNT = 100;
|
|
9740
9954
|
feeAssetAmount = feeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), feeAssetInfo.decimals) : MIN_FEE;
|
|
9741
|
-
resolvedFeeAssetInfo = getFeeAssetInfo(assetInfo, feeAssetInfo);
|
|
9742
9955
|
hopFeeAmount = resolvedFeeAssetInfo ? feeAssetAmount : MIN_FEE;
|
|
9743
9956
|
_t = createExecuteCall;
|
|
9744
9957
|
_t2 = chain;
|
|
9745
|
-
_context.n =
|
|
9958
|
+
_context.n = 6;
|
|
9746
9959
|
return createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
9747
9960
|
fees: {
|
|
9748
9961
|
originFee: feeAssetAmount,
|
|
@@ -9750,9 +9963,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
9750
9963
|
destFee: hopFeeAmount
|
|
9751
9964
|
}
|
|
9752
9965
|
}));
|
|
9753
|
-
case
|
|
9966
|
+
case 6:
|
|
9754
9967
|
call = _t(_t2, _context.v, MAX_WEIGHT);
|
|
9755
|
-
_context.n =
|
|
9968
|
+
_context.n = 7;
|
|
9756
9969
|
return dryRunInternal({
|
|
9757
9970
|
api: api,
|
|
9758
9971
|
tx: api.deserializeExtrinsics(call),
|
|
@@ -9764,22 +9977,22 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
9764
9977
|
feeAsset: feeCurrency,
|
|
9765
9978
|
useRootOrigin: true
|
|
9766
9979
|
});
|
|
9767
|
-
case
|
|
9980
|
+
case 7:
|
|
9768
9981
|
dryRunResult = _context.v;
|
|
9769
9982
|
if (dryRunResult.origin.success) {
|
|
9770
|
-
_context.n =
|
|
9983
|
+
_context.n = 8;
|
|
9771
9984
|
break;
|
|
9772
9985
|
}
|
|
9773
9986
|
throw new DryRunFailedError(_objectSpread2(_objectSpread2({}, dryRunResult.origin.dryRunError), {}, {
|
|
9774
9987
|
chainKind: 'origin',
|
|
9775
9988
|
chain: chain
|
|
9776
9989
|
}));
|
|
9777
|
-
case
|
|
9990
|
+
case 8:
|
|
9778
9991
|
originFee = padValueBy(dryRunResult.origin.fee, FEE_PADDING_PERCENTAGE$1);
|
|
9779
9992
|
reserveFee = padValueBy(getFeeFromResult((_dryRunResult$hops$at = dryRunResult.hops.at(0)) === null || _dryRunResult$hops$at === void 0 ? void 0 : _dryRunResult$hops$at.result), FEE_PADDING_PERCENTAGE$1);
|
|
9780
|
-
destFee = padValueBy(getFeeFromResult(dryRunResult.destination), FEE_PADDING_PERCENTAGE$1);
|
|
9993
|
+
destFee = padValueBy(getFeeFromResult(dryRunResult.destination), FEE_PADDING_PERCENTAGE$1) + (edDeposit !== null && edDeposit !== void 0 ? edDeposit : 0n);
|
|
9781
9994
|
if (!resolvedFeeAssetInfo) checkAmount(reserveFee);
|
|
9782
|
-
_context.n =
|
|
9995
|
+
_context.n = 9;
|
|
9783
9996
|
return createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
9784
9997
|
fees: {
|
|
9785
9998
|
originFee: originFee,
|
|
@@ -9787,11 +10000,11 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
9787
10000
|
destFee: destFee
|
|
9788
10001
|
}
|
|
9789
10002
|
}));
|
|
9790
|
-
case
|
|
10003
|
+
case 9:
|
|
9791
10004
|
xcm = _context.v;
|
|
9792
|
-
_context.n =
|
|
10005
|
+
_context.n = 10;
|
|
9793
10006
|
return api.getXcmWeight(xcm);
|
|
9794
|
-
case
|
|
10007
|
+
case 10:
|
|
9795
10008
|
weight = _context.v;
|
|
9796
10009
|
return _context.a(2, createExecuteCall(chain, xcm, weight));
|
|
9797
10010
|
}
|
|
@@ -10498,72 +10711,6 @@ var getLocalTransferAmount = function getLocalTransferAmount(_ref) {
|
|
|
10498
10711
|
return amount;
|
|
10499
10712
|
};
|
|
10500
10713
|
|
|
10501
|
-
var handleToAhTeleport = /*#__PURE__*/function () {
|
|
10502
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(origin, input, defaultTx) {
|
|
10503
|
-
var _dryRunResult$destina, _feeResult$origin$wei;
|
|
10504
|
-
var api, destination, sender, recipient, asset, currency, version, dryRunResult, dummyTx, feeResult, originExecutionFee, destinationExecutionFee;
|
|
10505
|
-
return _regenerator().w(function (_context) {
|
|
10506
|
-
while (1) switch (_context.n) {
|
|
10507
|
-
case 0:
|
|
10508
|
-
api = input.api, destination = input.destination, sender = input.sender, recipient = input.recipient, asset = input.assetInfo, currency = input.currency, version = input.version;
|
|
10509
|
-
assertToIsString(destination, 'Location destination is not supported for AH teleport.');
|
|
10510
|
-
if (!isTLocation(recipient)) {
|
|
10511
|
-
_context.n = 1;
|
|
10512
|
-
break;
|
|
10513
|
-
}
|
|
10514
|
-
throw new InvalidAddressError('Location address is not supported for this scenario');
|
|
10515
|
-
case 1:
|
|
10516
|
-
assertSender(sender);
|
|
10517
|
-
_context.n = 2;
|
|
10518
|
-
return dryRunInternal({
|
|
10519
|
-
api: api,
|
|
10520
|
-
tx: defaultTx,
|
|
10521
|
-
origin: origin,
|
|
10522
|
-
destination: destination,
|
|
10523
|
-
sender: sender,
|
|
10524
|
-
currency: currency,
|
|
10525
|
-
version: version
|
|
10526
|
-
});
|
|
10527
|
-
case 2:
|
|
10528
|
-
dryRunResult = _context.v;
|
|
10529
|
-
if (!((_dryRunResult$destina = dryRunResult.destination) !== null && _dryRunResult$destina !== void 0 && _dryRunResult$destina.success)) {
|
|
10530
|
-
_context.n = 3;
|
|
10531
|
-
break;
|
|
10532
|
-
}
|
|
10533
|
-
return _context.a(2, defaultTx);
|
|
10534
|
-
case 3:
|
|
10535
|
-
// If the default tx dry run failed, we need to create execute transaction
|
|
10536
|
-
dummyTx = createExecuteExchangeXcm(input, origin, MAX_WEIGHT,
|
|
10537
|
-
// Enter dummy fee values just to get the dry run to pass
|
|
10538
|
-
asset.amount, asset.amount / 2n);
|
|
10539
|
-
_context.n = 4;
|
|
10540
|
-
return getXcmFeeOnce({
|
|
10541
|
-
api: api,
|
|
10542
|
-
tx: dummyTx,
|
|
10543
|
-
origin: origin,
|
|
10544
|
-
destination: destination,
|
|
10545
|
-
sender: sender,
|
|
10546
|
-
recipient: recipient,
|
|
10547
|
-
version: version,
|
|
10548
|
-
currency: currency,
|
|
10549
|
-
disableFallback: false,
|
|
10550
|
-
useRootOrigin: true
|
|
10551
|
-
});
|
|
10552
|
-
case 4:
|
|
10553
|
-
feeResult = _context.v;
|
|
10554
|
-
originExecutionFee = padValueBy(feeResult.origin.fee, 20); // Pad by 20%
|
|
10555
|
-
destinationExecutionFee = padValueBy(
|
|
10556
|
-
// Pad by 20%
|
|
10557
|
-
feeResult.destination.feeType === 'paymentInfo' ? feeResult.origin.fee : feeResult.destination.fee, 20);
|
|
10558
|
-
return _context.a(2, createExecuteExchangeXcm(input, origin, (_feeResult$origin$wei = feeResult.origin.weight) !== null && _feeResult$origin$wei !== void 0 ? _feeResult$origin$wei : MAX_WEIGHT, originExecutionFee, destinationExecutionFee));
|
|
10559
|
-
}
|
|
10560
|
-
}, _callee);
|
|
10561
|
-
}));
|
|
10562
|
-
return function handleToAhTeleport(_x, _x2, _x3) {
|
|
10563
|
-
return _ref.apply(this, arguments);
|
|
10564
|
-
};
|
|
10565
|
-
}();
|
|
10566
|
-
|
|
10567
10714
|
var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain) {
|
|
10568
10715
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
10569
10716
|
isDestination: false
|
|
@@ -10595,50 +10742,6 @@ var Acala = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10595
10742
|
value: function isRelayToParaEnabled() {
|
|
10596
10743
|
return false;
|
|
10597
10744
|
}
|
|
10598
|
-
}, {
|
|
10599
|
-
key: "transferLocalNativeAsset",
|
|
10600
|
-
value: function () {
|
|
10601
|
-
var _transferLocalNativeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
10602
|
-
var api, recipient, sender, isAmountAll, keepAlive, createTx, fee, _yield$api$getPayment, partialFee, amount;
|
|
10603
|
-
return _regenerator().w(function (_context) {
|
|
10604
|
-
while (1) switch (_context.n) {
|
|
10605
|
-
case 0:
|
|
10606
|
-
api = options.api, recipient = options.recipient, sender = options.sender, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
10607
|
-
createTx = function createTx(amount) {
|
|
10608
|
-
return api.deserializeExtrinsics({
|
|
10609
|
-
module: 'Currencies',
|
|
10610
|
-
method: 'transfer_native_currency',
|
|
10611
|
-
params: {
|
|
10612
|
-
dest: {
|
|
10613
|
-
Id: recipient
|
|
10614
|
-
},
|
|
10615
|
-
amount: amount
|
|
10616
|
-
}
|
|
10617
|
-
});
|
|
10618
|
-
};
|
|
10619
|
-
fee = 0n;
|
|
10620
|
-
if (!(isAmountAll || keepAlive)) {
|
|
10621
|
-
_context.n = 2;
|
|
10622
|
-
break;
|
|
10623
|
-
}
|
|
10624
|
-
assertSender(sender);
|
|
10625
|
-
_context.n = 1;
|
|
10626
|
-
return api.getPaymentInfo(createTx(MIN_AMOUNT), sender);
|
|
10627
|
-
case 1:
|
|
10628
|
-
_yield$api$getPayment = _context.v;
|
|
10629
|
-
partialFee = _yield$api$getPayment.partialFee;
|
|
10630
|
-
fee = BigInt(partialFee);
|
|
10631
|
-
case 2:
|
|
10632
|
-
amount = getLocalTransferAmount(options, fee);
|
|
10633
|
-
return _context.a(2, createTx(amount));
|
|
10634
|
-
}
|
|
10635
|
-
}, _callee);
|
|
10636
|
-
}));
|
|
10637
|
-
function transferLocalNativeAsset(_x) {
|
|
10638
|
-
return _transferLocalNativeAsset.apply(this, arguments);
|
|
10639
|
-
}
|
|
10640
|
-
return transferLocalNativeAsset;
|
|
10641
|
-
}()
|
|
10642
10745
|
}, {
|
|
10643
10746
|
key: "transferLocalNonNativeAsset",
|
|
10644
10747
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -10646,7 +10749,7 @@ var Acala = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10646
10749
|
asset = options.assetInfo,
|
|
10647
10750
|
recipient = options.recipient;
|
|
10648
10751
|
if (asset.symbol.toLowerCase() === 'lcdot') {
|
|
10649
|
-
throw new
|
|
10752
|
+
throw new ScenarioNotSupportedError('LcDOT local transfers are not supported');
|
|
10650
10753
|
}
|
|
10651
10754
|
var amount = getLocalTransferAmount(options);
|
|
10652
10755
|
return api.deserializeExtrinsics({
|
|
@@ -10664,6 +10767,7 @@ var Acala = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10664
10767
|
}, {
|
|
10665
10768
|
key: "getCustomCurrencyId",
|
|
10666
10769
|
value: function getCustomCurrencyId(_api, asset) {
|
|
10770
|
+
// aSEED is registered as Token(AUSD) on Acala
|
|
10667
10771
|
var symbol = asset.symbol === 'aSEED' ? 'AUSD' : asset.symbol;
|
|
10668
10772
|
return asset.isNative ? {
|
|
10669
10773
|
Token: symbol
|
|
@@ -10964,7 +11068,7 @@ var Astar = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10964
11068
|
isAmountAll = options.isAmountAll,
|
|
10965
11069
|
keepAlive = options.keepAlive;
|
|
10966
11070
|
assertHasId(asset);
|
|
10967
|
-
var assetId =
|
|
11071
|
+
var assetId = BigInt(asset.assetId);
|
|
10968
11072
|
var dest = {
|
|
10969
11073
|
Id: recipient
|
|
10970
11074
|
};
|
|
@@ -11097,19 +11201,17 @@ var Hydration = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11097
11201
|
asset = options.assetInfo,
|
|
11098
11202
|
recipient = options.recipient,
|
|
11099
11203
|
isAmountAll = options.isAmountAll,
|
|
11100
|
-
keepAlive = options.keepAlive
|
|
11101
|
-
balance = options.balance;
|
|
11204
|
+
keepAlive = options.keepAlive;
|
|
11102
11205
|
assertHasId(asset);
|
|
11103
11206
|
var currencyId = Number(asset.assetId);
|
|
11104
11207
|
if (asset.erc20) {
|
|
11105
|
-
var amount = isAmountAll ? balance - (keepAlive ? BigInt(asset.existentialDeposit) : 0n) : asset.amount;
|
|
11106
11208
|
return api.deserializeExtrinsics({
|
|
11107
11209
|
module: 'Currencies',
|
|
11108
11210
|
method: 'transfer',
|
|
11109
11211
|
params: {
|
|
11110
11212
|
dest: recipient,
|
|
11111
11213
|
currency_id: currencyId,
|
|
11112
|
-
amount:
|
|
11214
|
+
amount: getLocalTransferAmount(options)
|
|
11113
11215
|
}
|
|
11114
11216
|
});
|
|
11115
11217
|
}
|
|
@@ -11716,6 +11818,39 @@ var EnergyWebX = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11716
11818
|
useLocationId: true
|
|
11717
11819
|
};
|
|
11718
11820
|
}
|
|
11821
|
+
}, {
|
|
11822
|
+
key: "transferLocalNonNativeAsset",
|
|
11823
|
+
value: function transferLocalNonNativeAsset(options) {
|
|
11824
|
+
var api = options.api,
|
|
11825
|
+
asset = options.assetInfo,
|
|
11826
|
+
recipient = options.recipient,
|
|
11827
|
+
isAmountAll = options.isAmountAll,
|
|
11828
|
+
keepAlive = options.keepAlive;
|
|
11829
|
+
var id = api.localizeLocation(this.chain, asset.location);
|
|
11830
|
+
var dest = {
|
|
11831
|
+
Id: recipient
|
|
11832
|
+
};
|
|
11833
|
+
if (isAmountAll) {
|
|
11834
|
+
return api.deserializeExtrinsics({
|
|
11835
|
+
module: 'Assets',
|
|
11836
|
+
method: 'transfer_all',
|
|
11837
|
+
params: {
|
|
11838
|
+
id: id,
|
|
11839
|
+
dest: dest,
|
|
11840
|
+
keep_alive: keepAlive
|
|
11841
|
+
}
|
|
11842
|
+
});
|
|
11843
|
+
}
|
|
11844
|
+
return api.deserializeExtrinsics({
|
|
11845
|
+
module: 'Assets',
|
|
11846
|
+
method: keepAlive ? 'transfer_keep_alive' : 'transfer',
|
|
11847
|
+
params: {
|
|
11848
|
+
id: id,
|
|
11849
|
+
target: dest,
|
|
11850
|
+
amount: asset.amount
|
|
11851
|
+
}
|
|
11852
|
+
});
|
|
11853
|
+
}
|
|
11719
11854
|
}, {
|
|
11720
11855
|
key: "getBalanceForeign",
|
|
11721
11856
|
value: function () {
|
|
@@ -11729,13 +11864,13 @@ var EnergyWebX = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11729
11864
|
return api.queryState({
|
|
11730
11865
|
module: 'Assets',
|
|
11731
11866
|
method: 'Account',
|
|
11732
|
-
params: [asset.location, address]
|
|
11867
|
+
params: [api.localizeLocation(this.chain, asset.location), address]
|
|
11733
11868
|
});
|
|
11734
11869
|
case 1:
|
|
11735
11870
|
balance = _context.v;
|
|
11736
11871
|
return _context.a(2, (_balance$balance = balance === null || balance === void 0 ? void 0 : balance.balance) !== null && _balance$balance !== void 0 ? _balance$balance : 0n);
|
|
11737
11872
|
}
|
|
11738
|
-
}, _callee);
|
|
11873
|
+
}, _callee, this);
|
|
11739
11874
|
}));
|
|
11740
11875
|
function getBalanceForeign(_x, _x2, _x3) {
|
|
11741
11876
|
return _getBalanceForeign.apply(this, arguments);
|
|
@@ -11828,6 +11963,7 @@ var HydrationPaseo = /*#__PURE__*/function (_Hydration) {
|
|
|
11828
11963
|
return _createClass(HydrationPaseo);
|
|
11829
11964
|
}(Hydration);
|
|
11830
11965
|
|
|
11966
|
+
var HERCULIS_GOLD_BALANCES_PREFIX = 'b5288313a908b05b8e6dc4c999b69de9c2261276cc9d1f8598ea4b6a74b15c2f';
|
|
11831
11967
|
var Jamton = /*#__PURE__*/function (_SubstrateChain) {
|
|
11832
11968
|
function Jamton() {
|
|
11833
11969
|
_classCallCheck(this, Jamton);
|
|
@@ -11868,6 +12004,76 @@ var Jamton = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11868
12004
|
}
|
|
11869
12005
|
return transferPolkadotXcm(input);
|
|
11870
12006
|
}
|
|
12007
|
+
}, {
|
|
12008
|
+
key: "transferLocalNonNativeAsset",
|
|
12009
|
+
value: function transferLocalNonNativeAsset(options) {
|
|
12010
|
+
var api = options.api,
|
|
12011
|
+
asset = options.assetInfo,
|
|
12012
|
+
recipient = options.recipient;
|
|
12013
|
+
if (!this.isHerculisGoldAsset(api, asset)) return _superPropGet(Jamton, "transferLocalNonNativeAsset", this, 3)([options]);
|
|
12014
|
+
return api.deserializeExtrinsics({
|
|
12015
|
+
module: 'Currencies',
|
|
12016
|
+
method: 'transfer',
|
|
12017
|
+
params: {
|
|
12018
|
+
dest: {
|
|
12019
|
+
Id: recipient
|
|
12020
|
+
},
|
|
12021
|
+
currency_id: this.getCustomCurrencyId(api, asset),
|
|
12022
|
+
amount: getLocalTransferAmount(options)
|
|
12023
|
+
}
|
|
12024
|
+
});
|
|
12025
|
+
}
|
|
12026
|
+
}, {
|
|
12027
|
+
key: "getBalanceForeign",
|
|
12028
|
+
value: function () {
|
|
12029
|
+
var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
|
|
12030
|
+
var balance;
|
|
12031
|
+
return _regenerator().w(function (_context) {
|
|
12032
|
+
while (1) switch (_context.n) {
|
|
12033
|
+
case 0:
|
|
12034
|
+
if (this.isHerculisGoldAsset(api, asset)) {
|
|
12035
|
+
_context.n = 1;
|
|
12036
|
+
break;
|
|
12037
|
+
}
|
|
12038
|
+
return _context.a(2, _superPropGet(Jamton, "getBalanceForeign", this, 3)([api, address, asset]));
|
|
12039
|
+
case 1:
|
|
12040
|
+
_context.n = 2;
|
|
12041
|
+
return api.queryRuntimeApi({
|
|
12042
|
+
module: 'Currencies',
|
|
12043
|
+
method: 'free_balance',
|
|
12044
|
+
params: [this.getCustomCurrencyId(api, asset), address]
|
|
12045
|
+
});
|
|
12046
|
+
case 2:
|
|
12047
|
+
balance = _context.v;
|
|
12048
|
+
return _context.a(2, BigInt(balance));
|
|
12049
|
+
}
|
|
12050
|
+
}, _callee, this);
|
|
12051
|
+
}));
|
|
12052
|
+
function getBalanceForeign(_x, _x2, _x3) {
|
|
12053
|
+
return _getBalanceForeign.apply(this, arguments);
|
|
12054
|
+
}
|
|
12055
|
+
return getBalanceForeign;
|
|
12056
|
+
}()
|
|
12057
|
+
}, {
|
|
12058
|
+
key: "mint",
|
|
12059
|
+
value: function mint(api, address, assetInfo, balance) {
|
|
12060
|
+
if (!this.isHerculisGoldAsset(api, assetInfo)) return _superPropGet(Jamton, "mint", this, 3)([api, address, assetInfo, balance]);
|
|
12061
|
+
var accountKey = blake2128Concat(bytesToHex(api.accountToUint8a(address)));
|
|
12062
|
+
return Promise.resolve({
|
|
12063
|
+
balanceTx: {
|
|
12064
|
+
module: 'System',
|
|
12065
|
+
method: 'set_storage',
|
|
12066
|
+
params: {
|
|
12067
|
+
items: [['0x' + HERCULIS_GOLD_BALANCES_PREFIX + accountKey, '0x' + toLeHex(balance + assetInfo.amount, 16)]]
|
|
12068
|
+
}
|
|
12069
|
+
}
|
|
12070
|
+
});
|
|
12071
|
+
}
|
|
12072
|
+
}, {
|
|
12073
|
+
key: "isHerculisGoldAsset",
|
|
12074
|
+
value: function isHerculisGoldAsset(api, asset) {
|
|
12075
|
+
return asset.isNative && !isAssetEqual(asset, api.findNativeAssetInfoOrThrow(this.chain));
|
|
12076
|
+
}
|
|
11871
12077
|
}]);
|
|
11872
12078
|
}(SubstrateChain);
|
|
11873
12079
|
|
|
@@ -11877,7 +12083,15 @@ var Karura = /*#__PURE__*/function (_Acala) {
|
|
|
11877
12083
|
return _callSuper(this, Karura, ['Karura', 'karura', 'Kusama', Version.V5]);
|
|
11878
12084
|
}
|
|
11879
12085
|
_inherits(Karura, _Acala);
|
|
11880
|
-
return _createClass(Karura
|
|
12086
|
+
return _createClass(Karura, [{
|
|
12087
|
+
key: "getCustomCurrencyId",
|
|
12088
|
+
value: function getCustomCurrencyId(api, asset) {
|
|
12089
|
+
// aSEED is registered as Token(KUSD) on Karura
|
|
12090
|
+
return asset.symbol === 'aSEED' ? {
|
|
12091
|
+
Token: 'KUSD'
|
|
12092
|
+
} : _superPropGet(Karura, "getCustomCurrencyId", this, 3)([api, asset]);
|
|
12093
|
+
}
|
|
12094
|
+
}]);
|
|
11881
12095
|
}(Acala);
|
|
11882
12096
|
|
|
11883
12097
|
var Relaychain = /*#__PURE__*/function (_SubstrateChain) {
|
|
@@ -11992,22 +12206,16 @@ var Mythos = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11992
12206
|
return transferPolkadotXcm(input);
|
|
11993
12207
|
case 2:
|
|
11994
12208
|
defaultTx = _context2.v;
|
|
11995
|
-
if (!(destination === 'AssetHubPolkadot')) {
|
|
11996
|
-
_context2.n = 3;
|
|
11997
|
-
break;
|
|
11998
|
-
}
|
|
11999
|
-
return _context2.a(2, handleToAhTeleport('Mythos', input, defaultTx));
|
|
12000
|
-
case 3:
|
|
12001
12209
|
if (!(destination == 'Ethereum')) {
|
|
12002
|
-
_context2.n =
|
|
12210
|
+
_context2.n = 4;
|
|
12003
12211
|
break;
|
|
12004
12212
|
}
|
|
12005
12213
|
_t = api;
|
|
12006
|
-
_context2.n =
|
|
12214
|
+
_context2.n = 3;
|
|
12007
12215
|
return createTypeAndThenTransfer(input, this.chain, this.version);
|
|
12008
|
-
case
|
|
12216
|
+
case 3:
|
|
12009
12217
|
return _context2.a(2, _t.deserializeExtrinsics.call(_t, _context2.v));
|
|
12010
|
-
case
|
|
12218
|
+
case 4:
|
|
12011
12219
|
return _context2.a(2, defaultTx);
|
|
12012
12220
|
}
|
|
12013
12221
|
}, _callee2, this);
|
|
@@ -12017,6 +12225,11 @@ var Mythos = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12017
12225
|
}
|
|
12018
12226
|
return transferPolkadotXCM;
|
|
12019
12227
|
}()
|
|
12228
|
+
}, {
|
|
12229
|
+
key: "shouldUseNativeAssetTeleport",
|
|
12230
|
+
value: function shouldUseNativeAssetTeleport() {
|
|
12231
|
+
return false;
|
|
12232
|
+
}
|
|
12020
12233
|
}, {
|
|
12021
12234
|
key: "isRelayToParaEnabled",
|
|
12022
12235
|
value: function isRelayToParaEnabled() {
|
|
@@ -12081,19 +12294,28 @@ var NeuroWeb = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12081
12294
|
var api = options.api,
|
|
12082
12295
|
asset = options.assetInfo,
|
|
12083
12296
|
recipient = options.recipient,
|
|
12084
|
-
balance = options.balance,
|
|
12085
12297
|
isAmountAll = options.isAmountAll,
|
|
12086
12298
|
keepAlive = options.keepAlive;
|
|
12087
|
-
|
|
12088
|
-
var
|
|
12089
|
-
|
|
12299
|
+
var module = asset.assetId === undefined ? 'ForeignAssets' : 'Assets';
|
|
12300
|
+
var id = asset.assetId === undefined ? asset.location : BigInt(asset.assetId);
|
|
12301
|
+
if (isAmountAll) {
|
|
12302
|
+
return api.deserializeExtrinsics({
|
|
12303
|
+
module: module,
|
|
12304
|
+
method: 'transfer_all',
|
|
12305
|
+
params: {
|
|
12306
|
+
id: id,
|
|
12307
|
+
dest: recipient,
|
|
12308
|
+
keep_alive: keepAlive
|
|
12309
|
+
}
|
|
12310
|
+
});
|
|
12311
|
+
}
|
|
12090
12312
|
return api.deserializeExtrinsics({
|
|
12091
|
-
module:
|
|
12313
|
+
module: module,
|
|
12092
12314
|
method: keepAlive ? 'transfer_keep_alive' : 'transfer',
|
|
12093
12315
|
params: {
|
|
12094
|
-
id:
|
|
12316
|
+
id: id,
|
|
12095
12317
|
target: recipient,
|
|
12096
|
-
amount: amount
|
|
12318
|
+
amount: asset.amount
|
|
12097
12319
|
}
|
|
12098
12320
|
});
|
|
12099
12321
|
}
|
|
@@ -12112,7 +12334,7 @@ var Paseo = /*#__PURE__*/function (_Polkadot) {
|
|
|
12112
12334
|
var Peaq = /*#__PURE__*/function (_SubstrateChain) {
|
|
12113
12335
|
function Peaq() {
|
|
12114
12336
|
_classCallCheck(this, Peaq);
|
|
12115
|
-
return _callSuper(this, Peaq, ['Peaq', 'peaq', 'Polkadot', Version.
|
|
12337
|
+
return _callSuper(this, Peaq, ['Peaq', 'peaq', 'Polkadot', Version.V5]);
|
|
12116
12338
|
}
|
|
12117
12339
|
_inherits(Peaq, _SubstrateChain);
|
|
12118
12340
|
return _createClass(Peaq, [{
|
|
@@ -12199,23 +12421,9 @@ var Pendulum = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12199
12421
|
}), currencySelection);
|
|
12200
12422
|
}
|
|
12201
12423
|
}, {
|
|
12202
|
-
key: "
|
|
12203
|
-
value: function
|
|
12204
|
-
|
|
12205
|
-
asset = options.assetInfo,
|
|
12206
|
-
recipient = options.recipient;
|
|
12207
|
-
var amount = getLocalTransferAmount(options);
|
|
12208
|
-
return api.deserializeExtrinsics({
|
|
12209
|
-
module: 'Currencies',
|
|
12210
|
-
method: 'transfer',
|
|
12211
|
-
params: {
|
|
12212
|
-
dest: {
|
|
12213
|
-
Id: recipient
|
|
12214
|
-
},
|
|
12215
|
-
currency_id: this.getCustomCurrencyId(api, asset),
|
|
12216
|
-
amount: amount
|
|
12217
|
-
}
|
|
12218
|
-
});
|
|
12424
|
+
key: "getLocalCurrencyId",
|
|
12425
|
+
value: function getLocalCurrencyId(api, asset) {
|
|
12426
|
+
return this.getCustomCurrencyId(api, asset);
|
|
12219
12427
|
}
|
|
12220
12428
|
}]);
|
|
12221
12429
|
}(SubstrateChain);
|
|
@@ -12223,7 +12431,7 @@ var Pendulum = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12223
12431
|
var Penpal = /*#__PURE__*/function (_SubstrateChain) {
|
|
12224
12432
|
function Penpal() {
|
|
12225
12433
|
_classCallCheck(this, Penpal);
|
|
12226
|
-
return _callSuper(this, Penpal, ['Penpal', 'westendPenpal', 'Westend', Version.
|
|
12434
|
+
return _callSuper(this, Penpal, ['Penpal', 'westendPenpal', 'Westend', Version.V5]);
|
|
12227
12435
|
}
|
|
12228
12436
|
_inherits(Penpal, _SubstrateChain);
|
|
12229
12437
|
return _createClass(Penpal, [{
|
|
@@ -12354,6 +12562,15 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12354
12562
|
}]);
|
|
12355
12563
|
}(SubstrateChain);
|
|
12356
12564
|
|
|
12565
|
+
var Shibuya = /*#__PURE__*/function (_Astar) {
|
|
12566
|
+
function Shibuya() {
|
|
12567
|
+
_classCallCheck(this, Shibuya);
|
|
12568
|
+
return _callSuper(this, Shibuya, ['Shibuya', 'PaseoShibuyaChain', 'Paseo', Version.V5]);
|
|
12569
|
+
}
|
|
12570
|
+
_inherits(Shibuya, _Astar);
|
|
12571
|
+
return _createClass(Shibuya);
|
|
12572
|
+
}(Astar);
|
|
12573
|
+
|
|
12357
12574
|
var Shiden = /*#__PURE__*/function (_Astar) {
|
|
12358
12575
|
function Shiden() {
|
|
12359
12576
|
_classCallCheck(this, Shiden);
|
|
@@ -12367,11 +12584,6 @@ var FUNGIBLE_ITEM_ID = 0;
|
|
|
12367
12584
|
var FUNGIBLE_BALANCE_PREFIX = 'b6f8df5e96e2c932e9bd00274d53a26f4ea8ea0c01faa42b6eb344a85c47b387';
|
|
12368
12585
|
var FUNGIBLE_TOTAL_SUPPLY_PREFIX = 'b6f8df5e96e2c932e9bd00274d53a26f5994cfda14cd67e1586647d40008abaa';
|
|
12369
12586
|
var SUBSTRATE_CROSS_ACCOUNT_PREFIX = '00';
|
|
12370
|
-
var toLeHex = function toLeHex(value, size) {
|
|
12371
|
-
return bytesToHex(numberToBytes(value, {
|
|
12372
|
-
size: size
|
|
12373
|
-
}).reverse());
|
|
12374
|
-
};
|
|
12375
12587
|
var Unique = /*#__PURE__*/function (_SubstrateChain) {
|
|
12376
12588
|
function Unique() {
|
|
12377
12589
|
_classCallCheck(this, Unique);
|
|
@@ -12485,6 +12697,40 @@ var Xode = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
12485
12697
|
value: function canReceiveFrom(origin) {
|
|
12486
12698
|
return origin === 'AssetHubPolkadot';
|
|
12487
12699
|
}
|
|
12700
|
+
}, {
|
|
12701
|
+
key: "transferLocalNonNativeAsset",
|
|
12702
|
+
value: function transferLocalNonNativeAsset(options) {
|
|
12703
|
+
var api = options.api,
|
|
12704
|
+
asset = options.assetInfo,
|
|
12705
|
+
recipient = options.recipient,
|
|
12706
|
+
isAmountAll = options.isAmountAll,
|
|
12707
|
+
keepAlive = options.keepAlive;
|
|
12708
|
+
assertHasId(asset);
|
|
12709
|
+
var assetId = Number(asset.assetId);
|
|
12710
|
+
var dest = {
|
|
12711
|
+
Id: recipient
|
|
12712
|
+
};
|
|
12713
|
+
if (isAmountAll) {
|
|
12714
|
+
return api.deserializeExtrinsics({
|
|
12715
|
+
module: 'Assets',
|
|
12716
|
+
method: 'transfer_all',
|
|
12717
|
+
params: {
|
|
12718
|
+
id: assetId,
|
|
12719
|
+
dest: dest,
|
|
12720
|
+
keep_alive: keepAlive
|
|
12721
|
+
}
|
|
12722
|
+
});
|
|
12723
|
+
}
|
|
12724
|
+
return api.deserializeExtrinsics({
|
|
12725
|
+
module: 'Assets',
|
|
12726
|
+
method: keepAlive ? 'transfer_keep_alive' : 'transfer',
|
|
12727
|
+
params: {
|
|
12728
|
+
id: assetId,
|
|
12729
|
+
target: dest,
|
|
12730
|
+
amount: asset.amount
|
|
12731
|
+
}
|
|
12732
|
+
});
|
|
12733
|
+
}
|
|
12488
12734
|
}]);
|
|
12489
12735
|
}(SubstrateChain);
|
|
12490
12736
|
|
|
@@ -12541,6 +12787,7 @@ var chains = function chains() {
|
|
|
12541
12787
|
PeoplePaseo: new PeoplePaseo(),
|
|
12542
12788
|
HeimaPaseo: new HeimaPaseo(),
|
|
12543
12789
|
HydrationPaseo: new HydrationPaseo(),
|
|
12790
|
+
Shibuya: new Shibuya(),
|
|
12544
12791
|
// External chains
|
|
12545
12792
|
Ethereum: new Ethereum(),
|
|
12546
12793
|
EthereumTestnet: new EthereumTestnet()
|
|
@@ -12768,6 +13015,17 @@ var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
|
|
|
12768
13015
|
return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
|
|
12769
13016
|
};
|
|
12770
13017
|
|
|
13018
|
+
var blake2128Concat = function blake2128Concat(hex) {
|
|
13019
|
+
return bytesToHex(blake2b(hexToBytes(hex), {
|
|
13020
|
+
dkLen: 16
|
|
13021
|
+
})) + hex;
|
|
13022
|
+
};
|
|
13023
|
+
var toLeHex = function toLeHex(value, size) {
|
|
13024
|
+
return bytesToHex(numberToBytes(value, {
|
|
13025
|
+
size: size
|
|
13026
|
+
}).reverse());
|
|
13027
|
+
};
|
|
13028
|
+
|
|
12771
13029
|
// twox128("EVM") ++ twox128("AccountStorages") — the pallet_evm::AccountStorages storage prefix.
|
|
12772
13030
|
var ACCOUNT_STORAGES_PREFIX = '1da53b775b270400e7e61ed5cbc5a146ab1160471b1418779239ba8e2b847e42';
|
|
12773
13031
|
// "ETH\0" — prefix of account ids that Hydration derives from an EVM address
|
|
@@ -12775,11 +13033,6 @@ var EVM_ACCOUNT_PREFIX = '45544800';
|
|
|
12775
13033
|
var word = function word(hex) {
|
|
12776
13034
|
return hex.padStart(64, '0');
|
|
12777
13035
|
};
|
|
12778
|
-
var blake2128Concat = function blake2128Concat(hex) {
|
|
12779
|
-
return bytesToHex(blake2b(hexToBytes(hex), {
|
|
12780
|
-
dkLen: 16
|
|
12781
|
-
})) + hex;
|
|
12782
|
-
};
|
|
12783
13036
|
// Mirrors pallet_evm_accounts::evm_address
|
|
12784
13037
|
var toEvmAddress = function toEvmAddress(accountId) {
|
|
12785
13038
|
return accountId.startsWith(EVM_ACCOUNT_PREFIX) && accountId.endsWith('0'.repeat(16)) ? accountId.slice(8, 48) : accountId.slice(0, 40);
|
|
@@ -12801,6 +13054,10 @@ var buildErc20StorageMint = function buildErc20StorageMint(api, address, asset,
|
|
|
12801
13054
|
};
|
|
12802
13055
|
};
|
|
12803
13056
|
|
|
13057
|
+
var isAssetXcEqualImpl = function isAssetXcEqualImpl(api, a, b) {
|
|
13058
|
+
return deepEqual(api.localizeLocation(a.chain, a.asset.location, a.chain), api.localizeLocation(a.chain, b.asset.location, b.chain));
|
|
13059
|
+
};
|
|
13060
|
+
|
|
12804
13061
|
var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets, overriddenCurrency) {
|
|
12805
13062
|
if (!overriddenCurrency) {
|
|
12806
13063
|
return assets;
|
|
@@ -13172,80 +13429,6 @@ var createChainClient = /*#__PURE__*/function () {
|
|
|
13172
13429
|
};
|
|
13173
13430
|
}();
|
|
13174
13431
|
|
|
13175
|
-
var createBridgedXcmPrefix = function createBridgedXcmPrefix(version, _ref) {
|
|
13176
|
-
var palletIndex = _ref.palletIndex,
|
|
13177
|
-
relay = _ref.relay,
|
|
13178
|
-
paraId = _ref.paraId;
|
|
13179
|
-
return [{
|
|
13180
|
-
DescendOrigin: createX1Payload(version, {
|
|
13181
|
-
PalletInstance: palletIndex
|
|
13182
|
-
})
|
|
13183
|
-
}, {
|
|
13184
|
-
UniversalOrigin: {
|
|
13185
|
-
GlobalConsensus: _defineProperty({}, relay.toLowerCase(), null)
|
|
13186
|
-
}
|
|
13187
|
-
}, {
|
|
13188
|
-
DescendOrigin: createX1Payload(version, {
|
|
13189
|
-
Parachain: paraId
|
|
13190
|
-
})
|
|
13191
|
-
}];
|
|
13192
|
-
};
|
|
13193
|
-
|
|
13194
|
-
var getErrorInstruction = function getErrorInstruction(message, index) {
|
|
13195
|
-
if (index === undefined || _typeof(message) !== 'object' || message === null) {
|
|
13196
|
-
return undefined;
|
|
13197
|
-
}
|
|
13198
|
-
var instructions = message;
|
|
13199
|
-
if (!Array.isArray(instructions)) {
|
|
13200
|
-
instructions = 'value' in message && Array.isArray(message.value) ? message.value : Object.values(message)[0];
|
|
13201
|
-
}
|
|
13202
|
-
if (!Array.isArray(instructions)) return undefined;
|
|
13203
|
-
var instruction = instructions[index];
|
|
13204
|
-
return _typeof(instruction) === 'object' && instruction !== null ? instruction : undefined;
|
|
13205
|
-
};
|
|
13206
|
-
var buildDryRunError = function buildDryRunError(error, message) {
|
|
13207
|
-
return _objectSpread2(_objectSpread2({}, error), {}, {
|
|
13208
|
-
instruction: getErrorInstruction(message, error.instructionIndex)
|
|
13209
|
-
});
|
|
13210
|
-
};
|
|
13211
|
-
|
|
13212
|
-
var resolveModuleError = function resolveModuleError(chain, error) {
|
|
13213
|
-
var palletDetails = getSupportedPalletsDetails(chain).find(function (p) {
|
|
13214
|
-
return p.index === Number(error.index);
|
|
13215
|
-
});
|
|
13216
|
-
if (!palletDetails) {
|
|
13217
|
-
throw new RoutingResolutionError("Pallet with index ".concat(error.index, " not found"));
|
|
13218
|
-
}
|
|
13219
|
-
// Use only the first byte of the error to get the error index
|
|
13220
|
-
// Including 0x prefix
|
|
13221
|
-
var errorIndex = Number(error.error.slice(0, 4));
|
|
13222
|
-
var name = palletDetails.name;
|
|
13223
|
-
if (name !== 'XTokens' && name !== 'PolkadotXcm' && name !== 'XcmPallet') {
|
|
13224
|
-
throw new UnsupportedOperationError("Pallet ".concat(name, " is not supported"));
|
|
13225
|
-
}
|
|
13226
|
-
var reason = name === 'XTokens' ? Object.values(XTokensError)[errorIndex] : Object.values(PolkadotXcmError)[errorIndex];
|
|
13227
|
-
if (!reason) {
|
|
13228
|
-
throw new RoutingResolutionError("Error index ".concat(errorIndex, " not found in ").concat(name, " pallet"));
|
|
13229
|
-
}
|
|
13230
|
-
if (reason === PolkadotXcmError.LocalExecutionIncompleteWithError) {
|
|
13231
|
-
// Byte layout: [pallet error variant][instruction index][xcm sub-error]
|
|
13232
|
-
var instructionIndex = Number("0x".concat(error.error.slice(4, 6)));
|
|
13233
|
-
var subErrorIndex = Number("0x".concat(error.error.slice(6, 8)));
|
|
13234
|
-
var subReason = Object.values(PolkadotXcmExecutionError)[subErrorIndex];
|
|
13235
|
-
if (!subReason) {
|
|
13236
|
-
throw new RoutingResolutionError("Sub-error index ".concat(subErrorIndex, " not found in PolkadotXcm pallet"));
|
|
13237
|
-
}
|
|
13238
|
-
return {
|
|
13239
|
-
reason: reason,
|
|
13240
|
-
subReason: subReason,
|
|
13241
|
-
instructionIndex: instructionIndex
|
|
13242
|
-
};
|
|
13243
|
-
}
|
|
13244
|
-
return {
|
|
13245
|
-
reason: reason
|
|
13246
|
-
};
|
|
13247
|
-
};
|
|
13248
|
-
|
|
13249
13432
|
var getEvmPrivateKeyHex = function getEvmPrivateKeyHex(path) {
|
|
13250
13433
|
var name = path.slice(2).toLowerCase();
|
|
13251
13434
|
if (name in EVM_DEV_PRIVATE_KEYS) {
|
|
@@ -13679,6 +13862,11 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
13679
13862
|
var resolveExternalReserve = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
13680
13863
|
return getAssetReserveChainImpl(this, chain, assetLocation, resolveExternalReserve);
|
|
13681
13864
|
}
|
|
13865
|
+
}, {
|
|
13866
|
+
key: "isAssetXcEqual",
|
|
13867
|
+
value: function isAssetXcEqual(a, b) {
|
|
13868
|
+
return isAssetXcEqualImpl(this, a, b);
|
|
13869
|
+
}
|
|
13682
13870
|
}, {
|
|
13683
13871
|
key: "init",
|
|
13684
13872
|
value: function () {
|
|
@@ -14056,4 +14244,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
|
|
|
14056
14244
|
};
|
|
14057
14245
|
};
|
|
14058
14246
|
|
|
14059
|
-
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall,
|
|
14247
|
+
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, calcSentAssetPreviewMint, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, isAssetXcEqualImpl, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, toLeHex, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateFeeAssetSupport, validateTransact, verifyEdOnDestination, wrapTxBypass };
|