@paraspell/sdk-core 11.2.0 → 11.2.2
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 +1176 -1301
- package/dist/index.d.ts +257 -256
- package/dist/index.mjs +1177 -1302
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, getNativeAssetSymbol, getOtherAssets, isAssetEqual,
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findAssetInfo, isTAsset, findAssetInfoOrThrow, getExistentialDeposit, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, isSymbolMatch, hasDryRunSupport, hasSupportForAsset, getRelayChainSymbol, isSymbolSpecifier, normalizeLocation, hasXcmPaymentApiSupport, getExistentialDepositOrThrow, normalizeSymbol, getNativeAssets } 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';
|
|
@@ -3474,6 +3474,86 @@ var createDirectExecuteXcm = function createDirectExecuteXcm(options) {
|
|
|
3474
3474
|
return addXcmVersionHeader(fullXcm, version);
|
|
3475
3475
|
};
|
|
3476
3476
|
|
|
3477
|
+
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
3478
|
+
var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
|
|
3479
|
+
var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
|
|
3480
|
+
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
3481
|
+
throwUnsupportedCurrency(feeAsset, origin);
|
|
3482
|
+
}
|
|
3483
|
+
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
3484
|
+
};
|
|
3485
|
+
|
|
3486
|
+
var isAssetHub = function isAssetHub(chain) {
|
|
3487
|
+
return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
|
|
3488
|
+
};
|
|
3489
|
+
var isBridgeHub = function isBridgeHub(chain) {
|
|
3490
|
+
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
3491
|
+
};
|
|
3492
|
+
var isPeople = function isPeople(chain) {
|
|
3493
|
+
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
3494
|
+
};
|
|
3495
|
+
var isSystemPara = function isSystemPara(chain) {
|
|
3496
|
+
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
3497
|
+
};
|
|
3498
|
+
var mul = function mul(v, num) {
|
|
3499
|
+
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
3500
|
+
return v * num / den;
|
|
3501
|
+
};
|
|
3502
|
+
var padFee = function padFee(raw, origin, dest, side) {
|
|
3503
|
+
var relayOrigin = isRelayChain(origin);
|
|
3504
|
+
var relayDest = isRelayChain(dest);
|
|
3505
|
+
var sysParaOrigin = isSystemPara(origin);
|
|
3506
|
+
var sysParaDest = isSystemPara(dest);
|
|
3507
|
+
var relayToPara = relayOrigin && !relayDest;
|
|
3508
|
+
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
3509
|
+
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
3510
|
+
if (sysParaToPara) return raw * 40n;
|
|
3511
|
+
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
3512
|
+
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
3513
|
+
return 150000000000000000n;
|
|
3514
|
+
}
|
|
3515
|
+
if (paraToPara) return mul(raw, 130n, 100n);
|
|
3516
|
+
// apply default 30% padding
|
|
3517
|
+
return mul(raw, 130n, 100n);
|
|
3518
|
+
};
|
|
3519
|
+
var padFeeBy = function padFeeBy(amount, percent) {
|
|
3520
|
+
return mul(amount, BigInt(100 + percent), 100n);
|
|
3521
|
+
};
|
|
3522
|
+
|
|
3523
|
+
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
3524
|
+
if (isChainEvm(chain)) {
|
|
3525
|
+
return isAddress(address) ? address : senderAddress;
|
|
3526
|
+
}
|
|
3527
|
+
return isAddress(address) ? senderAddress : address;
|
|
3528
|
+
};
|
|
3529
|
+
var getReverseTxFee = /*#__PURE__*/function () {
|
|
3530
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
3531
|
+
var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
|
|
3532
|
+
return _regenerator().w(function (_context) {
|
|
3533
|
+
while (1) switch (_context.n) {
|
|
3534
|
+
case 0:
|
|
3535
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
|
|
3536
|
+
toAddress = determineAddress(origin, address, senderAddress);
|
|
3537
|
+
fromAddress = determineAddress(destination, address, senderAddress);
|
|
3538
|
+
_context.n = 1;
|
|
3539
|
+
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
|
|
3540
|
+
amount: currency.amount
|
|
3541
|
+
})).build();
|
|
3542
|
+
case 1:
|
|
3543
|
+
tx = _context.v;
|
|
3544
|
+
_context.n = 2;
|
|
3545
|
+
return api.calculateTransactionFee(tx, fromAddress);
|
|
3546
|
+
case 2:
|
|
3547
|
+
rawFee = _context.v;
|
|
3548
|
+
return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
|
|
3549
|
+
}
|
|
3550
|
+
}, _callee);
|
|
3551
|
+
}));
|
|
3552
|
+
return function getReverseTxFee(_x, _x2) {
|
|
3553
|
+
return _ref2.apply(this, arguments);
|
|
3554
|
+
};
|
|
3555
|
+
}();
|
|
3556
|
+
|
|
3477
3557
|
var AssetsPallet = /*#__PURE__*/function () {
|
|
3478
3558
|
function AssetsPallet() {
|
|
3479
3559
|
_classCallCheck(this, AssetsPallet);
|
|
@@ -4010,331 +4090,88 @@ var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
|
4010
4090
|
};
|
|
4011
4091
|
}();
|
|
4012
4092
|
|
|
4013
|
-
var
|
|
4014
|
-
var
|
|
4015
|
-
|
|
4016
|
-
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
4017
|
-
throwUnsupportedCurrency(feeAsset, origin);
|
|
4018
|
-
}
|
|
4019
|
-
return asset !== null && asset !== void 0 ? asset : undefined;
|
|
4020
|
-
};
|
|
4021
|
-
|
|
4022
|
-
var isAssetHub = function isAssetHub(chain) {
|
|
4023
|
-
return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
|
|
4024
|
-
};
|
|
4025
|
-
var isBridgeHub = function isBridgeHub(chain) {
|
|
4026
|
-
return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
|
|
4027
|
-
};
|
|
4028
|
-
var isPeople = function isPeople(chain) {
|
|
4029
|
-
return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
|
|
4030
|
-
};
|
|
4031
|
-
var isSystemPara = function isSystemPara(chain) {
|
|
4032
|
-
return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
|
|
4033
|
-
};
|
|
4034
|
-
var mul = function mul(v, num) {
|
|
4035
|
-
var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
|
|
4036
|
-
return v * num / den;
|
|
4037
|
-
};
|
|
4038
|
-
var padFee = function padFee(raw, origin, dest, side) {
|
|
4039
|
-
var relayOrigin = isRelayChain(origin);
|
|
4040
|
-
var relayDest = isRelayChain(dest);
|
|
4041
|
-
var sysParaOrigin = isSystemPara(origin);
|
|
4042
|
-
var sysParaDest = isSystemPara(dest);
|
|
4043
|
-
var relayToPara = relayOrigin && !relayDest;
|
|
4044
|
-
var sysParaToPara = sysParaOrigin && !sysParaDest;
|
|
4045
|
-
var paraToPara = !relayOrigin && !sysParaOrigin;
|
|
4046
|
-
if (sysParaToPara) return raw * 40n;
|
|
4047
|
-
if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
|
|
4048
|
-
if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
|
|
4049
|
-
return 150000000000000000n;
|
|
4050
|
-
}
|
|
4051
|
-
if (paraToPara) return mul(raw, 130n, 100n);
|
|
4052
|
-
// apply default 30% padding
|
|
4053
|
-
return mul(raw, 130n, 100n);
|
|
4054
|
-
};
|
|
4055
|
-
var padFeeBy = function padFeeBy(amount, percent) {
|
|
4056
|
-
return mul(amount, BigInt(100 + percent), 100n);
|
|
4057
|
-
};
|
|
4058
|
-
|
|
4059
|
-
var determineAddress = function determineAddress(chain, address, senderAddress) {
|
|
4060
|
-
if (isChainEvm(chain)) {
|
|
4061
|
-
return isAddress(address) ? address : senderAddress;
|
|
4062
|
-
}
|
|
4063
|
-
return isAddress(address) ? senderAddress : address;
|
|
4064
|
-
};
|
|
4065
|
-
var getReverseTxFee = /*#__PURE__*/function () {
|
|
4066
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
4067
|
-
var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
|
|
4093
|
+
var dryRun = /*#__PURE__*/function () {
|
|
4094
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
4095
|
+
var api, senderAddress, origin;
|
|
4068
4096
|
return _regenerator().w(function (_context) {
|
|
4069
|
-
while (1) switch (_context.n) {
|
|
4097
|
+
while (1) switch (_context.p = _context.n) {
|
|
4070
4098
|
case 0:
|
|
4071
|
-
api =
|
|
4072
|
-
|
|
4073
|
-
fromAddress = determineAddress(destination, address, senderAddress);
|
|
4099
|
+
api = options.api, senderAddress = options.senderAddress, origin = options.origin;
|
|
4100
|
+
validateAddress(senderAddress, origin, false);
|
|
4074
4101
|
_context.n = 1;
|
|
4075
|
-
return
|
|
4076
|
-
amount: currency.amount
|
|
4077
|
-
})).build();
|
|
4102
|
+
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4078
4103
|
case 1:
|
|
4079
|
-
|
|
4104
|
+
_context.p = 1;
|
|
4080
4105
|
_context.n = 2;
|
|
4081
|
-
return
|
|
4106
|
+
return dryRunInternal(options);
|
|
4082
4107
|
case 2:
|
|
4083
|
-
|
|
4084
|
-
|
|
4108
|
+
return _context.a(2, _context.v);
|
|
4109
|
+
case 3:
|
|
4110
|
+
_context.p = 3;
|
|
4111
|
+
_context.n = 4;
|
|
4112
|
+
return api.disconnect();
|
|
4113
|
+
case 4:
|
|
4114
|
+
return _context.f(3);
|
|
4115
|
+
case 5:
|
|
4116
|
+
return _context.a(2);
|
|
4085
4117
|
}
|
|
4086
|
-
}, _callee);
|
|
4118
|
+
}, _callee, null, [[1,, 3, 5]]);
|
|
4087
4119
|
}));
|
|
4088
|
-
return function
|
|
4089
|
-
return
|
|
4120
|
+
return function dryRun(_x) {
|
|
4121
|
+
return _ref.apply(this, arguments);
|
|
4090
4122
|
};
|
|
4091
4123
|
}();
|
|
4092
4124
|
|
|
4093
|
-
var
|
|
4094
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(
|
|
4095
|
-
var
|
|
4125
|
+
var dryRunOrigin = /*#__PURE__*/function () {
|
|
4126
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
4127
|
+
var api, chain, address, result;
|
|
4096
4128
|
return _regenerator().w(function (_context) {
|
|
4097
|
-
while (1) switch (_context.n) {
|
|
4129
|
+
while (1) switch (_context.p = _context.n) {
|
|
4098
4130
|
case 0:
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
return _context.a(2, undefined);
|
|
4131
|
+
api = options.api, chain = options.chain, address = options.address;
|
|
4132
|
+
validateAddress(address, chain, false);
|
|
4133
|
+
_context.n = 1;
|
|
4134
|
+
return api.init(chain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4104
4135
|
case 1:
|
|
4105
|
-
|
|
4136
|
+
_context.p = 1;
|
|
4106
4137
|
_context.n = 2;
|
|
4107
|
-
return
|
|
4108
|
-
api: api,
|
|
4109
|
-
chain: origin,
|
|
4110
|
-
address: senderAddress
|
|
4111
|
-
});
|
|
4138
|
+
return api.getDryRunCall(options);
|
|
4112
4139
|
case 2:
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
4116
|
-
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
4140
|
+
result = _context.v;
|
|
4141
|
+
if (!result.success) {
|
|
4117
4142
|
_context.n = 3;
|
|
4118
4143
|
break;
|
|
4119
4144
|
}
|
|
4120
|
-
return _context.a(2,
|
|
4145
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
|
|
4146
|
+
currency: getNativeAssetSymbol(chain)
|
|
4147
|
+
}));
|
|
4121
4148
|
case 3:
|
|
4122
|
-
|
|
4123
|
-
_context.n = 5;
|
|
4124
|
-
break;
|
|
4125
|
-
}
|
|
4126
|
-
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
4127
|
-
_context.n = 4;
|
|
4128
|
-
return getAssetBalance({
|
|
4129
|
-
api: api,
|
|
4130
|
-
chain: origin,
|
|
4131
|
-
address: senderAddress,
|
|
4132
|
-
currency: currency
|
|
4133
|
-
});
|
|
4149
|
+
return _context.a(2, result);
|
|
4134
4150
|
case 4:
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
4151
|
+
_context.p = 4;
|
|
4152
|
+
_context.n = 5;
|
|
4153
|
+
return api.disconnect();
|
|
4139
4154
|
case 5:
|
|
4140
|
-
return _context.
|
|
4155
|
+
return _context.f(4);
|
|
4141
4156
|
case 6:
|
|
4142
4157
|
return _context.a(2);
|
|
4143
4158
|
}
|
|
4144
|
-
}, _callee);
|
|
4159
|
+
}, _callee, null, [[1,, 4, 6]]);
|
|
4145
4160
|
}));
|
|
4146
|
-
return function
|
|
4161
|
+
return function dryRunOrigin(_x) {
|
|
4147
4162
|
return _ref.apply(this, arguments);
|
|
4148
4163
|
};
|
|
4149
4164
|
}();
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4165
|
+
|
|
4166
|
+
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
4167
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ahApi) {
|
|
4168
|
+
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
4169
|
+
return _regenerator().w(function (_context) {
|
|
4170
|
+
while (1) switch (_context.n) {
|
|
4155
4171
|
case 0:
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
break;
|
|
4160
|
-
}
|
|
4161
|
-
return _context2.a(2, undefined);
|
|
4162
|
-
case 1:
|
|
4163
|
-
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
4164
|
-
_context2.n = 2;
|
|
4165
|
-
return getBalanceNativeInternal({
|
|
4166
|
-
api: api,
|
|
4167
|
-
chain: destination,
|
|
4168
|
-
address: address
|
|
4169
|
-
});
|
|
4170
|
-
case 2:
|
|
4171
|
-
nativeBalance = _context2.v;
|
|
4172
|
-
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
4173
|
-
}
|
|
4174
|
-
}, _callee2);
|
|
4175
|
-
}));
|
|
4176
|
-
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
4177
|
-
return _ref2.apply(this, arguments);
|
|
4178
|
-
};
|
|
4179
|
-
}();
|
|
4180
|
-
|
|
4181
|
-
var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
4182
|
-
if (isRelayChain(origin)) return DOT_LOCATION;
|
|
4183
|
-
return {
|
|
4184
|
-
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
4185
|
-
interior: {
|
|
4186
|
-
X1: [{
|
|
4187
|
-
Parachain: getParaId(origin)
|
|
4188
|
-
}]
|
|
4189
|
-
}
|
|
4190
|
-
};
|
|
4191
|
-
};
|
|
4192
|
-
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4193
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
4194
|
-
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4195
|
-
return _regenerator().w(function (_context2) {
|
|
4196
|
-
while (1) switch (_context2.n) {
|
|
4197
|
-
case 0:
|
|
4198
|
-
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4199
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4200
|
-
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4201
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
4202
|
-
var originAsset, _t;
|
|
4203
|
-
return _regenerator().w(function (_context) {
|
|
4204
|
-
while (1) switch (_context.p = _context.n) {
|
|
4205
|
-
case 0:
|
|
4206
|
-
if (!(destination === 'Ethereum')) {
|
|
4207
|
-
_context.n = 1;
|
|
4208
|
-
break;
|
|
4209
|
-
}
|
|
4210
|
-
return _context.a(2, 0n);
|
|
4211
|
-
case 1:
|
|
4212
|
-
originAsset = findAssetInfoOrThrow(origin, currency, destination);
|
|
4213
|
-
if (!originAsset.location) {
|
|
4214
|
-
_context.n = 7;
|
|
4215
|
-
break;
|
|
4216
|
-
}
|
|
4217
|
-
_context.p = 2;
|
|
4218
|
-
_context.n = 3;
|
|
4219
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4220
|
-
destination: destination
|
|
4221
|
-
}), {
|
|
4222
|
-
location: originAsset.location
|
|
4223
|
-
});
|
|
4224
|
-
case 3:
|
|
4225
|
-
return _context.a(2, _context.v);
|
|
4226
|
-
case 4:
|
|
4227
|
-
_context.p = 4;
|
|
4228
|
-
_t = _context.v;
|
|
4229
|
-
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4230
|
-
_context.n = 6;
|
|
4231
|
-
break;
|
|
4232
|
-
}
|
|
4233
|
-
_context.n = 5;
|
|
4234
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4235
|
-
destination: destination
|
|
4236
|
-
}), {
|
|
4237
|
-
symbol: originAsset.symbol
|
|
4238
|
-
});
|
|
4239
|
-
case 5:
|
|
4240
|
-
return _context.a(2, _context.v);
|
|
4241
|
-
case 6:
|
|
4242
|
-
throw _t;
|
|
4243
|
-
case 7:
|
|
4244
|
-
_context.n = 8;
|
|
4245
|
-
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4246
|
-
destination: destination
|
|
4247
|
-
}), {
|
|
4248
|
-
symbol: originAsset.symbol
|
|
4249
|
-
});
|
|
4250
|
-
case 8:
|
|
4251
|
-
return _context.a(2, _context.v);
|
|
4252
|
-
}
|
|
4253
|
-
}, _callee, null, [[2, 4]]);
|
|
4254
|
-
}));
|
|
4255
|
-
return function calcPaymentInfoFee() {
|
|
4256
|
-
return _ref2.apply(this, arguments);
|
|
4257
|
-
};
|
|
4258
|
-
}();
|
|
4259
|
-
if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
4260
|
-
_context2.n = 3;
|
|
4261
|
-
break;
|
|
4262
|
-
}
|
|
4263
|
-
_context2.n = 1;
|
|
4264
|
-
return calcPaymentInfoFee();
|
|
4265
|
-
case 1:
|
|
4266
|
-
_fee = _context2.v;
|
|
4267
|
-
_context2.n = 2;
|
|
4268
|
-
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
|
|
4269
|
-
case 2:
|
|
4270
|
-
sufficient = _context2.v;
|
|
4271
|
-
return _context2.a(2, {
|
|
4272
|
-
fee: _fee,
|
|
4273
|
-
feeType: 'paymentInfo',
|
|
4274
|
-
sufficient: !hasDryRunSupport(destination) ? sufficient : false
|
|
4275
|
-
});
|
|
4276
|
-
case 3:
|
|
4277
|
-
_context2.n = 4;
|
|
4278
|
-
return api.getDryRunXcm({
|
|
4279
|
-
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
|
|
4280
|
-
xcm: forwardedXcms[1][0],
|
|
4281
|
-
chain: destination,
|
|
4282
|
-
origin: origin,
|
|
4283
|
-
asset: asset,
|
|
4284
|
-
originFee: originFee,
|
|
4285
|
-
feeAsset: resolvedFeeAsset,
|
|
4286
|
-
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
4287
|
-
});
|
|
4288
|
-
case 4:
|
|
4289
|
-
dryRunResult = _context2.v;
|
|
4290
|
-
if (dryRunResult.success) {
|
|
4291
|
-
_context2.n = 7;
|
|
4292
|
-
break;
|
|
4293
|
-
}
|
|
4294
|
-
if (!disableFallback) {
|
|
4295
|
-
_context2.n = 5;
|
|
4296
|
-
break;
|
|
4297
|
-
}
|
|
4298
|
-
return _context2.a(2, {
|
|
4299
|
-
dryRunError: dryRunResult.failureReason
|
|
4300
|
-
});
|
|
4301
|
-
case 5:
|
|
4302
|
-
_context2.n = 6;
|
|
4303
|
-
return calcPaymentInfoFee();
|
|
4304
|
-
case 6:
|
|
4305
|
-
_fee2 = _context2.v;
|
|
4306
|
-
return _context2.a(2, {
|
|
4307
|
-
fee: _fee2,
|
|
4308
|
-
feeType: 'paymentInfo',
|
|
4309
|
-
dryRunError: dryRunResult.failureReason,
|
|
4310
|
-
sufficient: false
|
|
4311
|
-
});
|
|
4312
|
-
case 7:
|
|
4313
|
-
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4314
|
-
return _context2.a(2, {
|
|
4315
|
-
fee: fee,
|
|
4316
|
-
feeType: 'dryRun',
|
|
4317
|
-
sufficient: true,
|
|
4318
|
-
forwardedXcms: newForwardedXcms,
|
|
4319
|
-
destParaId: destParaId
|
|
4320
|
-
});
|
|
4321
|
-
}
|
|
4322
|
-
}, _callee2);
|
|
4323
|
-
}));
|
|
4324
|
-
return function getDestXcmFee(_x) {
|
|
4325
|
-
return _ref.apply(this, arguments);
|
|
4326
|
-
};
|
|
4327
|
-
}();
|
|
4328
|
-
|
|
4329
|
-
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
4330
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ahApi) {
|
|
4331
|
-
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
4332
|
-
return _regenerator().w(function (_context) {
|
|
4333
|
-
while (1) switch (_context.n) {
|
|
4334
|
-
case 0:
|
|
4335
|
-
DEFAULT_FEE = 2750872500000n;
|
|
4336
|
-
_context.n = 1;
|
|
4337
|
-
return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
4172
|
+
DEFAULT_FEE = 2750872500000n;
|
|
4173
|
+
_context.n = 1;
|
|
4174
|
+
return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
4338
4175
|
case 1:
|
|
4339
4176
|
feeStorageItem = _context.v;
|
|
4340
4177
|
leFeeHex = feeStorageItem.replace('0x', '');
|
|
@@ -5056,340 +4893,63 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5056
4893
|
};
|
|
5057
4894
|
}();
|
|
5058
4895
|
|
|
5059
|
-
var
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
4896
|
+
var AssetManagerPallet = /*#__PURE__*/function () {
|
|
4897
|
+
function AssetManagerPallet() {
|
|
4898
|
+
_classCallCheck(this, AssetManagerPallet);
|
|
4899
|
+
}
|
|
4900
|
+
return _createClass(AssetManagerPallet, [{
|
|
4901
|
+
key: "setBalance",
|
|
4902
|
+
value: function setBalance(address, asset) {
|
|
4903
|
+
assertHasId(asset);
|
|
4904
|
+
var assetId = asset.assetId,
|
|
4905
|
+
amount = asset.amount;
|
|
4906
|
+
return Promise.resolve({
|
|
4907
|
+
balanceTx: {
|
|
4908
|
+
module: 'AssetManager',
|
|
4909
|
+
method: 'updateBalance',
|
|
4910
|
+
parameters: {
|
|
4911
|
+
who: {
|
|
4912
|
+
Id: address
|
|
4913
|
+
},
|
|
4914
|
+
currency_id: {
|
|
4915
|
+
ForeignAsset: assetId
|
|
4916
|
+
},
|
|
4917
|
+
amount: amount
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
});
|
|
5069
4921
|
}
|
|
4922
|
+
}]);
|
|
4923
|
+
}();
|
|
4924
|
+
|
|
4925
|
+
var BalancesPallet = /*#__PURE__*/function () {
|
|
4926
|
+
function BalancesPallet() {
|
|
4927
|
+
_classCallCheck(this, BalancesPallet);
|
|
5070
4928
|
}
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
var
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
4929
|
+
return _createClass(BalancesPallet, [{
|
|
4930
|
+
key: "setBalance",
|
|
4931
|
+
value: function setBalance(address, assetInfo, chain) {
|
|
4932
|
+
var amount = assetInfo.amount;
|
|
4933
|
+
var notUseId = chain.startsWith('Hydration') || chain === 'Basilisk' || isChainEvm(chain);
|
|
4934
|
+
return Promise.resolve({
|
|
4935
|
+
balanceTx: {
|
|
4936
|
+
module: 'Balances',
|
|
4937
|
+
method: 'force_set_balance',
|
|
4938
|
+
parameters: {
|
|
4939
|
+
who: notUseId ? address : {
|
|
4940
|
+
Id: address
|
|
4941
|
+
},
|
|
4942
|
+
new_free: amount
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4945
|
+
});
|
|
5082
4946
|
}
|
|
5083
|
-
}
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
};
|
|
5090
|
-
var dryRunInternal = /*#__PURE__*/function () {
|
|
5091
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5092
|
-
var _traversalResult$brid, _traversalResult$asse, _traversalResult$dest;
|
|
5093
|
-
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, originWithCurrency, assetHubWithCurrency, bridgeHubWithCurrency, destinationWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
|
|
5094
|
-
return _regenerator().w(function (_context2) {
|
|
5095
|
-
while (1) switch (_context2.n) {
|
|
5096
|
-
case 0:
|
|
5097
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset, swapConfig = options.swapConfig;
|
|
5098
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
5099
|
-
asset = findAssetInfoOrThrow(origin, currency, destination);
|
|
5100
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
5101
|
-
_context2.n = 1;
|
|
5102
|
-
return api.getDryRunCall({
|
|
5103
|
-
tx: tx,
|
|
5104
|
-
chain: origin,
|
|
5105
|
-
address: senderAddress,
|
|
5106
|
-
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5107
|
-
amount: amount
|
|
5108
|
-
}),
|
|
5109
|
-
feeAsset: resolvedFeeAsset
|
|
5110
|
-
});
|
|
5111
|
-
case 1:
|
|
5112
|
-
originDryRun = _context2.v;
|
|
5113
|
-
if (originDryRun.success) {
|
|
5114
|
-
_context2.n = 2;
|
|
5115
|
-
break;
|
|
5116
|
-
}
|
|
5117
|
-
return _context2.a(2, {
|
|
5118
|
-
failureReason: originDryRun.failureReason,
|
|
5119
|
-
failureChain: 'origin',
|
|
5120
|
-
origin: originDryRun,
|
|
5121
|
-
hops: []
|
|
5122
|
-
});
|
|
5123
|
-
case 2:
|
|
5124
|
-
initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
|
|
5125
|
-
processHop = /*#__PURE__*/function () {
|
|
5126
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5127
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopDryRun, hopCurrency;
|
|
5128
|
-
return _regenerator().w(function (_context) {
|
|
5129
|
-
while (1) switch (_context.n) {
|
|
5130
|
-
case 0:
|
|
5131
|
-
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
5132
|
-
if (hasDryRunSupport(currentChain)) {
|
|
5133
|
-
_context.n = 1;
|
|
5134
|
-
break;
|
|
5135
|
-
}
|
|
5136
|
-
return _context.a(2, {
|
|
5137
|
-
success: false,
|
|
5138
|
-
failureReason: "DryRunApi is not available on chain ".concat(currentChain)
|
|
5139
|
-
});
|
|
5140
|
-
case 1:
|
|
5141
|
-
_context.n = 2;
|
|
5142
|
-
return hopApi.getDryRunXcm({
|
|
5143
|
-
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, currentChain), Version.V4),
|
|
5144
|
-
xcm: forwardedXcms[1][0],
|
|
5145
|
-
chain: currentChain,
|
|
5146
|
-
origin: currentOrigin,
|
|
5147
|
-
asset: currentAsset,
|
|
5148
|
-
feeAsset: resolvedFeeAsset,
|
|
5149
|
-
originFee: originDryRun.fee,
|
|
5150
|
-
amount: amount
|
|
5151
|
-
});
|
|
5152
|
-
case 2:
|
|
5153
|
-
hopDryRun = _context.v;
|
|
5154
|
-
if (!hopDryRun.success) {
|
|
5155
|
-
_context.n = 3;
|
|
5156
|
-
break;
|
|
5157
|
-
}
|
|
5158
|
-
if (destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub'))) {
|
|
5159
|
-
hopCurrency = getNativeAssetSymbol(currentChain);
|
|
5160
|
-
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5161
|
-
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
|
|
5162
|
-
} else if (isDestination) {
|
|
5163
|
-
hopCurrency = findAssetOnDestOrThrow(origin, currentChain, currency).symbol;
|
|
5164
|
-
} else {
|
|
5165
|
-
hopCurrency = asset.symbol;
|
|
5166
|
-
}
|
|
5167
|
-
return _context.a(2, _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
|
|
5168
|
-
currency: hopCurrency
|
|
5169
|
-
}));
|
|
5170
|
-
case 3:
|
|
5171
|
-
return _context.a(2, hopDryRun);
|
|
5172
|
-
}
|
|
5173
|
-
}, _callee);
|
|
5174
|
-
}));
|
|
5175
|
-
return function processHop(_x2) {
|
|
5176
|
-
return _ref2.apply(this, arguments);
|
|
5177
|
-
};
|
|
5178
|
-
}();
|
|
5179
|
-
_context2.n = 3;
|
|
5180
|
-
return traverseXcmHops({
|
|
5181
|
-
api: api,
|
|
5182
|
-
origin: origin,
|
|
5183
|
-
destination: destination,
|
|
5184
|
-
currency: currency,
|
|
5185
|
-
initialForwardedXcms: initialForwardedXcms,
|
|
5186
|
-
initialDestParaId: initialDestParaId,
|
|
5187
|
-
swapConfig: swapConfig,
|
|
5188
|
-
processHop: processHop,
|
|
5189
|
-
shouldContinue: function shouldContinue(hopResult) {
|
|
5190
|
-
return hopResult.success;
|
|
5191
|
-
},
|
|
5192
|
-
extractNextHopData: function extractNextHopData(hopResult) {
|
|
5193
|
-
return {
|
|
5194
|
-
forwardedXcms: hopResult.success ? hopResult.forwardedXcms : undefined,
|
|
5195
|
-
destParaId: hopResult.success ? hopResult.destParaId : undefined
|
|
5196
|
-
};
|
|
5197
|
-
}
|
|
5198
|
-
});
|
|
5199
|
-
case 3:
|
|
5200
|
-
traversalResult = _context2.v;
|
|
5201
|
-
// Process Ethereum bridge fees
|
|
5202
|
-
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
5203
|
-
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
|
|
5204
|
-
if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
|
|
5205
|
-
_context2.n = 5;
|
|
5206
|
-
break;
|
|
5207
|
-
}
|
|
5208
|
-
_context2.n = 4;
|
|
5209
|
-
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
|
|
5210
|
-
case 4:
|
|
5211
|
-
_t = _context2.v;
|
|
5212
|
-
_context2.n = 6;
|
|
5213
|
-
break;
|
|
5214
|
-
case 5:
|
|
5215
|
-
_t = traversalResult.bridgeHub;
|
|
5216
|
-
case 6:
|
|
5217
|
-
processedBridgeHub = _t;
|
|
5218
|
-
// Update bridge hub in hops if needed
|
|
5219
|
-
if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
5220
|
-
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
5221
|
-
return hop.chain === bridgeHubChain;
|
|
5222
|
-
});
|
|
5223
|
-
if (bridgeHubHopIndex !== -1 && traversalResult.hops[bridgeHubHopIndex].result.success) {
|
|
5224
|
-
traversalResult.hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, traversalResult.hops[bridgeHubHopIndex].result), {}, {
|
|
5225
|
-
fee: processedBridgeHub.fee
|
|
5226
|
-
});
|
|
5227
|
-
}
|
|
5228
|
-
}
|
|
5229
|
-
originWithCurrency = originDryRun.success ? _objectSpread2(_objectSpread2({}, originDryRun), {}, {
|
|
5230
|
-
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(origin)
|
|
5231
|
-
}) : originDryRun;
|
|
5232
|
-
assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
|
|
5233
|
-
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(assetHubChain)
|
|
5234
|
-
}) : traversalResult.assetHub;
|
|
5235
|
-
bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
|
|
5236
|
-
currency: getNativeAssetSymbol(bridgeHubChain)
|
|
5237
|
-
}) : processedBridgeHub;
|
|
5238
|
-
destinationWithCurrency = (_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0 && _traversalResult$dest.success ? _objectSpread2(_objectSpread2({}, traversalResult.destination), {}, {
|
|
5239
|
-
currency: asset === null || asset === void 0 ? void 0 : asset.symbol
|
|
5240
|
-
}) : traversalResult.destination;
|
|
5241
|
-
_getFailureInfo = getFailureInfo$1({
|
|
5242
|
-
destination: destinationWithCurrency,
|
|
5243
|
-
assetHub: assetHubWithCurrency,
|
|
5244
|
-
bridgeHub: bridgeHubWithCurrency
|
|
5245
|
-
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5246
|
-
return _context2.a(2, {
|
|
5247
|
-
failureReason: failureReason,
|
|
5248
|
-
failureChain: failureChain,
|
|
5249
|
-
origin: originWithCurrency,
|
|
5250
|
-
assetHub: assetHubWithCurrency,
|
|
5251
|
-
bridgeHub: bridgeHubWithCurrency,
|
|
5252
|
-
destination: destinationWithCurrency,
|
|
5253
|
-
hops: traversalResult.hops
|
|
5254
|
-
});
|
|
5255
|
-
}
|
|
5256
|
-
}, _callee2);
|
|
5257
|
-
}));
|
|
5258
|
-
return function dryRunInternal(_x) {
|
|
5259
|
-
return _ref.apply(this, arguments);
|
|
5260
|
-
};
|
|
5261
|
-
}();
|
|
5262
|
-
|
|
5263
|
-
var dryRun = /*#__PURE__*/function () {
|
|
5264
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
5265
|
-
var api, senderAddress, origin;
|
|
5266
|
-
return _regenerator().w(function (_context) {
|
|
5267
|
-
while (1) switch (_context.p = _context.n) {
|
|
5268
|
-
case 0:
|
|
5269
|
-
api = options.api, senderAddress = options.senderAddress, origin = options.origin;
|
|
5270
|
-
validateAddress(senderAddress, origin, false);
|
|
5271
|
-
_context.n = 1;
|
|
5272
|
-
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5273
|
-
case 1:
|
|
5274
|
-
_context.p = 1;
|
|
5275
|
-
_context.n = 2;
|
|
5276
|
-
return dryRunInternal(options);
|
|
5277
|
-
case 2:
|
|
5278
|
-
return _context.a(2, _context.v);
|
|
5279
|
-
case 3:
|
|
5280
|
-
_context.p = 3;
|
|
5281
|
-
_context.n = 4;
|
|
5282
|
-
return api.disconnect();
|
|
5283
|
-
case 4:
|
|
5284
|
-
return _context.f(3);
|
|
5285
|
-
case 5:
|
|
5286
|
-
return _context.a(2);
|
|
5287
|
-
}
|
|
5288
|
-
}, _callee, null, [[1,, 3, 5]]);
|
|
5289
|
-
}));
|
|
5290
|
-
return function dryRun(_x) {
|
|
5291
|
-
return _ref.apply(this, arguments);
|
|
5292
|
-
};
|
|
5293
|
-
}();
|
|
5294
|
-
|
|
5295
|
-
var dryRunOrigin = /*#__PURE__*/function () {
|
|
5296
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
5297
|
-
var api, chain, address, result;
|
|
5298
|
-
return _regenerator().w(function (_context) {
|
|
5299
|
-
while (1) switch (_context.p = _context.n) {
|
|
5300
|
-
case 0:
|
|
5301
|
-
api = options.api, chain = options.chain, address = options.address;
|
|
5302
|
-
validateAddress(address, chain, false);
|
|
5303
|
-
_context.n = 1;
|
|
5304
|
-
return api.init(chain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5305
|
-
case 1:
|
|
5306
|
-
_context.p = 1;
|
|
5307
|
-
_context.n = 2;
|
|
5308
|
-
return api.getDryRunCall(options);
|
|
5309
|
-
case 2:
|
|
5310
|
-
result = _context.v;
|
|
5311
|
-
if (!result.success) {
|
|
5312
|
-
_context.n = 3;
|
|
5313
|
-
break;
|
|
5314
|
-
}
|
|
5315
|
-
return _context.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
|
|
5316
|
-
currency: getNativeAssetSymbol(chain)
|
|
5317
|
-
}));
|
|
5318
|
-
case 3:
|
|
5319
|
-
return _context.a(2, result);
|
|
5320
|
-
case 4:
|
|
5321
|
-
_context.p = 4;
|
|
5322
|
-
_context.n = 5;
|
|
5323
|
-
return api.disconnect();
|
|
5324
|
-
case 5:
|
|
5325
|
-
return _context.f(4);
|
|
5326
|
-
case 6:
|
|
5327
|
-
return _context.a(2);
|
|
5328
|
-
}
|
|
5329
|
-
}, _callee, null, [[1,, 4, 6]]);
|
|
5330
|
-
}));
|
|
5331
|
-
return function dryRunOrigin(_x) {
|
|
5332
|
-
return _ref.apply(this, arguments);
|
|
5333
|
-
};
|
|
5334
|
-
}();
|
|
5335
|
-
|
|
5336
|
-
var AssetManagerPallet = /*#__PURE__*/function () {
|
|
5337
|
-
function AssetManagerPallet() {
|
|
5338
|
-
_classCallCheck(this, AssetManagerPallet);
|
|
5339
|
-
}
|
|
5340
|
-
return _createClass(AssetManagerPallet, [{
|
|
5341
|
-
key: "setBalance",
|
|
5342
|
-
value: function setBalance(address, asset) {
|
|
5343
|
-
assertHasId(asset);
|
|
5344
|
-
var assetId = asset.assetId,
|
|
5345
|
-
amount = asset.amount;
|
|
5346
|
-
return Promise.resolve({
|
|
5347
|
-
balanceTx: {
|
|
5348
|
-
module: 'AssetManager',
|
|
5349
|
-
method: 'updateBalance',
|
|
5350
|
-
parameters: {
|
|
5351
|
-
who: {
|
|
5352
|
-
Id: address
|
|
5353
|
-
},
|
|
5354
|
-
currency_id: {
|
|
5355
|
-
ForeignAsset: assetId
|
|
5356
|
-
},
|
|
5357
|
-
amount: amount
|
|
5358
|
-
}
|
|
5359
|
-
}
|
|
5360
|
-
});
|
|
5361
|
-
}
|
|
5362
|
-
}]);
|
|
5363
|
-
}();
|
|
5364
|
-
|
|
5365
|
-
var BalancesPallet = /*#__PURE__*/function () {
|
|
5366
|
-
function BalancesPallet() {
|
|
5367
|
-
_classCallCheck(this, BalancesPallet);
|
|
5368
|
-
}
|
|
5369
|
-
return _createClass(BalancesPallet, [{
|
|
5370
|
-
key: "setBalance",
|
|
5371
|
-
value: function setBalance(address, assetInfo, chain) {
|
|
5372
|
-
var amount = assetInfo.amount;
|
|
5373
|
-
var notUseId = chain.startsWith('Hydration') || chain === 'Basilisk' || isChainEvm(chain);
|
|
5374
|
-
return Promise.resolve({
|
|
5375
|
-
balanceTx: {
|
|
5376
|
-
module: 'Balances',
|
|
5377
|
-
method: 'force_set_balance',
|
|
5378
|
-
parameters: {
|
|
5379
|
-
who: notUseId ? address : {
|
|
5380
|
-
Id: address
|
|
5381
|
-
},
|
|
5382
|
-
new_free: amount
|
|
5383
|
-
}
|
|
5384
|
-
}
|
|
5385
|
-
});
|
|
5386
|
-
}
|
|
5387
|
-
}]);
|
|
5388
|
-
}();
|
|
5389
|
-
|
|
5390
|
-
var CurrenciesPallet = /*#__PURE__*/function () {
|
|
5391
|
-
function CurrenciesPallet() {
|
|
5392
|
-
_classCallCheck(this, CurrenciesPallet);
|
|
4947
|
+
}]);
|
|
4948
|
+
}();
|
|
4949
|
+
|
|
4950
|
+
var CurrenciesPallet = /*#__PURE__*/function () {
|
|
4951
|
+
function CurrenciesPallet() {
|
|
4952
|
+
_classCallCheck(this, CurrenciesPallet);
|
|
5393
4953
|
}
|
|
5394
4954
|
return _createClass(CurrenciesPallet, [{
|
|
5395
4955
|
key: "setBalance",
|
|
@@ -5784,7 +5344,7 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
|
|
|
5784
5344
|
destination = _ref.to,
|
|
5785
5345
|
currency = _ref.currency;
|
|
5786
5346
|
var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
5787
|
-
var allowedChainsToAh = ['AssetHubPolkadot', 'BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec', 'Jamton'];
|
|
5347
|
+
var allowedChainsToAh = ['AssetHubPolkadot', 'BridgeHubPolkadot', 'PeoplePolkadot', 'CoretimePolkadot', 'Collectives', 'BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec', 'Jamton'];
|
|
5788
5348
|
if (!isRelayChain(origin) && !isBridge && isDestAssetHub && !allowedChainsToAh.includes(origin) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
|
|
5789
5349
|
throw new TransferToAhNotSupported("Chain ".concat(origin, " does not support DOT transfer to AssetHub"));
|
|
5790
5350
|
}
|
|
@@ -5977,7 +5537,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
5977
5537
|
};
|
|
5978
5538
|
}();
|
|
5979
5539
|
|
|
5980
|
-
var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
5540
|
+
var getFailureInfo$1 = function getFailureInfo(chains, hops) {
|
|
5981
5541
|
var _chains$origin, _chains$assetHub, _chains$bridgeHub, _chains$destination;
|
|
5982
5542
|
// Check standard chains first for backwards compatibility
|
|
5983
5543
|
if ((_chains$origin = chains.origin) !== null && _chains$origin !== void 0 && _chains$origin.dryRunError) return {
|
|
@@ -6104,7 +5664,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
6104
5664
|
}),
|
|
6105
5665
|
hops: []
|
|
6106
5666
|
};
|
|
6107
|
-
_getFailureInfo = getFailureInfo({
|
|
5667
|
+
_getFailureInfo = getFailureInfo$1({
|
|
6108
5668
|
origin: _result.origin,
|
|
6109
5669
|
destination: _result.destination
|
|
6110
5670
|
}, []), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
|
|
@@ -6316,7 +5876,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
6316
5876
|
};
|
|
6317
5877
|
})
|
|
6318
5878
|
});
|
|
6319
|
-
_getFailureInfo2 = getFailureInfo({
|
|
5879
|
+
_getFailureInfo2 = getFailureInfo$1({
|
|
6320
5880
|
origin: result.origin,
|
|
6321
5881
|
assetHub: result.assetHub,
|
|
6322
5882
|
bridgeHub: result.bridgeHub,
|
|
@@ -6937,68 +6497,13 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
6937
6497
|
};
|
|
6938
6498
|
}();
|
|
6939
6499
|
|
|
6940
|
-
var attemptDryRunFee = /*#__PURE__*/function () {
|
|
6941
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
6942
|
-
var origin, currency, builder, reductionPcts, lastReduction, result, _i, _reductionPcts, percentage, modifiedBuilder, _t, _t2, _t3, _t4, _t5, _t6, _t7;
|
|
6943
|
-
return _regenerator().w(function (_context) {
|
|
6944
|
-
while (1) switch (_context.n) {
|
|
6945
|
-
case 0:
|
|
6946
|
-
origin = options.origin, currency = options.currency, builder = options.builder;
|
|
6947
|
-
reductionPcts = [0, 10, 20, 30, 40, 50];
|
|
6948
|
-
lastReduction = reductionPcts[reductionPcts.length - 1];
|
|
6949
|
-
result = null;
|
|
6950
|
-
_i = 0, _reductionPcts = reductionPcts;
|
|
6951
|
-
case 1:
|
|
6952
|
-
if (!(_i < _reductionPcts.length)) {
|
|
6953
|
-
_context.n = 5;
|
|
6954
|
-
break;
|
|
6955
|
-
}
|
|
6956
|
-
percentage = _reductionPcts[_i];
|
|
6957
|
-
modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
|
|
6958
|
-
amount: padFeeBy(BigInt(currency.amount), -percentage)
|
|
6959
|
-
}));
|
|
6960
|
-
_t = getOriginXcmFeeInternal;
|
|
6961
|
-
_t2 = _objectSpread2;
|
|
6962
|
-
_t3 = _objectSpread2({}, options);
|
|
6963
|
-
_t4 = {};
|
|
6964
|
-
_context.n = 2;
|
|
6965
|
-
return modifiedBuilder.build();
|
|
6966
|
-
case 2:
|
|
6967
|
-
_t5 = _context.v;
|
|
6968
|
-
_t6 = {
|
|
6969
|
-
tx: _t5
|
|
6970
|
-
};
|
|
6971
|
-
_t7 = _t2(_t3, _t4, _t6);
|
|
6972
|
-
_context.n = 3;
|
|
6973
|
-
return _t(_t7);
|
|
6974
|
-
case 3:
|
|
6975
|
-
result = _context.v;
|
|
6976
|
-
if (!(result.feeType === 'dryRun' || percentage === lastReduction || !hasDryRunSupport(origin))) {
|
|
6977
|
-
_context.n = 4;
|
|
6978
|
-
break;
|
|
6979
|
-
}
|
|
6980
|
-
return _context.a(2, result);
|
|
6981
|
-
case 4:
|
|
6982
|
-
_i++;
|
|
6983
|
-
_context.n = 1;
|
|
6984
|
-
break;
|
|
6985
|
-
case 5:
|
|
6986
|
-
return _context.a(2, result);
|
|
6987
|
-
}
|
|
6988
|
-
}, _callee);
|
|
6989
|
-
}));
|
|
6990
|
-
return function attemptDryRunFee(_x) {
|
|
6991
|
-
return _ref.apply(this, arguments);
|
|
6992
|
-
};
|
|
6993
|
-
}();
|
|
6994
|
-
|
|
6995
6500
|
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
6996
6501
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
6997
|
-
var api, senderAddress, chain, destination, currency,
|
|
6502
|
+
var api, senderAddress, chain, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, amount, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
|
|
6998
6503
|
return _regenerator().w(function (_context) {
|
|
6999
6504
|
while (1) switch (_context.n) {
|
|
7000
6505
|
case 0:
|
|
7001
|
-
api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency,
|
|
6506
|
+
api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, tx = _ref.tx, feeAsset = _ref.feeAsset;
|
|
7002
6507
|
validateAddress(senderAddress, chain, false);
|
|
7003
6508
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
|
|
7004
6509
|
asset = findAssetInfoOrThrow(chain, currency, null);
|
|
@@ -7021,9 +6526,9 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7021
6526
|
break;
|
|
7022
6527
|
}
|
|
7023
6528
|
_context.n = 2;
|
|
7024
|
-
return
|
|
6529
|
+
return getOriginXcmFee({
|
|
7025
6530
|
api: api,
|
|
7026
|
-
|
|
6531
|
+
tx: tx,
|
|
7027
6532
|
origin: chain,
|
|
7028
6533
|
destination: chain,
|
|
7029
6534
|
senderAddress: senderAddress,
|
|
@@ -7034,8 +6539,8 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
7034
6539
|
disableFallback: false
|
|
7035
6540
|
});
|
|
7036
6541
|
case 2:
|
|
7037
|
-
_yield$
|
|
7038
|
-
fee = _yield$
|
|
6542
|
+
_yield$getOriginXcmFe = _context.v;
|
|
6543
|
+
fee = _yield$getOriginXcmFe.fee;
|
|
7039
6544
|
if (!(fee === undefined)) {
|
|
7040
6545
|
_context.n = 3;
|
|
7041
6546
|
break;
|
|
@@ -7076,599 +6581,1018 @@ var getTransferableAmount = /*#__PURE__*/function () {
|
|
|
7076
6581
|
case 5:
|
|
7077
6582
|
return _context2.a(2);
|
|
7078
6583
|
}
|
|
7079
|
-
}, _callee2, null, [[1,, 3, 5]]);
|
|
6584
|
+
}, _callee2, null, [[1,, 3, 5]]);
|
|
6585
|
+
}));
|
|
6586
|
+
return function getTransferableAmount(_x2) {
|
|
6587
|
+
return _ref3.apply(this, arguments);
|
|
6588
|
+
};
|
|
6589
|
+
}();
|
|
6590
|
+
|
|
6591
|
+
var buildDestInfo = /*#__PURE__*/function () {
|
|
6592
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
6593
|
+
var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destAsset, edDest, edDestBn, destCurrency, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
6594
|
+
return _regenerator().w(function (_context) {
|
|
6595
|
+
while (1) switch (_context.n) {
|
|
6596
|
+
case 0:
|
|
6597
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, address = _ref.address, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, destFeeDetail = _ref.destFeeDetail, assetHubFee = _ref.assetHubFee, bridgeFee = _ref.bridgeFee;
|
|
6598
|
+
destApi = api.clone();
|
|
6599
|
+
if (!(destination !== 'Ethereum')) {
|
|
6600
|
+
_context.n = 1;
|
|
6601
|
+
break;
|
|
6602
|
+
}
|
|
6603
|
+
_context.n = 1;
|
|
6604
|
+
return destApi.init(destination);
|
|
6605
|
+
case 1:
|
|
6606
|
+
destAsset = findAssetOnDestOrThrow(origin, destination, currency);
|
|
6607
|
+
edDest = destAsset.existentialDeposit;
|
|
6608
|
+
if (edDest) {
|
|
6609
|
+
_context.n = 2;
|
|
6610
|
+
break;
|
|
6611
|
+
}
|
|
6612
|
+
throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency, replaceBigInt)));
|
|
6613
|
+
case 2:
|
|
6614
|
+
edDestBn = BigInt(edDest);
|
|
6615
|
+
destCurrency = destAsset.location ? {
|
|
6616
|
+
location: destAsset.location
|
|
6617
|
+
} : {
|
|
6618
|
+
symbol: destAsset.symbol
|
|
6619
|
+
};
|
|
6620
|
+
_context.n = 3;
|
|
6621
|
+
return getAssetBalanceInternal({
|
|
6622
|
+
api: destApi,
|
|
6623
|
+
address: address,
|
|
6624
|
+
chain: destination,
|
|
6625
|
+
currency: destCurrency
|
|
6626
|
+
});
|
|
6627
|
+
case 3:
|
|
6628
|
+
destBalance = _context.v;
|
|
6629
|
+
destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
|
|
6630
|
+
effectiveAmountForBalance = destAmount;
|
|
6631
|
+
if (destination === 'Ethereum' && assetHubFee !== undefined) {
|
|
6632
|
+
effectiveAmountForBalance -= assetHubFee;
|
|
6633
|
+
}
|
|
6634
|
+
destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
|
|
6635
|
+
destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
|
|
6636
|
+
destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
|
|
6637
|
+
destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
|
|
6638
|
+
isAssetHubToAssetHubRoute = origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot' || origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama';
|
|
6639
|
+
if (isAssetHubToAssetHubRoute) {
|
|
6640
|
+
nativeAssetOfOriginSymbol = getNativeAssetSymbol(origin);
|
|
6641
|
+
isOriginAssetNative = false;
|
|
6642
|
+
if (destAsset.symbol === nativeAssetOfOriginSymbol) {
|
|
6643
|
+
isOriginAssetNative = true;
|
|
6644
|
+
}
|
|
6645
|
+
if (isOriginAssetNative) {
|
|
6646
|
+
if (bridgeFee === undefined) {
|
|
6647
|
+
receivedAmount = new UnableToComputeError("bridgeFee is required for native asset transfer from ".concat(origin, " to ").concat(destination, " but was not provided."));
|
|
6648
|
+
} else {
|
|
6649
|
+
receivedAmount = BigInt(currency.amount) - originFee - bridgeFee;
|
|
6650
|
+
}
|
|
6651
|
+
} else {
|
|
6652
|
+
receivedAmount = new UnableToComputeError("Unable to compute received amount: The transferred asset (".concat(destAsset.symbol, ") is not the native asset (").concat(nativeAssetOfOriginSymbol, ") of origin ").concat(origin, " for the ").concat(origin, "->").concat(destination, " route."));
|
|
6653
|
+
}
|
|
6654
|
+
} else {
|
|
6655
|
+
if (destbalanceAfterResult instanceof UnableToComputeError) {
|
|
6656
|
+
receivedAmount = destbalanceAfterResult;
|
|
6657
|
+
} else {
|
|
6658
|
+
receivedAmount = destbalanceAfterResult - destBalance;
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
isDestFeeInNativeCurrency = destFeeDetail.currency === getNativeAssetSymbol(destination);
|
|
6662
|
+
if (!isDestFeeInNativeCurrency) {
|
|
6663
|
+
_context.n = 5;
|
|
6664
|
+
break;
|
|
6665
|
+
}
|
|
6666
|
+
_context.n = 4;
|
|
6667
|
+
return getBalanceNativeInternal({
|
|
6668
|
+
address: address,
|
|
6669
|
+
chain: destination,
|
|
6670
|
+
api: destApi
|
|
6671
|
+
});
|
|
6672
|
+
case 4:
|
|
6673
|
+
destRecipientNativeBalance = _context.v;
|
|
6674
|
+
destXcmFeeBalance = destRecipientNativeBalance;
|
|
6675
|
+
_context.n = 6;
|
|
6676
|
+
break;
|
|
6677
|
+
case 5:
|
|
6678
|
+
destXcmFeeBalance = destBalance;
|
|
6679
|
+
case 6:
|
|
6680
|
+
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
|
|
6681
|
+
return _context.a(2, {
|
|
6682
|
+
receivedCurrency: {
|
|
6683
|
+
sufficient: destBalanceSufficientResult,
|
|
6684
|
+
receivedAmount: receivedAmount,
|
|
6685
|
+
balance: destBalance,
|
|
6686
|
+
balanceAfter: destbalanceAfterResult,
|
|
6687
|
+
currencySymbol: destAsset.symbol,
|
|
6688
|
+
existentialDeposit: edDestBn
|
|
6689
|
+
},
|
|
6690
|
+
xcmFee: {
|
|
6691
|
+
fee: destFeeDetail.fee,
|
|
6692
|
+
balance: destXcmFeeBalance,
|
|
6693
|
+
balanceAfter: destXcmFeeBalanceAfter,
|
|
6694
|
+
currencySymbol: destFeeDetail.currency
|
|
6695
|
+
}
|
|
6696
|
+
});
|
|
6697
|
+
}
|
|
6698
|
+
}, _callee);
|
|
6699
|
+
}));
|
|
6700
|
+
return function buildDestInfo(_x) {
|
|
6701
|
+
return _ref2.apply(this, arguments);
|
|
6702
|
+
};
|
|
6703
|
+
}();
|
|
6704
|
+
|
|
6705
|
+
var buildHopInfo = /*#__PURE__*/function () {
|
|
6706
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
6707
|
+
var api, chain, feeData, originChain, currency, senderAddress, ahAddress, hopApi, resolvedAddress, nativeBalanceOnHop, nativeAssetSymbolOnHop, xcmFeeDetails, isBridgeHub, hopAsset, hopCurrencyPayload, balance, ed;
|
|
6708
|
+
return _regenerator().w(function (_context) {
|
|
6709
|
+
while (1) switch (_context.p = _context.n) {
|
|
6710
|
+
case 0:
|
|
6711
|
+
api = _ref.api, chain = _ref.chain, feeData = _ref.feeData, originChain = _ref.originChain, currency = _ref.currency, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress;
|
|
6712
|
+
hopApi = api.clone();
|
|
6713
|
+
_context.n = 1;
|
|
6714
|
+
return hopApi.init(chain);
|
|
6715
|
+
case 1:
|
|
6716
|
+
hopApi.setDisconnectAllowed(false);
|
|
6717
|
+
_context.p = 2;
|
|
6718
|
+
resolvedAddress = isChainEvm(originChain) && ahAddress ? ahAddress : senderAddress;
|
|
6719
|
+
_context.n = 3;
|
|
6720
|
+
return getBalanceNativeInternal({
|
|
6721
|
+
api: hopApi,
|
|
6722
|
+
address: resolvedAddress,
|
|
6723
|
+
chain: chain
|
|
6724
|
+
});
|
|
6725
|
+
case 3:
|
|
6726
|
+
nativeBalanceOnHop = _context.v;
|
|
6727
|
+
nativeAssetSymbolOnHop = getNativeAssetSymbol(chain);
|
|
6728
|
+
xcmFeeDetails = {
|
|
6729
|
+
fee: feeData.fee,
|
|
6730
|
+
balance: nativeBalanceOnHop,
|
|
6731
|
+
currencySymbol: nativeAssetSymbolOnHop
|
|
6732
|
+
};
|
|
6733
|
+
isBridgeHub = chain.includes('BridgeHub');
|
|
6734
|
+
if (!isBridgeHub) {
|
|
6735
|
+
_context.n = 4;
|
|
6736
|
+
break;
|
|
6737
|
+
}
|
|
6738
|
+
return _context.a(2, {
|
|
6739
|
+
currencySymbol: getNativeAssetSymbol(chain),
|
|
6740
|
+
xcmFee: xcmFeeDetails
|
|
6741
|
+
});
|
|
6742
|
+
case 4:
|
|
6743
|
+
hopAsset = findAssetOnDestOrThrow(originChain, chain, currency);
|
|
6744
|
+
hopCurrencyPayload = hopAsset.location ? {
|
|
6745
|
+
location: hopAsset.location
|
|
6746
|
+
} : {
|
|
6747
|
+
symbol: hopAsset.symbol
|
|
6748
|
+
};
|
|
6749
|
+
_context.n = 5;
|
|
6750
|
+
return getAssetBalanceInternal({
|
|
6751
|
+
api: hopApi,
|
|
6752
|
+
address: resolvedAddress,
|
|
6753
|
+
chain: chain,
|
|
6754
|
+
currency: hopCurrencyPayload
|
|
6755
|
+
});
|
|
6756
|
+
case 5:
|
|
6757
|
+
balance = _context.v;
|
|
6758
|
+
ed = getExistentialDeposit(chain, hopCurrencyPayload);
|
|
6759
|
+
if (ed) {
|
|
6760
|
+
_context.n = 6;
|
|
6761
|
+
break;
|
|
6762
|
+
}
|
|
6763
|
+
throw new InvalidParameterError("Existential deposit not found for chain ".concat(chain, " with currency ").concat(JSON.stringify(hopCurrencyPayload)));
|
|
6764
|
+
case 6:
|
|
6765
|
+
return _context.a(2, {
|
|
6766
|
+
balance: balance,
|
|
6767
|
+
currencySymbol: hopAsset.symbol,
|
|
6768
|
+
existentialDeposit: BigInt(ed),
|
|
6769
|
+
xcmFee: xcmFeeDetails
|
|
6770
|
+
});
|
|
6771
|
+
case 7:
|
|
6772
|
+
_context.p = 7;
|
|
6773
|
+
hopApi.setDisconnectAllowed(true);
|
|
6774
|
+
_context.n = 8;
|
|
6775
|
+
return hopApi.disconnect();
|
|
6776
|
+
case 8:
|
|
6777
|
+
return _context.f(7);
|
|
6778
|
+
case 9:
|
|
6779
|
+
return _context.a(2);
|
|
6780
|
+
}
|
|
6781
|
+
}, _callee, null, [[2,, 7, 9]]);
|
|
7080
6782
|
}));
|
|
7081
|
-
return function
|
|
7082
|
-
return
|
|
6783
|
+
return function buildHopInfo(_x) {
|
|
6784
|
+
return _ref2.apply(this, arguments);
|
|
7083
6785
|
};
|
|
7084
6786
|
}();
|
|
7085
6787
|
|
|
7086
|
-
var
|
|
7087
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
7088
|
-
var api, origin, destination, address, currency,
|
|
7089
|
-
return _regenerator().w(function (
|
|
7090
|
-
while (1) switch (
|
|
6788
|
+
var getTransferInfo = /*#__PURE__*/function () {
|
|
6789
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
6790
|
+
var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, amount, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubChain, builtHops, destinationInfo, _t;
|
|
6791
|
+
return _regenerator().w(function (_context2) {
|
|
6792
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
7091
6793
|
case 0:
|
|
7092
|
-
api = _ref.api,
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
_context.n = 1;
|
|
6794
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
|
|
6795
|
+
if (!(isChainEvm(origin) && !ahAddress)) {
|
|
6796
|
+
_context2.n = 1;
|
|
7096
6797
|
break;
|
|
7097
6798
|
}
|
|
7098
|
-
|
|
7099
|
-
return destApi.init(destination);
|
|
6799
|
+
throw new InvalidParameterError("ahAddress is required for EVM origin ".concat(origin, "."));
|
|
7100
6800
|
case 1:
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
6801
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
6802
|
+
_context2.n = 2;
|
|
6803
|
+
return api.init(origin);
|
|
6804
|
+
case 2:
|
|
6805
|
+
api.setDisconnectAllowed(false);
|
|
6806
|
+
_context2.p = 3;
|
|
6807
|
+
originAsset = findAssetInfoOrThrow(origin, currency, destination);
|
|
6808
|
+
amount = abstractDecimals(currency.amount, originAsset.decimals, api);
|
|
6809
|
+
if (!(feeAsset && resolvedFeeAsset)) {
|
|
6810
|
+
_context2.n = 5;
|
|
7105
6811
|
break;
|
|
7106
6812
|
}
|
|
7107
|
-
|
|
7108
|
-
case 2:
|
|
7109
|
-
edDestBn = BigInt(edDest);
|
|
7110
|
-
destCurrency = destAsset.location ? {
|
|
7111
|
-
location: destAsset.location
|
|
7112
|
-
} : {
|
|
7113
|
-
symbol: destAsset.symbol
|
|
7114
|
-
};
|
|
7115
|
-
_context.n = 3;
|
|
6813
|
+
_context2.n = 4;
|
|
7116
6814
|
return getAssetBalanceInternal({
|
|
7117
|
-
api:
|
|
6815
|
+
api: api,
|
|
6816
|
+
address: senderAddress,
|
|
6817
|
+
chain: origin,
|
|
6818
|
+
currency: feeAsset
|
|
6819
|
+
});
|
|
6820
|
+
case 4:
|
|
6821
|
+
_t = _context2.v;
|
|
6822
|
+
_context2.n = 7;
|
|
6823
|
+
break;
|
|
6824
|
+
case 5:
|
|
6825
|
+
_context2.n = 6;
|
|
6826
|
+
return getBalanceNativeInternal({
|
|
6827
|
+
api: api,
|
|
6828
|
+
address: senderAddress,
|
|
6829
|
+
chain: origin
|
|
6830
|
+
});
|
|
6831
|
+
case 6:
|
|
6832
|
+
_t = _context2.v;
|
|
6833
|
+
case 7:
|
|
6834
|
+
originBalanceFee = _t;
|
|
6835
|
+
_context2.n = 8;
|
|
6836
|
+
return getAssetBalanceInternal({
|
|
6837
|
+
api: api,
|
|
6838
|
+
address: senderAddress,
|
|
6839
|
+
chain: origin,
|
|
6840
|
+
currency: currency
|
|
6841
|
+
});
|
|
6842
|
+
case 8:
|
|
6843
|
+
originBalance = _context2.v;
|
|
6844
|
+
edOrigin = getExistentialDepositOrThrow(origin, currency);
|
|
6845
|
+
_context2.n = 9;
|
|
6846
|
+
return getXcmFee({
|
|
6847
|
+
api: api,
|
|
6848
|
+
tx: tx,
|
|
6849
|
+
origin: origin,
|
|
6850
|
+
destination: destination,
|
|
6851
|
+
senderAddress: senderAddress,
|
|
7118
6852
|
address: address,
|
|
7119
|
-
|
|
7120
|
-
|
|
6853
|
+
currency: currency,
|
|
6854
|
+
feeAsset: feeAsset,
|
|
6855
|
+
disableFallback: false
|
|
7121
6856
|
});
|
|
7122
|
-
case
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
6857
|
+
case 9:
|
|
6858
|
+
_yield$getXcmFee = _context2.v;
|
|
6859
|
+
_yield$getXcmFee$orig = _yield$getXcmFee.origin;
|
|
6860
|
+
originFee = _yield$getXcmFee$orig.fee;
|
|
6861
|
+
originFeeCurrency = _yield$getXcmFee$orig.currency;
|
|
6862
|
+
assetHubFeeResult = _yield$getXcmFee.assetHub;
|
|
6863
|
+
bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
|
|
6864
|
+
destFeeDetail = _yield$getXcmFee.destination;
|
|
6865
|
+
hops = _yield$getXcmFee.hops;
|
|
6866
|
+
isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
|
|
6867
|
+
originBalanceAfter = originBalance - amount;
|
|
6868
|
+
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
|
|
6869
|
+
originBalanceNativeSufficient = originBalanceFee >= originFee;
|
|
6870
|
+
originBalanceSufficient = originBalanceAfter >= edOrigin;
|
|
6871
|
+
if (!assetHubFeeResult) {
|
|
6872
|
+
_context2.n = 11;
|
|
6873
|
+
break;
|
|
7128
6874
|
}
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
}
|
|
7146
|
-
} else {
|
|
7147
|
-
receivedAmount = new UnableToComputeError("Unable to compute received amount: The transferred asset (".concat(destAsset.symbol, ") is not the native asset (").concat(nativeAssetOfOriginSymbol, ") of origin ").concat(origin, " for the ").concat(origin, "->").concat(destination, " route."));
|
|
7148
|
-
}
|
|
7149
|
-
} else {
|
|
7150
|
-
if (destbalanceAfterResult instanceof UnableToComputeError) {
|
|
7151
|
-
receivedAmount = destbalanceAfterResult;
|
|
7152
|
-
} else {
|
|
7153
|
-
receivedAmount = destbalanceAfterResult - destBalance;
|
|
7154
|
-
}
|
|
6875
|
+
_context2.n = 10;
|
|
6876
|
+
return buildHopInfo({
|
|
6877
|
+
api: api,
|
|
6878
|
+
chain: "AssetHub".concat(getRelayChainOf(origin)),
|
|
6879
|
+
feeData: assetHubFeeResult,
|
|
6880
|
+
originChain: origin,
|
|
6881
|
+
currency: currency,
|
|
6882
|
+
senderAddress: senderAddress,
|
|
6883
|
+
ahAddress: ahAddress
|
|
6884
|
+
});
|
|
6885
|
+
case 10:
|
|
6886
|
+
assetHub = _context2.v;
|
|
6887
|
+
case 11:
|
|
6888
|
+
if (!bridgeHubFeeResult) {
|
|
6889
|
+
_context2.n = 13;
|
|
6890
|
+
break;
|
|
7155
6891
|
}
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
6892
|
+
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
|
|
6893
|
+
_context2.n = 12;
|
|
6894
|
+
return buildHopInfo({
|
|
6895
|
+
api: api,
|
|
6896
|
+
chain: bridgeHubChain,
|
|
6897
|
+
feeData: bridgeHubFeeResult,
|
|
6898
|
+
originChain: origin,
|
|
6899
|
+
currency: currency,
|
|
6900
|
+
senderAddress: senderAddress,
|
|
6901
|
+
ahAddress: ahAddress
|
|
6902
|
+
});
|
|
6903
|
+
case 12:
|
|
6904
|
+
bridgeHub = _context2.v;
|
|
6905
|
+
case 13:
|
|
6906
|
+
builtHops = [];
|
|
6907
|
+
if (!(hops && hops.length > 0)) {
|
|
6908
|
+
_context2.n = 15;
|
|
7159
6909
|
break;
|
|
7160
6910
|
}
|
|
7161
|
-
|
|
7162
|
-
return
|
|
6911
|
+
_context2.n = 14;
|
|
6912
|
+
return Promise.all(hops.map(/*#__PURE__*/function () {
|
|
6913
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(hop) {
|
|
6914
|
+
var result;
|
|
6915
|
+
return _regenerator().w(function (_context) {
|
|
6916
|
+
while (1) switch (_context.n) {
|
|
6917
|
+
case 0:
|
|
6918
|
+
_context.n = 1;
|
|
6919
|
+
return buildHopInfo({
|
|
6920
|
+
api: api,
|
|
6921
|
+
chain: hop.chain,
|
|
6922
|
+
feeData: hop.result,
|
|
6923
|
+
originChain: origin,
|
|
6924
|
+
currency: currency,
|
|
6925
|
+
senderAddress: senderAddress,
|
|
6926
|
+
ahAddress: ahAddress
|
|
6927
|
+
});
|
|
6928
|
+
case 1:
|
|
6929
|
+
result = _context.v;
|
|
6930
|
+
return _context.a(2, {
|
|
6931
|
+
chain: hop.chain,
|
|
6932
|
+
result: result
|
|
6933
|
+
});
|
|
6934
|
+
}
|
|
6935
|
+
}, _callee);
|
|
6936
|
+
}));
|
|
6937
|
+
return function (_x2) {
|
|
6938
|
+
return _ref3.apply(this, arguments);
|
|
6939
|
+
};
|
|
6940
|
+
}()));
|
|
6941
|
+
case 14:
|
|
6942
|
+
builtHops = _context2.v;
|
|
6943
|
+
case 15:
|
|
6944
|
+
_context2.n = 16;
|
|
6945
|
+
return buildDestInfo({
|
|
6946
|
+
api: api,
|
|
6947
|
+
origin: origin,
|
|
6948
|
+
destination: destination,
|
|
7163
6949
|
address: address,
|
|
7164
|
-
|
|
7165
|
-
|
|
6950
|
+
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
6951
|
+
amount: amount
|
|
6952
|
+
}),
|
|
6953
|
+
originFee: originFee,
|
|
6954
|
+
isFeeAssetAh: !!isFeeAssetAh,
|
|
6955
|
+
destFeeDetail: destFeeDetail,
|
|
6956
|
+
assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
|
|
6957
|
+
bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
|
|
7166
6958
|
});
|
|
7167
|
-
case
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
6959
|
+
case 16:
|
|
6960
|
+
destinationInfo = _context2.v;
|
|
6961
|
+
return _context2.a(2, {
|
|
6962
|
+
chain: {
|
|
6963
|
+
origin: origin,
|
|
6964
|
+
destination: destination,
|
|
6965
|
+
ecosystem: getRelayChainSymbol(origin)
|
|
6966
|
+
},
|
|
6967
|
+
origin: {
|
|
6968
|
+
selectedCurrency: {
|
|
6969
|
+
sufficient: originBalanceSufficient,
|
|
6970
|
+
balance: originBalance,
|
|
6971
|
+
balanceAfter: originBalanceAfter,
|
|
6972
|
+
currencySymbol: originAsset.symbol,
|
|
6973
|
+
existentialDeposit: edOrigin
|
|
6974
|
+
},
|
|
6975
|
+
xcmFee: {
|
|
6976
|
+
sufficient: originBalanceNativeSufficient,
|
|
6977
|
+
fee: originFee,
|
|
6978
|
+
balance: originBalanceFee,
|
|
6979
|
+
balanceAfter: originBalanceFeeAfter,
|
|
6980
|
+
currencySymbol: originFeeCurrency
|
|
6981
|
+
}
|
|
7184
6982
|
},
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
currencySymbol: destFeeDetail.currency
|
|
7190
|
-
}
|
|
6983
|
+
assetHub: assetHub,
|
|
6984
|
+
bridgeHub: bridgeHub,
|
|
6985
|
+
hops: builtHops,
|
|
6986
|
+
destination: destinationInfo
|
|
7191
6987
|
});
|
|
6988
|
+
case 17:
|
|
6989
|
+
_context2.p = 17;
|
|
6990
|
+
api.setDisconnectAllowed(true);
|
|
6991
|
+
_context2.n = 18;
|
|
6992
|
+
return api.disconnect();
|
|
6993
|
+
case 18:
|
|
6994
|
+
return _context2.f(17);
|
|
6995
|
+
case 19:
|
|
6996
|
+
return _context2.a(2);
|
|
7192
6997
|
}
|
|
7193
|
-
},
|
|
6998
|
+
}, _callee2, null, [[3,, 17, 19]]);
|
|
7194
6999
|
}));
|
|
7195
|
-
return function
|
|
7000
|
+
return function getTransferInfo(_x) {
|
|
7196
7001
|
return _ref2.apply(this, arguments);
|
|
7197
7002
|
};
|
|
7198
7003
|
}();
|
|
7199
7004
|
|
|
7200
|
-
var
|
|
7005
|
+
var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
7006
|
+
var _feeResult$assetHub;
|
|
7007
|
+
var totalFee = 0n;
|
|
7008
|
+
if (((_feeResult$assetHub = feeResult.assetHub) === null || _feeResult$assetHub === void 0 ? void 0 : _feeResult$assetHub.fee) !== undefined) {
|
|
7009
|
+
totalFee += feeResult.assetHub.fee;
|
|
7010
|
+
}
|
|
7011
|
+
if (feeResult.destination.fee !== undefined) {
|
|
7012
|
+
totalFee += feeResult.destination.fee;
|
|
7013
|
+
}
|
|
7014
|
+
return totalFee;
|
|
7015
|
+
};
|
|
7016
|
+
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
7201
7017
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
7202
|
-
var api,
|
|
7018
|
+
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, amount, destCurrency, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
|
|
7203
7019
|
return _regenerator().w(function (_context) {
|
|
7204
|
-
while (1) switch (_context.
|
|
7020
|
+
while (1) switch (_context.n) {
|
|
7205
7021
|
case 0:
|
|
7206
|
-
api = _ref.api,
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7022
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, address = _ref.address, senderAddress = _ref.senderAddress, feeAsset = _ref.feeAsset, currency = _ref.currency;
|
|
7023
|
+
if (!(destination === 'Ethereum')) {
|
|
7024
|
+
_context.n = 1;
|
|
7025
|
+
break;
|
|
7026
|
+
}
|
|
7027
|
+
return _context.a(2, true);
|
|
7210
7028
|
case 1:
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
_context.n = 3;
|
|
7215
|
-
return getBalanceNativeInternal({
|
|
7216
|
-
api: hopApi,
|
|
7217
|
-
address: resolvedAddress,
|
|
7218
|
-
chain: chain
|
|
7219
|
-
});
|
|
7220
|
-
case 3:
|
|
7221
|
-
nativeBalanceOnHop = _context.v;
|
|
7222
|
-
nativeAssetSymbolOnHop = getNativeAssetSymbol(chain);
|
|
7223
|
-
xcmFeeDetails = {
|
|
7224
|
-
fee: feeData.fee,
|
|
7225
|
-
balance: nativeBalanceOnHop,
|
|
7226
|
-
currencySymbol: nativeAssetSymbolOnHop
|
|
7227
|
-
};
|
|
7228
|
-
isBridgeHub = chain.includes('BridgeHub');
|
|
7229
|
-
if (!isBridgeHub) {
|
|
7230
|
-
_context.n = 4;
|
|
7029
|
+
validateAddress(address, destination);
|
|
7030
|
+
if (!(origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama')) {
|
|
7031
|
+
_context.n = 2;
|
|
7231
7032
|
break;
|
|
7232
7033
|
}
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7034
|
+
throw new InvalidParameterError('Kusama is outside of Polkadot ecosystem, thus function is unable to verify the existential deposit for it.');
|
|
7035
|
+
case 2:
|
|
7036
|
+
if (!(origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot')) {
|
|
7037
|
+
_context.n = 3;
|
|
7038
|
+
break;
|
|
7039
|
+
}
|
|
7040
|
+
throw new InvalidParameterError('Polkadot is outside of Kusama ecosystem, thus function is unable to verify the existential deposit for it.');
|
|
7041
|
+
case 3:
|
|
7042
|
+
destApi = api.clone();
|
|
7043
|
+
_context.n = 4;
|
|
7044
|
+
return destApi.init(destination);
|
|
7237
7045
|
case 4:
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7046
|
+
asset = findAssetOnDestOrThrow(origin, destination, currency);
|
|
7047
|
+
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
7048
|
+
destCurrency = asset.location ? {
|
|
7049
|
+
location: asset.location
|
|
7241
7050
|
} : {
|
|
7242
|
-
symbol:
|
|
7051
|
+
symbol: asset.symbol
|
|
7243
7052
|
};
|
|
7053
|
+
ed = getExistentialDepositOrThrow(destination, destCurrency);
|
|
7244
7054
|
_context.n = 5;
|
|
7245
7055
|
return getAssetBalanceInternal({
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
currency:
|
|
7056
|
+
address: address,
|
|
7057
|
+
chain: destination,
|
|
7058
|
+
api: destApi,
|
|
7059
|
+
currency: destCurrency
|
|
7250
7060
|
});
|
|
7251
7061
|
case 5:
|
|
7252
7062
|
balance = _context.v;
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7063
|
+
_context.n = 6;
|
|
7064
|
+
return getXcmFee({
|
|
7065
|
+
api: api,
|
|
7066
|
+
tx: tx,
|
|
7067
|
+
origin: origin,
|
|
7068
|
+
destination: destination,
|
|
7069
|
+
senderAddress: senderAddress,
|
|
7070
|
+
address: address,
|
|
7071
|
+
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
7072
|
+
amount: amount
|
|
7073
|
+
}),
|
|
7074
|
+
feeAsset: feeAsset,
|
|
7075
|
+
disableFallback: false
|
|
7076
|
+
});
|
|
7077
|
+
case 6:
|
|
7078
|
+
xcmFeeResult = _context.v;
|
|
7079
|
+
dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
7080
|
+
if (!(destFee === undefined)) {
|
|
7081
|
+
_context.n = 7;
|
|
7256
7082
|
break;
|
|
7257
7083
|
}
|
|
7258
|
-
throw new InvalidParameterError("
|
|
7259
|
-
case 6:
|
|
7260
|
-
return _context.a(2, {
|
|
7261
|
-
balance: balance,
|
|
7262
|
-
currencySymbol: hopAsset.symbol,
|
|
7263
|
-
existentialDeposit: BigInt(ed),
|
|
7264
|
-
xcmFee: xcmFeeDetails
|
|
7265
|
-
});
|
|
7084
|
+
throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(destination, "."));
|
|
7266
7085
|
case 7:
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7086
|
+
if (!dryRunError) {
|
|
7087
|
+
_context.n = 8;
|
|
7088
|
+
break;
|
|
7089
|
+
}
|
|
7090
|
+
throw new DryRunFailedError(dryRunError, 'origin');
|
|
7271
7091
|
case 8:
|
|
7272
|
-
|
|
7092
|
+
hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
|
|
7093
|
+
if (!hopDryRunError) {
|
|
7094
|
+
_context.n = 9;
|
|
7095
|
+
break;
|
|
7096
|
+
}
|
|
7097
|
+
throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
|
|
7273
7098
|
case 9:
|
|
7274
|
-
|
|
7099
|
+
if (!destDryRunError) {
|
|
7100
|
+
_context.n = 10;
|
|
7101
|
+
break;
|
|
7102
|
+
}
|
|
7103
|
+
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
7104
|
+
case 10:
|
|
7105
|
+
if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
|
|
7106
|
+
_context.n = 11;
|
|
7107
|
+
break;
|
|
7108
|
+
}
|
|
7109
|
+
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
7110
|
+
case 11:
|
|
7111
|
+
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
7112
|
+
method = api.getMethod(tx);
|
|
7113
|
+
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
7114
|
+
feeToSubtract = totalFee;
|
|
7115
|
+
} else {
|
|
7116
|
+
feeToSubtract = destFee;
|
|
7117
|
+
}
|
|
7118
|
+
return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
|
|
7275
7119
|
}
|
|
7276
|
-
}, _callee
|
|
7120
|
+
}, _callee);
|
|
7277
7121
|
}));
|
|
7278
|
-
return function
|
|
7122
|
+
return function verifyEdOnDestinationInternal(_x) {
|
|
7279
7123
|
return _ref2.apply(this, arguments);
|
|
7280
7124
|
};
|
|
7281
7125
|
}();
|
|
7282
7126
|
|
|
7283
|
-
var
|
|
7284
|
-
var
|
|
7285
|
-
var api
|
|
7286
|
-
return _regenerator().w(function (
|
|
7287
|
-
while (1) switch (
|
|
7127
|
+
var verifyEdOnDestination = /*#__PURE__*/function () {
|
|
7128
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
7129
|
+
var api;
|
|
7130
|
+
return _regenerator().w(function (_context) {
|
|
7131
|
+
while (1) switch (_context.p = _context.n) {
|
|
7288
7132
|
case 0:
|
|
7289
|
-
api =
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
}
|
|
7294
|
-
throw new InvalidParameterError("ahAddress is required for EVM origin ".concat(origin, "."));
|
|
7295
|
-
case 1:
|
|
7296
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
7297
|
-
_context2.n = 2;
|
|
7298
|
-
return api.init(origin);
|
|
7133
|
+
api = options.api;
|
|
7134
|
+
_context.p = 1;
|
|
7135
|
+
_context.n = 2;
|
|
7136
|
+
return verifyEdOnDestinationInternal(options);
|
|
7299
7137
|
case 2:
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
_context2.n = 5;
|
|
7306
|
-
break;
|
|
7307
|
-
}
|
|
7308
|
-
_context2.n = 4;
|
|
7309
|
-
return getAssetBalanceInternal({
|
|
7310
|
-
api: api,
|
|
7311
|
-
address: senderAddress,
|
|
7312
|
-
chain: origin,
|
|
7313
|
-
currency: feeAsset
|
|
7314
|
-
});
|
|
7138
|
+
return _context.a(2, _context.v);
|
|
7139
|
+
case 3:
|
|
7140
|
+
_context.p = 3;
|
|
7141
|
+
_context.n = 4;
|
|
7142
|
+
return api.disconnect();
|
|
7315
7143
|
case 4:
|
|
7316
|
-
|
|
7317
|
-
_context2.n = 7;
|
|
7318
|
-
break;
|
|
7144
|
+
return _context.f(3);
|
|
7319
7145
|
case 5:
|
|
7320
|
-
|
|
7146
|
+
return _context.a(2);
|
|
7147
|
+
}
|
|
7148
|
+
}, _callee, null, [[1,, 3, 5]]);
|
|
7149
|
+
}));
|
|
7150
|
+
return function verifyEdOnDestination(_x) {
|
|
7151
|
+
return _ref.apply(this, arguments);
|
|
7152
|
+
};
|
|
7153
|
+
}();
|
|
7154
|
+
|
|
7155
|
+
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
7156
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
|
|
7157
|
+
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
7158
|
+
return _regenerator().w(function (_context) {
|
|
7159
|
+
while (1) switch (_context.n) {
|
|
7160
|
+
case 0:
|
|
7161
|
+
if (!feeAsset) {
|
|
7162
|
+
_context.n = 1;
|
|
7163
|
+
break;
|
|
7164
|
+
}
|
|
7165
|
+
return _context.a(2, undefined);
|
|
7166
|
+
case 1:
|
|
7167
|
+
edNative = getExistentialDepositOrThrow(origin);
|
|
7168
|
+
_context.n = 2;
|
|
7321
7169
|
return getBalanceNativeInternal({
|
|
7322
7170
|
api: api,
|
|
7323
|
-
address: senderAddress,
|
|
7324
|
-
chain: origin
|
|
7325
|
-
});
|
|
7326
|
-
case 6:
|
|
7327
|
-
_t = _context2.v;
|
|
7328
|
-
case 7:
|
|
7329
|
-
originBalanceFee = _t;
|
|
7330
|
-
_context2.n = 8;
|
|
7331
|
-
return getAssetBalanceInternal({
|
|
7332
|
-
api: api,
|
|
7333
|
-
address: senderAddress,
|
|
7334
7171
|
chain: origin,
|
|
7335
|
-
|
|
7336
|
-
});
|
|
7337
|
-
case 8:
|
|
7338
|
-
originBalance = _context2.v;
|
|
7339
|
-
edOrigin = getExistentialDepositOrThrow(origin, currency);
|
|
7340
|
-
_context2.n = 9;
|
|
7341
|
-
return getXcmFee({
|
|
7342
|
-
api: api,
|
|
7343
|
-
tx: tx,
|
|
7344
|
-
origin: origin,
|
|
7345
|
-
destination: destination,
|
|
7346
|
-
senderAddress: senderAddress,
|
|
7347
|
-
address: address,
|
|
7348
|
-
currency: currency,
|
|
7349
|
-
feeAsset: feeAsset,
|
|
7350
|
-
disableFallback: false
|
|
7172
|
+
address: senderAddress
|
|
7351
7173
|
});
|
|
7352
|
-
case
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
|
|
7359
|
-
destFeeDetail = _yield$getXcmFee.destination;
|
|
7360
|
-
hops = _yield$getXcmFee.hops;
|
|
7361
|
-
if (!(originFee === undefined)) {
|
|
7362
|
-
_context2.n = 10;
|
|
7174
|
+
case 2:
|
|
7175
|
+
balanceNative = _context.v;
|
|
7176
|
+
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
|
|
7177
|
+
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
7178
|
+
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
7179
|
+
_context.n = 3;
|
|
7363
7180
|
break;
|
|
7364
7181
|
}
|
|
7365
|
-
|
|
7366
|
-
case
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
|
|
7370
|
-
originBalanceNativeSufficient = originBalanceFee >= originFee;
|
|
7371
|
-
originBalanceSufficient = originBalanceAfter >= edOrigin;
|
|
7372
|
-
if (!assetHubFeeResult) {
|
|
7373
|
-
_context2.n = 12;
|
|
7182
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
7183
|
+
case 3:
|
|
7184
|
+
if (isNativeAssetToOrigin) {
|
|
7185
|
+
_context.n = 5;
|
|
7374
7186
|
break;
|
|
7375
7187
|
}
|
|
7376
|
-
|
|
7377
|
-
|
|
7188
|
+
isSufficientNative = balanceNative - edNative - feeNative > 0n;
|
|
7189
|
+
_context.n = 4;
|
|
7190
|
+
return getAssetBalance({
|
|
7378
7191
|
api: api,
|
|
7379
|
-
chain:
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
currency: currency,
|
|
7383
|
-
senderAddress: senderAddress,
|
|
7384
|
-
ahAddress: ahAddress
|
|
7192
|
+
chain: origin,
|
|
7193
|
+
address: senderAddress,
|
|
7194
|
+
currency: currency
|
|
7385
7195
|
});
|
|
7386
|
-
case
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7196
|
+
case 4:
|
|
7197
|
+
balanceAsset = _context.v;
|
|
7198
|
+
edAsset = getExistentialDepositOrThrow(origin, currency);
|
|
7199
|
+
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
7200
|
+
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
7201
|
+
case 5:
|
|
7202
|
+
return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
|
|
7203
|
+
case 6:
|
|
7204
|
+
return _context.a(2);
|
|
7205
|
+
}
|
|
7206
|
+
}, _callee);
|
|
7207
|
+
}));
|
|
7208
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
7209
|
+
return _ref.apply(this, arguments);
|
|
7210
|
+
};
|
|
7211
|
+
}();
|
|
7212
|
+
var isSufficientDestination = /*#__PURE__*/function () {
|
|
7213
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
|
|
7214
|
+
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
7215
|
+
return _regenerator().w(function (_context2) {
|
|
7216
|
+
while (1) switch (_context2.n) {
|
|
7217
|
+
case 0:
|
|
7218
|
+
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
|
|
7219
|
+
if (isNativeAsset) {
|
|
7220
|
+
_context2.n = 1;
|
|
7391
7221
|
break;
|
|
7392
7222
|
}
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7223
|
+
return _context2.a(2, undefined);
|
|
7224
|
+
case 1:
|
|
7225
|
+
existentialDeposit = getExistentialDepositOrThrow(destination);
|
|
7226
|
+
_context2.n = 2;
|
|
7227
|
+
return getBalanceNativeInternal({
|
|
7396
7228
|
api: api,
|
|
7397
|
-
chain:
|
|
7398
|
-
|
|
7399
|
-
originChain: origin,
|
|
7400
|
-
currency: currency,
|
|
7401
|
-
senderAddress: senderAddress,
|
|
7402
|
-
ahAddress: ahAddress
|
|
7229
|
+
chain: destination,
|
|
7230
|
+
address: address
|
|
7403
7231
|
});
|
|
7404
|
-
case
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7232
|
+
case 2:
|
|
7233
|
+
nativeBalance = _context2.v;
|
|
7234
|
+
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
7235
|
+
}
|
|
7236
|
+
}, _callee2);
|
|
7237
|
+
}));
|
|
7238
|
+
return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
|
|
7239
|
+
return _ref2.apply(this, arguments);
|
|
7240
|
+
};
|
|
7241
|
+
}();
|
|
7242
|
+
|
|
7243
|
+
var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
7244
|
+
if (isRelayChain(origin)) return DOT_LOCATION;
|
|
7245
|
+
return {
|
|
7246
|
+
parents: isRelayChain(destination) ? Parents.ZERO : Parents.ONE,
|
|
7247
|
+
interior: {
|
|
7248
|
+
X1: [{
|
|
7249
|
+
Parachain: getParaId(origin)
|
|
7250
|
+
}]
|
|
7251
|
+
}
|
|
7252
|
+
};
|
|
7253
|
+
};
|
|
7254
|
+
var getDestXcmFee = /*#__PURE__*/function () {
|
|
7255
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
7256
|
+
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
7257
|
+
return _regenerator().w(function (_context2) {
|
|
7258
|
+
while (1) switch (_context2.n) {
|
|
7259
|
+
case 0:
|
|
7260
|
+
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
7261
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
7262
|
+
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
7263
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
7264
|
+
var originAsset, _t;
|
|
7416
7265
|
return _regenerator().w(function (_context) {
|
|
7417
|
-
while (1) switch (_context.n) {
|
|
7266
|
+
while (1) switch (_context.p = _context.n) {
|
|
7418
7267
|
case 0:
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
originChain: origin,
|
|
7425
|
-
currency: currency,
|
|
7426
|
-
senderAddress: senderAddress,
|
|
7427
|
-
ahAddress: ahAddress
|
|
7428
|
-
});
|
|
7268
|
+
if (!(destination === 'Ethereum')) {
|
|
7269
|
+
_context.n = 1;
|
|
7270
|
+
break;
|
|
7271
|
+
}
|
|
7272
|
+
return _context.a(2, 0n);
|
|
7429
7273
|
case 1:
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7274
|
+
originAsset = findAssetInfoOrThrow(origin, currency, destination);
|
|
7275
|
+
if (!originAsset.location) {
|
|
7276
|
+
_context.n = 7;
|
|
7277
|
+
break;
|
|
7278
|
+
}
|
|
7279
|
+
_context.p = 2;
|
|
7280
|
+
_context.n = 3;
|
|
7281
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7282
|
+
destination: destination
|
|
7283
|
+
}), {
|
|
7284
|
+
location: originAsset.location
|
|
7285
|
+
});
|
|
7286
|
+
case 3:
|
|
7287
|
+
return _context.a(2, _context.v);
|
|
7288
|
+
case 4:
|
|
7289
|
+
_context.p = 4;
|
|
7290
|
+
_t = _context.v;
|
|
7291
|
+
if (!(_t instanceof InvalidCurrencyError)) {
|
|
7292
|
+
_context.n = 6;
|
|
7293
|
+
break;
|
|
7294
|
+
}
|
|
7295
|
+
_context.n = 5;
|
|
7296
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7297
|
+
destination: destination
|
|
7298
|
+
}), {
|
|
7299
|
+
symbol: originAsset.symbol
|
|
7300
|
+
});
|
|
7301
|
+
case 5:
|
|
7302
|
+
return _context.a(2, _context.v);
|
|
7303
|
+
case 6:
|
|
7304
|
+
throw _t;
|
|
7305
|
+
case 7:
|
|
7306
|
+
_context.n = 8;
|
|
7307
|
+
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
7308
|
+
destination: destination
|
|
7309
|
+
}), {
|
|
7310
|
+
symbol: originAsset.symbol
|
|
7434
7311
|
});
|
|
7312
|
+
case 8:
|
|
7313
|
+
return _context.a(2, _context.v);
|
|
7435
7314
|
}
|
|
7436
|
-
}, _callee);
|
|
7315
|
+
}, _callee, null, [[2, 4]]);
|
|
7437
7316
|
}));
|
|
7438
|
-
return function (
|
|
7439
|
-
return
|
|
7317
|
+
return function calcPaymentInfoFee() {
|
|
7318
|
+
return _ref2.apply(this, arguments);
|
|
7440
7319
|
};
|
|
7441
|
-
}()
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7320
|
+
}();
|
|
7321
|
+
if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
|
|
7322
|
+
_context2.n = 3;
|
|
7323
|
+
break;
|
|
7324
|
+
}
|
|
7325
|
+
_context2.n = 1;
|
|
7326
|
+
return calcPaymentInfoFee();
|
|
7327
|
+
case 1:
|
|
7328
|
+
_fee = _context2.v;
|
|
7329
|
+
_context2.n = 2;
|
|
7330
|
+
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
|
|
7331
|
+
case 2:
|
|
7332
|
+
sufficient = _context2.v;
|
|
7333
|
+
return _context2.a(2, {
|
|
7334
|
+
fee: _fee,
|
|
7335
|
+
feeType: 'paymentInfo',
|
|
7336
|
+
sufficient: !hasDryRunSupport(destination) ? sufficient : false
|
|
7337
|
+
});
|
|
7338
|
+
case 3:
|
|
7339
|
+
_context2.n = 4;
|
|
7340
|
+
return api.getDryRunXcm({
|
|
7341
|
+
originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
|
|
7342
|
+
xcm: forwardedXcms[1][0],
|
|
7343
|
+
chain: destination,
|
|
7448
7344
|
origin: origin,
|
|
7449
|
-
|
|
7450
|
-
address: address,
|
|
7451
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
7452
|
-
amount: amount
|
|
7453
|
-
}),
|
|
7345
|
+
asset: asset,
|
|
7454
7346
|
originFee: originFee,
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
|
|
7458
|
-
bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
|
|
7347
|
+
feeAsset: resolvedFeeAsset,
|
|
7348
|
+
amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
|
|
7459
7349
|
});
|
|
7460
|
-
case
|
|
7461
|
-
|
|
7350
|
+
case 4:
|
|
7351
|
+
dryRunResult = _context2.v;
|
|
7352
|
+
if (dryRunResult.success) {
|
|
7353
|
+
_context2.n = 7;
|
|
7354
|
+
break;
|
|
7355
|
+
}
|
|
7356
|
+
if (!disableFallback) {
|
|
7357
|
+
_context2.n = 5;
|
|
7358
|
+
break;
|
|
7359
|
+
}
|
|
7462
7360
|
return _context2.a(2, {
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
assetHub: assetHub,
|
|
7485
|
-
bridgeHub: bridgeHub,
|
|
7486
|
-
hops: builtHops,
|
|
7487
|
-
destination: destinationInfo
|
|
7361
|
+
dryRunError: dryRunResult.failureReason
|
|
7362
|
+
});
|
|
7363
|
+
case 5:
|
|
7364
|
+
_context2.n = 6;
|
|
7365
|
+
return calcPaymentInfoFee();
|
|
7366
|
+
case 6:
|
|
7367
|
+
_fee2 = _context2.v;
|
|
7368
|
+
return _context2.a(2, {
|
|
7369
|
+
fee: _fee2,
|
|
7370
|
+
feeType: 'paymentInfo',
|
|
7371
|
+
dryRunError: dryRunResult.failureReason,
|
|
7372
|
+
sufficient: false
|
|
7373
|
+
});
|
|
7374
|
+
case 7:
|
|
7375
|
+
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
7376
|
+
return _context2.a(2, {
|
|
7377
|
+
fee: fee,
|
|
7378
|
+
feeType: 'dryRun',
|
|
7379
|
+
sufficient: true,
|
|
7380
|
+
forwardedXcms: newForwardedXcms,
|
|
7381
|
+
destParaId: destParaId
|
|
7488
7382
|
});
|
|
7489
|
-
case 18:
|
|
7490
|
-
_context2.p = 18;
|
|
7491
|
-
api.setDisconnectAllowed(true);
|
|
7492
|
-
_context2.n = 19;
|
|
7493
|
-
return api.disconnect();
|
|
7494
|
-
case 19:
|
|
7495
|
-
return _context2.f(18);
|
|
7496
|
-
case 20:
|
|
7497
|
-
return _context2.a(2);
|
|
7498
7383
|
}
|
|
7499
|
-
}, _callee2
|
|
7384
|
+
}, _callee2);
|
|
7500
7385
|
}));
|
|
7501
|
-
return function
|
|
7502
|
-
return
|
|
7386
|
+
return function getDestXcmFee(_x) {
|
|
7387
|
+
return _ref.apply(this, arguments);
|
|
7503
7388
|
};
|
|
7504
7389
|
}();
|
|
7505
7390
|
|
|
7506
|
-
var
|
|
7507
|
-
|
|
7508
|
-
var
|
|
7509
|
-
|
|
7510
|
-
|
|
7391
|
+
var getFailureInfo = function getFailureInfo(results, hops) {
|
|
7392
|
+
// Check standard chains first for backwards compatibility
|
|
7393
|
+
for (var _i = 0, _arr = ['destination', 'assetHub', 'bridgeHub']; _i < _arr.length; _i++) {
|
|
7394
|
+
var chain = _arr[_i];
|
|
7395
|
+
var res = results[chain];
|
|
7396
|
+
if (res && !res.success && res.failureReason) {
|
|
7397
|
+
return {
|
|
7398
|
+
failureReason: res.failureReason,
|
|
7399
|
+
failureChain: chain
|
|
7400
|
+
};
|
|
7401
|
+
}
|
|
7511
7402
|
}
|
|
7512
|
-
|
|
7513
|
-
|
|
7403
|
+
var _iterator = _createForOfIteratorHelper(hops),
|
|
7404
|
+
_step;
|
|
7405
|
+
try {
|
|
7406
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
7407
|
+
var hop = _step.value;
|
|
7408
|
+
if (!hop.result.success && hop.result.failureReason) {
|
|
7409
|
+
return {
|
|
7410
|
+
failureReason: hop.result.failureReason,
|
|
7411
|
+
failureChain: hop.chain
|
|
7412
|
+
};
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
} catch (err) {
|
|
7416
|
+
_iterator.e(err);
|
|
7417
|
+
} finally {
|
|
7418
|
+
_iterator.f();
|
|
7514
7419
|
}
|
|
7515
|
-
return
|
|
7420
|
+
return {};
|
|
7516
7421
|
};
|
|
7517
|
-
var
|
|
7518
|
-
var
|
|
7519
|
-
var
|
|
7520
|
-
|
|
7521
|
-
|
|
7422
|
+
var dryRunInternal = /*#__PURE__*/function () {
|
|
7423
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
7424
|
+
var _traversalResult$brid, _traversalResult$asse, _traversalResult$dest;
|
|
7425
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, originWithCurrency, assetHubWithCurrency, bridgeHubWithCurrency, destinationWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
|
|
7426
|
+
return _regenerator().w(function (_context2) {
|
|
7427
|
+
while (1) switch (_context2.n) {
|
|
7522
7428
|
case 0:
|
|
7523
|
-
api =
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
break;
|
|
7527
|
-
}
|
|
7528
|
-
return _context.a(2, true);
|
|
7529
|
-
case 1:
|
|
7530
|
-
validateAddress(address, destination);
|
|
7531
|
-
if (!(origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama')) {
|
|
7532
|
-
_context.n = 2;
|
|
7533
|
-
break;
|
|
7534
|
-
}
|
|
7535
|
-
throw new InvalidParameterError('Kusama is outside of Polkadot ecosystem, thus function is unable to verify the existential deposit for it.');
|
|
7536
|
-
case 2:
|
|
7537
|
-
if (!(origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot')) {
|
|
7538
|
-
_context.n = 3;
|
|
7539
|
-
break;
|
|
7540
|
-
}
|
|
7541
|
-
throw new InvalidParameterError('Polkadot is outside of Kusama ecosystem, thus function is unable to verify the existential deposit for it.');
|
|
7542
|
-
case 3:
|
|
7543
|
-
destApi = api.clone();
|
|
7544
|
-
_context.n = 4;
|
|
7545
|
-
return destApi.init(destination);
|
|
7546
|
-
case 4:
|
|
7547
|
-
asset = findAssetOnDestOrThrow(origin, destination, currency);
|
|
7429
|
+
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset, swapConfig = options.swapConfig, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
7430
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
7431
|
+
asset = findAssetInfoOrThrow(origin, currency, destination);
|
|
7548
7432
|
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
} : {
|
|
7552
|
-
symbol: asset.symbol
|
|
7553
|
-
};
|
|
7554
|
-
ed = getExistentialDepositOrThrow(destination, destCurrency);
|
|
7555
|
-
_context.n = 5;
|
|
7556
|
-
return getAssetBalanceInternal({
|
|
7557
|
-
address: address,
|
|
7558
|
-
chain: destination,
|
|
7559
|
-
api: destApi,
|
|
7560
|
-
currency: destCurrency
|
|
7561
|
-
});
|
|
7562
|
-
case 5:
|
|
7563
|
-
balance = _context.v;
|
|
7564
|
-
_context.n = 6;
|
|
7565
|
-
return getXcmFee({
|
|
7566
|
-
api: api,
|
|
7433
|
+
_context2.n = 1;
|
|
7434
|
+
return api.getDryRunCall({
|
|
7567
7435
|
tx: tx,
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
address: address,
|
|
7572
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
7436
|
+
chain: origin,
|
|
7437
|
+
address: senderAddress,
|
|
7438
|
+
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
7573
7439
|
amount: amount
|
|
7574
7440
|
}),
|
|
7575
|
-
feeAsset:
|
|
7576
|
-
|
|
7441
|
+
feeAsset: resolvedFeeAsset,
|
|
7442
|
+
useRootOrigin: useRootOrigin
|
|
7443
|
+
});
|
|
7444
|
+
case 1:
|
|
7445
|
+
originDryRun = _context2.v;
|
|
7446
|
+
if (originDryRun.success) {
|
|
7447
|
+
_context2.n = 2;
|
|
7448
|
+
break;
|
|
7449
|
+
}
|
|
7450
|
+
return _context2.a(2, {
|
|
7451
|
+
failureReason: originDryRun.failureReason,
|
|
7452
|
+
failureChain: 'origin',
|
|
7453
|
+
origin: originDryRun,
|
|
7454
|
+
hops: []
|
|
7455
|
+
});
|
|
7456
|
+
case 2:
|
|
7457
|
+
initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
|
|
7458
|
+
processHop = /*#__PURE__*/function () {
|
|
7459
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
7460
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopDryRun, hopCurrency;
|
|
7461
|
+
return _regenerator().w(function (_context) {
|
|
7462
|
+
while (1) switch (_context.n) {
|
|
7463
|
+
case 0:
|
|
7464
|
+
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
7465
|
+
if (hasDryRunSupport(currentChain)) {
|
|
7466
|
+
_context.n = 1;
|
|
7467
|
+
break;
|
|
7468
|
+
}
|
|
7469
|
+
return _context.a(2, {
|
|
7470
|
+
success: false,
|
|
7471
|
+
failureReason: "DryRunApi is not available on chain ".concat(currentChain)
|
|
7472
|
+
});
|
|
7473
|
+
case 1:
|
|
7474
|
+
_context.n = 2;
|
|
7475
|
+
return hopApi.getDryRunXcm({
|
|
7476
|
+
originLocation: addXcmVersionHeader(createOriginLocation(currentOrigin, currentChain), Version.V4),
|
|
7477
|
+
xcm: forwardedXcms[1][0],
|
|
7478
|
+
chain: currentChain,
|
|
7479
|
+
origin: currentOrigin,
|
|
7480
|
+
asset: currentAsset,
|
|
7481
|
+
feeAsset: resolvedFeeAsset,
|
|
7482
|
+
originFee: originDryRun.fee,
|
|
7483
|
+
amount: amount
|
|
7484
|
+
});
|
|
7485
|
+
case 2:
|
|
7486
|
+
hopDryRun = _context.v;
|
|
7487
|
+
if (!hopDryRun.success) {
|
|
7488
|
+
_context.n = 3;
|
|
7489
|
+
break;
|
|
7490
|
+
}
|
|
7491
|
+
if (destination === 'Ethereum' && (currentChain.includes('AssetHub') || currentChain.includes('BridgeHub'))) {
|
|
7492
|
+
hopCurrency = getNativeAssetSymbol(currentChain);
|
|
7493
|
+
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
7494
|
+
hopCurrency = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo).symbol;
|
|
7495
|
+
} else if (isDestination) {
|
|
7496
|
+
hopCurrency = findAssetOnDestOrThrow(origin, currentChain, currency).symbol;
|
|
7497
|
+
} else {
|
|
7498
|
+
hopCurrency = asset.symbol;
|
|
7499
|
+
}
|
|
7500
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
|
|
7501
|
+
currency: hopCurrency
|
|
7502
|
+
}));
|
|
7503
|
+
case 3:
|
|
7504
|
+
return _context.a(2, hopDryRun);
|
|
7505
|
+
}
|
|
7506
|
+
}, _callee);
|
|
7507
|
+
}));
|
|
7508
|
+
return function processHop(_x2) {
|
|
7509
|
+
return _ref2.apply(this, arguments);
|
|
7510
|
+
};
|
|
7511
|
+
}();
|
|
7512
|
+
_context2.n = 3;
|
|
7513
|
+
return traverseXcmHops({
|
|
7514
|
+
api: api,
|
|
7515
|
+
origin: origin,
|
|
7516
|
+
destination: destination,
|
|
7517
|
+
currency: currency,
|
|
7518
|
+
initialForwardedXcms: initialForwardedXcms,
|
|
7519
|
+
initialDestParaId: initialDestParaId,
|
|
7520
|
+
swapConfig: swapConfig,
|
|
7521
|
+
processHop: processHop,
|
|
7522
|
+
shouldContinue: function shouldContinue(hopResult) {
|
|
7523
|
+
return hopResult.success;
|
|
7524
|
+
},
|
|
7525
|
+
extractNextHopData: function extractNextHopData(hopResult) {
|
|
7526
|
+
return {
|
|
7527
|
+
forwardedXcms: hopResult.success ? hopResult.forwardedXcms : undefined,
|
|
7528
|
+
destParaId: hopResult.success ? hopResult.destParaId : undefined
|
|
7529
|
+
};
|
|
7530
|
+
}
|
|
7577
7531
|
});
|
|
7578
|
-
case
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(destination, "."));
|
|
7586
|
-
case 7:
|
|
7587
|
-
if (!dryRunError) {
|
|
7588
|
-
_context.n = 8;
|
|
7589
|
-
break;
|
|
7590
|
-
}
|
|
7591
|
-
throw new DryRunFailedError(dryRunError, 'origin');
|
|
7592
|
-
case 8:
|
|
7593
|
-
hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
|
|
7594
|
-
if (!hopDryRunError) {
|
|
7595
|
-
_context.n = 9;
|
|
7596
|
-
break;
|
|
7597
|
-
}
|
|
7598
|
-
throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
|
|
7599
|
-
case 9:
|
|
7600
|
-
if (!destDryRunError) {
|
|
7601
|
-
_context.n = 10;
|
|
7602
|
-
break;
|
|
7603
|
-
}
|
|
7604
|
-
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
7605
|
-
case 10:
|
|
7606
|
-
if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
|
|
7607
|
-
_context.n = 11;
|
|
7532
|
+
case 3:
|
|
7533
|
+
traversalResult = _context2.v;
|
|
7534
|
+
// Process Ethereum bridge fees
|
|
7535
|
+
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
7536
|
+
bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
|
|
7537
|
+
if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
|
|
7538
|
+
_context2.n = 5;
|
|
7608
7539
|
break;
|
|
7609
7540
|
}
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
7613
|
-
method = api.getMethod(tx);
|
|
7614
|
-
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
7615
|
-
feeToSubtract = totalFee;
|
|
7616
|
-
} else {
|
|
7617
|
-
feeToSubtract = destFee;
|
|
7618
|
-
}
|
|
7619
|
-
return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
|
|
7620
|
-
}
|
|
7621
|
-
}, _callee);
|
|
7622
|
-
}));
|
|
7623
|
-
return function verifyEdOnDestinationInternal(_x) {
|
|
7624
|
-
return _ref2.apply(this, arguments);
|
|
7625
|
-
};
|
|
7626
|
-
}();
|
|
7627
|
-
|
|
7628
|
-
var verifyEdOnDestination = /*#__PURE__*/function () {
|
|
7629
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
7630
|
-
var api;
|
|
7631
|
-
return _regenerator().w(function (_context) {
|
|
7632
|
-
while (1) switch (_context.p = _context.n) {
|
|
7633
|
-
case 0:
|
|
7634
|
-
api = options.api;
|
|
7635
|
-
_context.p = 1;
|
|
7636
|
-
_context.n = 2;
|
|
7637
|
-
return verifyEdOnDestinationInternal(options);
|
|
7638
|
-
case 2:
|
|
7639
|
-
return _context.a(2, _context.v);
|
|
7640
|
-
case 3:
|
|
7641
|
-
_context.p = 3;
|
|
7642
|
-
_context.n = 4;
|
|
7643
|
-
return api.disconnect();
|
|
7541
|
+
_context2.n = 4;
|
|
7542
|
+
return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
|
|
7644
7543
|
case 4:
|
|
7645
|
-
|
|
7544
|
+
_t = _context2.v;
|
|
7545
|
+
_context2.n = 6;
|
|
7546
|
+
break;
|
|
7646
7547
|
case 5:
|
|
7647
|
-
|
|
7548
|
+
_t = traversalResult.bridgeHub;
|
|
7549
|
+
case 6:
|
|
7550
|
+
processedBridgeHub = _t;
|
|
7551
|
+
// Update bridge hub in hops if needed
|
|
7552
|
+
if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
|
|
7553
|
+
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
7554
|
+
return hop.chain === bridgeHubChain;
|
|
7555
|
+
});
|
|
7556
|
+
if (bridgeHubHopIndex !== -1 && traversalResult.hops[bridgeHubHopIndex].result.success) {
|
|
7557
|
+
traversalResult.hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, traversalResult.hops[bridgeHubHopIndex].result), {}, {
|
|
7558
|
+
fee: processedBridgeHub.fee
|
|
7559
|
+
});
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
originWithCurrency = originDryRun.success ? _objectSpread2(_objectSpread2({}, originDryRun), {}, {
|
|
7563
|
+
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(origin)
|
|
7564
|
+
}) : originDryRun;
|
|
7565
|
+
assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
|
|
7566
|
+
currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(assetHubChain)
|
|
7567
|
+
}) : traversalResult.assetHub;
|
|
7568
|
+
bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
|
|
7569
|
+
currency: getNativeAssetSymbol(bridgeHubChain)
|
|
7570
|
+
}) : processedBridgeHub;
|
|
7571
|
+
destinationWithCurrency = (_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0 && _traversalResult$dest.success ? _objectSpread2(_objectSpread2({}, traversalResult.destination), {}, {
|
|
7572
|
+
currency: asset === null || asset === void 0 ? void 0 : asset.symbol
|
|
7573
|
+
}) : traversalResult.destination;
|
|
7574
|
+
_getFailureInfo = getFailureInfo({
|
|
7575
|
+
destination: destinationWithCurrency,
|
|
7576
|
+
assetHub: assetHubWithCurrency,
|
|
7577
|
+
bridgeHub: bridgeHubWithCurrency
|
|
7578
|
+
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
7579
|
+
return _context2.a(2, {
|
|
7580
|
+
failureReason: failureReason,
|
|
7581
|
+
failureChain: failureChain,
|
|
7582
|
+
origin: originWithCurrency,
|
|
7583
|
+
assetHub: assetHubWithCurrency,
|
|
7584
|
+
bridgeHub: bridgeHubWithCurrency,
|
|
7585
|
+
destination: destinationWithCurrency,
|
|
7586
|
+
hops: traversalResult.hops
|
|
7587
|
+
});
|
|
7648
7588
|
}
|
|
7649
|
-
},
|
|
7589
|
+
}, _callee2);
|
|
7650
7590
|
}));
|
|
7651
|
-
return function
|
|
7591
|
+
return function dryRunInternal(_x) {
|
|
7652
7592
|
return _ref.apply(this, arguments);
|
|
7653
7593
|
};
|
|
7654
7594
|
}();
|
|
7655
7595
|
|
|
7656
|
-
var validateHops = function validateHops(hops) {
|
|
7657
|
-
var _iterator = _createForOfIteratorHelper(hops),
|
|
7658
|
-
_step;
|
|
7659
|
-
try {
|
|
7660
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
7661
|
-
var hop = _step.value;
|
|
7662
|
-
if (!hop.result.success) {
|
|
7663
|
-
throw new DryRunFailedError("Dry run failed on an intermediate hop (".concat(hop.chain, "). Reason: ").concat(hop.result.failureReason || 'Unknown'));
|
|
7664
|
-
}
|
|
7665
|
-
}
|
|
7666
|
-
} catch (err) {
|
|
7667
|
-
_iterator.e(err);
|
|
7668
|
-
} finally {
|
|
7669
|
-
_iterator.f();
|
|
7670
|
-
}
|
|
7671
|
-
};
|
|
7672
7596
|
var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
|
|
7673
7597
|
if (!hops || hops.length === 0 || !hops[0].result.success) {
|
|
7674
7598
|
return MIN_FEE;
|
|
@@ -7678,7 +7602,7 @@ var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
|
|
|
7678
7602
|
var FEE_PADDING_PERCENTAGE$1 = 40;
|
|
7679
7603
|
var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
7680
7604
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
7681
|
-
var api, senderAddress, paraIdTo, assetInfo, currency, feeCurrency, address, feeAssetInfo, version,
|
|
7605
|
+
var api, senderAddress, paraIdTo, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, destChain, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
|
|
7682
7606
|
return _regenerator().w(function (_context) {
|
|
7683
7607
|
while (1) switch (_context.n) {
|
|
7684
7608
|
case 0:
|
|
@@ -7690,25 +7614,6 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
7690
7614
|
throw new InvalidParameterError('Please provide senderAddress');
|
|
7691
7615
|
case 1:
|
|
7692
7616
|
assertAddressIsString(address);
|
|
7693
|
-
if (!(feeCurrency && feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo))) {
|
|
7694
|
-
_context.n = 3;
|
|
7695
|
-
break;
|
|
7696
|
-
}
|
|
7697
|
-
_context.n = 2;
|
|
7698
|
-
return getAssetBalanceInternal({
|
|
7699
|
-
api: api,
|
|
7700
|
-
address: senderAddress,
|
|
7701
|
-
chain: chain,
|
|
7702
|
-
currency: feeCurrency
|
|
7703
|
-
});
|
|
7704
|
-
case 2:
|
|
7705
|
-
_t = _context.v;
|
|
7706
|
-
_context.n = 4;
|
|
7707
|
-
break;
|
|
7708
|
-
case 3:
|
|
7709
|
-
_t = undefined;
|
|
7710
|
-
case 4:
|
|
7711
|
-
feeAssetBalance = _t;
|
|
7712
7617
|
checkAmount = function checkAmount(fee) {
|
|
7713
7618
|
if (assetInfo.amount <= fee) {
|
|
7714
7619
|
throw new InvalidParameterError("Asset amount is too low, please increase the amount or use a different fee asset.");
|
|
@@ -7729,14 +7634,16 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
7729
7634
|
senderAddress: senderAddress,
|
|
7730
7635
|
version: version,
|
|
7731
7636
|
paraIdTo: paraIdTo
|
|
7732
|
-
};
|
|
7637
|
+
}; // We mint 1000 units of feeAsset and use 100
|
|
7638
|
+
FEE_ASSET_AMOUNT = 100;
|
|
7639
|
+
feeAssetAmount = feeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), feeAssetInfo.decimals) : MIN_FEE;
|
|
7733
7640
|
call = createExecuteCall(chain, createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
7734
7641
|
fees: {
|
|
7735
|
-
originFee:
|
|
7642
|
+
originFee: feeAssetAmount,
|
|
7736
7643
|
reserveFee: MIN_FEE
|
|
7737
7644
|
}
|
|
7738
7645
|
})), MAX_WEIGHT);
|
|
7739
|
-
_context.n =
|
|
7646
|
+
_context.n = 2;
|
|
7740
7647
|
return dryRunInternal({
|
|
7741
7648
|
api: api,
|
|
7742
7649
|
tx: api.callTxMethod(call),
|
|
@@ -7745,17 +7652,17 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
7745
7652
|
senderAddress: senderAddress,
|
|
7746
7653
|
address: address,
|
|
7747
7654
|
currency: currency,
|
|
7748
|
-
feeAsset: feeCurrency
|
|
7655
|
+
feeAsset: feeCurrency,
|
|
7656
|
+
useRootOrigin: true
|
|
7749
7657
|
});
|
|
7750
|
-
case
|
|
7658
|
+
case 2:
|
|
7751
7659
|
dryRunResult = _context.v;
|
|
7752
7660
|
if (dryRunResult.origin.success) {
|
|
7753
|
-
_context.n =
|
|
7661
|
+
_context.n = 3;
|
|
7754
7662
|
break;
|
|
7755
7663
|
}
|
|
7756
7664
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
7757
|
-
case
|
|
7758
|
-
validateHops(dryRunResult.hops);
|
|
7665
|
+
case 3:
|
|
7759
7666
|
originFeeEstimate = dryRunResult.origin.fee;
|
|
7760
7667
|
originFee = padFeeBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$1);
|
|
7761
7668
|
reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
|
|
@@ -7767,9 +7674,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
7767
7674
|
reserveFee: reserveFee
|
|
7768
7675
|
}
|
|
7769
7676
|
}));
|
|
7770
|
-
_context.n =
|
|
7677
|
+
_context.n = 4;
|
|
7771
7678
|
return api.getXcmWeight(xcm);
|
|
7772
|
-
case
|
|
7679
|
+
case 4:
|
|
7773
7680
|
weight = _context.v;
|
|
7774
7681
|
return _context.a(2, createExecuteCall(chain, xcm, weight));
|
|
7775
7682
|
}
|
|
@@ -8060,7 +7967,7 @@ var createXcmAndCall = /*#__PURE__*/function () {
|
|
|
8060
7967
|
}();
|
|
8061
7968
|
var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
8062
7969
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
8063
|
-
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, internalOptions, dryRunParams, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex,
|
|
7970
|
+
var api, chain, exchangeChain, destChain, assetFrom, assetTo, currencyTo, senderAddress, recipientAddress, calculateMinAmountOut, version, internalOptions, dryRunParams, _yield$createXcmAndCa, initialCall, firstDryRunResult, exchangeHopIndex, extractedFees, totalFeesInFromAsset, updatedAssetTo, amountAvailableForSwap, recalculatedMinAmountOut, _yield$createXcmAndCa2, finalCall;
|
|
8064
7971
|
return _regenerator().w(function (_context3) {
|
|
8065
7972
|
while (1) switch (_context3.n) {
|
|
8066
7973
|
case 0:
|
|
@@ -8087,7 +7994,8 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
8087
7994
|
swapConfig: {
|
|
8088
7995
|
currencyTo: currencyTo,
|
|
8089
7996
|
exchangeChain: exchangeChain
|
|
8090
|
-
}
|
|
7997
|
+
},
|
|
7998
|
+
useRootOrigin: true
|
|
8091
7999
|
}; // First dry run with dummy fees to extract actual fees
|
|
8092
8000
|
_context3.n = 2;
|
|
8093
8001
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
@@ -8106,38 +8014,8 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
8106
8014
|
}));
|
|
8107
8015
|
case 3:
|
|
8108
8016
|
firstDryRunResult = _context3.v;
|
|
8109
|
-
exchangeHopIndex = findExchangeHopIndex(chain, firstDryRunResult.hops, exchangeChain, destChain);
|
|
8110
|
-
|
|
8111
|
-
requireExchangeSuccess = !hasOriginReserveHop;
|
|
8112
|
-
extractedFees = extractFeesFromDryRun(chain, firstDryRunResult, exchangeHopIndex, destChain, false); // If we need exchange to succeed but it failed, throw error
|
|
8113
|
-
if (!(requireExchangeSuccess && extractedFees.exchangeFee === 0n)) {
|
|
8114
|
-
_context3.n = 6;
|
|
8115
|
-
break;
|
|
8116
|
-
}
|
|
8117
|
-
if (!destChain) {
|
|
8118
|
-
_context3.n = 5;
|
|
8119
|
-
break;
|
|
8120
|
-
}
|
|
8121
|
-
if (!chain) {
|
|
8122
|
-
_context3.n = 4;
|
|
8123
|
-
break;
|
|
8124
|
-
}
|
|
8125
|
-
exchangeHop = firstDryRunResult.hops[exchangeHopIndex];
|
|
8126
|
-
if (exchangeHop.result.success) {
|
|
8127
|
-
_context3.n = 4;
|
|
8128
|
-
break;
|
|
8129
|
-
}
|
|
8130
|
-
throw new DryRunFailedError("Exchange hop failed when no origin reserve exists: ".concat(exchangeHop.result.failureReason || 'Unknown reason'));
|
|
8131
|
-
case 4:
|
|
8132
|
-
_context3.n = 6;
|
|
8133
|
-
break;
|
|
8134
|
-
case 5:
|
|
8135
|
-
if (!(firstDryRunResult.destination && !firstDryRunResult.destination.success)) {
|
|
8136
|
-
_context3.n = 6;
|
|
8137
|
-
break;
|
|
8138
|
-
}
|
|
8139
|
-
throw new DryRunFailedError("Exchange (destination) failed when no origin reserve exists: ".concat(firstDryRunResult.destination.failureReason || 'Unknown reason'));
|
|
8140
|
-
case 6:
|
|
8017
|
+
exchangeHopIndex = findExchangeHopIndex(chain, firstDryRunResult.hops, exchangeChain, destChain);
|
|
8018
|
+
extractedFees = extractFeesFromDryRun(chain, firstDryRunResult, exchangeHopIndex, destChain, false);
|
|
8141
8019
|
if (extractedFees.exchangeFee === 0n) {
|
|
8142
8020
|
// We set the exchange fee to non-zero value to prevent creating dummy tx
|
|
8143
8021
|
extractedFees.exchangeFee = MIN_FEE;
|
|
@@ -8147,67 +8025,27 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
8147
8025
|
validateAmount(BigInt(assetFrom.amount), totalFeesInFromAsset);
|
|
8148
8026
|
updatedAssetTo = assetTo;
|
|
8149
8027
|
if (!chain) {
|
|
8150
|
-
_context3.n =
|
|
8028
|
+
_context3.n = 5;
|
|
8151
8029
|
break;
|
|
8152
8030
|
}
|
|
8153
8031
|
amountAvailableForSwap = BigInt(assetFrom.amount) - totalFeesInFromAsset;
|
|
8154
|
-
_context3.n =
|
|
8032
|
+
_context3.n = 4;
|
|
8155
8033
|
return calculateMinAmountOut(amountAvailableForSwap);
|
|
8156
|
-
case
|
|
8034
|
+
case 4:
|
|
8157
8035
|
recalculatedMinAmountOut = _context3.v;
|
|
8158
8036
|
updatedAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
8159
8037
|
amount: recalculatedMinAmountOut
|
|
8160
8038
|
});
|
|
8161
|
-
case
|
|
8162
|
-
_context3.n =
|
|
8039
|
+
case 5:
|
|
8040
|
+
_context3.n = 6;
|
|
8163
8041
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
8164
8042
|
assetInfoTo: updatedAssetTo,
|
|
8165
8043
|
fees: extractedFees
|
|
8166
8044
|
}), firstDryRunResult.origin.success ? firstDryRunResult.origin.weight : undefined);
|
|
8167
|
-
case
|
|
8045
|
+
case 6:
|
|
8168
8046
|
_yield$createXcmAndCa2 = _context3.v;
|
|
8169
|
-
|
|
8170
|
-
_context3.n = 10;
|
|
8171
|
-
return executeDryRun(_objectSpread2(_objectSpread2({}, dryRunParams), {}, {
|
|
8172
|
-
tx: api.callTxMethod(secondCall)
|
|
8173
|
-
}));
|
|
8174
|
-
case 10:
|
|
8175
|
-
secondDryRunResult = _context3.v;
|
|
8176
|
-
hasHopsInSecondRun = secondDryRunResult.hops && secondDryRunResult.hops.length > 0;
|
|
8177
|
-
isOnExchangeChain = chain === exchangeChain;
|
|
8178
|
-
if (hasHopsInSecondRun && !isOnExchangeChain) {
|
|
8179
|
-
finalExchangeHopIndex = findExchangeHopIndex(chain, secondDryRunResult.hops, exchangeChain, destChain);
|
|
8180
|
-
finalFees = extractFeesFromDryRun(chain, secondDryRunResult, finalExchangeHopIndex, destChain, true);
|
|
8181
|
-
} else {
|
|
8182
|
-
finalFees = extractFeesFromDryRun(chain, secondDryRunResult, 0, destChain, true);
|
|
8183
|
-
}
|
|
8184
|
-
// Validate that we have enough after accounting for final fees
|
|
8185
|
-
finalTotalFeesInFromAsset = chain ? finalFees.originReserveFee + finalFees.exchangeFee : 0n;
|
|
8186
|
-
validateAmount(BigInt(assetFrom.amount), finalTotalFeesInFromAsset);
|
|
8187
|
-
// If the final fees are different, we might need one more iteration
|
|
8188
|
-
if (!(finalFees.exchangeFee !== extractedFees.exchangeFee || finalFees.originReserveFee !== extractedFees.originReserveFee)) {
|
|
8189
|
-
_context3.n = 13;
|
|
8190
|
-
break;
|
|
8191
|
-
}
|
|
8192
|
-
finalAmountAvailableForSwap = BigInt(assetFrom.amount) - finalTotalFeesInFromAsset;
|
|
8193
|
-
_context3.n = 11;
|
|
8194
|
-
return calculateMinAmountOut(finalAmountAvailableForSwap);
|
|
8195
|
-
case 11:
|
|
8196
|
-
finalMinAmountOut = _context3.v;
|
|
8197
|
-
finalAssetTo = _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
8198
|
-
amount: finalMinAmountOut
|
|
8199
|
-
});
|
|
8200
|
-
_context3.n = 12;
|
|
8201
|
-
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
8202
|
-
assetInfoTo: finalAssetTo,
|
|
8203
|
-
fees: finalFees
|
|
8204
|
-
}), secondDryRunResult.origin.success ? secondDryRunResult.origin.weight : undefined);
|
|
8205
|
-
case 12:
|
|
8206
|
-
_yield$createXcmAndCa3 = _context3.v;
|
|
8207
|
-
finalCall = _yield$createXcmAndCa3.call;
|
|
8047
|
+
finalCall = _yield$createXcmAndCa2.call;
|
|
8208
8048
|
return _context3.a(2, api.callTxMethod(finalCall));
|
|
8209
|
-
case 13:
|
|
8210
|
-
return _context3.a(2, api.callTxMethod(secondCall));
|
|
8211
8049
|
}
|
|
8212
8050
|
}, _callee3);
|
|
8213
8051
|
}));
|
|
@@ -8576,7 +8414,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
8576
8414
|
method: method
|
|
8577
8415
|
};
|
|
8578
8416
|
shouldUseTeleport = this.shouldUseNativeAssetTeleport(sendOptions);
|
|
8579
|
-
if (!(
|
|
8417
|
+
if (!((this.chain.includes('AssetHub') && destination !== 'Mythos' && typeof destination === 'string' && !isSystemChain(destination) || !isSystemChain(this.chain) && this.chain !== 'Mythos' && typeof destination === 'string' && destination.includes('AssetHub')) && shouldUseTeleport)) {
|
|
8580
8418
|
_context.n = 6;
|
|
8581
8419
|
break;
|
|
8582
8420
|
}
|
|
@@ -9795,9 +9633,17 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
9795
9633
|
return _createClass(BridgeHubPolkadot, [{
|
|
9796
9634
|
key: "transferPolkadotXCM",
|
|
9797
9635
|
value: function transferPolkadotXCM(input) {
|
|
9798
|
-
var scenario = input.scenario
|
|
9799
|
-
|
|
9800
|
-
|
|
9636
|
+
var scenario = input.scenario,
|
|
9637
|
+
destination = input.destination;
|
|
9638
|
+
var newOverridenAsset = {
|
|
9639
|
+
parents: 1,
|
|
9640
|
+
interior: {
|
|
9641
|
+
Here: null
|
|
9642
|
+
}
|
|
9643
|
+
};
|
|
9644
|
+
input.overriddenAsset = newOverridenAsset;
|
|
9645
|
+
if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
|
|
9646
|
+
throw new ScenarioNotSupportedError(this.chain, scenario, 'Unable to use bridge hub for transfers to other Parachains.');
|
|
9801
9647
|
}
|
|
9802
9648
|
var method = 'limited_teleport_assets';
|
|
9803
9649
|
return transferPolkadotXcm(input, method, 'Unlimited');
|
|
@@ -9888,8 +9734,16 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
|
|
|
9888
9734
|
return _createClass(Collectives, [{
|
|
9889
9735
|
key: "transferPolkadotXCM",
|
|
9890
9736
|
value: function transferPolkadotXCM(input) {
|
|
9891
|
-
var scenario = input.scenario
|
|
9892
|
-
|
|
9737
|
+
var scenario = input.scenario,
|
|
9738
|
+
destination = input.destination;
|
|
9739
|
+
var newOverridenAsset = {
|
|
9740
|
+
parents: 1,
|
|
9741
|
+
interior: {
|
|
9742
|
+
Here: null
|
|
9743
|
+
}
|
|
9744
|
+
};
|
|
9745
|
+
input.overriddenAsset = newOverridenAsset;
|
|
9746
|
+
if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
|
|
9893
9747
|
throw new ScenarioNotSupportedError(this.chain, scenario);
|
|
9894
9748
|
}
|
|
9895
9749
|
return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
|
|
@@ -9969,8 +9823,17 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
9969
9823
|
key: "transferPolkadotXCM",
|
|
9970
9824
|
value: function transferPolkadotXCM(input) {
|
|
9971
9825
|
var scenario = input.scenario;
|
|
9972
|
-
var
|
|
9973
|
-
|
|
9826
|
+
var newOverridenAsset = {
|
|
9827
|
+
parents: 1,
|
|
9828
|
+
interior: {
|
|
9829
|
+
Here: null
|
|
9830
|
+
}
|
|
9831
|
+
};
|
|
9832
|
+
input.overriddenAsset = newOverridenAsset;
|
|
9833
|
+
if (scenario === 'ParaToPara') {
|
|
9834
|
+
throw new ScenarioNotSupportedError(this.chain, scenario);
|
|
9835
|
+
}
|
|
9836
|
+
return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
|
|
9974
9837
|
}
|
|
9975
9838
|
}, {
|
|
9976
9839
|
key: "getRelayToParaOverrides",
|
|
@@ -11381,10 +11244,18 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
11381
11244
|
return _createClass(PeoplePolkadot, [{
|
|
11382
11245
|
key: "transferPolkadotXCM",
|
|
11383
11246
|
value: function transferPolkadotXCM(input) {
|
|
11384
|
-
var scenario = input.scenario
|
|
11385
|
-
|
|
11247
|
+
var scenario = input.scenario,
|
|
11248
|
+
destination = input.destination;
|
|
11249
|
+
if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
|
|
11386
11250
|
throw new ScenarioNotSupportedError(this.chain, scenario);
|
|
11387
11251
|
}
|
|
11252
|
+
var newOverridenAsset = {
|
|
11253
|
+
parents: 1,
|
|
11254
|
+
interior: {
|
|
11255
|
+
Here: null
|
|
11256
|
+
}
|
|
11257
|
+
};
|
|
11258
|
+
input.overriddenAsset = newOverridenAsset;
|
|
11388
11259
|
return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
|
|
11389
11260
|
}
|
|
11390
11261
|
}, {
|
|
@@ -12673,15 +12544,19 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
12673
12544
|
key: "getTransferableAmount",
|
|
12674
12545
|
value: (function () {
|
|
12675
12546
|
var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
12676
|
-
var _this$_options7, from, to, senderAddress, currency, feeAsset;
|
|
12547
|
+
var _this$_options7, from, to, senderAddress, currency, feeAsset, tx;
|
|
12677
12548
|
return _regenerator().w(function (_context8) {
|
|
12678
12549
|
while (1) switch (_context8.n) {
|
|
12679
12550
|
case 0:
|
|
12680
12551
|
_this$_options7 = this._options, from = _this$_options7.from, to = _this$_options7.to, senderAddress = _this$_options7.senderAddress, currency = _this$_options7.currency, feeAsset = _this$_options7.feeAsset;
|
|
12681
12552
|
assertToIsString(to);
|
|
12553
|
+
_context8.n = 1;
|
|
12554
|
+
return this.build();
|
|
12555
|
+
case 1:
|
|
12556
|
+
tx = _context8.v;
|
|
12682
12557
|
return _context8.a(2, getTransferableAmount({
|
|
12683
12558
|
api: this.api,
|
|
12684
|
-
|
|
12559
|
+
tx: tx,
|
|
12685
12560
|
origin: from,
|
|
12686
12561
|
destination: to,
|
|
12687
12562
|
senderAddress: senderAddress,
|