@paraspell/sdk-core 10.10.3 → 10.10.5
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 +764 -678
- package/dist/index.d.ts +85 -13
- package/dist/index.mjs +764 -680
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, extractMultiAssetLoc, isAssetEqual, isForeignAsset, findAssetForNodeOrThrow, getExistentialDeposit,
|
|
2
|
+
import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, extractMultiAssetLoc, isAssetEqual, isForeignAsset, findAssetForNodeOrThrow, getExistentialDeposit, findAsset, isTMultiAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAssetOnDestOrThrow, hasSupportForAsset, getRelayChainSymbol, isSymbolSpecifier, normalizeMultiLocation, normalizeSymbol, getAssetId, getNativeAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, createPublicClient, http, getContract } from 'viem';
|
|
@@ -3303,7 +3303,7 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, origin,
|
|
|
3303
3303
|
version: version
|
|
3304
3304
|
});
|
|
3305
3305
|
assertHasLocation(asset);
|
|
3306
|
-
var transformedMultiLocation = localizeLocation(
|
|
3306
|
+
var transformedMultiLocation = localizeLocation(origin, asset.multiLocation);
|
|
3307
3307
|
var call = {
|
|
3308
3308
|
module: 'PolkadotXcm',
|
|
3309
3309
|
method: 'execute',
|
|
@@ -3959,6 +3959,324 @@ var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
|
3959
3959
|
};
|
|
3960
3960
|
}();
|
|
3961
3961
|
|
|
3962
|
+
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
3963
|
+
var asset = findAsset(origin, feeAsset, !isTMultiLocation(destination) ? destination : null);
|
|
3964
|
+
var usesRawOverriddenMultiAssets = 'multiasset' in currency && currency.multiasset.every(isTMultiAsset);
|
|
3965
|
+
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
3966
|
+
throwUnsupportedCurrency(feeAsset, origin);
|
|
3967
|
+
}
|
|
3968
|
+
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
3969
|
+
};
|
|
3970
|
+
|
|
3971
|
+
var isAssetHub = function isAssetHub(chain) {
|
|
3972
|
+
return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
|
|
3973
|
+
};
|
|
3974
|
+
var isBridgeHub = function isBridgeHub(chain) {
|
|
3975
|
+
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
3976
|
+
};
|
|
3977
|
+
var isPeople = function isPeople(chain) {
|
|
3978
|
+
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
3979
|
+
};
|
|
3980
|
+
var isSystemPara = function isSystemPara(chain) {
|
|
3981
|
+
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
3982
|
+
};
|
|
3983
|
+
var mul = function mul(v, num) {
|
|
3984
|
+
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
3985
|
+
return v * num / den;
|
|
3986
|
+
};
|
|
3987
|
+
var padFee = function padFee(raw, origin, dest, side) {
|
|
3988
|
+
var relayOrigin = isRelayChain(origin);
|
|
3989
|
+
var relayDest = isRelayChain(dest);
|
|
3990
|
+
var sysParaOrigin = isSystemPara(origin);
|
|
3991
|
+
var sysParaDest = isSystemPara(dest);
|
|
3992
|
+
var relayToPara = relayOrigin && !relayDest;
|
|
3993
|
+
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
3994
|
+
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
3995
|
+
if (sysParaToPara) return raw * 40n;
|
|
3996
|
+
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
3997
|
+
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
3998
|
+
return 150000000000000000n;
|
|
3999
|
+
}
|
|
4000
|
+
if (paraToPara) return mul(raw, 130n, 100n);
|
|
4001
|
+
// apply default 30% padding
|
|
4002
|
+
return mul(raw, 130n, 100n);
|
|
4003
|
+
};
|
|
4004
|
+
var padFeeBy = function padFeeBy(amount, percent) {
|
|
4005
|
+
return mul(amount, BigInt(100 + percent), 100n);
|
|
4006
|
+
};
|
|
4007
|
+
|
|
4008
|
+
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
4009
|
+
if (isNodeEvm(chain)) {
|
|
4010
|
+
return isAddress(address) ? address : senderAddress;
|
|
4011
|
+
}
|
|
4012
|
+
return isAddress(address) ? senderAddress : address;
|
|
4013
|
+
};
|
|
4014
|
+
var getReverseTxFee = /*#__PURE__*/function () {
|
|
4015
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
4016
|
+
var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
|
|
4017
|
+
return _regenerator().w(function (_context) {
|
|
4018
|
+
while (1) switch (_context.n) {
|
|
4019
|
+
case 0:
|
|
4020
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
|
|
4021
|
+
toAddress = determineAddress(origin, address, senderAddress);
|
|
4022
|
+
fromAddress = determineAddress(destination, address, senderAddress);
|
|
4023
|
+
_context.n = 1;
|
|
4024
|
+
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
|
|
4025
|
+
amount: currency.amount
|
|
4026
|
+
})).build();
|
|
4027
|
+
case 1:
|
|
4028
|
+
tx = _context.v;
|
|
4029
|
+
_context.n = 2;
|
|
4030
|
+
return api.calculateTransactionFee(tx, fromAddress);
|
|
4031
|
+
case 2:
|
|
4032
|
+
rawFee = _context.v;
|
|
4033
|
+
return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
|
|
4034
|
+
}
|
|
4035
|
+
}, _callee);
|
|
4036
|
+
}));
|
|
4037
|
+
return function getReverseTxFee(_x, _x2) {
|
|
4038
|
+
return _ref2.apply(this, arguments);
|
|
4039
|
+
};
|
|
4040
|
+
}();
|
|
4041
|
+
|
|
4042
|
+
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4043
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
4044
|
+
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
4045
|
+
return _regenerator().w(function (_context) {
|
|
4046
|
+
while (1) switch (_context.n) {
|
|
4047
|
+
case 0:
|
|
4048
|
+
if (!feeAsset) {
|
|
4049
|
+
_context.n = 1;
|
|
4050
|
+
break;
|
|
4051
|
+
}
|
|
4052
|
+
return _context.a(2, undefined);
|
|
4053
|
+
case 1:
|
|
4054
|
+
edNative = getExistentialDepositOrThrow(origin);
|
|
4055
|
+
_context.n = 2;
|
|
4056
|
+
return getBalanceNativeInternal({
|
|
4057
|
+
api: api,
|
|
4058
|
+
node: origin,
|
|
4059
|
+
address: senderAddress
|
|
4060
|
+
});
|
|
4061
|
+
case 2:
|
|
4062
|
+
balanceNative = _context.v;
|
|
4063
|
+
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
|
|
4064
|
+
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4065
|
+
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
4066
|
+
_context.n = 3;
|
|
4067
|
+
break;
|
|
4068
|
+
}
|
|
4069
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4070
|
+
case 3:
|
|
4071
|
+
if (isNativeAssetToOrigin) {
|
|
4072
|
+
_context.n = 5;
|
|
4073
|
+
break;
|
|
4074
|
+
}
|
|
4075
|
+
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
4076
|
+
_context.n = 4;
|
|
4077
|
+
return getAssetBalance({
|
|
4078
|
+
api: api,
|
|
4079
|
+
node: origin,
|
|
4080
|
+
address: senderAddress,
|
|
4081
|
+
currency: currency
|
|
4082
|
+
});
|
|
4083
|
+
case 4:
|
|
4084
|
+
balanceAsset = _context.v;
|
|
4085
|
+
edAsset = getExistentialDepositOrThrow(origin, currency);
|
|
4086
|
+
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
4087
|
+
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
4088
|
+
case 5:
|
|
4089
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4090
|
+
}
|
|
4091
|
+
}, _callee);
|
|
4092
|
+
}));
|
|
4093
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
4094
|
+
return _ref.apply(this, arguments);
|
|
4095
|
+
};
|
|
4096
|
+
}();
|
|
4097
|
+
var isSufficientDestination = /*#__PURE__*/function () {
|
|
4098
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
|
|
4099
|
+
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
4100
|
+
return _regenerator().w(function (_context2) {
|
|
4101
|
+
while (1) switch (_context2.n) {
|
|
4102
|
+
case 0:
|
|
4103
|
+
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4104
|
+
if (isNativeAsset) {
|
|
4105
|
+
_context2.n = 1;
|
|
4106
|
+
break;
|
|
4107
|
+
}
|
|
4108
|
+
return _context2.a(2, undefined);
|
|
4109
|
+
case 1:
|
|
4110
|
+
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
4111
|
+
_context2.n = 2;
|
|
4112
|
+
return getBalanceNativeInternal({
|
|
4113
|
+
api: api,
|
|
4114
|
+
node: destination,
|
|
4115
|
+
address: address
|
|
4116
|
+
});
|
|
4117
|
+
case 2:
|
|
4118
|
+
nativeBalance = _context2.v;
|
|
4119
|
+
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
4120
|
+
}
|
|
4121
|
+
}, _callee2);
|
|
4122
|
+
}));
|
|
4123
|
+
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
4124
|
+
return _ref2.apply(this, arguments);
|
|
4125
|
+
};
|
|
4126
|
+
}();
|
|
4127
|
+
|
|
4128
|
+
var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
4129
|
+
if (isRelayChain(origin)) return DOT_MULTILOCATION;
|
|
4130
|
+
return {
|
|
4131
|
+
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
4132
|
+
interior: {
|
|
4133
|
+
X1: [{
|
|
4134
|
+
Parachain: getParaId(origin)
|
|
4135
|
+
}]
|
|
4136
|
+
}
|
|
4137
|
+
};
|
|
4138
|
+
};
|
|
4139
|
+
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4140
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
4141
|
+
var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, _sufficient, fee, newForwardedXcms, destParaId;
|
|
4142
|
+
return _regenerator().w(function (_context2) {
|
|
4143
|
+
while (1) switch (_context2.n) {
|
|
4144
|
+
case 0:
|
|
4145
|
+
api = options.api, origin = options.origin, hopNode = options.prevNode, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4146
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4147
|
+
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4148
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
4149
|
+
var originAsset, _t;
|
|
4150
|
+
return _regenerator().w(function (_context) {
|
|
4151
|
+
while (1) switch (_context.n) {
|
|
4152
|
+
case 0:
|
|
4153
|
+
if (!(destination === 'Ethereum')) {
|
|
4154
|
+
_context.n = 1;
|
|
4155
|
+
break;
|
|
4156
|
+
}
|
|
4157
|
+
return _context.a(2, 0n);
|
|
4158
|
+
case 1:
|
|
4159
|
+
originAsset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
4160
|
+
if (!originAsset.multiLocation) {
|
|
4161
|
+
_context.n = 7;
|
|
4162
|
+
break;
|
|
4163
|
+
}
|
|
4164
|
+
_context.p = 2;
|
|
4165
|
+
_context.n = 3;
|
|
4166
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4167
|
+
destination: destination
|
|
4168
|
+
}), {
|
|
4169
|
+
multilocation: originAsset.multiLocation
|
|
4170
|
+
});
|
|
4171
|
+
case 3:
|
|
4172
|
+
return _context.a(2, _context.v);
|
|
4173
|
+
case 4:
|
|
4174
|
+
_context.p = 4;
|
|
4175
|
+
_t = _context.v;
|
|
4176
|
+
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4177
|
+
_context.n = 6;
|
|
4178
|
+
break;
|
|
4179
|
+
}
|
|
4180
|
+
_context.n = 5;
|
|
4181
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4182
|
+
destination: destination
|
|
4183
|
+
}), {
|
|
4184
|
+
symbol: originAsset.symbol
|
|
4185
|
+
});
|
|
4186
|
+
case 5:
|
|
4187
|
+
return _context.a(2, _context.v);
|
|
4188
|
+
case 6:
|
|
4189
|
+
throw _t;
|
|
4190
|
+
case 7:
|
|
4191
|
+
_context.n = 8;
|
|
4192
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4193
|
+
destination: destination
|
|
4194
|
+
}), {
|
|
4195
|
+
symbol: originAsset.symbol
|
|
4196
|
+
});
|
|
4197
|
+
case 8:
|
|
4198
|
+
return _context.a(2, _context.v);
|
|
4199
|
+
}
|
|
4200
|
+
}, _callee, null, [[2, 4]]);
|
|
4201
|
+
}));
|
|
4202
|
+
return function calcPaymentInfoFee() {
|
|
4203
|
+
return _ref2.apply(this, arguments);
|
|
4204
|
+
};
|
|
4205
|
+
}();
|
|
4206
|
+
if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
4207
|
+
_context2.n = 3;
|
|
4208
|
+
break;
|
|
4209
|
+
}
|
|
4210
|
+
_context2.n = 1;
|
|
4211
|
+
return calcPaymentInfoFee();
|
|
4212
|
+
case 1:
|
|
4213
|
+
_fee = _context2.v;
|
|
4214
|
+
_context2.n = 2;
|
|
4215
|
+
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
|
|
4216
|
+
case 2:
|
|
4217
|
+
sufficient = _context2.v;
|
|
4218
|
+
return _context2.a(2, {
|
|
4219
|
+
fee: _fee,
|
|
4220
|
+
feeType: 'paymentInfo',
|
|
4221
|
+
sufficient: sufficient
|
|
4222
|
+
});
|
|
4223
|
+
case 3:
|
|
4224
|
+
_context2.n = 4;
|
|
4225
|
+
return api.getDryRunXcm({
|
|
4226
|
+
originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), Version.V4),
|
|
4227
|
+
xcm: forwardedXcms[1][0],
|
|
4228
|
+
node: destination,
|
|
4229
|
+
origin: origin,
|
|
4230
|
+
asset: asset,
|
|
4231
|
+
originFee: originFee,
|
|
4232
|
+
feeAsset: resolvedFeeAsset,
|
|
4233
|
+
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
4234
|
+
});
|
|
4235
|
+
case 4:
|
|
4236
|
+
dryRunResult = _context2.v;
|
|
4237
|
+
if (dryRunResult.success) {
|
|
4238
|
+
_context2.n = 8;
|
|
4239
|
+
break;
|
|
4240
|
+
}
|
|
4241
|
+
if (!disableFallback) {
|
|
4242
|
+
_context2.n = 5;
|
|
4243
|
+
break;
|
|
4244
|
+
}
|
|
4245
|
+
return _context2.a(2, {
|
|
4246
|
+
dryRunError: dryRunResult.failureReason
|
|
4247
|
+
});
|
|
4248
|
+
case 5:
|
|
4249
|
+
_context2.n = 6;
|
|
4250
|
+
return calcPaymentInfoFee();
|
|
4251
|
+
case 6:
|
|
4252
|
+
_fee2 = _context2.v;
|
|
4253
|
+
_context2.n = 7;
|
|
4254
|
+
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee2);
|
|
4255
|
+
case 7:
|
|
4256
|
+
_sufficient = _context2.v;
|
|
4257
|
+
return _context2.a(2, {
|
|
4258
|
+
fee: _fee2,
|
|
4259
|
+
feeType: 'paymentInfo',
|
|
4260
|
+
dryRunError: dryRunResult.failureReason,
|
|
4261
|
+
sufficient: _sufficient
|
|
4262
|
+
});
|
|
4263
|
+
case 8:
|
|
4264
|
+
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4265
|
+
return _context2.a(2, {
|
|
4266
|
+
fee: fee,
|
|
4267
|
+
feeType: 'dryRun',
|
|
4268
|
+
sufficient: true,
|
|
4269
|
+
forwardedXcms: newForwardedXcms,
|
|
4270
|
+
destParaId: destParaId
|
|
4271
|
+
});
|
|
4272
|
+
}
|
|
4273
|
+
}, _callee2);
|
|
4274
|
+
}));
|
|
4275
|
+
return function getDestXcmFee(_x) {
|
|
4276
|
+
return _ref.apply(this, arguments);
|
|
4277
|
+
};
|
|
4278
|
+
}();
|
|
4279
|
+
|
|
3962
4280
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
3963
4281
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ahApi) {
|
|
3964
4282
|
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
@@ -4519,346 +4837,169 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
4519
4837
|
};
|
|
4520
4838
|
numberToHex32 = function numberToHex32(num) {
|
|
4521
4839
|
return typeof num !== 'number' || isNaN(num) ? function () {
|
|
4522
|
-
throw new InvalidParameterError('Input must be a valid number');
|
|
4523
|
-
}() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
|
|
4524
|
-
}; // Execute the custom XCM message with the precompile
|
|
4525
|
-
_context.n = 14;
|
|
4526
|
-
return createTx('transferAssetsUsingTypeAndThenAddress', [
|
|
4527
|
-
// This represents (1,X1(Parachain(1000)))
|
|
4528
|
-
[1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
|
|
4529
|
-
// Assets including fee and the ERC20 asset, with fee be the first
|
|
4530
|
-
[[XCDOT, transferFee], [ethAsset.assetId, currency.amount.toString()]],
|
|
4531
|
-
// The TransferType corresponding to asset being sent, 2 represents `DestinationReserve`
|
|
4532
|
-
2,
|
|
4533
|
-
// index for the fee
|
|
4534
|
-
0,
|
|
4535
|
-
// The TransferType corresponding to fee asset
|
|
4536
|
-
2, customXcmOnDest]);
|
|
4537
|
-
case 14:
|
|
4538
|
-
tx = _context.v;
|
|
4539
|
-
return _context.a(2, tx);
|
|
4540
|
-
}
|
|
4541
|
-
}, _callee);
|
|
4542
|
-
}));
|
|
4543
|
-
return function transferMoonbeamToEth(_x) {
|
|
4544
|
-
return _ref2.apply(this, arguments);
|
|
4545
|
-
};
|
|
4546
|
-
}();
|
|
4547
|
-
|
|
4548
|
-
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
4549
|
-
var asset = findAsset(origin, feeAsset, !isTMultiLocation(destination) ? destination : null);
|
|
4550
|
-
var usesRawOverriddenMultiAssets = 'multiasset' in currency && currency.multiasset.every(isTMultiAsset);
|
|
4551
|
-
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
4552
|
-
throwUnsupportedCurrency(feeAsset, origin);
|
|
4553
|
-
}
|
|
4554
|
-
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
4555
|
-
};
|
|
4556
|
-
|
|
4557
|
-
var isAssetHub = function isAssetHub(chain) {
|
|
4558
|
-
return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
|
|
4559
|
-
};
|
|
4560
|
-
var isBridgeHub = function isBridgeHub(chain) {
|
|
4561
|
-
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
4562
|
-
};
|
|
4563
|
-
var isPeople = function isPeople(chain) {
|
|
4564
|
-
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
4565
|
-
};
|
|
4566
|
-
var isSystemPara = function isSystemPara(chain) {
|
|
4567
|
-
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
4568
|
-
};
|
|
4569
|
-
var mul = function mul(v, num) {
|
|
4570
|
-
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
4571
|
-
return v * num / den;
|
|
4572
|
-
};
|
|
4573
|
-
var padFee = function padFee(raw, origin, dest, side) {
|
|
4574
|
-
var relayOrigin = isRelayChain(origin);
|
|
4575
|
-
var relayDest = isRelayChain(dest);
|
|
4576
|
-
var sysParaOrigin = isSystemPara(origin);
|
|
4577
|
-
var sysParaDest = isSystemPara(dest);
|
|
4578
|
-
var relayToPara = relayOrigin && !relayDest;
|
|
4579
|
-
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
4580
|
-
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
4581
|
-
if (sysParaToPara) return raw * 40n;
|
|
4582
|
-
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
4583
|
-
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
4584
|
-
return 150000000000000000n;
|
|
4585
|
-
}
|
|
4586
|
-
if (paraToPara) return mul(raw, 130n, 100n);
|
|
4587
|
-
// apply default 30% padding
|
|
4588
|
-
return mul(raw, 130n, 100n);
|
|
4589
|
-
};
|
|
4590
|
-
var padFeeBy = function padFeeBy(amount, percent) {
|
|
4591
|
-
return mul(amount, BigInt(100 + percent), 100n);
|
|
4592
|
-
};
|
|
4593
|
-
|
|
4594
|
-
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
4595
|
-
if (isNodeEvm(chain)) {
|
|
4596
|
-
return isAddress(address) ? address : senderAddress;
|
|
4597
|
-
}
|
|
4598
|
-
return isAddress(address) ? senderAddress : address;
|
|
4599
|
-
};
|
|
4600
|
-
var getReverseTxFee = /*#__PURE__*/function () {
|
|
4601
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
4602
|
-
var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
|
|
4603
|
-
return _regenerator().w(function (_context) {
|
|
4604
|
-
while (1) switch (_context.n) {
|
|
4605
|
-
case 0:
|
|
4606
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
|
|
4607
|
-
toAddress = determineAddress(origin, address, senderAddress);
|
|
4608
|
-
fromAddress = determineAddress(destination, address, senderAddress);
|
|
4609
|
-
_context.n = 1;
|
|
4610
|
-
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
|
|
4611
|
-
amount: currency.amount
|
|
4612
|
-
})).build();
|
|
4613
|
-
case 1:
|
|
4614
|
-
tx = _context.v;
|
|
4615
|
-
_context.n = 2;
|
|
4616
|
-
return api.calculateTransactionFee(tx, fromAddress);
|
|
4617
|
-
case 2:
|
|
4618
|
-
rawFee = _context.v;
|
|
4619
|
-
return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
|
|
4620
|
-
}
|
|
4621
|
-
}, _callee);
|
|
4622
|
-
}));
|
|
4623
|
-
return function getReverseTxFee(_x, _x2) {
|
|
4624
|
-
return _ref2.apply(this, arguments);
|
|
4625
|
-
};
|
|
4626
|
-
}();
|
|
4627
|
-
|
|
4628
|
-
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4629
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
4630
|
-
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
4631
|
-
return _regenerator().w(function (_context) {
|
|
4632
|
-
while (1) switch (_context.n) {
|
|
4633
|
-
case 0:
|
|
4634
|
-
if (!feeAsset) {
|
|
4635
|
-
_context.n = 1;
|
|
4636
|
-
break;
|
|
4637
|
-
}
|
|
4638
|
-
return _context.a(2, undefined);
|
|
4639
|
-
case 1:
|
|
4640
|
-
edNative = getExistentialDepositOrThrow(origin);
|
|
4641
|
-
_context.n = 2;
|
|
4642
|
-
return getBalanceNativeInternal({
|
|
4643
|
-
api: api,
|
|
4644
|
-
node: origin,
|
|
4645
|
-
address: senderAddress
|
|
4646
|
-
});
|
|
4647
|
-
case 2:
|
|
4648
|
-
balanceNative = _context.v;
|
|
4649
|
-
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
|
|
4650
|
-
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4651
|
-
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
4652
|
-
_context.n = 3;
|
|
4653
|
-
break;
|
|
4654
|
-
}
|
|
4655
|
-
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4656
|
-
case 3:
|
|
4657
|
-
if (isNativeAssetToOrigin) {
|
|
4658
|
-
_context.n = 5;
|
|
4659
|
-
break;
|
|
4660
|
-
}
|
|
4661
|
-
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
4662
|
-
_context.n = 4;
|
|
4663
|
-
return getAssetBalance({
|
|
4664
|
-
api: api,
|
|
4665
|
-
node: origin,
|
|
4666
|
-
address: senderAddress,
|
|
4667
|
-
currency: currency
|
|
4668
|
-
});
|
|
4669
|
-
case 4:
|
|
4670
|
-
balanceAsset = _context.v;
|
|
4671
|
-
edAsset = getExistentialDepositOrThrow(origin, currency);
|
|
4672
|
-
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
4673
|
-
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
4674
|
-
case 5:
|
|
4675
|
-
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
4840
|
+
throw new InvalidParameterError('Input must be a valid number');
|
|
4841
|
+
}() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
|
|
4842
|
+
}; // Execute the custom XCM message with the precompile
|
|
4843
|
+
_context.n = 14;
|
|
4844
|
+
return createTx('transferAssetsUsingTypeAndThenAddress', [
|
|
4845
|
+
// This represents (1,X1(Parachain(1000)))
|
|
4846
|
+
[1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
|
|
4847
|
+
// Assets including fee and the ERC20 asset, with fee be the first
|
|
4848
|
+
[[XCDOT, transferFee], [ethAsset.assetId, currency.amount.toString()]],
|
|
4849
|
+
// The TransferType corresponding to asset being sent, 2 represents `DestinationReserve`
|
|
4850
|
+
2,
|
|
4851
|
+
// index for the fee
|
|
4852
|
+
0,
|
|
4853
|
+
// The TransferType corresponding to fee asset
|
|
4854
|
+
2, customXcmOnDest]);
|
|
4855
|
+
case 14:
|
|
4856
|
+
tx = _context.v;
|
|
4857
|
+
return _context.a(2, tx);
|
|
4676
4858
|
}
|
|
4677
4859
|
}, _callee);
|
|
4678
4860
|
}));
|
|
4679
|
-
return function
|
|
4680
|
-
return _ref.apply(this, arguments);
|
|
4681
|
-
};
|
|
4682
|
-
}();
|
|
4683
|
-
var isSufficientDestination = /*#__PURE__*/function () {
|
|
4684
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
|
|
4685
|
-
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
4686
|
-
return _regenerator().w(function (_context2) {
|
|
4687
|
-
while (1) switch (_context2.n) {
|
|
4688
|
-
case 0:
|
|
4689
|
-
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4690
|
-
if (isNativeAsset) {
|
|
4691
|
-
_context2.n = 1;
|
|
4692
|
-
break;
|
|
4693
|
-
}
|
|
4694
|
-
return _context2.a(2, undefined);
|
|
4695
|
-
case 1:
|
|
4696
|
-
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
4697
|
-
_context2.n = 2;
|
|
4698
|
-
return getBalanceNativeInternal({
|
|
4699
|
-
api: api,
|
|
4700
|
-
node: destination,
|
|
4701
|
-
address: address
|
|
4702
|
-
});
|
|
4703
|
-
case 2:
|
|
4704
|
-
nativeBalance = _context2.v;
|
|
4705
|
-
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
4706
|
-
}
|
|
4707
|
-
}, _callee2);
|
|
4708
|
-
}));
|
|
4709
|
-
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
4861
|
+
return function transferMoonbeamToEth(_x) {
|
|
4710
4862
|
return _ref2.apply(this, arguments);
|
|
4711
4863
|
};
|
|
4712
4864
|
}();
|
|
4713
4865
|
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
Parachain: getParaId(origin)
|
|
4721
|
-
}]
|
|
4722
|
-
}
|
|
4723
|
-
};
|
|
4724
|
-
};
|
|
4725
|
-
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4726
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
4727
|
-
var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, _sufficient, fee, newForwardedXcms, destParaId;
|
|
4866
|
+
function traverseXcmHops(_x) {
|
|
4867
|
+
return _traverseXcmHops.apply(this, arguments);
|
|
4868
|
+
}
|
|
4869
|
+
function _traverseXcmHops() {
|
|
4870
|
+
_traverseXcmHops = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(config) {
|
|
4871
|
+
var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, intermediateResults, destinationResult, nextChain, hopApi, isDestination, isAssetHub, isBridgeHub, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
4728
4872
|
return _regenerator().w(function (_context2) {
|
|
4729
4873
|
while (1) switch (_context2.n) {
|
|
4730
4874
|
case 0:
|
|
4731
|
-
api =
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
originAsset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
4746
|
-
if (!originAsset.multiLocation) {
|
|
4747
|
-
_context.n = 7;
|
|
4748
|
-
break;
|
|
4749
|
-
}
|
|
4750
|
-
_context.p = 2;
|
|
4751
|
-
_context.n = 3;
|
|
4752
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4753
|
-
destination: destination
|
|
4754
|
-
}), {
|
|
4755
|
-
multilocation: originAsset.multiLocation
|
|
4756
|
-
});
|
|
4757
|
-
case 3:
|
|
4758
|
-
return _context.a(2, _context.v);
|
|
4759
|
-
case 4:
|
|
4760
|
-
_context.p = 4;
|
|
4761
|
-
_t = _context.v;
|
|
4762
|
-
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4763
|
-
_context.n = 6;
|
|
4764
|
-
break;
|
|
4765
|
-
}
|
|
4766
|
-
_context.n = 5;
|
|
4767
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4768
|
-
destination: destination
|
|
4769
|
-
}), {
|
|
4770
|
-
symbol: originAsset.symbol
|
|
4771
|
-
});
|
|
4772
|
-
case 5:
|
|
4773
|
-
return _context.a(2, _context.v);
|
|
4774
|
-
case 6:
|
|
4775
|
-
throw _t;
|
|
4776
|
-
case 7:
|
|
4777
|
-
_context.n = 8;
|
|
4778
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4779
|
-
destination: destination
|
|
4780
|
-
}), {
|
|
4781
|
-
symbol: originAsset.symbol
|
|
4782
|
-
});
|
|
4783
|
-
case 8:
|
|
4784
|
-
return _context.a(2, _context.v);
|
|
4785
|
-
}
|
|
4786
|
-
}, _callee, null, [[2, 4]]);
|
|
4787
|
-
}));
|
|
4788
|
-
return function calcPaymentInfoFee() {
|
|
4789
|
-
return _ref2.apply(this, arguments);
|
|
4790
|
-
};
|
|
4791
|
-
}();
|
|
4792
|
-
if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
4793
|
-
_context2.n = 3;
|
|
4875
|
+
api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
4876
|
+
assetHubNode = "AssetHub".concat(getRelayChainOf(origin));
|
|
4877
|
+
bridgeHubNode = "BridgeHub".concat(getRelayChainOf(origin));
|
|
4878
|
+
currentOrigin = origin;
|
|
4879
|
+
forwardedXcms = initialForwardedXcms;
|
|
4880
|
+
nextParaId = initialDestParaId;
|
|
4881
|
+
asset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
4882
|
+
currentAsset = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain) ? findAssetForNodeOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, null) : asset;
|
|
4883
|
+
hasPassedExchange = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain);
|
|
4884
|
+
hops = [];
|
|
4885
|
+
intermediateResults = {};
|
|
4886
|
+
case 1:
|
|
4887
|
+
if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
|
|
4888
|
+
_context2.n = 10;
|
|
4794
4889
|
break;
|
|
4795
4890
|
}
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4891
|
+
nextChain = getTNode(nextParaId, getRelayChainOf(origin).toLowerCase());
|
|
4892
|
+
if (nextChain) {
|
|
4893
|
+
_context2.n = 2;
|
|
4894
|
+
break;
|
|
4895
|
+
}
|
|
4896
|
+
throw new InvalidParameterError("Unable to find TNode for paraId ".concat(nextParaId));
|
|
4802
4897
|
case 2:
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
fee: _fee,
|
|
4806
|
-
feeType: 'paymentInfo',
|
|
4807
|
-
sufficient: sufficient
|
|
4808
|
-
});
|
|
4809
|
-
case 3:
|
|
4898
|
+
hopApi = api.clone();
|
|
4899
|
+
_context2.p = 3;
|
|
4810
4900
|
_context2.n = 4;
|
|
4811
|
-
return
|
|
4812
|
-
originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), Version.V4),
|
|
4813
|
-
xcm: forwardedXcms[1][0],
|
|
4814
|
-
node: destination,
|
|
4815
|
-
origin: origin,
|
|
4816
|
-
asset: asset,
|
|
4817
|
-
originFee: originFee,
|
|
4818
|
-
feeAsset: resolvedFeeAsset,
|
|
4819
|
-
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
4820
|
-
});
|
|
4901
|
+
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4821
4902
|
case 4:
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4903
|
+
isDestination = nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination);
|
|
4904
|
+
isAssetHub = nextChain === assetHubNode;
|
|
4905
|
+
isBridgeHub = nextChain === bridgeHubNode;
|
|
4906
|
+
_context2.n = 5;
|
|
4907
|
+
return processHop({
|
|
4908
|
+
api: hopApi,
|
|
4909
|
+
currentChain: nextChain,
|
|
4910
|
+
currentOrigin: currentOrigin,
|
|
4911
|
+
currentAsset: currentAsset,
|
|
4912
|
+
forwardedXcms: forwardedXcms,
|
|
4913
|
+
hasPassedExchange: hasPassedExchange,
|
|
4914
|
+
isDestination: isDestination,
|
|
4915
|
+
isAssetHub: isAssetHub,
|
|
4916
|
+
isBridgeHub: isBridgeHub
|
|
4917
|
+
});
|
|
4918
|
+
case 5:
|
|
4919
|
+
hopResult = _context2.v;
|
|
4920
|
+
if (!isDestination) {
|
|
4921
|
+
hops.push({
|
|
4922
|
+
chain: nextChain,
|
|
4923
|
+
result: hopResult
|
|
4924
|
+
});
|
|
4826
4925
|
}
|
|
4827
|
-
if (
|
|
4828
|
-
|
|
4926
|
+
if (isDestination) {
|
|
4927
|
+
destinationResult = hopResult;
|
|
4928
|
+
} else if (isAssetHub) {
|
|
4929
|
+
intermediateResults.assetHub = hopResult;
|
|
4930
|
+
} else if (isBridgeHub) {
|
|
4931
|
+
intermediateResults.bridgeHub = hopResult;
|
|
4932
|
+
}
|
|
4933
|
+
if (shouldContinue(hopResult)) {
|
|
4934
|
+
_context2.n = 6;
|
|
4829
4935
|
break;
|
|
4830
4936
|
}
|
|
4831
|
-
return _context2.a(
|
|
4832
|
-
dryRunError: dryRunResult.failureReason
|
|
4833
|
-
});
|
|
4834
|
-
case 5:
|
|
4835
|
-
_context2.n = 6;
|
|
4836
|
-
return calcPaymentInfoFee();
|
|
4937
|
+
return _context2.a(3, 10);
|
|
4837
4938
|
case 6:
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4939
|
+
// Update state for next iteration
|
|
4940
|
+
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
4941
|
+
hasPassedExchange = true;
|
|
4942
|
+
currentAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, nextChain, swapConfig.currencyTo);
|
|
4943
|
+
}
|
|
4944
|
+
_extractNextHopData = extractNextHopData(hopResult), newXcms = _extractNextHopData.forwardedXcms, destParaId = _extractNextHopData.destParaId;
|
|
4945
|
+
forwardedXcms = newXcms;
|
|
4946
|
+
nextParaId = destParaId;
|
|
4947
|
+
currentOrigin = nextChain;
|
|
4841
4948
|
case 7:
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
feeType: 'paymentInfo',
|
|
4846
|
-
dryRunError: dryRunResult.failureReason,
|
|
4847
|
-
sufficient: _sufficient
|
|
4848
|
-
});
|
|
4949
|
+
_context2.p = 7;
|
|
4950
|
+
_context2.n = 8;
|
|
4951
|
+
return hopApi.disconnect();
|
|
4849
4952
|
case 8:
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
}
|
|
4953
|
+
return _context2.f(7);
|
|
4954
|
+
case 9:
|
|
4955
|
+
_context2.n = 1;
|
|
4956
|
+
break;
|
|
4957
|
+
case 10:
|
|
4958
|
+
return _context2.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
4959
|
+
hops: hops
|
|
4960
|
+
}, intermediateResults.assetHub && {
|
|
4961
|
+
assetHub: intermediateResults.assetHub
|
|
4962
|
+
}), intermediateResults.bridgeHub && {
|
|
4963
|
+
bridgeHub: intermediateResults.bridgeHub
|
|
4964
|
+
}), destinationResult && {
|
|
4965
|
+
destination: destinationResult
|
|
4966
|
+
}), {}, {
|
|
4967
|
+
lastProcessedChain: currentOrigin
|
|
4968
|
+
}));
|
|
4858
4969
|
}
|
|
4859
|
-
}, _callee2);
|
|
4970
|
+
}, _callee2, null, [[3,, 7, 9]]);
|
|
4860
4971
|
}));
|
|
4861
|
-
return
|
|
4972
|
+
return _traverseXcmHops.apply(this, arguments);
|
|
4973
|
+
}
|
|
4974
|
+
var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
4975
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, bridgeHubResult, destination, assetHubNode) {
|
|
4976
|
+
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
4977
|
+
return _regenerator().w(function (_context) {
|
|
4978
|
+
while (1) switch (_context.n) {
|
|
4979
|
+
case 0:
|
|
4980
|
+
if (!(!bridgeHubResult || !('fee' in bridgeHubResult) || destination !== 'Ethereum')) {
|
|
4981
|
+
_context.n = 1;
|
|
4982
|
+
break;
|
|
4983
|
+
}
|
|
4984
|
+
return _context.a(2, bridgeHubResult);
|
|
4985
|
+
case 1:
|
|
4986
|
+
ahApi = api.clone();
|
|
4987
|
+
_context.n = 2;
|
|
4988
|
+
return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4989
|
+
case 2:
|
|
4990
|
+
_context.n = 3;
|
|
4991
|
+
return getParaEthTransferFees(ahApi);
|
|
4992
|
+
case 3:
|
|
4993
|
+
_yield$getParaEthTran = _context.v;
|
|
4994
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
4995
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
4996
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
|
|
4997
|
+
fee: bridgeHubResult.fee + bridgeFee
|
|
4998
|
+
}));
|
|
4999
|
+
}
|
|
5000
|
+
}, _callee);
|
|
5001
|
+
}));
|
|
5002
|
+
return function addEthereumBridgeFees(_x2, _x3, _x4, _x5) {
|
|
4862
5003
|
return _ref.apply(this, arguments);
|
|
4863
5004
|
};
|
|
4864
5005
|
}();
|
|
@@ -4895,16 +5036,16 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
|
4895
5036
|
return {};
|
|
4896
5037
|
};
|
|
4897
5038
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
4898
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4899
|
-
var
|
|
4900
|
-
var origin, destination, currency, api, tx, senderAddress, feeAsset, swapConfig, resolvedFeeAsset, asset, originDryRun, initialForwardedXcms, initialDestParaId,
|
|
4901
|
-
return _regenerator().w(function (
|
|
4902
|
-
while (1) switch (
|
|
5039
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5040
|
+
var _traversalResult$brid, _traversalResult$asse, _traversalResult$dest;
|
|
5041
|
+
var origin, destination, currency, api, tx, senderAddress, feeAsset, swapConfig, resolvedFeeAsset, asset, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubNode, bridgeHubNode, processedBridgeHub, bridgeHubHopIndex, originWithCurrency, assetHubWithCurrency, bridgeHubWithCurrency, destinationWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
|
|
5042
|
+
return _regenerator().w(function (_context2) {
|
|
5043
|
+
while (1) switch (_context2.n) {
|
|
4903
5044
|
case 0:
|
|
4904
5045
|
origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset, swapConfig = options.swapConfig;
|
|
4905
5046
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4906
5047
|
asset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
4907
|
-
|
|
5048
|
+
_context2.n = 1;
|
|
4908
5049
|
return api.getDryRunCall({
|
|
4909
5050
|
tx: tx,
|
|
4910
5051
|
node: origin,
|
|
@@ -4912,12 +5053,12 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
4912
5053
|
feeAsset: resolvedFeeAsset
|
|
4913
5054
|
});
|
|
4914
5055
|
case 1:
|
|
4915
|
-
originDryRun =
|
|
5056
|
+
originDryRun = _context2.v;
|
|
4916
5057
|
if (originDryRun.success) {
|
|
4917
|
-
|
|
5058
|
+
_context2.n = 2;
|
|
4918
5059
|
break;
|
|
4919
5060
|
}
|
|
4920
|
-
return
|
|
5061
|
+
return _context2.a(2, {
|
|
4921
5062
|
failureReason: originDryRun.failureReason,
|
|
4922
5063
|
failureChain: 'origin',
|
|
4923
5064
|
origin: originDryRun,
|
|
@@ -4925,156 +5066,136 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
4925
5066
|
});
|
|
4926
5067
|
case 2:
|
|
4927
5068
|
initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
|
|
5069
|
+
processHop = /*#__PURE__*/function () {
|
|
5070
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5071
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopDryRun, hopCurrency;
|
|
5072
|
+
return _regenerator().w(function (_context) {
|
|
5073
|
+
while (1) switch (_context.n) {
|
|
5074
|
+
case 0:
|
|
5075
|
+
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
5076
|
+
if (hasDryRunSupport(currentChain)) {
|
|
5077
|
+
_context.n = 1;
|
|
5078
|
+
break;
|
|
5079
|
+
}
|
|
5080
|
+
return _context.a(2, {
|
|
5081
|
+
success: false,
|
|
5082
|
+
failureReason: "DryRunApi is not available on node ".concat(currentChain)
|
|
5083
|
+
});
|
|
5084
|
+
case 1:
|
|
5085
|
+
_context.n = 2;
|
|
5086
|
+
return hopApi.getDryRunXcm({
|
|
5087
|
+
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, currentChain), Version.V4),
|
|
5088
|
+
xcm: forwardedXcms[1][0],
|
|
5089
|
+
node: currentChain,
|
|
5090
|
+
origin: currentOrigin,
|
|
5091
|
+
asset: currentAsset,
|
|
5092
|
+
feeAsset: resolvedFeeAsset,
|
|
5093
|
+
originFee: originDryRun.fee,
|
|
5094
|
+
amount: BigInt(currency.amount)
|
|
5095
|
+
});
|
|
5096
|
+
case 2:
|
|
5097
|
+
hopDryRun = _context.v;
|
|
5098
|
+
if (!hopDryRun.success) {
|
|
5099
|
+
_context.n = 3;
|
|
5100
|
+
break;
|
|
5101
|
+
}
|
|
5102
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5103
|
+
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
|
|
5104
|
+
} else if (isDestination) {
|
|
5105
|
+
hopCurrency = findAssetOnDestOrThrow(origin, currentChain, currency).symbol;
|
|
5106
|
+
} else {
|
|
5107
|
+
hopCurrency = asset.symbol;
|
|
5108
|
+
}
|
|
5109
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
|
|
5110
|
+
currency: hopCurrency
|
|
5111
|
+
}));
|
|
5112
|
+
case 3:
|
|
5113
|
+
return _context.a(2, hopDryRun);
|
|
5114
|
+
}
|
|
5115
|
+
}, _callee);
|
|
5116
|
+
}));
|
|
5117
|
+
return function processHop(_x2) {
|
|
5118
|
+
return _ref2.apply(this, arguments);
|
|
5119
|
+
};
|
|
5120
|
+
}();
|
|
5121
|
+
_context2.n = 3;
|
|
5122
|
+
return traverseXcmHops({
|
|
5123
|
+
api: api,
|
|
5124
|
+
origin: origin,
|
|
5125
|
+
destination: destination,
|
|
5126
|
+
currency: currency,
|
|
5127
|
+
initialForwardedXcms: initialForwardedXcms,
|
|
5128
|
+
initialDestParaId: initialDestParaId,
|
|
5129
|
+
swapConfig: swapConfig,
|
|
5130
|
+
processHop: processHop,
|
|
5131
|
+
shouldContinue: function shouldContinue(hopResult) {
|
|
5132
|
+
return hopResult.success;
|
|
5133
|
+
},
|
|
5134
|
+
extractNextHopData: function extractNextHopData(hopResult) {
|
|
5135
|
+
return {
|
|
5136
|
+
forwardedXcms: hopResult.success ? hopResult.forwardedXcms : undefined,
|
|
5137
|
+
destParaId: hopResult.success ? hopResult.destParaId : undefined
|
|
5138
|
+
};
|
|
5139
|
+
}
|
|
5140
|
+
});
|
|
5141
|
+
case 3:
|
|
5142
|
+
traversalResult = _context2.v;
|
|
5143
|
+
// Process Ethereum bridge fees
|
|
4928
5144
|
assetHubNode = "AssetHub".concat(getRelayChainOf(origin));
|
|
4929
5145
|
bridgeHubNode = "BridgeHub".concat(getRelayChainOf(origin));
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
currentOrigin = origin;
|
|
4933
|
-
forwardedXcms = initialForwardedXcms;
|
|
4934
|
-
nextParaId = initialDestParaId;
|
|
4935
|
-
intermediateFees = {};
|
|
4936
|
-
hops = [];
|
|
4937
|
-
case 3:
|
|
4938
|
-
if (!(Array.isArray(forwardedXcms) && forwardedXcms.length && forwardedXcms[1].length && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
|
|
4939
|
-
_context.n = 13;
|
|
4940
|
-
break;
|
|
4941
|
-
}
|
|
4942
|
-
nextChain = getTNode(nextParaId, getRelayChainOf(origin).toLowerCase());
|
|
4943
|
-
if (nextChain) {
|
|
4944
|
-
_context.n = 4;
|
|
5146
|
+
if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
|
|
5147
|
+
_context2.n = 5;
|
|
4945
5148
|
break;
|
|
4946
5149
|
}
|
|
4947
|
-
|
|
5150
|
+
_context2.n = 4;
|
|
5151
|
+
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubNode);
|
|
4948
5152
|
case 4:
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
if (hasDryRunSupport(nextChain)) {
|
|
4952
|
-
_context.n = 6;
|
|
4953
|
-
break;
|
|
4954
|
-
}
|
|
4955
|
-
if (nextChain === destination) {
|
|
4956
|
-
destinationDryRun = {
|
|
4957
|
-
success: false,
|
|
4958
|
-
failureReason: "DryRunApi is not available on node ".concat(nextChain)
|
|
4959
|
-
};
|
|
4960
|
-
}
|
|
4961
|
-
return _context.a(3, 13);
|
|
4962
|
-
case 6:
|
|
4963
|
-
_context.n = 7;
|
|
4964
|
-
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4965
|
-
case 7:
|
|
4966
|
-
_context.n = 8;
|
|
4967
|
-
return hopApi.getDryRunXcm({
|
|
4968
|
-
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, nextChain), Version.V4),
|
|
4969
|
-
xcm: forwardedXcms[1][0],
|
|
4970
|
-
node: nextChain,
|
|
4971
|
-
origin: currentOrigin,
|
|
4972
|
-
asset: currentAsset,
|
|
4973
|
-
feeAsset: resolvedFeeAsset,
|
|
4974
|
-
originFee: originDryRun.fee,
|
|
4975
|
-
amount: BigInt(currency.amount)
|
|
4976
|
-
});
|
|
4977
|
-
case 8:
|
|
4978
|
-
hopDryRun = _context.v;
|
|
4979
|
-
hopCurrency = void 0;
|
|
4980
|
-
if (hasPassedExchange && swapConfig && nextChain !== swapConfig.exchangeChain) {
|
|
4981
|
-
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, nextChain, swapConfig.currencyTo).symbol;
|
|
4982
|
-
} else {
|
|
4983
|
-
hopCurrency = asset.symbol;
|
|
4984
|
-
}
|
|
4985
|
-
// Add to hops array (only if not the destination)
|
|
4986
|
-
if (nextChain !== destination) {
|
|
4987
|
-
hops.push({
|
|
4988
|
-
chain: nextChain,
|
|
4989
|
-
result: hopDryRun.success && hopCurrency ? _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
|
|
4990
|
-
currency: hopCurrency
|
|
4991
|
-
}) : hopDryRun
|
|
4992
|
-
});
|
|
4993
|
-
}
|
|
4994
|
-
// Keep existing logic for backwards compatibility
|
|
4995
|
-
if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
|
|
4996
|
-
destinationDryRun = hopDryRun;
|
|
4997
|
-
} else if (nextChain === assetHubNode) {
|
|
4998
|
-
intermediateFees.assetHub = hopDryRun;
|
|
4999
|
-
} else if (nextChain === bridgeHubNode) {
|
|
5000
|
-
intermediateFees.bridgeHub = hopDryRun;
|
|
5001
|
-
}
|
|
5002
|
-
if (hopDryRun.success) {
|
|
5003
|
-
_context.n = 9;
|
|
5004
|
-
break;
|
|
5005
|
-
}
|
|
5006
|
-
return _context.a(3, 13);
|
|
5007
|
-
case 9:
|
|
5008
|
-
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
5009
|
-
hasPassedExchange = true;
|
|
5010
|
-
currentAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, nextChain, swapConfig.currencyTo);
|
|
5011
|
-
}
|
|
5012
|
-
newXcms = hopDryRun.forwardedXcms, destParaId = hopDryRun.destParaId;
|
|
5013
|
-
forwardedXcms = newXcms;
|
|
5014
|
-
nextParaId = destParaId;
|
|
5015
|
-
currentOrigin = nextChain;
|
|
5016
|
-
case 10:
|
|
5017
|
-
_context.p = 10;
|
|
5018
|
-
_context.n = 11;
|
|
5019
|
-
return hopApi.disconnect();
|
|
5020
|
-
case 11:
|
|
5021
|
-
return _context.f(10);
|
|
5022
|
-
case 12:
|
|
5023
|
-
_context.n = 3;
|
|
5153
|
+
_t = _context2.v;
|
|
5154
|
+
_context2.n = 6;
|
|
5024
5155
|
break;
|
|
5025
|
-
case
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5034
|
-
case 14:
|
|
5035
|
-
_context.n = 15;
|
|
5036
|
-
return getParaEthTransferFees(ahApi);
|
|
5037
|
-
case 15:
|
|
5038
|
-
_yield$getParaEthTran = _context.v;
|
|
5039
|
-
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
5040
|
-
bridgeFee = _yield$getParaEthTran2[0];
|
|
5041
|
-
processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
|
|
5042
|
-
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
5043
|
-
});
|
|
5044
|
-
// Update the hop data if BridgeHub is in the hops array
|
|
5045
|
-
bridgeHubHopIndex = hops.findIndex(function (hop) {
|
|
5046
|
-
return hop.chain === bridgeHubNode;
|
|
5047
|
-
});
|
|
5048
|
-
if (bridgeHubHopIndex !== -1 && hops[bridgeHubHopIndex].result.success) {
|
|
5049
|
-
hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
|
|
5050
|
-
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
5156
|
+
case 5:
|
|
5157
|
+
_t = traversalResult.bridgeHub;
|
|
5158
|
+
case 6:
|
|
5159
|
+
processedBridgeHub = _t;
|
|
5160
|
+
// Update bridge hub in hops if needed
|
|
5161
|
+
if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
5162
|
+
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
5163
|
+
return hop.chain === bridgeHubNode;
|
|
5051
5164
|
});
|
|
5165
|
+
if (bridgeHubHopIndex !== -1 && traversalResult.hops[bridgeHubHopIndex].result.success) {
|
|
5166
|
+
traversalResult.hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, traversalResult.hops[bridgeHubHopIndex].result), {}, {
|
|
5167
|
+
fee: processedBridgeHub.fee
|
|
5168
|
+
});
|
|
5169
|
+
}
|
|
5052
5170
|
}
|
|
5053
|
-
|
|
5171
|
+
originWithCurrency = originDryRun.success ? _objectSpread2(_objectSpread2({}, originDryRun), {}, {
|
|
5172
|
+
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(origin)
|
|
5173
|
+
}) : originDryRun;
|
|
5174
|
+
assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
|
|
5175
|
+
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(assetHubNode)
|
|
5176
|
+
}) : traversalResult.assetHub;
|
|
5177
|
+
bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
|
|
5178
|
+
currency: getNativeAssetSymbol(bridgeHubNode)
|
|
5179
|
+
}) : processedBridgeHub;
|
|
5180
|
+
destinationWithCurrency = (_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0 && _traversalResult$dest.success ? _objectSpread2(_objectSpread2({}, traversalResult.destination), {}, {
|
|
5181
|
+
currency: asset === null || asset === void 0 ? void 0 : asset.symbol
|
|
5182
|
+
}) : traversalResult.destination;
|
|
5054
5183
|
_getFailureInfo = getFailureInfo$1({
|
|
5055
|
-
destination:
|
|
5056
|
-
assetHub:
|
|
5057
|
-
bridgeHub:
|
|
5058
|
-
}, hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5059
|
-
return
|
|
5184
|
+
destination: destinationWithCurrency,
|
|
5185
|
+
assetHub: assetHubWithCurrency,
|
|
5186
|
+
bridgeHub: bridgeHubWithCurrency
|
|
5187
|
+
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5188
|
+
return _context2.a(2, {
|
|
5060
5189
|
failureReason: failureReason,
|
|
5061
5190
|
failureChain: failureChain,
|
|
5062
|
-
origin:
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
}) : intermediateFees.assetHub,
|
|
5068
|
-
bridgeHub: (_processedBridgeHubDa = processedBridgeHubData) !== null && _processedBridgeHubDa !== void 0 && _processedBridgeHubDa.success ? _objectSpread2(_objectSpread2({}, processedBridgeHubData), {}, {
|
|
5069
|
-
currency: getNativeAssetSymbol(bridgeHubNode)
|
|
5070
|
-
}) : processedBridgeHubData,
|
|
5071
|
-
destination: (_destinationDryRun = destinationDryRun) !== null && _destinationDryRun !== void 0 && _destinationDryRun.success ? _objectSpread2(_objectSpread2({}, destinationDryRun), {}, {
|
|
5072
|
-
currency: asset === null || asset === void 0 ? void 0 : asset.symbol
|
|
5073
|
-
}) : destinationDryRun,
|
|
5074
|
-
hops: hops
|
|
5191
|
+
origin: originWithCurrency,
|
|
5192
|
+
assetHub: assetHubWithCurrency,
|
|
5193
|
+
bridgeHub: bridgeHubWithCurrency,
|
|
5194
|
+
destination: destinationWithCurrency,
|
|
5195
|
+
hops: traversalResult.hops
|
|
5075
5196
|
});
|
|
5076
5197
|
}
|
|
5077
|
-
},
|
|
5198
|
+
}, _callee2);
|
|
5078
5199
|
}));
|
|
5079
5200
|
return function dryRunInternal(_x) {
|
|
5080
5201
|
return _ref.apply(this, arguments);
|
|
@@ -5486,14 +5607,14 @@ var getFailureInfo = function getFailureInfo(nodes, hops) {
|
|
|
5486
5607
|
return {};
|
|
5487
5608
|
};
|
|
5488
5609
|
var getXcmFee = /*#__PURE__*/function () {
|
|
5489
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5490
|
-
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee,
|
|
5491
|
-
return _regenerator().w(function (
|
|
5492
|
-
while (1) switch (
|
|
5610
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
5611
|
+
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubNode, processedBridgeHub, bridgeHubNode, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason;
|
|
5612
|
+
return _regenerator().w(function (_context2) {
|
|
5613
|
+
while (1) switch (_context2.n) {
|
|
5493
5614
|
case 0:
|
|
5494
5615
|
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig;
|
|
5495
|
-
asset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
5496
|
-
|
|
5616
|
+
asset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
5617
|
+
_context2.n = 1;
|
|
5497
5618
|
return getOriginXcmFee({
|
|
5498
5619
|
api: api,
|
|
5499
5620
|
tx: tx,
|
|
@@ -5505,7 +5626,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5505
5626
|
disableFallback: disableFallback
|
|
5506
5627
|
});
|
|
5507
5628
|
case 1:
|
|
5508
|
-
_yield$getOriginXcmFe =
|
|
5629
|
+
_yield$getOriginXcmFe = _context2.v;
|
|
5509
5630
|
originFee = _yield$getOriginXcmFe.fee;
|
|
5510
5631
|
originCurrency = _yield$getOriginXcmFe.currency;
|
|
5511
5632
|
originFeeType = _yield$getOriginXcmFe.feeType;
|
|
@@ -5515,22 +5636,20 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5515
5636
|
originWeight = _yield$getOriginXcmFe.weight;
|
|
5516
5637
|
sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
|
|
5517
5638
|
api.setDisconnectAllowed(true);
|
|
5518
|
-
|
|
5639
|
+
_context2.n = 2;
|
|
5519
5640
|
return api.disconnect();
|
|
5520
5641
|
case 2:
|
|
5521
|
-
// Initialize hops array
|
|
5522
|
-
hops = [];
|
|
5523
5642
|
if (!(originDryRunError || originFeeType === 'paymentInfo')) {
|
|
5524
|
-
|
|
5643
|
+
_context2.n = 8;
|
|
5525
5644
|
break;
|
|
5526
5645
|
}
|
|
5527
5646
|
destApi = api.clone();
|
|
5528
|
-
|
|
5529
|
-
|
|
5647
|
+
_context2.p = 3;
|
|
5648
|
+
_context2.n = 4;
|
|
5530
5649
|
return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5531
5650
|
case 4:
|
|
5532
5651
|
destApi.setDisconnectAllowed(false);
|
|
5533
|
-
|
|
5652
|
+
_context2.n = 5;
|
|
5534
5653
|
return getDestXcmFee({
|
|
5535
5654
|
api: destApi,
|
|
5536
5655
|
forwardedXcms: undefined,
|
|
@@ -5546,7 +5665,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5546
5665
|
disableFallback: disableFallback
|
|
5547
5666
|
});
|
|
5548
5667
|
case 5:
|
|
5549
|
-
destFeeRes =
|
|
5668
|
+
destFeeRes = _context2.v;
|
|
5550
5669
|
_result = {
|
|
5551
5670
|
origin: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
|
|
5552
5671
|
fee: originFee
|
|
@@ -5570,134 +5689,127 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5570
5689
|
}), {}, {
|
|
5571
5690
|
currency: getNativeAssetSymbol(destination)
|
|
5572
5691
|
}),
|
|
5573
|
-
hops:
|
|
5692
|
+
hops: []
|
|
5574
5693
|
};
|
|
5575
5694
|
_getFailureInfo = getFailureInfo({
|
|
5576
5695
|
origin: _result.origin,
|
|
5577
5696
|
destination: _result.destination
|
|
5578
|
-
},
|
|
5579
|
-
return
|
|
5697
|
+
}, []), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
|
|
5698
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, _result), {}, {
|
|
5580
5699
|
failureChain: _failureChain,
|
|
5581
5700
|
failureReason: _failureReason
|
|
5582
5701
|
}));
|
|
5583
5702
|
case 6:
|
|
5584
|
-
|
|
5703
|
+
_context2.p = 6;
|
|
5585
5704
|
destApi.setDisconnectAllowed(true);
|
|
5586
|
-
|
|
5705
|
+
_context2.n = 7;
|
|
5587
5706
|
return destApi.disconnect();
|
|
5588
5707
|
case 7:
|
|
5589
|
-
return
|
|
5708
|
+
return _context2.f(6);
|
|
5590
5709
|
case 8:
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5710
|
+
processHop = /*#__PURE__*/function () {
|
|
5711
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5712
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopResult, hopCurrency;
|
|
5713
|
+
return _regenerator().w(function (_context) {
|
|
5714
|
+
while (1) switch (_context.n) {
|
|
5715
|
+
case 0:
|
|
5716
|
+
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
5717
|
+
_context.n = 1;
|
|
5718
|
+
return getDestXcmFee({
|
|
5719
|
+
api: hopApi,
|
|
5720
|
+
forwardedXcms: forwardedXcms,
|
|
5721
|
+
origin: origin,
|
|
5722
|
+
prevNode: currentOrigin,
|
|
5723
|
+
destination: currentChain,
|
|
5724
|
+
currency: currency,
|
|
5725
|
+
address: address,
|
|
5726
|
+
senderAddress: senderAddress,
|
|
5727
|
+
asset: currentAsset,
|
|
5728
|
+
feeAsset: feeAsset,
|
|
5729
|
+
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
5730
|
+
disableFallback: disableFallback
|
|
5731
|
+
});
|
|
5732
|
+
case 1:
|
|
5733
|
+
hopResult = _context.v;
|
|
5734
|
+
if (hopResult.feeType === 'dryRun') {
|
|
5735
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5736
|
+
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
|
|
5737
|
+
} else if (destination === currentChain) {
|
|
5738
|
+
hopCurrency = findAssetOnDestOrThrow(origin, currentChain, currency).symbol;
|
|
5739
|
+
} else {
|
|
5740
|
+
hopCurrency = asset.symbol;
|
|
5741
|
+
}
|
|
5742
|
+
} else {
|
|
5743
|
+
hopCurrency = getNativeAssetSymbol(currentChain);
|
|
5744
|
+
}
|
|
5745
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
|
|
5746
|
+
currency: hopCurrency
|
|
5747
|
+
}));
|
|
5748
|
+
}
|
|
5749
|
+
}, _callee);
|
|
5750
|
+
}));
|
|
5751
|
+
return function processHop(_x2) {
|
|
5752
|
+
return _ref3.apply(this, arguments);
|
|
5753
|
+
};
|
|
5754
|
+
}();
|
|
5755
|
+
_context2.n = 9;
|
|
5756
|
+
return traverseXcmHops({
|
|
5757
|
+
api: api,
|
|
5623
5758
|
origin: origin,
|
|
5624
|
-
|
|
5625
|
-
destination: nextChain,
|
|
5759
|
+
destination: destination,
|
|
5626
5760
|
currency: currency,
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, nextChain, swapConfig.currencyTo).symbol;
|
|
5640
|
-
} else if (destination === nextChain) {
|
|
5641
|
-
hopCurrency = findAssetOnDestOrThrow(origin, nextChain, currency).symbol;
|
|
5642
|
-
} else {
|
|
5643
|
-
hopCurrency = asset.symbol;
|
|
5761
|
+
initialForwardedXcms: initialForwardedXcm,
|
|
5762
|
+
initialDestParaId: initialDestParaId,
|
|
5763
|
+
swapConfig: swapConfig,
|
|
5764
|
+
processHop: processHop,
|
|
5765
|
+
shouldContinue: function shouldContinue(hopResult) {
|
|
5766
|
+
return !hopResult.dryRunError;
|
|
5767
|
+
},
|
|
5768
|
+
extractNextHopData: function extractNextHopData(hopResult) {
|
|
5769
|
+
return {
|
|
5770
|
+
forwardedXcms: hopResult.forwardedXcms,
|
|
5771
|
+
destParaId: hopResult.destParaId
|
|
5772
|
+
};
|
|
5644
5773
|
}
|
|
5645
|
-
}
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
} : {
|
|
5655
|
-
fee: hopResult.fee,
|
|
5656
|
-
feeType: hopResult.feeType,
|
|
5657
|
-
currency: hopCurrency,
|
|
5658
|
-
sufficient: hopResult.sufficient
|
|
5659
|
-
};
|
|
5660
|
-
if (nextChain !== destination) {
|
|
5661
|
-
hops.push({
|
|
5662
|
-
chain: nextChain,
|
|
5663
|
-
result: hopDetail
|
|
5664
|
-
});
|
|
5665
|
-
}
|
|
5666
|
-
if (!hopResult.dryRunError) {
|
|
5667
|
-
_context.n = 17;
|
|
5774
|
+
});
|
|
5775
|
+
case 9:
|
|
5776
|
+
traversalResult = _context2.v;
|
|
5777
|
+
// Handle case where we failed before reaching destination
|
|
5778
|
+
destFee = 0n;
|
|
5779
|
+
destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
|
|
5780
|
+
destSufficient = undefined;
|
|
5781
|
+
if (!traversalResult.destination) {
|
|
5782
|
+
_context2.n = 10;
|
|
5668
5783
|
break;
|
|
5669
5784
|
}
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
}
|
|
5682
|
-
// We failed before the true destination, use fallback via paymentInfo.
|
|
5683
|
-
if (hopIsDestination) {
|
|
5684
|
-
_context.n = 16;
|
|
5785
|
+
destResult = traversalResult.destination;
|
|
5786
|
+
destFee = destResult.fee;
|
|
5787
|
+
destFeeType = destResult.feeType;
|
|
5788
|
+
destDryRunError = destResult.dryRunError;
|
|
5789
|
+
destSufficient = destResult.sufficient;
|
|
5790
|
+
destCurrency = destResult.currency;
|
|
5791
|
+
_context2.n = 14;
|
|
5792
|
+
break;
|
|
5793
|
+
case 10:
|
|
5794
|
+
if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
|
|
5795
|
+
_context2.n = 13;
|
|
5685
5796
|
break;
|
|
5686
5797
|
}
|
|
5798
|
+
// We failed before reaching destination, use fallback
|
|
5687
5799
|
_destApi = api.clone();
|
|
5688
5800
|
if (!(destination !== 'Ethereum')) {
|
|
5689
|
-
|
|
5801
|
+
_context2.n = 11;
|
|
5690
5802
|
break;
|
|
5691
5803
|
}
|
|
5692
|
-
|
|
5804
|
+
_context2.n = 11;
|
|
5693
5805
|
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5694
|
-
case
|
|
5695
|
-
|
|
5806
|
+
case 11:
|
|
5807
|
+
_context2.n = 12;
|
|
5696
5808
|
return getDestXcmFee({
|
|
5697
5809
|
api: _destApi,
|
|
5698
5810
|
forwardedXcms: undefined,
|
|
5699
5811
|
origin: origin,
|
|
5700
|
-
prevNode:
|
|
5812
|
+
prevNode: traversalResult.lastProcessedChain || origin,
|
|
5701
5813
|
destination: destination,
|
|
5702
5814
|
currency: currency,
|
|
5703
5815
|
address: address,
|
|
@@ -5706,78 +5818,52 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5706
5818
|
senderAddress: senderAddress,
|
|
5707
5819
|
disableFallback: disableFallback
|
|
5708
5820
|
});
|
|
5709
|
-
case
|
|
5710
|
-
destFallback =
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
case 17:
|
|
5717
|
-
if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
|
|
5718
|
-
destinationFee = hopResult.fee;
|
|
5719
|
-
destinationFeeType = hopResult.feeType;
|
|
5720
|
-
destinationSufficient = hopResult.sufficient;
|
|
5721
|
-
} else if (nextChain === assetHubNode) {
|
|
5722
|
-
intermediateFees.assetHub = hopDetail;
|
|
5723
|
-
} else if (nextChain === bridgeHubNode) {
|
|
5724
|
-
intermediateFees.bridgeHub = hopDetail;
|
|
5725
|
-
} else ;
|
|
5726
|
-
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
5727
|
-
hasPassedExchange = true;
|
|
5728
|
-
currentAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, nextChain, swapConfig.currencyTo);
|
|
5729
|
-
}
|
|
5730
|
-
forwardedXcms = hopResult.forwardedXcms;
|
|
5731
|
-
nextParaId = hopResult.destParaId;
|
|
5732
|
-
currentOrigin = nextChain;
|
|
5733
|
-
case 18:
|
|
5734
|
-
_context.p = 18;
|
|
5735
|
-
_context.n = 19;
|
|
5736
|
-
return hopApi.disconnect();
|
|
5737
|
-
case 19:
|
|
5738
|
-
return _context.f(18);
|
|
5739
|
-
case 20:
|
|
5740
|
-
_context.n = 9;
|
|
5821
|
+
case 12:
|
|
5822
|
+
destFallback = _context2.v;
|
|
5823
|
+
destFee = destFallback.fee;
|
|
5824
|
+
destFeeType = destFallback.feeType;
|
|
5825
|
+
destSufficient = destFallback.sufficient;
|
|
5826
|
+
destCurrency = getNativeAssetSymbol(destination);
|
|
5827
|
+
_context2.n = 14;
|
|
5741
5828
|
break;
|
|
5742
|
-
case
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
5760
|
-
});
|
|
5761
|
-
bridgeHubHopIndex = hops.findIndex(function (hop) {
|
|
5762
|
-
return hop.chain === bridgeHubNode;
|
|
5763
|
-
});
|
|
5764
|
-
if (bridgeHubHopIndex !== -1) {
|
|
5765
|
-
hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
|
|
5766
|
-
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
5829
|
+
case 13:
|
|
5830
|
+
destFee = 0n;
|
|
5831
|
+
destFeeType = 'noFeeRequired';
|
|
5832
|
+
destSufficient = true;
|
|
5833
|
+
destCurrency = getNativeAssetSymbol(destination);
|
|
5834
|
+
case 14:
|
|
5835
|
+
// Process Ethereum bridge fees
|
|
5836
|
+
assetHubNode = "AssetHub".concat(getRelayChainOf(origin));
|
|
5837
|
+
_context2.n = 15;
|
|
5838
|
+
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubNode);
|
|
5839
|
+
case 15:
|
|
5840
|
+
processedBridgeHub = _context2.v;
|
|
5841
|
+
// Update bridge hub fee in hops if needed
|
|
5842
|
+
if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
5843
|
+
bridgeHubNode = "BridgeHub".concat(getRelayChainOf(origin));
|
|
5844
|
+
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
5845
|
+
return hop.chain === bridgeHubNode;
|
|
5767
5846
|
});
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
if (hasPassedExchange && swapConfig && destination !== swapConfig.exchangeChain) {
|
|
5773
|
-
destCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, destination, swapConfig.currencyTo).symbol;
|
|
5774
|
-
} else {
|
|
5775
|
-
destCurrency = findAssetOnDestOrThrow(origin, destination, currency).symbol;
|
|
5847
|
+
if (bridgeHubHopIndex !== -1) {
|
|
5848
|
+
traversalResult.hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, traversalResult.hops[bridgeHubHopIndex].result), {}, {
|
|
5849
|
+
fee: processedBridgeHub.fee
|
|
5850
|
+
});
|
|
5776
5851
|
}
|
|
5777
|
-
} else {
|
|
5778
|
-
destCurrency = getNativeAssetSymbol(destination);
|
|
5779
5852
|
}
|
|
5780
|
-
|
|
5853
|
+
convertToFeeDetail = function convertToFeeDetail(result) {
|
|
5854
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, result.fee !== undefined && {
|
|
5855
|
+
fee: result.fee
|
|
5856
|
+
}), result.feeType && {
|
|
5857
|
+
feeType: result.feeType
|
|
5858
|
+
}), result.sufficient !== undefined && {
|
|
5859
|
+
sufficient: result.sufficient
|
|
5860
|
+
}), {}, {
|
|
5861
|
+
currency: result.currency
|
|
5862
|
+
}, result.dryRunError && {
|
|
5863
|
+
dryRunError: result.dryRunError
|
|
5864
|
+
});
|
|
5865
|
+
};
|
|
5866
|
+
result = _objectSpread2(_objectSpread2(_objectSpread2({
|
|
5781
5867
|
origin: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, originWeight && {
|
|
5782
5868
|
weight: originWeight
|
|
5783
5869
|
}), originFee && {
|
|
@@ -5791,31 +5877,40 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5791
5877
|
}, originDryRunError && {
|
|
5792
5878
|
dryRunError: originDryRunError
|
|
5793
5879
|
})
|
|
5794
|
-
},
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5880
|
+
}, traversalResult.assetHub && {
|
|
5881
|
+
assetHub: convertToFeeDetail(traversalResult.assetHub)
|
|
5882
|
+
}), processedBridgeHub && {
|
|
5883
|
+
bridgeHub: convertToFeeDetail(processedBridgeHub)
|
|
5884
|
+
}), {}, {
|
|
5885
|
+
destination: _objectSpread2(_objectSpread2(_objectSpread2({}, destFee !== undefined && {
|
|
5886
|
+
fee: destFee
|
|
5887
|
+
}), destFeeType && {
|
|
5888
|
+
feeType: destFeeType
|
|
5799
5889
|
}), {}, {
|
|
5800
|
-
sufficient:
|
|
5890
|
+
sufficient: destSufficient,
|
|
5801
5891
|
currency: destCurrency
|
|
5802
|
-
},
|
|
5803
|
-
dryRunError:
|
|
5892
|
+
}, destDryRunError && {
|
|
5893
|
+
dryRunError: destDryRunError
|
|
5804
5894
|
}),
|
|
5805
|
-
hops: hops
|
|
5895
|
+
hops: traversalResult.hops.map(function (hop) {
|
|
5896
|
+
return {
|
|
5897
|
+
chain: hop.chain,
|
|
5898
|
+
result: convertToFeeDetail(hop.result)
|
|
5899
|
+
};
|
|
5900
|
+
})
|
|
5806
5901
|
});
|
|
5807
5902
|
_getFailureInfo2 = getFailureInfo({
|
|
5808
5903
|
origin: result.origin,
|
|
5809
5904
|
assetHub: result.assetHub,
|
|
5810
5905
|
bridgeHub: result.bridgeHub,
|
|
5811
5906
|
destination: result.destination
|
|
5812
|
-
}, hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
|
|
5813
|
-
return
|
|
5907
|
+
}, result.hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
|
|
5908
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
|
|
5814
5909
|
failureChain: failureChain,
|
|
5815
5910
|
failureReason: failureReason
|
|
5816
5911
|
}));
|
|
5817
5912
|
}
|
|
5818
|
-
},
|
|
5913
|
+
}, _callee2, null, [[3,, 6, 8]]);
|
|
5819
5914
|
}));
|
|
5820
5915
|
return function getXcmFee(_x) {
|
|
5821
5916
|
return _ref2.apply(this, arguments);
|
|
@@ -11533,24 +11628,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
11533
11628
|
}, {
|
|
11534
11629
|
key: "getXcmFee",
|
|
11535
11630
|
value: (function () {
|
|
11536
|
-
var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
11537
|
-
var
|
|
11538
|
-
|
|
11539
|
-
_this$_options3,
|
|
11540
|
-
from,
|
|
11541
|
-
to,
|
|
11542
|
-
address,
|
|
11543
|
-
senderAddress,
|
|
11544
|
-
feeAsset,
|
|
11545
|
-
currency,
|
|
11546
|
-
tx,
|
|
11547
|
-
_args4 = arguments;
|
|
11631
|
+
var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
11632
|
+
var _options$disableFallb;
|
|
11633
|
+
var _this$_options3, from, to, address, senderAddress, feeAsset, currency, tx, disableFallback;
|
|
11548
11634
|
return _regenerator().w(function (_context4) {
|
|
11549
11635
|
while (1) switch (_context4.n) {
|
|
11550
11636
|
case 0:
|
|
11551
|
-
_ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {
|
|
11552
|
-
disableFallback: false
|
|
11553
|
-
}, disableFallback = _ref.disableFallback;
|
|
11554
11637
|
_this$_options3 = this._options, from = _this$_options3.from, to = _this$_options3.to, address = _this$_options3.address, senderAddress = _this$_options3.senderAddress, feeAsset = _this$_options3.feeAsset, currency = _this$_options3.currency;
|
|
11555
11638
|
assertToIsString(to);
|
|
11556
11639
|
assertAddressIsString(address);
|
|
@@ -11558,6 +11641,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
11558
11641
|
return this.build();
|
|
11559
11642
|
case 1:
|
|
11560
11643
|
tx = _context4.v;
|
|
11644
|
+
disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
|
|
11561
11645
|
_context4.p = 2;
|
|
11562
11646
|
_context4.n = 3;
|
|
11563
11647
|
return getXcmFee({
|
|
@@ -11584,7 +11668,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
11584
11668
|
}
|
|
11585
11669
|
}, _callee4, this, [[2,, 4, 6]]);
|
|
11586
11670
|
}));
|
|
11587
|
-
function getXcmFee$1() {
|
|
11671
|
+
function getXcmFee$1(_x2) {
|
|
11588
11672
|
return _getXcmFee2.apply(this, arguments);
|
|
11589
11673
|
}
|
|
11590
11674
|
return getXcmFee$1;
|
|
@@ -11599,7 +11683,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
11599
11683
|
key: "getOriginXcmFee",
|
|
11600
11684
|
value: (function () {
|
|
11601
11685
|
var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
11602
|
-
var
|
|
11686
|
+
var _ref,
|
|
11603
11687
|
disableFallback,
|
|
11604
11688
|
_this$_options4,
|
|
11605
11689
|
from,
|
|
@@ -11612,9 +11696,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
11612
11696
|
return _regenerator().w(function (_context5) {
|
|
11613
11697
|
while (1) switch (_context5.n) {
|
|
11614
11698
|
case 0:
|
|
11615
|
-
|
|
11699
|
+
_ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {
|
|
11616
11700
|
disableFallback: false
|
|
11617
|
-
}, disableFallback =
|
|
11701
|
+
}, disableFallback = _ref.disableFallback;
|
|
11618
11702
|
_this$_options4 = this._options, from = _this$_options4.from, to = _this$_options4.to, senderAddress = _this$_options4.senderAddress, currency = _this$_options4.currency, feeAsset = _this$_options4.feeAsset;
|
|
11619
11703
|
assertToIsString(to);
|
|
11620
11704
|
_context5.n = 1;
|
|
@@ -11901,4 +11985,4 @@ var Builder = function Builder(api) {
|
|
|
11901
11985
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
11902
11986
|
};
|
|
11903
11987
|
|
|
11904
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createMultiAsset, createVersionedMultiAssets, createX1Payload, deriveAccountId, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChainLocation, getChainVersion, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getRelayChainOf, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, localizeLocation, maybeOverrideMultiAsset, maybeOverrideMultiAssets, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, sortMultiAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, validateAddress, verifyEdOnDestination };
|
|
11988
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addEthereumBridgeFees, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createMultiAsset, createVersionedMultiAssets, createX1Payload, deriveAccountId, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChainLocation, getChainVersion, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getRelayChainOf, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, localizeLocation, maybeOverrideMultiAsset, maybeOverrideMultiAssets, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, sortMultiAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination };
|