@paraspell/sdk-core 11.8.5 → 11.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +537 -245
- package/dist/index.d.ts +40 -8
- package/dist/index.mjs +539 -248
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset,
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, hasXcmPaymentApiSupport, getRelayChainSymbol, getExistentialDeposit, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, parseUnits, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
|
|
6
6
|
import { getSupportedPalletsDetails, getDefaultPallet, getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets } from '@paraspell/pallets';
|
|
7
7
|
export * from '@paraspell/pallets';
|
|
8
|
-
import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, Parents, PARACHAINS, deepEqual, isTrustedChain, isExternalChain, isDotKsmBridge } from '@paraspell/sdk-common';
|
|
8
|
+
import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, Parents, PARACHAINS, deepEqual, isTrustedChain, isExternalChain, isDotKsmBridge, isSystemChain } from '@paraspell/sdk-common';
|
|
9
9
|
export * from '@paraspell/sdk-common';
|
|
10
10
|
import { moonbeam, moonriver, mainnet } from 'viem/chains';
|
|
11
11
|
|
|
@@ -772,6 +772,20 @@ var createVersionedAssets = function createVersionedAssets(version, amount, loca
|
|
|
772
772
|
return addXcmVersionHeader([asset], version);
|
|
773
773
|
};
|
|
774
774
|
|
|
775
|
+
var getCurrencySelection = function getCurrencySelection(asset) {
|
|
776
|
+
if (asset.location) return {
|
|
777
|
+
location: asset.location
|
|
778
|
+
};
|
|
779
|
+
if (isForeignAsset(asset) && asset.assetId) {
|
|
780
|
+
return {
|
|
781
|
+
id: asset.assetId
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
symbol: asset.symbol
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
|
|
775
789
|
var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets, overriddenCurrency) {
|
|
776
790
|
if (!overriddenCurrency) {
|
|
777
791
|
return assets;
|
|
@@ -909,7 +923,7 @@ var getRelayChainOf = function getRelayChainOf(chain) {
|
|
|
909
923
|
};
|
|
910
924
|
|
|
911
925
|
var AssetHubPolkadot$1 = {
|
|
912
|
-
name: "
|
|
926
|
+
name: "Asset Hub",
|
|
913
927
|
info: "PolkadotAssetHub",
|
|
914
928
|
paraId: 1000,
|
|
915
929
|
providers: [
|
|
@@ -1010,10 +1024,6 @@ var Astar$1 = {
|
|
|
1010
1024
|
name: "Astar",
|
|
1011
1025
|
endpoint: "wss://rpc.astar.network"
|
|
1012
1026
|
},
|
|
1013
|
-
{
|
|
1014
|
-
name: "Automata 1RPC",
|
|
1015
|
-
endpoint: "wss://1rpc.io/astr"
|
|
1016
|
-
},
|
|
1017
1027
|
{
|
|
1018
1028
|
name: "Blast",
|
|
1019
1029
|
endpoint: "wss://astar.public.blastapi.io"
|
|
@@ -1052,15 +1062,11 @@ var BifrostPolkadot$1 = {
|
|
|
1052
1062
|
{
|
|
1053
1063
|
name: "LiebiEU",
|
|
1054
1064
|
endpoint: "wss://eu.bifrost-polkadot-rpc.liebi.com/ws"
|
|
1055
|
-
},
|
|
1056
|
-
{
|
|
1057
|
-
name: "RadiumBlock",
|
|
1058
|
-
endpoint: "wss://bifrost.public.curie.radiumblock.co/ws"
|
|
1059
1065
|
}
|
|
1060
1066
|
]
|
|
1061
1067
|
};
|
|
1062
1068
|
var BridgeHubPolkadot$1 = {
|
|
1063
|
-
name: "
|
|
1069
|
+
name: "Bridge Hub",
|
|
1064
1070
|
info: "polkadotBridgeHub",
|
|
1065
1071
|
paraId: 1002,
|
|
1066
1072
|
providers: [
|
|
@@ -1209,16 +1215,16 @@ var Interlay$1 = {
|
|
|
1209
1215
|
};
|
|
1210
1216
|
var Heima$1 = {
|
|
1211
1217
|
name: "Heima",
|
|
1212
|
-
info: "
|
|
1218
|
+
info: "heima",
|
|
1213
1219
|
paraId: 2013,
|
|
1214
1220
|
providers: [
|
|
1215
1221
|
{
|
|
1216
1222
|
name: "Dwellir",
|
|
1217
|
-
endpoint: "wss://
|
|
1223
|
+
endpoint: "wss://heima-rpc.n.dwellir.com"
|
|
1218
1224
|
},
|
|
1219
1225
|
{
|
|
1220
|
-
name: "
|
|
1221
|
-
endpoint: "wss://rpc.
|
|
1226
|
+
name: "Heima",
|
|
1227
|
+
endpoint: "wss://rpc.heima-parachain.heima.network"
|
|
1222
1228
|
}
|
|
1223
1229
|
]
|
|
1224
1230
|
};
|
|
@@ -1643,7 +1649,7 @@ var Xode$1 = {
|
|
|
1643
1649
|
]
|
|
1644
1650
|
};
|
|
1645
1651
|
var AssetHubKusama$1 = {
|
|
1646
|
-
name: "
|
|
1652
|
+
name: "Asset Hub",
|
|
1647
1653
|
info: "KusamaAssetHub",
|
|
1648
1654
|
paraId: 1000,
|
|
1649
1655
|
providers: [
|
|
@@ -1686,7 +1692,7 @@ var AssetHubKusama$1 = {
|
|
|
1686
1692
|
]
|
|
1687
1693
|
};
|
|
1688
1694
|
var BridgeHubKusama$1 = {
|
|
1689
|
-
name: "
|
|
1695
|
+
name: "Bridge Hub",
|
|
1690
1696
|
info: "kusamaBridgeHub",
|
|
1691
1697
|
paraId: 1002,
|
|
1692
1698
|
providers: [
|
|
@@ -1988,10 +1994,6 @@ var Quartz$1 = {
|
|
|
1988
1994
|
name: "Geo Load Balancer",
|
|
1989
1995
|
endpoint: "wss://ws-quartz.unique.network"
|
|
1990
1996
|
},
|
|
1991
|
-
{
|
|
1992
|
-
name: "Unique Asia",
|
|
1993
|
-
endpoint: "wss://asia-ws-quartz.unique.network"
|
|
1994
|
-
},
|
|
1995
1997
|
{
|
|
1996
1998
|
name: "Unique Europe",
|
|
1997
1999
|
endpoint: "wss://eu-ws-quartz.unique.network"
|
|
@@ -2083,7 +2085,7 @@ var Zeitgeist$1 = {
|
|
|
2083
2085
|
]
|
|
2084
2086
|
};
|
|
2085
2087
|
var AssetHubWestend$1 = {
|
|
2086
|
-
name: "
|
|
2088
|
+
name: "Asset Hub",
|
|
2087
2089
|
info: "WestendAssetHub",
|
|
2088
2090
|
paraId: 1000,
|
|
2089
2091
|
providers: [
|
|
@@ -2106,7 +2108,7 @@ var AssetHubWestend$1 = {
|
|
|
2106
2108
|
]
|
|
2107
2109
|
};
|
|
2108
2110
|
var BridgeHubWestend$1 = {
|
|
2109
|
-
name: "
|
|
2111
|
+
name: "Bridge Hub",
|
|
2110
2112
|
info: "westendBridgeHub",
|
|
2111
2113
|
paraId: 1002,
|
|
2112
2114
|
providers: [
|
|
@@ -2196,7 +2198,7 @@ var AjunaPaseo$1 = {
|
|
|
2196
2198
|
]
|
|
2197
2199
|
};
|
|
2198
2200
|
var AssetHubPaseo$1 = {
|
|
2199
|
-
name: "
|
|
2201
|
+
name: "Asset Hub",
|
|
2200
2202
|
info: "PaseoAssetHub",
|
|
2201
2203
|
paraId: 1000,
|
|
2202
2204
|
providers: [
|
|
@@ -2234,7 +2236,7 @@ var BifrostPaseo$1 = {
|
|
|
2234
2236
|
]
|
|
2235
2237
|
};
|
|
2236
2238
|
var BridgeHubPaseo$1 = {
|
|
2237
|
-
name: "
|
|
2239
|
+
name: "Bridge Hub",
|
|
2238
2240
|
info: "PaseoBridgeHub",
|
|
2239
2241
|
paraId: 1002,
|
|
2240
2242
|
providers: [
|
|
@@ -2401,7 +2403,7 @@ var ZeitgeistPaseo$1 = {
|
|
|
2401
2403
|
]
|
|
2402
2404
|
};
|
|
2403
2405
|
var Polkadot = {
|
|
2404
|
-
name: "Polkadot",
|
|
2406
|
+
name: "Polkadot Relay",
|
|
2405
2407
|
info: "polkadot",
|
|
2406
2408
|
paraId: 0,
|
|
2407
2409
|
providers: [
|
|
@@ -2464,7 +2466,7 @@ var Polkadot = {
|
|
|
2464
2466
|
]
|
|
2465
2467
|
};
|
|
2466
2468
|
var Kusama = {
|
|
2467
|
-
name: "Kusama",
|
|
2469
|
+
name: "Kusama Relay",
|
|
2468
2470
|
info: "kusama",
|
|
2469
2471
|
paraId: 0,
|
|
2470
2472
|
providers: [
|
|
@@ -2515,7 +2517,7 @@ var Kusama = {
|
|
|
2515
2517
|
]
|
|
2516
2518
|
};
|
|
2517
2519
|
var Westend = {
|
|
2518
|
-
name: "Westend",
|
|
2520
|
+
name: "Westend Relay",
|
|
2519
2521
|
info: "westend",
|
|
2520
2522
|
paraId: 0,
|
|
2521
2523
|
providers: [
|
|
@@ -2542,7 +2544,7 @@ var Westend = {
|
|
|
2542
2544
|
]
|
|
2543
2545
|
};
|
|
2544
2546
|
var Paseo = {
|
|
2545
|
-
name: "Paseo",
|
|
2547
|
+
name: "Paseo Relay",
|
|
2546
2548
|
info: "paseo",
|
|
2547
2549
|
paraId: 0,
|
|
2548
2550
|
providers: [
|
|
@@ -3292,6 +3294,7 @@ var getAssetReserveChain = function getAssetReserveChain(chain, destChain, asset
|
|
|
3292
3294
|
Here: null
|
|
3293
3295
|
}
|
|
3294
3296
|
})) {
|
|
3297
|
+
if (relaychain === 'Paseo') return ahChain;
|
|
3295
3298
|
return CHAINS_DOT_RESERVE_AH.has(destChain) ? ahChain : relaychain;
|
|
3296
3299
|
}
|
|
3297
3300
|
return chain;
|
|
@@ -3775,49 +3778,6 @@ var getReverseTxFee = /*#__PURE__*/function () {
|
|
|
3775
3778
|
};
|
|
3776
3779
|
}();
|
|
3777
3780
|
|
|
3778
|
-
var AssetsPallet = /*#__PURE__*/function () {
|
|
3779
|
-
function AssetsPallet() {
|
|
3780
|
-
_classCallCheck(this, AssetsPallet);
|
|
3781
|
-
}
|
|
3782
|
-
return _createClass(AssetsPallet, [{
|
|
3783
|
-
key: "mint",
|
|
3784
|
-
value: function mint(address, asset, _balance, chain) {
|
|
3785
|
-
assertHasId(asset);
|
|
3786
|
-
var assetId = asset.assetId,
|
|
3787
|
-
amount = asset.amount;
|
|
3788
|
-
var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
|
|
3789
|
-
var addr = isChainEvm(chain) ? address : {
|
|
3790
|
-
Id: address
|
|
3791
|
-
};
|
|
3792
|
-
return Promise.resolve({
|
|
3793
|
-
assetStatusTx: {
|
|
3794
|
-
module: 'Assets',
|
|
3795
|
-
method: 'force_asset_status',
|
|
3796
|
-
parameters: {
|
|
3797
|
-
id: id,
|
|
3798
|
-
owner: addr,
|
|
3799
|
-
issuer: addr,
|
|
3800
|
-
admin: addr,
|
|
3801
|
-
freezer: addr,
|
|
3802
|
-
min_balance: 0n,
|
|
3803
|
-
is_sufficient: true,
|
|
3804
|
-
is_frozen: false
|
|
3805
|
-
}
|
|
3806
|
-
},
|
|
3807
|
-
balanceTx: {
|
|
3808
|
-
module: 'Assets',
|
|
3809
|
-
method: 'mint',
|
|
3810
|
-
parameters: {
|
|
3811
|
-
id: id,
|
|
3812
|
-
beneficiary: addr,
|
|
3813
|
-
amount: amount
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
|
-
});
|
|
3817
|
-
}
|
|
3818
|
-
}]);
|
|
3819
|
-
}();
|
|
3820
|
-
|
|
3821
3781
|
// Inspired by Moonbeam XCM-SDK
|
|
3822
3782
|
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/utils/src/format/asset.ts#L1
|
|
3823
3783
|
var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
|
|
@@ -3898,7 +3858,7 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
|
|
|
3898
3858
|
assertHasLocation(asset);
|
|
3899
3859
|
return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.location));
|
|
3900
3860
|
case 3:
|
|
3901
|
-
if (!(
|
|
3861
|
+
if (!chain.startsWith('AssetHub')) {
|
|
3902
3862
|
_context.n = 5;
|
|
3903
3863
|
break;
|
|
3904
3864
|
}
|
|
@@ -3912,7 +3872,7 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
|
|
|
3912
3872
|
case 4:
|
|
3913
3873
|
return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.location));
|
|
3914
3874
|
case 5:
|
|
3915
|
-
return _context.a(2, api.getBalanceForeignPolkadotXcm(address, asset
|
|
3875
|
+
return _context.a(2, api.getBalanceForeignPolkadotXcm(chain, address, asset));
|
|
3916
3876
|
}
|
|
3917
3877
|
}, _callee);
|
|
3918
3878
|
}));
|
|
@@ -4240,77 +4200,6 @@ var getAssetBalance = /*#__PURE__*/function () {
|
|
|
4240
4200
|
};
|
|
4241
4201
|
}();
|
|
4242
4202
|
|
|
4243
|
-
var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
|
|
4244
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
4245
|
-
var _getExistentialDeposi;
|
|
4246
|
-
var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
|
|
4247
|
-
return _regenerator().w(function (_context) {
|
|
4248
|
-
while (1) switch (_context.n) {
|
|
4249
|
-
case 0:
|
|
4250
|
-
api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
4251
|
-
_context.n = 1;
|
|
4252
|
-
return api.init(origin);
|
|
4253
|
-
case 1:
|
|
4254
|
-
_context.n = 2;
|
|
4255
|
-
return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
|
|
4256
|
-
case 2:
|
|
4257
|
-
tx = _context.v;
|
|
4258
|
-
_context.n = 3;
|
|
4259
|
-
return api.calculateTransactionFee(tx, account);
|
|
4260
|
-
case 3:
|
|
4261
|
-
xcmFee = _context.v;
|
|
4262
|
-
xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
|
|
4263
|
-
_context.n = 4;
|
|
4264
|
-
return getBalanceNativeInternal({
|
|
4265
|
-
address: account,
|
|
4266
|
-
chain: origin,
|
|
4267
|
-
api: api
|
|
4268
|
-
});
|
|
4269
|
-
case 4:
|
|
4270
|
-
nativeBalance = _context.v;
|
|
4271
|
-
existentialDeposit = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
|
|
4272
|
-
sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
|
|
4273
|
-
return _context.a(2, {
|
|
4274
|
-
sufficientForXCM: sufficientForXCM,
|
|
4275
|
-
xcmFee: xcmFee
|
|
4276
|
-
});
|
|
4277
|
-
}
|
|
4278
|
-
}, _callee);
|
|
4279
|
-
}));
|
|
4280
|
-
return function getOriginFeeDetailsInternal(_x) {
|
|
4281
|
-
return _ref2.apply(this, arguments);
|
|
4282
|
-
};
|
|
4283
|
-
}();
|
|
4284
|
-
var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
4285
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
4286
|
-
var api;
|
|
4287
|
-
return _regenerator().w(function (_context2) {
|
|
4288
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
4289
|
-
case 0:
|
|
4290
|
-
api = options.api;
|
|
4291
|
-
api.setDisconnectAllowed(false);
|
|
4292
|
-
_context2.p = 1;
|
|
4293
|
-
_context2.n = 2;
|
|
4294
|
-
return getOriginFeeDetailsInternal(options);
|
|
4295
|
-
case 2:
|
|
4296
|
-
return _context2.a(2, _context2.v);
|
|
4297
|
-
case 3:
|
|
4298
|
-
_context2.p = 3;
|
|
4299
|
-
api.setDisconnectAllowed(true);
|
|
4300
|
-
_context2.n = 4;
|
|
4301
|
-
return api.disconnect();
|
|
4302
|
-
case 4:
|
|
4303
|
-
return _context2.f(3);
|
|
4304
|
-
case 5:
|
|
4305
|
-
return _context2.a(2);
|
|
4306
|
-
}
|
|
4307
|
-
}, _callee2, null, [[1,, 3, 5]]);
|
|
4308
|
-
}));
|
|
4309
|
-
return function getOriginFeeDetails(_x2) {
|
|
4310
|
-
return _ref3.apply(this, arguments);
|
|
4311
|
-
};
|
|
4312
|
-
}();
|
|
4313
|
-
|
|
4314
4203
|
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4315
4204
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
4316
4205
|
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
@@ -4498,7 +4387,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4498
4387
|
_context2.n = 5;
|
|
4499
4388
|
break;
|
|
4500
4389
|
}
|
|
4501
|
-
|
|
4390
|
+
return _context2.a(2, 0n);
|
|
4502
4391
|
case 5:
|
|
4503
4392
|
_context2.n = 6;
|
|
4504
4393
|
return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
|
|
@@ -5933,20 +5822,15 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5933
5822
|
while (1) switch (_context.n) {
|
|
5934
5823
|
case 0:
|
|
5935
5824
|
api = input.api, destination = input.destination, address = input.address, senderAddress = input.senderAddress, asset = input.assetInfo, currency = input.currency;
|
|
5936
|
-
|
|
5937
|
-
_context.n = 1;
|
|
5938
|
-
break;
|
|
5939
|
-
}
|
|
5940
|
-
throw new InvalidParameterError('Location destination is not supported for this scenario');
|
|
5941
|
-
case 1:
|
|
5825
|
+
assertToIsString(destination, 'Location destination is not supported for AH teleport.');
|
|
5942
5826
|
if (!isTLocation(address)) {
|
|
5943
|
-
_context.n =
|
|
5827
|
+
_context.n = 1;
|
|
5944
5828
|
break;
|
|
5945
5829
|
}
|
|
5946
5830
|
throw new InvalidParameterError('Location address is not supported for this scenario');
|
|
5947
|
-
case
|
|
5831
|
+
case 1:
|
|
5948
5832
|
assertSenderAddress(senderAddress);
|
|
5949
|
-
_context.n =
|
|
5833
|
+
_context.n = 2;
|
|
5950
5834
|
return dryRunInternal({
|
|
5951
5835
|
api: api,
|
|
5952
5836
|
tx: defaultTx,
|
|
@@ -5956,19 +5840,19 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5956
5840
|
address: address,
|
|
5957
5841
|
currency: currency
|
|
5958
5842
|
});
|
|
5959
|
-
case
|
|
5843
|
+
case 2:
|
|
5960
5844
|
dryRunResult = _context.v;
|
|
5961
5845
|
if (!((_dryRunResult$destina = dryRunResult.destination) !== null && _dryRunResult$destina !== void 0 && _dryRunResult$destina.success)) {
|
|
5962
|
-
_context.n =
|
|
5846
|
+
_context.n = 3;
|
|
5963
5847
|
break;
|
|
5964
5848
|
}
|
|
5965
5849
|
return _context.a(2, defaultTx);
|
|
5966
|
-
case
|
|
5850
|
+
case 3:
|
|
5967
5851
|
// If the default tx dry run failed, we need to create execute transaction
|
|
5968
5852
|
dummyTx = createExecuteExchangeXcm(input, origin, MAX_WEIGHT,
|
|
5969
5853
|
// Enter dummy fee values just to get the dry run to pass
|
|
5970
5854
|
asset.amount, asset.amount / 2n);
|
|
5971
|
-
_context.n =
|
|
5855
|
+
_context.n = 4;
|
|
5972
5856
|
return getXcmFeeInternal({
|
|
5973
5857
|
api: api,
|
|
5974
5858
|
tx: dummyTx,
|
|
@@ -5980,7 +5864,7 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5980
5864
|
disableFallback: false,
|
|
5981
5865
|
useRootOrigin: true
|
|
5982
5866
|
});
|
|
5983
|
-
case
|
|
5867
|
+
case 4:
|
|
5984
5868
|
feeResult = _context.v;
|
|
5985
5869
|
originExecutionFee = padFeeBy(feeResult.origin.fee, 20); // Pad by 20%
|
|
5986
5870
|
destinationExecutionFee = padFeeBy(
|
|
@@ -6203,7 +6087,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6203
6087
|
key: "transfer",
|
|
6204
6088
|
value: function () {
|
|
6205
6089
|
var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
|
|
6206
|
-
var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
|
|
6090
|
+
var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call, _t;
|
|
6207
6091
|
return _regenerator().w(function (_context) {
|
|
6208
6092
|
while (1) switch (_context.n) {
|
|
6209
6093
|
case 0:
|
|
@@ -6226,7 +6110,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6226
6110
|
case 2:
|
|
6227
6111
|
this.throwIfTempDisabled(sendOptions, destChain);
|
|
6228
6112
|
this.throwIfCantReceive(destChain);
|
|
6229
|
-
isRelayAsset = deepEqual(asset.location, RELAY_LOCATION);
|
|
6113
|
+
isRelayAsset = deepEqual(asset.location, RELAY_LOCATION) && isSymbolMatch(getRelayChainSymbol(this.chain), asset.symbol);
|
|
6230
6114
|
_context.n = 3;
|
|
6231
6115
|
return api.hasMethod('PolkadotXcm', 'transfer_assets_using_type_and_then');
|
|
6232
6116
|
case 3:
|
|
@@ -6237,7 +6121,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6237
6121
|
}
|
|
6238
6122
|
throw new InvalidParameterError('Relaychain assets can only be transferred using the type-and-then method which is not supported by this chain');
|
|
6239
6123
|
case 4:
|
|
6240
|
-
useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && (!isTrustedChain(this.chain) || !isTrustedChain(destChain));
|
|
6124
|
+
useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && !feeAsset && (!isTrustedChain(this.chain) || !isTrustedChain(destChain));
|
|
6241
6125
|
if (!(supportsXTokens(this) && this.canUseXTokens(sendOptions) && !useTypeAndThen)) {
|
|
6242
6126
|
_context.n = 6;
|
|
6243
6127
|
break;
|
|
@@ -6284,7 +6168,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6284
6168
|
}));
|
|
6285
6169
|
case 7:
|
|
6286
6170
|
if (!(supportsPolkadotXCM(this) || useTypeAndThen)) {
|
|
6287
|
-
_context.n =
|
|
6171
|
+
_context.n = 16;
|
|
6288
6172
|
break;
|
|
6289
6173
|
}
|
|
6290
6174
|
options = {
|
|
@@ -6337,7 +6221,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6337
6221
|
isExternalAssetViaAh = isExternalAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
|
|
6338
6222
|
isExternalAssetToAh = isExternalAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
|
|
6339
6223
|
if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
|
|
6340
|
-
_context.n =
|
|
6224
|
+
_context.n = 15;
|
|
6341
6225
|
break;
|
|
6342
6226
|
}
|
|
6343
6227
|
if (!(useTypeAndThen && supportsPolkadotXCM(this))) {
|
|
@@ -6347,20 +6231,33 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6347
6231
|
_context.n = 10;
|
|
6348
6232
|
return this.transferPolkadotXCM(options);
|
|
6349
6233
|
case 10:
|
|
6234
|
+
if (!isRelayAsset) {
|
|
6235
|
+
_context.n = 12;
|
|
6236
|
+
break;
|
|
6237
|
+
}
|
|
6350
6238
|
_context.n = 11;
|
|
6351
|
-
return
|
|
6239
|
+
return createTypeThenAutoReserve(this.chain, options);
|
|
6352
6240
|
case 11:
|
|
6353
|
-
|
|
6354
|
-
|
|
6241
|
+
_t = _context.v;
|
|
6242
|
+
_context.n = 14;
|
|
6243
|
+
break;
|
|
6355
6244
|
case 12:
|
|
6245
|
+
_context.n = 13;
|
|
6246
|
+
return createTypeAndThenCall(this.chain, options);
|
|
6247
|
+
case 13:
|
|
6248
|
+
_t = _context.v;
|
|
6249
|
+
case 14:
|
|
6250
|
+
call = _t;
|
|
6251
|
+
return _context.a(2, api.callTxMethod(call));
|
|
6252
|
+
case 15:
|
|
6356
6253
|
if (!supportsPolkadotXCM(this)) {
|
|
6357
|
-
_context.n =
|
|
6254
|
+
_context.n = 16;
|
|
6358
6255
|
break;
|
|
6359
6256
|
}
|
|
6360
6257
|
return _context.a(2, this.transferPolkadotXCM(options));
|
|
6361
|
-
case
|
|
6258
|
+
case 16:
|
|
6362
6259
|
throw new NoXCMSupportImplementedError(this._chain);
|
|
6363
|
-
case
|
|
6260
|
+
case 17:
|
|
6364
6261
|
return _context.a(2);
|
|
6365
6262
|
}
|
|
6366
6263
|
}, _callee, this);
|
|
@@ -6387,7 +6284,8 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6387
6284
|
if (isSendingDisabled) {
|
|
6388
6285
|
throw new InvalidParameterError("Sending from ".concat(this.chain, " is temporarily disabled"));
|
|
6389
6286
|
}
|
|
6390
|
-
var
|
|
6287
|
+
var scenario = resolveScenario(this.chain, options.to);
|
|
6288
|
+
var isReceivingDisabled = destChain && !isRelayChain(destChain) && !isExternalChain(destChain) && getChain(destChain).isReceivingTempDisabled(scenario);
|
|
6391
6289
|
if (isReceivingDisabled) {
|
|
6392
6290
|
throw new InvalidParameterError("Receiving on ".concat(destChain, " is temporarily disabled"));
|
|
6393
6291
|
}
|
|
@@ -6399,7 +6297,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6399
6297
|
}
|
|
6400
6298
|
}, {
|
|
6401
6299
|
key: "isReceivingTempDisabled",
|
|
6402
|
-
value: function isReceivingTempDisabled(
|
|
6300
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
6403
6301
|
return false;
|
|
6404
6302
|
}
|
|
6405
6303
|
}, {
|
|
@@ -6435,39 +6333,46 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6435
6333
|
key: "transferRelayToPara",
|
|
6436
6334
|
value: function () {
|
|
6437
6335
|
var _transferRelayToPara = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
6438
|
-
var api, version, pallet, assetInfo, address, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
|
|
6336
|
+
var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
|
|
6439
6337
|
return _regenerator().w(function (_context2) {
|
|
6440
6338
|
while (1) switch (_context2.n) {
|
|
6441
6339
|
case 0:
|
|
6442
|
-
api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, methodOverride = options.method;
|
|
6340
|
+
api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo, methodOverride = options.method;
|
|
6443
6341
|
_this$getRelayToParaO = this.getRelayToParaOverrides(), method = _this$getRelayToParaO.method, includeFee = _this$getRelayToParaO.includeFee;
|
|
6342
|
+
if (!this.isReceivingTempDisabled('RelayToPara')) {
|
|
6343
|
+
_context2.n = 1;
|
|
6344
|
+
break;
|
|
6345
|
+
}
|
|
6346
|
+
throw new InvalidParameterError("Receiving on ".concat(this.chain, " is temporarily disabled"));
|
|
6347
|
+
case 1:
|
|
6444
6348
|
customMethod = methodOverride !== null && methodOverride !== void 0 ? methodOverride : method;
|
|
6445
6349
|
if (!(customMethod === 'transfer_assets_using_type_and_then')) {
|
|
6446
|
-
_context2.n =
|
|
6350
|
+
_context2.n = 3;
|
|
6447
6351
|
break;
|
|
6448
6352
|
}
|
|
6449
6353
|
paraId = resolveParaId(paraIdTo, destination);
|
|
6450
6354
|
destChain = resolveDestChain(this.chain, paraId);
|
|
6451
6355
|
scenario = 'RelayToPara';
|
|
6452
6356
|
if (destChain) {
|
|
6453
|
-
_context2.n =
|
|
6357
|
+
_context2.n = 2;
|
|
6454
6358
|
break;
|
|
6455
6359
|
}
|
|
6456
6360
|
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
6457
|
-
case
|
|
6458
|
-
return _context2.a(2,
|
|
6361
|
+
case 2:
|
|
6362
|
+
return _context2.a(2, createTypeThenAutoReserve(getRelayChainOf(destChain), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
6459
6363
|
beneficiaryLocation: createBeneficiaryLocation({
|
|
6460
6364
|
api: api,
|
|
6461
6365
|
address: address,
|
|
6462
6366
|
version: version
|
|
6463
6367
|
}),
|
|
6368
|
+
senderAddress: senderAddress,
|
|
6464
6369
|
asset: this.createCurrencySpec(assetInfo.amount, scenario, version, assetInfo, false),
|
|
6465
6370
|
destLocation: createDestination(version, this.chain, destination, paraId),
|
|
6466
6371
|
scenario: scenario,
|
|
6467
6372
|
destChain: destChain,
|
|
6468
6373
|
paraIdTo: paraId
|
|
6469
6374
|
})));
|
|
6470
|
-
case
|
|
6375
|
+
case 3:
|
|
6471
6376
|
return _context2.a(2, {
|
|
6472
6377
|
module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
|
|
6473
6378
|
method: customMethod,
|
|
@@ -7731,6 +7636,16 @@ var ComposableFinance = /*#__PURE__*/function (_Parachain) {
|
|
|
7731
7636
|
assertHasId(asset);
|
|
7732
7637
|
return transferXTokens(input, BigInt(asset.assetId));
|
|
7733
7638
|
}
|
|
7639
|
+
}, {
|
|
7640
|
+
key: "isSendingTempDisabled",
|
|
7641
|
+
value: function isSendingTempDisabled(_options) {
|
|
7642
|
+
return true;
|
|
7643
|
+
}
|
|
7644
|
+
}, {
|
|
7645
|
+
key: "isReceivingTempDisabled",
|
|
7646
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
7647
|
+
return true;
|
|
7648
|
+
}
|
|
7734
7649
|
}]);
|
|
7735
7650
|
}(Parachain);
|
|
7736
7651
|
|
|
@@ -7743,10 +7658,11 @@ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
7743
7658
|
return _createClass(CoretimeKusama, [{
|
|
7744
7659
|
key: "transferPolkadotXCM",
|
|
7745
7660
|
value: function transferPolkadotXCM(input) {
|
|
7746
|
-
// TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
|
|
7747
7661
|
var scenario = input.scenario;
|
|
7748
|
-
|
|
7749
|
-
|
|
7662
|
+
if (scenario === 'ParaToPara') {
|
|
7663
|
+
throw new ScenarioNotSupportedError(this.chain, scenario);
|
|
7664
|
+
}
|
|
7665
|
+
return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
|
|
7750
7666
|
}
|
|
7751
7667
|
}, {
|
|
7752
7668
|
key: "getRelayToParaOverrides",
|
|
@@ -7778,6 +7694,11 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7778
7694
|
}
|
|
7779
7695
|
return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
|
|
7780
7696
|
}
|
|
7697
|
+
}, {
|
|
7698
|
+
key: "canReceiveFrom",
|
|
7699
|
+
value: function canReceiveFrom(origin) {
|
|
7700
|
+
return origin !== 'Hydration' && origin !== 'Moonbeam';
|
|
7701
|
+
}
|
|
7781
7702
|
}, {
|
|
7782
7703
|
key: "getRelayToParaOverrides",
|
|
7783
7704
|
value: function getRelayToParaOverrides() {
|
|
@@ -7945,6 +7866,16 @@ var Curio = /*#__PURE__*/function (_Parachain) {
|
|
|
7945
7866
|
};
|
|
7946
7867
|
return transferXTokens(input, currencySelection);
|
|
7947
7868
|
}
|
|
7869
|
+
}, {
|
|
7870
|
+
key: "isSendingTempDisabled",
|
|
7871
|
+
value: function isSendingTempDisabled(_options) {
|
|
7872
|
+
return true;
|
|
7873
|
+
}
|
|
7874
|
+
}, {
|
|
7875
|
+
key: "isReceivingTempDisabled",
|
|
7876
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
7877
|
+
return true;
|
|
7878
|
+
}
|
|
7948
7879
|
}]);
|
|
7949
7880
|
}(Parachain);
|
|
7950
7881
|
|
|
@@ -8067,7 +7998,7 @@ var EnergyWebXPaseo = /*#__PURE__*/function (_EnergyWebX) {
|
|
|
8067
7998
|
var Heima = /*#__PURE__*/function (_Parachain) {
|
|
8068
7999
|
function Heima() {
|
|
8069
8000
|
var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Heima';
|
|
8070
|
-
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '
|
|
8001
|
+
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'heima';
|
|
8071
8002
|
var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
|
|
8072
8003
|
var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.V5;
|
|
8073
8004
|
_classCallCheck(this, Heima);
|
|
@@ -8239,6 +8170,12 @@ var Polimec = /*#__PURE__*/function (_Parachain) {
|
|
|
8239
8170
|
}
|
|
8240
8171
|
return transferPolkadotXCM;
|
|
8241
8172
|
}()
|
|
8173
|
+
}, {
|
|
8174
|
+
key: "isSendingTempDisabled",
|
|
8175
|
+
value: function isSendingTempDisabled(_ref3) {
|
|
8176
|
+
var assetInfo = _ref3.assetInfo;
|
|
8177
|
+
return isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol());
|
|
8178
|
+
}
|
|
8242
8179
|
}, {
|
|
8243
8180
|
key: "transferRelayToPara",
|
|
8244
8181
|
value: function transferRelayToPara(options) {
|
|
@@ -9175,7 +9112,17 @@ var PAssetHub = /*#__PURE__*/function (_PeoplePolkadot) {
|
|
|
9175
9112
|
return _callSuper(this, PAssetHub, ['PAssetHub', 'PAssetHub - Contracts', 'Paseo', Version.V5]);
|
|
9176
9113
|
}
|
|
9177
9114
|
_inherits(PAssetHub, _PeoplePolkadot);
|
|
9178
|
-
return _createClass(PAssetHub
|
|
9115
|
+
return _createClass(PAssetHub, [{
|
|
9116
|
+
key: "isSendingTempDisabled",
|
|
9117
|
+
value: function isSendingTempDisabled(_options) {
|
|
9118
|
+
return true;
|
|
9119
|
+
}
|
|
9120
|
+
}, {
|
|
9121
|
+
key: "isReceivingTempDisabled",
|
|
9122
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
9123
|
+
return true;
|
|
9124
|
+
}
|
|
9125
|
+
}]);
|
|
9179
9126
|
}(PeoplePolkadot);
|
|
9180
9127
|
|
|
9181
9128
|
var Peaq = /*#__PURE__*/function (_Parachain) {
|
|
@@ -9200,6 +9147,16 @@ var Peaq = /*#__PURE__*/function (_Parachain) {
|
|
|
9200
9147
|
value: function transferRelayToPara() {
|
|
9201
9148
|
throw new ChainNotSupportedError();
|
|
9202
9149
|
}
|
|
9150
|
+
}, {
|
|
9151
|
+
key: "isSendingTempDisabled",
|
|
9152
|
+
value: function isSendingTempDisabled(_options) {
|
|
9153
|
+
return true;
|
|
9154
|
+
}
|
|
9155
|
+
}, {
|
|
9156
|
+
key: "isReceivingTempDisabled",
|
|
9157
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
9158
|
+
return true;
|
|
9159
|
+
}
|
|
9203
9160
|
}, {
|
|
9204
9161
|
key: "transferLocalNonNativeAsset",
|
|
9205
9162
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -9451,8 +9408,17 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
9451
9408
|
return _createClass(RobonomicsPolkadot, [{
|
|
9452
9409
|
key: "transferPolkadotXCM",
|
|
9453
9410
|
value: function transferPolkadotXCM(input) {
|
|
9411
|
+
var scenario = input.scenario;
|
|
9412
|
+
if (scenario === 'ParaToPara') {
|
|
9413
|
+
throw new ScenarioNotSupportedError(this.chain, scenario);
|
|
9414
|
+
}
|
|
9454
9415
|
return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
9455
9416
|
}
|
|
9417
|
+
}, {
|
|
9418
|
+
key: "isReceivingTempDisabled",
|
|
9419
|
+
value: function isReceivingTempDisabled(scenario) {
|
|
9420
|
+
return scenario !== 'RelayToPara';
|
|
9421
|
+
}
|
|
9456
9422
|
}, {
|
|
9457
9423
|
key: "transferLocalNonNativeAsset",
|
|
9458
9424
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -9526,6 +9492,16 @@ var Subsocial = /*#__PURE__*/function (_Parachain) {
|
|
|
9526
9492
|
}
|
|
9527
9493
|
return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
9528
9494
|
}
|
|
9495
|
+
}, {
|
|
9496
|
+
key: "isSendingTempDisabled",
|
|
9497
|
+
value: function isSendingTempDisabled(_options) {
|
|
9498
|
+
return true;
|
|
9499
|
+
}
|
|
9500
|
+
}, {
|
|
9501
|
+
key: "isReceivingTempDisabled",
|
|
9502
|
+
value: function isReceivingTempDisabled(_scenario) {
|
|
9503
|
+
return true;
|
|
9504
|
+
}
|
|
9529
9505
|
}]);
|
|
9530
9506
|
}(Parachain);
|
|
9531
9507
|
|
|
@@ -9608,6 +9584,11 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
|
|
|
9608
9584
|
var currencySelection = this.getCurrencySelection(asset);
|
|
9609
9585
|
return transferXTokens(input, currencySelection);
|
|
9610
9586
|
}
|
|
9587
|
+
}, {
|
|
9588
|
+
key: "canReceiveFrom",
|
|
9589
|
+
value: function canReceiveFrom(origin) {
|
|
9590
|
+
return origin !== 'Astar';
|
|
9591
|
+
}
|
|
9611
9592
|
}, {
|
|
9612
9593
|
key: "transferLocalNonNativeAsset",
|
|
9613
9594
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -9911,10 +9892,17 @@ var dryRunOrigin = /*#__PURE__*/function () {
|
|
|
9911
9892
|
};
|
|
9912
9893
|
}();
|
|
9913
9894
|
|
|
9914
|
-
var
|
|
9895
|
+
var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
|
|
9896
|
+
_classCallCheck(this, BaseAssetsPallet);
|
|
9897
|
+
this.palletName = palletName;
|
|
9898
|
+
});
|
|
9899
|
+
|
|
9900
|
+
var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
9915
9901
|
function AssetManagerPallet() {
|
|
9916
9902
|
_classCallCheck(this, AssetManagerPallet);
|
|
9903
|
+
return _callSuper(this, AssetManagerPallet, arguments);
|
|
9917
9904
|
}
|
|
9905
|
+
_inherits(AssetManagerPallet, _BaseAssetsPallet);
|
|
9918
9906
|
return _createClass(AssetManagerPallet, [{
|
|
9919
9907
|
key: "mint",
|
|
9920
9908
|
value: function mint(address, asset, balance) {
|
|
@@ -9923,7 +9911,7 @@ var AssetManagerPallet = /*#__PURE__*/function () {
|
|
|
9923
9911
|
amount = asset.amount;
|
|
9924
9912
|
return Promise.resolve({
|
|
9925
9913
|
balanceTx: {
|
|
9926
|
-
module:
|
|
9914
|
+
module: this.palletName,
|
|
9927
9915
|
method: 'updateBalance',
|
|
9928
9916
|
parameters: {
|
|
9929
9917
|
who: {
|
|
@@ -9938,12 +9926,59 @@ var AssetManagerPallet = /*#__PURE__*/function () {
|
|
|
9938
9926
|
});
|
|
9939
9927
|
}
|
|
9940
9928
|
}]);
|
|
9941
|
-
}();
|
|
9929
|
+
}(BaseAssetsPallet);
|
|
9942
9930
|
|
|
9943
|
-
var
|
|
9931
|
+
var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
9932
|
+
function AssetsPallet() {
|
|
9933
|
+
_classCallCheck(this, AssetsPallet);
|
|
9934
|
+
return _callSuper(this, AssetsPallet, arguments);
|
|
9935
|
+
}
|
|
9936
|
+
_inherits(AssetsPallet, _BaseAssetsPallet);
|
|
9937
|
+
return _createClass(AssetsPallet, [{
|
|
9938
|
+
key: "mint",
|
|
9939
|
+
value: function mint(address, asset, _balance, chain) {
|
|
9940
|
+
assertHasId(asset);
|
|
9941
|
+
var assetId = asset.assetId,
|
|
9942
|
+
amount = asset.amount;
|
|
9943
|
+
var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
|
|
9944
|
+
var addr = isChainEvm(chain) ? address : {
|
|
9945
|
+
Id: address
|
|
9946
|
+
};
|
|
9947
|
+
return Promise.resolve({
|
|
9948
|
+
assetStatusTx: {
|
|
9949
|
+
module: this.palletName,
|
|
9950
|
+
method: 'force_asset_status',
|
|
9951
|
+
parameters: {
|
|
9952
|
+
id: id,
|
|
9953
|
+
owner: addr,
|
|
9954
|
+
issuer: addr,
|
|
9955
|
+
admin: addr,
|
|
9956
|
+
freezer: addr,
|
|
9957
|
+
min_balance: 0n,
|
|
9958
|
+
is_sufficient: true,
|
|
9959
|
+
is_frozen: false
|
|
9960
|
+
}
|
|
9961
|
+
},
|
|
9962
|
+
balanceTx: {
|
|
9963
|
+
module: this.palletName,
|
|
9964
|
+
method: 'mint',
|
|
9965
|
+
parameters: {
|
|
9966
|
+
id: id,
|
|
9967
|
+
beneficiary: addr,
|
|
9968
|
+
amount: amount
|
|
9969
|
+
}
|
|
9970
|
+
}
|
|
9971
|
+
});
|
|
9972
|
+
}
|
|
9973
|
+
}]);
|
|
9974
|
+
}(BaseAssetsPallet);
|
|
9975
|
+
|
|
9976
|
+
var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
9944
9977
|
function BalancesPallet() {
|
|
9945
9978
|
_classCallCheck(this, BalancesPallet);
|
|
9979
|
+
return _callSuper(this, BalancesPallet, arguments);
|
|
9946
9980
|
}
|
|
9981
|
+
_inherits(BalancesPallet, _BaseAssetsPallet);
|
|
9947
9982
|
return _createClass(BalancesPallet, [{
|
|
9948
9983
|
key: "mint",
|
|
9949
9984
|
value: function mint(address, assetInfo, balance, chain) {
|
|
@@ -9951,7 +9986,7 @@ var BalancesPallet = /*#__PURE__*/function () {
|
|
|
9951
9986
|
var notUseId = chain.startsWith('Hydration') || chain === 'Basilisk' || isChainEvm(chain);
|
|
9952
9987
|
return Promise.resolve({
|
|
9953
9988
|
balanceTx: {
|
|
9954
|
-
module:
|
|
9989
|
+
module: this.palletName,
|
|
9955
9990
|
method: 'force_set_balance',
|
|
9956
9991
|
parameters: {
|
|
9957
9992
|
who: notUseId ? address : {
|
|
@@ -9963,12 +9998,14 @@ var BalancesPallet = /*#__PURE__*/function () {
|
|
|
9963
9998
|
});
|
|
9964
9999
|
}
|
|
9965
10000
|
}]);
|
|
9966
|
-
}();
|
|
10001
|
+
}(BaseAssetsPallet);
|
|
9967
10002
|
|
|
9968
|
-
var CurrenciesPallet = /*#__PURE__*/function () {
|
|
10003
|
+
var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
9969
10004
|
function CurrenciesPallet() {
|
|
9970
10005
|
_classCallCheck(this, CurrenciesPallet);
|
|
10006
|
+
return _callSuper(this, CurrenciesPallet, arguments);
|
|
9971
10007
|
}
|
|
10008
|
+
_inherits(CurrenciesPallet, _BaseAssetsPallet);
|
|
9972
10009
|
return _createClass(CurrenciesPallet, [{
|
|
9973
10010
|
key: "mint",
|
|
9974
10011
|
value: function mint(address, assetInfo, balance) {
|
|
@@ -9977,7 +10014,7 @@ var CurrenciesPallet = /*#__PURE__*/function () {
|
|
|
9977
10014
|
amount = assetInfo.amount;
|
|
9978
10015
|
return Promise.resolve({
|
|
9979
10016
|
balanceTx: {
|
|
9980
|
-
module:
|
|
10017
|
+
module: this.palletName,
|
|
9981
10018
|
method: 'update_balance',
|
|
9982
10019
|
parameters: {
|
|
9983
10020
|
who: address,
|
|
@@ -9988,12 +10025,14 @@ var CurrenciesPallet = /*#__PURE__*/function () {
|
|
|
9988
10025
|
});
|
|
9989
10026
|
}
|
|
9990
10027
|
}]);
|
|
9991
|
-
}();
|
|
10028
|
+
}(BaseAssetsPallet);
|
|
9992
10029
|
|
|
9993
|
-
var ForeignAssetsPallet = /*#__PURE__*/function () {
|
|
10030
|
+
var ForeignAssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
9994
10031
|
function ForeignAssetsPallet() {
|
|
9995
10032
|
_classCallCheck(this, ForeignAssetsPallet);
|
|
10033
|
+
return _callSuper(this, ForeignAssetsPallet, arguments);
|
|
9996
10034
|
}
|
|
10035
|
+
_inherits(ForeignAssetsPallet, _BaseAssetsPallet);
|
|
9997
10036
|
return _createClass(ForeignAssetsPallet, [{
|
|
9998
10037
|
key: "mint",
|
|
9999
10038
|
value: function mint(address, asset) {
|
|
@@ -10002,7 +10041,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
|
|
|
10002
10041
|
amount = asset.amount;
|
|
10003
10042
|
return Promise.resolve({
|
|
10004
10043
|
assetStatusTx: {
|
|
10005
|
-
module:
|
|
10044
|
+
module: this.palletName,
|
|
10006
10045
|
method: 'force_asset_status',
|
|
10007
10046
|
parameters: {
|
|
10008
10047
|
id: location,
|
|
@@ -10024,7 +10063,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
|
|
|
10024
10063
|
}
|
|
10025
10064
|
},
|
|
10026
10065
|
balanceTx: {
|
|
10027
|
-
module:
|
|
10066
|
+
module: this.palletName,
|
|
10028
10067
|
method: 'mint',
|
|
10029
10068
|
parameters: {
|
|
10030
10069
|
id: location,
|
|
@@ -10037,7 +10076,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
|
|
|
10037
10076
|
});
|
|
10038
10077
|
}
|
|
10039
10078
|
}]);
|
|
10040
|
-
}();
|
|
10079
|
+
}(BaseAssetsPallet);
|
|
10041
10080
|
|
|
10042
10081
|
var SIZE = 32;
|
|
10043
10082
|
var BALANCE_SLOT = 0;
|
|
@@ -10052,10 +10091,12 @@ var calculateMappingSlot = function calculateMappingSlot(key) {
|
|
|
10052
10091
|
var encoded = concat([keyPadded, slotHex]);
|
|
10053
10092
|
return keccak256(encoded);
|
|
10054
10093
|
};
|
|
10055
|
-
var SystemPallet = /*#__PURE__*/function () {
|
|
10094
|
+
var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
10056
10095
|
function SystemPallet() {
|
|
10057
10096
|
_classCallCheck(this, SystemPallet);
|
|
10097
|
+
return _callSuper(this, SystemPallet, arguments);
|
|
10058
10098
|
}
|
|
10099
|
+
_inherits(SystemPallet, _BaseAssetsPallet);
|
|
10059
10100
|
return _createClass(SystemPallet, [{
|
|
10060
10101
|
key: "mint",
|
|
10061
10102
|
value: function () {
|
|
@@ -10076,7 +10117,7 @@ var SystemPallet = /*#__PURE__*/function () {
|
|
|
10076
10117
|
storageKey = _context.v;
|
|
10077
10118
|
return _context.a(2, {
|
|
10078
10119
|
balanceTx: {
|
|
10079
|
-
module:
|
|
10120
|
+
module: this.palletName,
|
|
10080
10121
|
method: 'set_storage',
|
|
10081
10122
|
parameters: {
|
|
10082
10123
|
items: [[storageKey, amountEncoded]]
|
|
@@ -10084,7 +10125,7 @@ var SystemPallet = /*#__PURE__*/function () {
|
|
|
10084
10125
|
}
|
|
10085
10126
|
});
|
|
10086
10127
|
}
|
|
10087
|
-
}, _callee);
|
|
10128
|
+
}, _callee, this);
|
|
10088
10129
|
}));
|
|
10089
10130
|
function mint(_x, _x2, _x3, _x4, _x5) {
|
|
10090
10131
|
return _mint.apply(this, arguments);
|
|
@@ -10092,12 +10133,14 @@ var SystemPallet = /*#__PURE__*/function () {
|
|
|
10092
10133
|
return mint;
|
|
10093
10134
|
}()
|
|
10094
10135
|
}]);
|
|
10095
|
-
}();
|
|
10136
|
+
}(BaseAssetsPallet);
|
|
10096
10137
|
|
|
10097
|
-
var TokensPallet = /*#__PURE__*/function () {
|
|
10138
|
+
var TokensPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
10098
10139
|
function TokensPallet() {
|
|
10099
10140
|
_classCallCheck(this, TokensPallet);
|
|
10141
|
+
return _callSuper(this, TokensPallet, arguments);
|
|
10100
10142
|
}
|
|
10143
|
+
_inherits(TokensPallet, _BaseAssetsPallet);
|
|
10101
10144
|
return _createClass(TokensPallet, [{
|
|
10102
10145
|
key: "mint",
|
|
10103
10146
|
value: function mint(address, asset, balance, chain) {
|
|
@@ -10107,7 +10150,7 @@ var TokensPallet = /*#__PURE__*/function () {
|
|
|
10107
10150
|
var amount = asset.amount;
|
|
10108
10151
|
return Promise.resolve({
|
|
10109
10152
|
balanceTx: {
|
|
10110
|
-
module:
|
|
10153
|
+
module: this.palletName,
|
|
10111
10154
|
method: 'set_balance',
|
|
10112
10155
|
parameters: {
|
|
10113
10156
|
who: {
|
|
@@ -10121,35 +10164,93 @@ var TokensPallet = /*#__PURE__*/function () {
|
|
|
10121
10164
|
});
|
|
10122
10165
|
}
|
|
10123
10166
|
}]);
|
|
10124
|
-
}();
|
|
10167
|
+
}(BaseAssetsPallet);
|
|
10125
10168
|
|
|
10126
10169
|
var palletRegistry = {
|
|
10127
|
-
Balances: BalancesPallet,
|
|
10128
|
-
Tokens: TokensPallet,
|
|
10129
|
-
Currencies: CurrenciesPallet,
|
|
10130
|
-
Assets: AssetsPallet,
|
|
10131
|
-
ForeignAssets: ForeignAssetsPallet,
|
|
10132
|
-
AssetManager: AssetManagerPallet,
|
|
10133
|
-
System: SystemPallet
|
|
10170
|
+
Balances: new BalancesPallet('Balances'),
|
|
10171
|
+
Tokens: new TokensPallet('Tokens'),
|
|
10172
|
+
Currencies: new CurrenciesPallet('Currencies'),
|
|
10173
|
+
Assets: new AssetsPallet('Assets'),
|
|
10174
|
+
ForeignAssets: new ForeignAssetsPallet('ForeignAssets'),
|
|
10175
|
+
AssetManager: new AssetManagerPallet('AssetManager'),
|
|
10176
|
+
System: new SystemPallet('System'),
|
|
10177
|
+
Fungibles: new AssetsPallet('Fungibles')
|
|
10134
10178
|
};
|
|
10135
10179
|
var getPalletInstance = function getPalletInstance(type) {
|
|
10136
|
-
|
|
10137
|
-
return new HandlerClass();
|
|
10180
|
+
return palletRegistry[type];
|
|
10138
10181
|
};
|
|
10139
10182
|
|
|
10140
|
-
var
|
|
10141
|
-
|
|
10142
|
-
|
|
10183
|
+
var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
|
|
10184
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
10185
|
+
var _getExistentialDeposi;
|
|
10186
|
+
var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
|
|
10187
|
+
return _regenerator().w(function (_context) {
|
|
10188
|
+
while (1) switch (_context.n) {
|
|
10189
|
+
case 0:
|
|
10190
|
+
api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
10191
|
+
_context.n = 1;
|
|
10192
|
+
return api.init(origin);
|
|
10193
|
+
case 1:
|
|
10194
|
+
_context.n = 2;
|
|
10195
|
+
return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
|
|
10196
|
+
case 2:
|
|
10197
|
+
tx = _context.v;
|
|
10198
|
+
_context.n = 3;
|
|
10199
|
+
return api.calculateTransactionFee(tx, account);
|
|
10200
|
+
case 3:
|
|
10201
|
+
xcmFee = _context.v;
|
|
10202
|
+
xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
|
|
10203
|
+
_context.n = 4;
|
|
10204
|
+
return getBalanceNativeInternal({
|
|
10205
|
+
address: account,
|
|
10206
|
+
chain: origin,
|
|
10207
|
+
api: api
|
|
10208
|
+
});
|
|
10209
|
+
case 4:
|
|
10210
|
+
nativeBalance = _context.v;
|
|
10211
|
+
existentialDeposit = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
|
|
10212
|
+
sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
|
|
10213
|
+
return _context.a(2, {
|
|
10214
|
+
sufficientForXCM: sufficientForXCM,
|
|
10215
|
+
xcmFee: xcmFee
|
|
10216
|
+
});
|
|
10217
|
+
}
|
|
10218
|
+
}, _callee);
|
|
10219
|
+
}));
|
|
10220
|
+
return function getOriginFeeDetailsInternal(_x) {
|
|
10221
|
+
return _ref2.apply(this, arguments);
|
|
10143
10222
|
};
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10223
|
+
}();
|
|
10224
|
+
var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
10225
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
10226
|
+
var api;
|
|
10227
|
+
return _regenerator().w(function (_context2) {
|
|
10228
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
10229
|
+
case 0:
|
|
10230
|
+
api = options.api;
|
|
10231
|
+
api.setDisconnectAllowed(false);
|
|
10232
|
+
_context2.p = 1;
|
|
10233
|
+
_context2.n = 2;
|
|
10234
|
+
return getOriginFeeDetailsInternal(options);
|
|
10235
|
+
case 2:
|
|
10236
|
+
return _context2.a(2, _context2.v);
|
|
10237
|
+
case 3:
|
|
10238
|
+
_context2.p = 3;
|
|
10239
|
+
api.setDisconnectAllowed(true);
|
|
10240
|
+
_context2.n = 4;
|
|
10241
|
+
return api.disconnect();
|
|
10242
|
+
case 4:
|
|
10243
|
+
return _context2.f(3);
|
|
10244
|
+
case 5:
|
|
10245
|
+
return _context2.a(2);
|
|
10246
|
+
}
|
|
10247
|
+
}, _callee2, null, [[1,, 3, 5]]);
|
|
10248
|
+
}));
|
|
10249
|
+
return function getOriginFeeDetails(_x2) {
|
|
10250
|
+
return _ref3.apply(this, arguments);
|
|
10151
10251
|
};
|
|
10152
|
-
};
|
|
10252
|
+
}();
|
|
10253
|
+
|
|
10153
10254
|
var pickOtherPallet = function pickOtherPallet(asset, pallets) {
|
|
10154
10255
|
if (isForeignAsset(asset) && (!asset.assetId || asset.assetId.startsWith('0x'))) {
|
|
10155
10256
|
var _pallets$find;
|
|
@@ -11505,6 +11606,7 @@ var send = /*#__PURE__*/function () {
|
|
|
11505
11606
|
origin: origin,
|
|
11506
11607
|
destination: destination,
|
|
11507
11608
|
address: address,
|
|
11609
|
+
senderAddress: senderAddress,
|
|
11508
11610
|
assetInfo: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
11509
11611
|
amount: finalAmount
|
|
11510
11612
|
}),
|
|
@@ -12245,12 +12347,13 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12245
12347
|
}();
|
|
12246
12348
|
var computeAllFees = /*#__PURE__*/function () {
|
|
12247
12349
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3, customXcm, isDotAsset, refundInstruction) {
|
|
12350
|
+
var _customXcm$DepositRes;
|
|
12248
12351
|
var reserve, dest, version, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
12249
12352
|
return _regenerator().w(function (_context2) {
|
|
12250
12353
|
while (1) switch (_context2.n) {
|
|
12251
12354
|
case 0:
|
|
12252
12355
|
reserve = _ref3.reserve, dest = _ref3.dest, version = _ref3.options.version;
|
|
12253
|
-
if (!('DepositReserveAsset' in customXcm)) {
|
|
12356
|
+
if (!('DepositReserveAsset' in customXcm || 'InitiateTeleport' in customXcm)) {
|
|
12254
12357
|
_context2.n = 6;
|
|
12255
12358
|
break;
|
|
12256
12359
|
}
|
|
@@ -12273,7 +12376,7 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12273
12376
|
case 4:
|
|
12274
12377
|
_t5 = _t4;
|
|
12275
12378
|
_context2.n = 5;
|
|
12276
|
-
return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm.DepositReserveAsset.xcm);
|
|
12379
|
+
return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, ((_customXcm$DepositRes = customXcm === null || customXcm === void 0 ? void 0 : customXcm.DepositReserveAsset) !== null && _customXcm$DepositRes !== void 0 ? _customXcm$DepositRes : customXcm.InitiateTeleport).xcm);
|
|
12277
12380
|
case 5:
|
|
12278
12381
|
_t6 = _context2.v;
|
|
12279
12382
|
_t2 = {
|
|
@@ -12328,7 +12431,7 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
12328
12431
|
}();
|
|
12329
12432
|
|
|
12330
12433
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
12331
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12434
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12332
12435
|
var api, destChain, assetInfo, reserveChain, destApi, reserveApi;
|
|
12333
12436
|
return _regenerator().w(function (_context) {
|
|
12334
12437
|
while (1) switch (_context.n) {
|
|
@@ -12341,12 +12444,14 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12341
12444
|
}
|
|
12342
12445
|
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
12343
12446
|
case 1:
|
|
12344
|
-
reserveChain =
|
|
12447
|
+
reserveChain = overrideReserve !== undefined ? overrideReserve :
|
|
12448
|
+
// Paseo ecosystem migrated reserves to AssetHub
|
|
12449
|
+
getRelayChainOf(chain) === 'Paseo' ? getAssetReserveChain(chain, chain, assetInfo.location) : isRelayChain(destChain) ? destChain : getAssetReserveChain(chain, chain, assetInfo.location);
|
|
12345
12450
|
destApi = api.clone();
|
|
12346
12451
|
_context.n = 2;
|
|
12347
12452
|
return destApi.init(destChain);
|
|
12348
12453
|
case 2:
|
|
12349
|
-
reserveApi = reserveChain
|
|
12454
|
+
reserveApi = reserveChain === chain ? api : reserveChain === destChain ? destApi : api.clone();
|
|
12350
12455
|
_context.n = 3;
|
|
12351
12456
|
return reserveApi.init(reserveChain);
|
|
12352
12457
|
case 3:
|
|
@@ -12369,7 +12474,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12369
12474
|
}
|
|
12370
12475
|
}, _callee);
|
|
12371
12476
|
}));
|
|
12372
|
-
return function createTypeAndThenCallContext(_x, _x2) {
|
|
12477
|
+
return function createTypeAndThenCallContext(_x, _x2, _x3) {
|
|
12373
12478
|
return _ref.apply(this, arguments);
|
|
12374
12479
|
};
|
|
12375
12480
|
}();
|
|
@@ -12417,20 +12522,33 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12417
12522
|
if (origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12418
12523
|
var buyExecutionAmount = !isDotAsset ? destFee : assetInfo.amount - reserveFee - refundFee;
|
|
12419
12524
|
if (buyExecutionAmount < 0n) throw new AmountTooLowError();
|
|
12525
|
+
var filter = fees.destFee === MIN_FEE ? {
|
|
12526
|
+
Wild: 'All'
|
|
12527
|
+
} : {
|
|
12528
|
+
Definite: assetsFilter
|
|
12529
|
+
};
|
|
12530
|
+
var buyExecution = {
|
|
12531
|
+
BuyExecution: {
|
|
12532
|
+
fees: createAsset(version, buyExecutionAmount, feeAssetLocation),
|
|
12533
|
+
weight_limit: 'Unlimited'
|
|
12534
|
+
}
|
|
12535
|
+
};
|
|
12536
|
+
var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
|
|
12537
|
+
// If destination is a system chain, use teleport instead of reserve deposit
|
|
12538
|
+
if (isSystemChain(dest.chain)) {
|
|
12539
|
+
return {
|
|
12540
|
+
InitiateTeleport: {
|
|
12541
|
+
assets: filter,
|
|
12542
|
+
dest: destLoc,
|
|
12543
|
+
xcm: [buyExecution, depositInstruction]
|
|
12544
|
+
}
|
|
12545
|
+
};
|
|
12546
|
+
}
|
|
12420
12547
|
return {
|
|
12421
12548
|
DepositReserveAsset: {
|
|
12422
|
-
assets:
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
Definite: assetsFilter
|
|
12426
|
-
},
|
|
12427
|
-
dest: createDestination(version, origin.chain, destination, paraIdTo),
|
|
12428
|
-
xcm: [{
|
|
12429
|
-
BuyExecution: {
|
|
12430
|
-
fees: createAsset(version, buyExecutionAmount, feeAssetLocation),
|
|
12431
|
-
weight_limit: 'Unlimited'
|
|
12432
|
-
}
|
|
12433
|
-
}, depositInstruction]
|
|
12549
|
+
assets: filter,
|
|
12550
|
+
dest: destLoc,
|
|
12551
|
+
xcm: [buyExecution, depositInstruction]
|
|
12434
12552
|
}
|
|
12435
12553
|
};
|
|
12436
12554
|
}
|
|
@@ -12468,14 +12586,14 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12468
12586
|
* Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
|
|
12469
12587
|
*/
|
|
12470
12588
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12471
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12589
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12472
12590
|
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12473
12591
|
return _regenerator().w(function (_context) {
|
|
12474
12592
|
while (1) switch (_context.n) {
|
|
12475
12593
|
case 0:
|
|
12476
12594
|
api = options.api, senderAddress = options.senderAddress, version = options.version;
|
|
12477
12595
|
_context.n = 1;
|
|
12478
|
-
return createTypeAndThenCallContext(chain, options);
|
|
12596
|
+
return createTypeAndThenCallContext(chain, options, overrideReserve);
|
|
12479
12597
|
case 1:
|
|
12480
12598
|
context = _context.v;
|
|
12481
12599
|
assetInfo = context.assetInfo;
|
|
@@ -12505,11 +12623,184 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12505
12623
|
}
|
|
12506
12624
|
}, _callee);
|
|
12507
12625
|
}));
|
|
12508
|
-
return function createTypeAndThenCall(_x, _x2) {
|
|
12626
|
+
return function createTypeAndThenCall(_x, _x2, _x3) {
|
|
12509
12627
|
return _ref.apply(this, arguments);
|
|
12510
12628
|
};
|
|
12511
12629
|
}();
|
|
12512
12630
|
|
|
12631
|
+
/**
|
|
12632
|
+
* Choose a reserve (AssetHub or Relay) by checking the beneficiary’s balance on each.
|
|
12633
|
+
* We resolve the beneficiary account on every candidate and return the first with
|
|
12634
|
+
* balance \>= amount, or undefined if none qualify.
|
|
12635
|
+
*/
|
|
12636
|
+
var selectReserveByBalance = /*#__PURE__*/function () {
|
|
12637
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12638
|
+
var api, assetInfo, destination, version, paraIdTo, relay, candidates, _i, _candidates, reserve, reserveApi, location, resolvedAddress, balance;
|
|
12639
|
+
return _regenerator().w(function (_context) {
|
|
12640
|
+
while (1) switch (_context.n) {
|
|
12641
|
+
case 0:
|
|
12642
|
+
api = options.api, assetInfo = options.assetInfo, destination = options.destination, version = options.version, paraIdTo = options.paraIdTo;
|
|
12643
|
+
relay = getRelayChainOf(chain);
|
|
12644
|
+
candidates = ["AssetHub".concat(relay), relay];
|
|
12645
|
+
_i = 0, _candidates = candidates;
|
|
12646
|
+
case 1:
|
|
12647
|
+
if (!(_i < _candidates.length)) {
|
|
12648
|
+
_context.n = 7;
|
|
12649
|
+
break;
|
|
12650
|
+
}
|
|
12651
|
+
reserve = _candidates[_i];
|
|
12652
|
+
reserveApi = api.clone();
|
|
12653
|
+
_context.n = 2;
|
|
12654
|
+
return reserveApi.init(reserve);
|
|
12655
|
+
case 2:
|
|
12656
|
+
location = createDestination(version, chain, destination, paraIdTo);
|
|
12657
|
+
_context.n = 3;
|
|
12658
|
+
return reserveApi.convertLocationToAccount(location);
|
|
12659
|
+
case 3:
|
|
12660
|
+
resolvedAddress = _context.v;
|
|
12661
|
+
if (resolvedAddress) {
|
|
12662
|
+
_context.n = 4;
|
|
12663
|
+
break;
|
|
12664
|
+
}
|
|
12665
|
+
return _context.a(3, 6);
|
|
12666
|
+
case 4:
|
|
12667
|
+
assertAddressIsString(resolvedAddress);
|
|
12668
|
+
_context.n = 5;
|
|
12669
|
+
return getAssetBalanceInternal({
|
|
12670
|
+
api: reserveApi,
|
|
12671
|
+
chain: reserve,
|
|
12672
|
+
address: resolvedAddress,
|
|
12673
|
+
currency: getCurrencySelection(assetInfo)
|
|
12674
|
+
});
|
|
12675
|
+
case 5:
|
|
12676
|
+
balance = _context.v;
|
|
12677
|
+
if (!(balance >= assetInfo.amount)) {
|
|
12678
|
+
_context.n = 6;
|
|
12679
|
+
break;
|
|
12680
|
+
}
|
|
12681
|
+
return _context.a(2, reserve);
|
|
12682
|
+
case 6:
|
|
12683
|
+
_i++;
|
|
12684
|
+
_context.n = 1;
|
|
12685
|
+
break;
|
|
12686
|
+
case 7:
|
|
12687
|
+
return _context.a(2, undefined);
|
|
12688
|
+
}
|
|
12689
|
+
}, _callee);
|
|
12690
|
+
}));
|
|
12691
|
+
return function selectReserveByBalance(_x, _x2) {
|
|
12692
|
+
return _ref.apply(this, arguments);
|
|
12693
|
+
};
|
|
12694
|
+
}();
|
|
12695
|
+
|
|
12696
|
+
var createCallForReserve = /*#__PURE__*/function () {
|
|
12697
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, reserveChain, options) {
|
|
12698
|
+
var api, destination, address, senderAddress, currency, feeCurrency, serialized, tx, dryRunResult, success;
|
|
12699
|
+
return _regenerator().w(function (_context) {
|
|
12700
|
+
while (1) switch (_context.n) {
|
|
12701
|
+
case 0:
|
|
12702
|
+
api = options.api, destination = options.destination, address = options.address, senderAddress = options.senderAddress, currency = options.currency, feeCurrency = options.feeCurrency;
|
|
12703
|
+
_context.n = 1;
|
|
12704
|
+
return createTypeAndThenCall(chain, options, reserveChain);
|
|
12705
|
+
case 1:
|
|
12706
|
+
serialized = _context.v;
|
|
12707
|
+
assertAddressIsString(address);
|
|
12708
|
+
assertToIsString(destination, 'Location destination is not supported for reserve auto-selection.');
|
|
12709
|
+
assertSenderAddress(senderAddress);
|
|
12710
|
+
tx = api.callTxMethod(serialized);
|
|
12711
|
+
_context.n = 2;
|
|
12712
|
+
return dryRunInternal({
|
|
12713
|
+
api: api,
|
|
12714
|
+
tx: tx,
|
|
12715
|
+
origin: chain,
|
|
12716
|
+
destination: destination,
|
|
12717
|
+
address: address,
|
|
12718
|
+
senderAddress: senderAddress,
|
|
12719
|
+
currency: currency,
|
|
12720
|
+
feeAsset: feeCurrency,
|
|
12721
|
+
useRootOrigin: true
|
|
12722
|
+
});
|
|
12723
|
+
case 2:
|
|
12724
|
+
dryRunResult = _context.v;
|
|
12725
|
+
success = !dryRunResult.failureReason;
|
|
12726
|
+
return _context.a(2, {
|
|
12727
|
+
call: serialized,
|
|
12728
|
+
success: success
|
|
12729
|
+
});
|
|
12730
|
+
}
|
|
12731
|
+
}, _callee);
|
|
12732
|
+
}));
|
|
12733
|
+
return function createCallForReserve(_x, _x2, _x3) {
|
|
12734
|
+
return _ref.apply(this, arguments);
|
|
12735
|
+
};
|
|
12736
|
+
}();
|
|
12737
|
+
/**
|
|
12738
|
+
* Creates a type-and-then call but auto-selects the asset reserve between AssetHub and the Relay chain
|
|
12739
|
+
* by dry-running both variants and preferring the one that succeeds. If both fail, returns the
|
|
12740
|
+
* AssetHub variant. Supports only relaychain assets.
|
|
12741
|
+
*/
|
|
12742
|
+
var createTypeThenAutoReserve = /*#__PURE__*/function () {
|
|
12743
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain, options) {
|
|
12744
|
+
var originSupports, destSupports, reserve, relay, assetHubReserve, ahResult, relayResult;
|
|
12745
|
+
return _regenerator().w(function (_context2) {
|
|
12746
|
+
while (1) switch (_context2.n) {
|
|
12747
|
+
case 0:
|
|
12748
|
+
// Use dry-run path only when BOTH origin and destination support it
|
|
12749
|
+
originSupports = hasDryRunSupport(chain);
|
|
12750
|
+
destSupports = options.destChain ? hasDryRunSupport(options.destChain) : false;
|
|
12751
|
+
if (originSupports && destSupports) {
|
|
12752
|
+
_context2.n = 5;
|
|
12753
|
+
break;
|
|
12754
|
+
}
|
|
12755
|
+
_context2.n = 1;
|
|
12756
|
+
return selectReserveByBalance(chain, options);
|
|
12757
|
+
case 1:
|
|
12758
|
+
reserve = _context2.v;
|
|
12759
|
+
if (!reserve) {
|
|
12760
|
+
_context2.n = 3;
|
|
12761
|
+
break;
|
|
12762
|
+
}
|
|
12763
|
+
_context2.n = 2;
|
|
12764
|
+
return createTypeAndThenCall(chain, options, reserve);
|
|
12765
|
+
case 2:
|
|
12766
|
+
return _context2.a(2, _context2.v);
|
|
12767
|
+
case 3:
|
|
12768
|
+
_context2.n = 4;
|
|
12769
|
+
return createTypeAndThenCall(chain, options);
|
|
12770
|
+
case 4:
|
|
12771
|
+
return _context2.a(2, _context2.v);
|
|
12772
|
+
case 5:
|
|
12773
|
+
relay = getRelayChainOf(chain);
|
|
12774
|
+
assetHubReserve = "AssetHub".concat(relay);
|
|
12775
|
+
_context2.n = 6;
|
|
12776
|
+
return createCallForReserve(chain, assetHubReserve, options);
|
|
12777
|
+
case 6:
|
|
12778
|
+
ahResult = _context2.v;
|
|
12779
|
+
if (!ahResult.success) {
|
|
12780
|
+
_context2.n = 7;
|
|
12781
|
+
break;
|
|
12782
|
+
}
|
|
12783
|
+
return _context2.a(2, ahResult.call);
|
|
12784
|
+
case 7:
|
|
12785
|
+
_context2.n = 8;
|
|
12786
|
+
return createCallForReserve(chain, relay, options);
|
|
12787
|
+
case 8:
|
|
12788
|
+
relayResult = _context2.v;
|
|
12789
|
+
if (!relayResult.success) {
|
|
12790
|
+
_context2.n = 9;
|
|
12791
|
+
break;
|
|
12792
|
+
}
|
|
12793
|
+
return _context2.a(2, relayResult.call);
|
|
12794
|
+
case 9:
|
|
12795
|
+
return _context2.a(2, ahResult.call);
|
|
12796
|
+
}
|
|
12797
|
+
}, _callee2);
|
|
12798
|
+
}));
|
|
12799
|
+
return function createTypeThenAutoReserve(_x4, _x5) {
|
|
12800
|
+
return _ref2.apply(this, arguments);
|
|
12801
|
+
};
|
|
12802
|
+
}();
|
|
12803
|
+
|
|
12513
12804
|
var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
12514
12805
|
var _feeResult$assetHub;
|
|
12515
12806
|
var totalFee = 0n;
|
|
@@ -13567,4 +13858,4 @@ var Builder = function Builder(api) {
|
|
|
13567
13858
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
13568
13859
|
};
|
|
13569
13860
|
|
|
13570
|
-
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee, padFeeBy, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };
|
|
13861
|
+
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee, padFeeBy, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };
|