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